Skip to content

Commit

Permalink
Add logic for thread safety
Browse files Browse the repository at this point in the history
  • Loading branch information
PhysSong committed Dec 1, 2017
1 parent 554c272 commit 3f22073
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/AudioJack.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <QtCore/QVector>
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QMutexLocker>

#include "AudioDevice.h"
#include "AudioDeviceSetupWidget.h"
Expand Down Expand Up @@ -107,6 +108,7 @@ private slots:

bool m_active;
bool m_stopped;
QMutex m_processingMutex;

MidiJack *m_midiClient;
QVector<jack_port_t *> m_outputPorts;
Expand Down
4 changes: 4 additions & 0 deletions src/core/audio/AudioJack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ bool AudioJack::initJackClient()

void AudioJack::startProcessing()
{
QMutexLocker m( &m_processingMutex );
m_stopped = false;

if( m_active || m_client == NULL )
Expand Down Expand Up @@ -253,6 +254,7 @@ void AudioJack::startProcessing()

void AudioJack::stopProcessing()
{
QMutexLocker m( &m_processingMutex );
m_stopped = true;
}

Expand Down Expand Up @@ -340,6 +342,8 @@ void AudioJack::renamePort( AudioPort * _port )

int AudioJack::processCallback( jack_nframes_t _nframes, void * _udata )
{
QMutexLocker m( &m_processingMutex );

// do midi processing first so that midi input can
// add to the following sound processing
if( m_midiClient && _nframes > 0 )
Expand Down

0 comments on commit 3f22073

Please sign in to comment.