Skip to content

Commit 19741b0

Browse files
committed
Fix producing of NaN from Env/LFO parameter change while playing (LMMS#3761)
Guarantee thread safety to ensure fillLevel() not to read value from wrong buffer address.
1 parent 8c2b357 commit 19741b0

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

include/EnvelopeAndLfoParameters.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ public slots:
121121
static LfoInstances * s_lfoInstances;
122122
bool m_used;
123123

124+
QMutex m_paramMutex;
124125

125126
FloatModel m_predelayModel;
126127
FloatModel m_attackModel;

src/core/EnvelopeAndLfoParameters.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ void EnvelopeAndLfoParameters::fillLevel( float * _buf, f_cnt_t _frame,
293293
const f_cnt_t _release_begin,
294294
const fpp_t _frames )
295295
{
296+
QMutexLocker m(&m_paramMutex);
297+
296298
if( _frame < 0 || _release_begin < 0 )
297299
{
298300
return;
@@ -404,6 +406,8 @@ void EnvelopeAndLfoParameters::loadSettings( const QDomElement & _this )
404406

405407
void EnvelopeAndLfoParameters::updateSampleVars()
406408
{
409+
QMutexLocker m(&m_paramMutex);
410+
407411
const float frames_per_env_seg = SECS_PER_ENV_SEGMENT *
408412
Engine::mixer()->processingSampleRate();
409413

0 commit comments

Comments
 (0)