comparison audioio/AudioJACKTarget.cpp @ 70:716e9d2f91c7

* Skip ID3 block when reading MP3 files (so long as ID3 support is included) * Show progress when retrieving audio file from playlist * Avoid -- but do not actually fix -- segmentation fault on exit. I am totally stumped at the moment about why both the PA and JACK audio targets should crash when properly shut down. For the moment, we just don't shut them down... * Fix incorrect behaviour (introduced on Friday as part of a different fix) when replacing main model in situation where no current main model exists
author Chris Cannam
date Fri, 30 Nov 2007 17:31:09 +0000
parents eb596ef12041
children 19142c58cc4c
comparison
equal deleted inserted replaced
68:cedeab01d4c8 70:716e9d2f91c7
67 67
68 static jack_client_t *dynamic_jack_client_open(const char *client_name, 68 static jack_client_t *dynamic_jack_client_open(const char *client_name,
69 jack_options_t options, 69 jack_options_t options,
70 jack_status_t *status, ...) 70 jack_status_t *status, ...)
71 { 71 {
72 typedef jack_client_t (*func)(const char *client_name, 72 typedef jack_client_t *(*func)(const char *client_name,
73 jack_options_t options, 73 jack_options_t options,
74 jack_status_t *status, ...); 74 jack_status_t *status, ...);
75 void *s = symbol("jack_client_open"); 75 void *s = symbol("jack_client_open");
76 if (!s) return 0; 76 if (!s) return 0;
77 func f = (func)s; 77 func f = (func)s;
78 return f(client_name, options, status); // varargs not supported here 78 return f(client_name, options, status); // varargs not supported here
79 } 79 }
209 209
210 AudioJACKTarget::AudioJACKTarget(AudioCallbackPlaySource *source) : 210 AudioJACKTarget::AudioJACKTarget(AudioCallbackPlaySource *source) :
211 AudioCallbackPlayTarget(source), 211 AudioCallbackPlayTarget(source),
212 m_client(0), 212 m_client(0),
213 m_bufferSize(0), 213 m_bufferSize(0),
214 m_sampleRate(0) 214 m_sampleRate(0),
215 m_done(false)
215 { 216 {
216 JackOptions options = JackNullOption; 217 JackOptions options = JackNullOption;
217 #ifdef HAVE_PORTAUDIO 218 #ifdef HAVE_PORTAUDIO
218 options = JackNoStartServer; 219 options = JackNoStartServer;
219 #endif 220 #endif
245 } 246 }
246 247
247 AudioJACKTarget::~AudioJACKTarget() 248 AudioJACKTarget::~AudioJACKTarget()
248 { 249 {
249 std::cerr << "AudioJACKTarget::~AudioJACKTarget()" << std::endl; 250 std::cerr << "AudioJACKTarget::~AudioJACKTarget()" << std::endl;
251
252 shutdown();
253
250 if (m_client) { 254 if (m_client) {
255
256 while (m_outputs.size() > 0) {
257 std::vector<jack_port_t *>::iterator itr = m_outputs.end();
258 --itr;
259 jack_port_t *port = *itr;
260 std::cerr << "unregister " << m_outputs.size() << std::endl;
261 if (port) jack_port_unregister(m_client, port);
262 m_outputs.erase(itr);
263 }
264 std::cerr << "Deactivating... ";
251 jack_deactivate(m_client); 265 jack_deactivate(m_client);
266 std::cerr << "done\nClosing... ";
252 jack_client_close(m_client); 267 jack_client_close(m_client);
253 } 268 std::cerr << "done" << std::endl;
269 }
270
271 m_client = 0;
272
254 std::cerr << "AudioJACKTarget::~AudioJACKTarget() done" << std::endl; 273 std::cerr << "AudioJACKTarget::~AudioJACKTarget() done" << std::endl;
274 }
275
276 void
277 AudioJACKTarget::shutdown()
278 {
279 m_done = true;
255 } 280 }
256 281
257 bool 282 bool
258 AudioJACKTarget::isOK() const 283 AudioJACKTarget::isOK() const
259 { 284 {
340 } 365 }
341 366
342 int 367 int
343 AudioJACKTarget::process(jack_nframes_t nframes) 368 AudioJACKTarget::process(jack_nframes_t nframes)
344 { 369 {
370 if (m_done) return 0;
371
345 if (!m_mutex.tryLock()) { 372 if (!m_mutex.tryLock()) {
346 return 0; 373 return 0;
347 } 374 }
348 375
349 if (m_outputs.empty()) { 376 if (m_outputs.empty()) {