Skip to content

Commit

Permalink
Merge pull request #597 from pljones/feature/574-command-line-disable…
Browse files Browse the repository at this point in the history
…-recording

#574 Disable recording on start up
  • Loading branch information
corrados authored Sep 19, 2020
2 parents d37cea4 + f74507d commit dfa18fc
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
19 changes: 17 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ int main ( int argc, char** argv )
bool bUseMultithreading = false;
bool bShowAnalyzerConsole = false;
bool bMuteStream = false;
bool bDisableRecording = false;
bool bCentServPingServerInList = false;
bool bNoAutoJackConnect = false;
bool bUseTranslation = true;
Expand Down Expand Up @@ -392,6 +393,19 @@ int main ( int argc, char** argv )
}


// Disable recording on startup ----------------------------------------
if ( GetFlagArgument ( argv,
i,
"--norecord",
"--norecord" ) )
{
bDisableRecording = true;
tsConsole << "- recording will not be enabled" << endl;
CommandLineOptions << "--norecord";
continue;
}


// Central server ------------------------------------------------------
if ( GetStringArgument ( tsConsole,
argc,
Expand Down Expand Up @@ -688,6 +702,7 @@ int main ( int argc, char** argv )
bDisconnectAllClientsOnQuit,
bUseDoubleSystemFrameSize,
bUseMultithreading,
bDisableRecording,
eLicenceType );

#ifndef HEADLESS
Expand Down Expand Up @@ -798,8 +813,8 @@ QString UsageArguments ( char **argv )
" [server1 city]; ...\n"
" [server1 country as QLocale ID]; ...\n"
" [server2 address]; ...\n"
" -R, --recording enables recording and sets directory to contain\n"
" recorded jams\n"
" -R, --recording sets directory to contain recorded jams\n"
" --norecord disables recording (when enabled by default by -R)\n"
" -s, --server start server\n"
" -T, --multithreading use multithreading to make better use of\n"
" multi-core CPUs and support more clients\n"
Expand Down
5 changes: 3 additions & 2 deletions src/recorder/jamcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ void CJamController::SetEnableRecording ( bool bNewEnableRecording, bool isRunn
}

void CJamController::SetRecordingDir ( QString newRecordingDir,
int iServerFrameSizeSamples )
int iServerFrameSizeSamples,
bool bDisableRecording )
{
if ( bRecorderInitialised && pthJamRecorder != nullptr )
{
Expand All @@ -89,7 +90,7 @@ void CJamController::SetRecordingDir ( QString newRecordingDir,
pJamRecorder = new recorder::CJamRecorder ( newRecordingDir, iServerFrameSizeSamples );
strRecorderErrMsg = pJamRecorder->Init();
bRecorderInitialised = ( strRecorderErrMsg == QString::null );
bEnableRecording = bRecorderInitialised;
bEnableRecording = bRecorderInitialised && !bDisableRecording;

#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
// TODO we should use the ConsoleWriterFactory() instead of qInfo()
Expand Down
3 changes: 1 addition & 2 deletions src/recorder/jamcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class CJamController : public QObject
void RequestNewRecording();
void SetEnableRecording ( bool bNewEnableRecording, bool isRunning );
QString GetRecordingDir() { return strRecordingDir; }
void SetRecordingDir ( QString newRecordingDir,
int iServerFrameSizeSamples );
void SetRecordingDir ( QString newRecordingDir, int iServerFrameSizeSamples, bool bDisableRecording );
ERecorderState GetRecorderState();

private:
Expand Down
4 changes: 4 additions & 0 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ CServer::CServer ( const int iNewMaxNumChan,
const bool bNDisconnectAllClientsOnQuit,
const bool bNUseDoubleSystemFrameSize,
const bool bNUseMultithreading,
const bool bDisableRecording,
const ELicenceType eNLicenceType ) :
bUseDoubleSystemFrameSize ( bNUseDoubleSystemFrameSize ),
bUseMultithreading ( bNUseMultithreading ),
Expand All @@ -249,6 +250,7 @@ CServer::CServer ( const int iNewMaxNumChan,
iNewMaxNumChan,
bNCentServPingServerInList,
&ConnLessProtocol ),
bDisableRecording ( bDisableRecording ),
bAutoRunMinimized ( false ),
eLicenceType ( eNLicenceType ),
bDisconnectAllClientsOnQuit ( bNDisconnectAllClientsOnQuit ),
Expand Down Expand Up @@ -1578,6 +1580,8 @@ void CServer::SetEnableRecording ( bool bNewEnableRecording )
{
JamController.SetEnableRecording ( bNewEnableRecording, IsRunning() );

bDisableRecording = !bNewEnableRecording;

// the recording state may have changed, send recording state message
CreateAndSendRecorderStateForAllConChannels();
}
Expand Down
4 changes: 3 additions & 1 deletion src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class CServer :
const bool bNDisconnectAllClientsOnQuit,
const bool bNUseDoubleSystemFrameSize,
const bool bNUseMultithreading,
const bool bDisableRecording,
const ELicenceType eNLicenceType );

virtual ~CServer();
Expand Down Expand Up @@ -216,7 +217,7 @@ class CServer :
QString GetRecordingDir() { return JamController.GetRecordingDir(); }

void SetRecordingDir( QString newRecordingDir )
{ JamController.SetRecordingDir ( newRecordingDir, iServerFrameSizeSamples ); }
{ JamController.SetRecordingDir ( newRecordingDir, iServerFrameSizeSamples, bDisableRecording ); }

void CreateAndSendRecorderStateForAllConChannels();

Expand Down Expand Up @@ -388,6 +389,7 @@ class CServer :

// jam recorder
recorder::CJamController JamController;
bool bDisableRecording;

// GUI settings
bool bAutoRunMinimized;
Expand Down

0 comments on commit dfa18fc

Please sign in to comment.