Skip to content

Commit

Permalink
attempt for the 12th time to fix crashes related to mufft
Browse files Browse the repository at this point in the history
race condition? probably not im running out of ideas
  • Loading branch information
poco0317 committed Nov 28, 2021
1 parent 7d6cd26 commit 6238ea8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/RageUtil/Sound/RageSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,16 @@ RageSound::GetDataToPlay(float* pBuffer,
RageSoundUtil::ConvertMonoToStereoInPlace(pBuffer, iFramesStored);
if (soundPlayCallback != nullptr) {
std::lock_guard<std::mutex> guard(recentSamplesMutex);
if (!soundPlayCallback->IsNil() && soundPlayCallback->IsSet()) {
// checking to see that the lua function exists
// also check to see that the source exists
// if the source exists, the sound is still valid
// why check to see that the source exists?
// the above lock has a chance to race:
// lock is grabbed at ~RageSound, and source is nulled
// lock is released, and then this code is executed
// so if the source disappears before the lock is released, bad.
if (!soundPlayCallback->IsNil() && soundPlayCallback->IsSet() &&
m_pSource != nullptr) {
unsigned int currentSamples = recentPCMSamples.size();
auto samplesToCopy =
std::min(iFramesStored * m_pSource->GetNumChannels(),
Expand Down

0 comments on commit 6238ea8

Please sign in to comment.