ProjectRenderer: lock Mixer while calling Song::{start,stop}Export()
We have to lock Mixer when touching Song's state via Song::startExport() and Song::stopExport() in ProjectRenderer::run() as the FIFO writer thread may call Mixer::renderNextBuffer() (which calls Song::doActions()) simultaneously. Fixes a random segfault when exporting project. This was a new bug as the ProjectRenderer does not operate FIFO-less anymore.
This commit is contained in:
@@ -495,8 +495,7 @@ sampleFrameA * Mixer::renderNextBuffer()
|
||||
MicroTimer timer;
|
||||
static song::playPos last_metro_pos = -1;
|
||||
|
||||
song::playPos p = engine::getSong()->getPlayPos(
|
||||
song::Mode_PlayPattern );
|
||||
song::playPos p = engine::getSong()->getPlayPos( song::Mode_PlayPattern );
|
||||
if( engine::getSong()->playMode() == song::Mode_PlayPattern &&
|
||||
engine::getPianoRoll()->isRecording() == true &&
|
||||
p != last_metro_pos && p.getTicks() %
|
||||
|
||||
@@ -59,9 +59,9 @@ FileEncodeDevice __fileEncodeDevices[] =
|
||||
".mp3", &AudioFileMp3::getInst },
|
||||
{ ProjectRenderer::FlacFile,
|
||||
QT_TRANSLATE_NOOP( "ProjectRenderer", "FLAC File (*.flac)" ),
|
||||
".flac",
|
||||
".flac",
|
||||
#ifdef LMMS_HAVE_FLAC
|
||||
&AudioFileFlac::getInst
|
||||
&AudioFileFlac::getInst
|
||||
#else
|
||||
NULL
|
||||
#endif
|
||||
@@ -219,7 +219,12 @@ void ProjectRenderer::run()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// have to lock Mixer when touching Song's state as the FIFO writer thread
|
||||
// may call Mixer::renderNextBuffer() (which calls Song::doActions())
|
||||
// simultaneously
|
||||
engine::mixer()->lock();
|
||||
engine::getSong()->startExport();
|
||||
engine::mixer()->unlock();
|
||||
|
||||
song::playPos & pp = engine::getSong()->getPlayPos(
|
||||
song::Mode_PlaySong );
|
||||
@@ -239,7 +244,9 @@ void ProjectRenderer::run()
|
||||
}
|
||||
}
|
||||
|
||||
engine::mixer()->lock();
|
||||
engine::getSong()->stopExport();
|
||||
engine::mixer()->unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user