From 59e186d208e500f469791c66798337d6c00df08b Mon Sep 17 00:00:00 2001 From: Johannes Lorenz <1042576+JohannesLorenz@users.noreply.github.com> Date: Thu, 11 Jul 2019 18:22:41 +0200 Subject: [PATCH] Closes #5050: Add Mixer threading comments (#5069) [ci skip] --- include/Mixer.h | 3 +++ src/core/Mixer.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/include/Mixer.h b/include/Mixer.h index cea592905..69ea0d12d 100644 --- a/include/Mixer.h +++ b/include/Mixer.h @@ -315,6 +315,7 @@ public: inline bool isMetronomeActive() const { return m_metronomeActive; } inline void setMetronomeActive(bool value = true) { m_metronomeActive = value; } + //! Block until a change in model can be done (i.e. wait for audio thread) void requestChangeInModel(); void doneChangeInModel(); @@ -366,6 +367,8 @@ private: void clearInternal(); + //! Called by the audio thread to give control to other threads, + //! such that they can do changes in the model (like e.g. removing effects) void runChangesInModel(); bool m_renderOnly; diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index 7e41f2097..2550b072e 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -831,7 +831,9 @@ void Mixer::runChangesInModel() if( m_changesSignal ) { m_waitChangesMutex.lock(); + // allow changes in the model from other threads ... m_changesRequestCondition.wakeOne(); + // ... and wait until they are done m_changesMixerCondition.wait( &m_waitChangesMutex ); m_waitChangesMutex.unlock(); }