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
11 changes: 10 additions & 1 deletion src/recorder/jamcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ CJamController::CJamController() :
bRecorderInitialised ( false ),
bEnableRecording ( false ),
strRecordingDir ( "" ),
pthJamRecorder ( nullptr )
pthJamRecorder ( nullptr ),
pJamRecorder ( nullptr )
{
}

Expand Down Expand Up @@ -85,11 +86,19 @@ void CJamController::SetRecordingDir ( QString newRecordingDir,
// Hopefully changing recording directory will NOT happen during a long jam...
emit EndRecorderThread();
pthJamRecorder->wait();
delete pthJamRecorder;
pthJamRecorder = nullptr;
}

if ( !newRecordingDir.isEmpty() )
{
if ( pJamRecorder != nullptr )
Comment thread
pljones marked this conversation as resolved.
{
// We have a reference to a CJamRecorder instance that should now have finished.
// Clean up the instance before replacing it.
delete pJamRecorder;
pJamRecorder = nullptr;
}
pJamRecorder = new recorder::CJamRecorder ( newRecordingDir, iServerFrameSizeSamples );
strRecorderErrMsg = pJamRecorder->Init();
bRecorderInitialised = ( strRecorderErrMsg == QString::null );
Expand Down
27 changes: 24 additions & 3 deletions src/recorder/jamrecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ CJamClient::CJamClient(const qint64 frame, const int _numChannels, const QString
startFrame (frame),
numChannels (static_cast<uint16_t>(_numChannels)),
name (name),
address (address)
address (address),
out (nullptr)
{
// At this point we may not have much of a name
QString fileName = ClientName() + "-" + QString::number(frame) + "-" + QString::number(_numChannels);
Expand Down Expand Up @@ -88,8 +89,12 @@ void CJamClient::Frame(const QString _name, const CVector<int16_t>& pcm, int iSe
*/
void CJamClient::Disconnect()
{
static_cast<CWaveStream*>(out)->finalise();
out = nullptr;
if (out)
{
static_cast<CWaveStream*>(out)->finalise();
Comment thread
pljones marked this conversation as resolved.
delete out;
out = nullptr;
}

wavFile->close();

Expand Down Expand Up @@ -134,6 +139,22 @@ CJamSession::CJamSession(QDir recordBaseDir) :
vecptrJamClients.fill(nullptr);
}

/**
* @brief CJamSession::~CJamSession
*/
CJamSession::~CJamSession()
{
// free up any active jamClientConnections
for (int i = 0; i < jamClientConnections.count(); i++ )
{
if ( jamClientConnections[i] )
{
delete jamClientConnections[i];
Comment thread
pljones marked this conversation as resolved.
jamClientConnections[i] = nullptr;
}
}
}

/**
* @brief CJamSession::DisconnectClient Capture details of the departing client's connection
* @param iChID the channel id of the client that disconnected
Expand Down
2 changes: 2 additions & 0 deletions src/recorder/jamrecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class CJamSession : public QObject

CJamSession(QDir recordBaseDir);

virtual ~CJamSession();

void Frame(const int iChID, const QString name, const CHostAddress address, const int numAudioChannels, const CVector<int16_t> data, int iServerFrameSizeSamples);

void End();
Expand Down