Skip to content

Commit

Permalink
SampleTrack: call requestChangesInModel before unref SampleBuffer
Browse files Browse the repository at this point in the history
To avoid a race condition between the gui thread which destroys the
samplebuffer and the mixer thread which increases the buffer's ref-
count, we'll make sure to touch the ref-count only when whe're synced
with the mixer.
  • Loading branch information
Reflexe committed May 19, 2019
1 parent ec64de0 commit ccff7d6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/tracks/SampleTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ SampleTCO::~SampleTCO()
{
sampletrack->updateTcos();
}
Engine::mixer()->requestChangeInModel();
sharedObject::unref( m_sampleBuffer );
Engine::mixer()->doneChangeInModel();
}


Expand All @@ -133,7 +135,9 @@ const QString & SampleTCO::sampleFile() const

void SampleTCO::setSampleBuffer( SampleBuffer* sb )
{
sharedObject::unref( m_sampleBuffer );
Engine::mixer()->requestChangeInModel();
sharedObject::unref( m_sampleBuffer );
Engine::mixer()->doneChangeInModel();
m_sampleBuffer = sb;
updateLength();

Expand Down

0 comments on commit ccff7d6

Please sign in to comment.