Fix bounce + callback concurrency
Prevent Session::write_one_track to commence while latency callback is already in progress. See also *19067f8c87
*2eaa0183ef
This commit is contained in:
parent
1725fdadf6
commit
f103b984ab
|
@ -135,6 +135,7 @@ class LIBARDOUR_API AudioEngine : public PortManager, public SessionHandlePtr
|
|||
bool running() const { return _running; }
|
||||
|
||||
Glib::Threads::Mutex& process_lock() { return _process_lock; }
|
||||
Glib::Threads::Mutex& latency_lock() { return _latency_lock; }
|
||||
Glib::Threads::RecMutex& state_lock() { return _state_lock; }
|
||||
|
||||
int request_buffer_size (pframes_t samples) {
|
||||
|
@ -268,6 +269,7 @@ class LIBARDOUR_API AudioEngine : public PortManager, public SessionHandlePtr
|
|||
static AudioEngine* _instance;
|
||||
|
||||
Glib::Threads::Mutex _process_lock;
|
||||
Glib::Threads::Mutex _latency_lock;
|
||||
Glib::Threads::RecMutex _state_lock;
|
||||
Glib::Threads::Cond session_removed;
|
||||
bool session_remove_pending;
|
||||
|
|
|
@ -308,6 +308,7 @@ AudioEngine::process_callback (pframes_t nframes)
|
|||
lc = true;
|
||||
}
|
||||
if (lp || lc) {
|
||||
Glib::Threads::Mutex::Lock ll (_latency_lock);
|
||||
tm.release ();
|
||||
/* re-check after releasing lock */
|
||||
if (_session->processing_blocked ()) {
|
||||
|
@ -1479,12 +1480,18 @@ AudioEngine::latency_callback (bool for_playback)
|
|||
return;
|
||||
}
|
||||
|
||||
if (in_process_thread () && ! _session->processing_blocked ()) {
|
||||
if (in_process_thread ()) {
|
||||
/* internal backends emit the latency callback in the rt-callback,
|
||||
* async to connect/disconnect or port creation/deletion.
|
||||
* All is fine.
|
||||
*/
|
||||
_session->update_latency (for_playback);
|
||||
Glib::Threads::Mutex::Lock ll (_latency_lock);
|
||||
if (_session->processing_blocked ()) {
|
||||
/* Except Session::write_one_track() might just have called block_processing() */
|
||||
queue_latency_update (for_playback);
|
||||
} else {
|
||||
_session->update_latency (for_playback);
|
||||
}
|
||||
} else {
|
||||
/* However jack 1/2 emit the callback in sync with creating the port
|
||||
* (or while handling the connection change).
|
||||
|
|
|
@ -5762,6 +5762,8 @@ Session::write_one_track (Track& track, samplepos_t start, samplepos_t end,
|
|||
// and processing_blocked() is honored before
|
||||
// acquiring thread buffers
|
||||
Glib::Threads::Mutex::Lock lm (_engine.process_lock());
|
||||
/* latency callback may be in process, wait until complete */
|
||||
Glib::Threads::Mutex::Lock lx (_engine.latency_lock());
|
||||
}
|
||||
|
||||
_bounce_processing_active = true;
|
||||
|
|
Loading…
Reference in New Issue