Skip to content

Commit

Permalink
SampleTrack: call requestChangesInModel before unref SampleBuffer (#4982
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 wh're synced
with the mixer.
  • Loading branch information
Reflexe authored May 27, 2019
1 parent ec64de0 commit 9c6e227
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 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 )
{
Engine::mixer()->requestChangeInModel();
sharedObject::unref( m_sampleBuffer );
Engine::mixer()->doneChangeInModel();
m_sampleBuffer = sb;
updateLength();

Expand Down

0 comments on commit 9c6e227

Please sign in to comment.