Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 21 additions & 29 deletions src/recorder/jamrecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ void CJamRecorder::Start()

QString error;

// needs to be after OnEnd() as that also locks
ChIdMutex.lock();
{
// needs to be after OnEnd() as that also locks
QMutexLocker mutexLocker ( &ChIdMutex );
try
{
currentSession = new CJamSession ( recordBaseDir );
Expand All @@ -413,7 +413,6 @@ void CJamRecorder::Start()
error = err.GetErrorText();
}
}
ChIdMutex.unlock();

if ( !currentSession )
{
Expand All @@ -429,21 +428,18 @@ void CJamRecorder::Start()
*/
void CJamRecorder::OnEnd()
{
ChIdMutex.lock(); // iChId used in currentSession->End()
QMutexLocker mutexLocker ( &ChIdMutex );
if ( isRecording )
{
if ( isRecording )
{
isRecording = false;
currentSession->End();
isRecording = false;
currentSession->End();

ReaperProjectFromCurrentSession();
AudacityLofFromCurrentSession();
ReaperProjectFromCurrentSession();
AudacityLofFromCurrentSession();

delete currentSession;
currentSession = nullptr;
}
delete currentSession;
currentSession = nullptr;
}
ChIdMutex.unlock();
}

/**
Expand Down Expand Up @@ -571,21 +567,18 @@ void CJamRecorder::SessionDirToReaper ( QString& strSessionDirName, int serverFr
*/
void CJamRecorder::OnDisconnected ( int iChID )
{
ChIdMutex.lock();
QMutexLocker mutexLocker ( &ChIdMutex );
if ( !isRecording )
{
if ( !isRecording )
{
qWarning() << "CJamRecorder::OnDisconnected: channel" << iChID << "disconnected but not recording";
}
if ( currentSession == nullptr )
{
qWarning() << "CJamRecorder::OnDisconnected: channel" << iChID << "disconnected but no currentSession";
return;
}

currentSession->DisconnectClient ( iChID );
qWarning() << "CJamRecorder::OnDisconnected: channel" << iChID << "disconnected but not recording";
}
ChIdMutex.unlock();
if ( currentSession == nullptr )
{
qWarning() << "CJamRecorder::OnDisconnected: channel" << iChID << "disconnected but no currentSession";
return;
}

currentSession->DisconnectClient ( iChID );
}

/**
Expand Down Expand Up @@ -617,9 +610,8 @@ void CJamRecorder::OnFrame ( const int iChID,
}

// needs to be after Start() as that also locks
ChIdMutex.lock();
{
QMutexLocker mutexLocker ( &ChIdMutex );
currentSession->Frame ( iChID, name, address, numAudioChannels, data, iServerFrameSizeSamples );
}
ChIdMutex.unlock();
}
3 changes: 2 additions & 1 deletion src/recorder/jamrecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ class CJamRecorder : public QObject
CJamRecorder ( const QString strRecordingBaseDir, const int iServerFrameSizeSamples ) :
recordBaseDir ( strRecordingBaseDir ),
iServerFrameSizeSamples ( iServerFrameSizeSamples ),
isRecording ( false )
isRecording ( false ),
currentSession ( nullptr )
{}

/**
Expand Down