Skip to content

Commit

Permalink
Merge pull request #529 from hselasky/various_fixes
Browse files Browse the repository at this point in the history
Fix for crash when using the JACK backend and quickly reconfiguring
  • Loading branch information
corrados authored Aug 29, 2020
2 parents 8c347a2 + ecff80f commit 05783a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions linux/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
CSound* pSound = static_cast<CSound*> ( arg );
int i;

// make sure we are locked during execution
QMutexLocker locker(&pSound->MutexAudioProcessCb);

if ( pSound->IsRunning() && ( nframes == static_cast<jack_nframes_t> ( pSound->iJACKBufferSizeMono ) ) )
{
// get input data pointer
Expand Down
10 changes: 5 additions & 5 deletions src/soundbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ void CSoundBase::Stop()
// set flag so that thread can leave the main loop
bRun = false;

// give thread some time to terminate
if ( !bIsCallbackAudioInterface )
{
wait ( 5000 );
}
// drain the audio process callback
QMutexLocker locker(&MutexAudioProcessCb);
}

void CSoundBase::run()
{
// make sure we are locked during execution
QMutexLocker locker(&MutexAudioProcessCb);

// main loop of working thread
while ( bRun )
{
Expand Down
2 changes: 2 additions & 0 deletions src/soundbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <QThread>
#include <QString>
#include <QMutex>
#ifndef HEADLESS
# include <QMessageBox>
#endif
Expand Down Expand Up @@ -137,6 +138,7 @@ class CSoundBase : public QThread

void run();
bool bRun;
QMutex MutexAudioProcessCb;

void ParseMIDIMessage ( const CVector<uint8_t>& vMIDIPaketBytes );

Expand Down

0 comments on commit 05783a6

Please sign in to comment.