Mercurial > hg > svapp
comparison audioio/AudioJACKTarget.cpp @ 293:068235cf5bf7
Drop std:: from cout, cerr, endl -- pull these in through Debug.h
author | Chris Cannam |
---|---|
date | Tue, 26 Nov 2013 14:12:50 +0000 |
parents | 8aace2d9f1c2 |
children | 0876ea394902 |
comparison
equal
deleted
inserted
replaced
291:3fc0df289533 | 293:068235cf5bf7 |
---|---|
48 if (!attempted) { | 48 if (!attempted) { |
49 library = ::dlopen("libjack.so.1", RTLD_NOW); | 49 library = ::dlopen("libjack.so.1", RTLD_NOW); |
50 if (!library) library = ::dlopen("libjack.so.0", RTLD_NOW); | 50 if (!library) library = ::dlopen("libjack.so.0", RTLD_NOW); |
51 if (!library) library = ::dlopen("libjack.so", RTLD_NOW); | 51 if (!library) library = ::dlopen("libjack.so", RTLD_NOW); |
52 if (!library) { | 52 if (!library) { |
53 std::cerr << "WARNING: AudioJACKTarget: Failed to load JACK library: " | 53 cerr << "WARNING: AudioJACKTarget: Failed to load JACK library: " |
54 << ::dlerror() << " (tried .so, .so.0, .so.1)" | 54 << ::dlerror() << " (tried .so, .so.0, .so.1)" |
55 << std::endl; | 55 << endl; |
56 } | 56 } |
57 attempted = true; | 57 attempted = true; |
58 } | 58 } |
59 if (!library) return 0; | 59 if (!library) return 0; |
60 } | 60 } |
61 void *symbol = ::dlsym(library, name); | 61 void *symbol = ::dlsym(library, name); |
62 if (!symbol) { | 62 if (!symbol) { |
63 std::cerr << "WARNING: AudioJACKTarget: Failed to locate symbol " | 63 cerr << "WARNING: AudioJACKTarget: Failed to locate symbol " |
64 << name << ": " << ::dlerror() << std::endl; | 64 << name << ": " << ::dlerror() << endl; |
65 } | 65 } |
66 symbols[name] = symbol; | 66 symbols[name] = symbol; |
67 return symbol; | 67 return symbol; |
68 } | 68 } |
69 | 69 |
229 JackStatus status = JackStatus(0); | 229 JackStatus status = JackStatus(0); |
230 m_client = jack_client_open(source->getClientName().toLocal8Bit().data(), | 230 m_client = jack_client_open(source->getClientName().toLocal8Bit().data(), |
231 options, &status); | 231 options, &status); |
232 | 232 |
233 if (!m_client) { | 233 if (!m_client) { |
234 std::cerr << "AudioJACKTarget: Failed to connect to JACK server: status code " | 234 cerr << "AudioJACKTarget: Failed to connect to JACK server: status code " |
235 << status << std::endl; | 235 << status << endl; |
236 return; | 236 return; |
237 } | 237 } |
238 | 238 |
239 m_bufferSize = jack_get_buffer_size(m_client); | 239 m_bufferSize = jack_get_buffer_size(m_client); |
240 m_sampleRate = jack_get_sample_rate(m_client); | 240 m_sampleRate = jack_get_sample_rate(m_client); |
241 | 241 |
242 jack_set_xrun_callback(m_client, xrunStatic, this); | 242 jack_set_xrun_callback(m_client, xrunStatic, this); |
243 jack_set_process_callback(m_client, processStatic, this); | 243 jack_set_process_callback(m_client, processStatic, this); |
244 | 244 |
245 if (jack_activate(m_client)) { | 245 if (jack_activate(m_client)) { |
246 std::cerr << "ERROR: AudioJACKTarget: Failed to activate JACK client" | 246 cerr << "ERROR: AudioJACKTarget: Failed to activate JACK client" |
247 << std::endl; | 247 << endl; |
248 } | 248 } |
249 | 249 |
250 if (m_source) { | 250 if (m_source) { |
251 sourceModelReplaced(); | 251 sourceModelReplaced(); |
252 } | 252 } |
274 | 274 |
275 while (m_outputs.size() > 0) { | 275 while (m_outputs.size() > 0) { |
276 std::vector<jack_port_t *>::iterator itr = m_outputs.end(); | 276 std::vector<jack_port_t *>::iterator itr = m_outputs.end(); |
277 --itr; | 277 --itr; |
278 jack_port_t *port = *itr; | 278 jack_port_t *port = *itr; |
279 std::cerr << "unregister " << m_outputs.size() << std::endl; | 279 cerr << "unregister " << m_outputs.size() << endl; |
280 if (port) jack_port_unregister(m_client, port); | 280 if (port) jack_port_unregister(m_client, port); |
281 m_outputs.erase(itr); | 281 m_outputs.erase(itr); |
282 } | 282 } |
283 std::cerr << "Deactivating... "; | 283 cerr << "Deactivating... "; |
284 jack_deactivate(m_client); | 284 jack_deactivate(m_client); |
285 std::cerr << "done\nClosing... "; | 285 cerr << "done\nClosing... "; |
286 jack_client_close(m_client); | 286 jack_client_close(m_client); |
287 std::cerr << "done" << std::endl; | 287 cerr << "done" << endl; |
288 } | 288 } |
289 | 289 |
290 m_client = 0; | 290 m_client = 0; |
291 | 291 |
292 SVDEBUG << "AudioJACKTarget::~AudioJACKTarget() done" << endl; | 292 SVDEBUG << "AudioJACKTarget::~AudioJACKTarget() done" << endl; |
366 JACK_DEFAULT_AUDIO_TYPE, | 366 JACK_DEFAULT_AUDIO_TYPE, |
367 JackPortIsOutput, | 367 JackPortIsOutput, |
368 0); | 368 0); |
369 | 369 |
370 if (!port) { | 370 if (!port) { |
371 std::cerr | 371 cerr |
372 << "ERROR: AudioJACKTarget: Failed to create JACK output port " | 372 << "ERROR: AudioJACKTarget: Failed to create JACK output port " |
373 << m_outputs.size() << std::endl; | 373 << m_outputs.size() << endl; |
374 } else { | 374 } else { |
375 m_source->setTargetPlayLatency(jack_port_get_latency(port)); | 375 m_source->setTargetPlayLatency(jack_port_get_latency(port)); |
376 } | 376 } |
377 | 377 |
378 if (m_outputs.size() < physicalPortCount) { | 378 if (m_outputs.size() < physicalPortCount) { |
406 m_mutex.unlock(); | 406 m_mutex.unlock(); |
407 return 0; | 407 return 0; |
408 } | 408 } |
409 | 409 |
410 #ifdef DEBUG_AUDIO_JACK_TARGET | 410 #ifdef DEBUG_AUDIO_JACK_TARGET |
411 std::cout << "AudioJACKTarget::process(" << nframes << "): have a source" << std::endl; | 411 cout << "AudioJACKTarget::process(" << nframes << "): have a source" << endl; |
412 #endif | 412 #endif |
413 | 413 |
414 #ifdef DEBUG_AUDIO_JACK_TARGET | 414 #ifdef DEBUG_AUDIO_JACK_TARGET |
415 if (m_bufferSize != nframes) { | 415 if (m_bufferSize != nframes) { |
416 std::cerr << "WARNING: m_bufferSize != nframes (" << m_bufferSize << " != " << nframes << ")" << std::endl; | 416 cerr << "WARNING: m_bufferSize != nframes (" << m_bufferSize << " != " << nframes << ")" << endl; |
417 } | 417 } |
418 #endif | 418 #endif |
419 | 419 |
420 float **buffers = (float **)alloca(m_outputs.size() * sizeof(float *)); | 420 float **buffers = (float **)alloca(m_outputs.size() * sizeof(float *)); |
421 | 421 |
460 } | 460 } |
461 | 461 |
462 int | 462 int |
463 AudioJACKTarget::xrun() | 463 AudioJACKTarget::xrun() |
464 { | 464 { |
465 std::cerr << "AudioJACKTarget: xrun!" << std::endl; | 465 cerr << "AudioJACKTarget: xrun!" << endl; |
466 if (m_source) m_source->audioProcessingOverload(); | 466 if (m_source) m_source->audioProcessingOverload(); |
467 return 0; | 467 return 0; |
468 } | 468 } |
469 | 469 |
470 #endif /* HAVE_JACK */ | 470 #endif /* HAVE_JACK */ |