diff --git a/ChangeLog b/ChangeLog index a16872cf..aa6a931b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ - added support for controlling the audio mixer faders with a MIDI controller (MacOS only) +- added command line argument for disabling auto jack connection (Ticket #49) + - audio recording for the server, coded by pljones - SVG server history graph, coded by pljones diff --git a/android/sound.cpp b/android/sound.cpp index 1397e9fd..d095f667 100644 --- a/android/sound.cpp +++ b/android/sound.cpp @@ -26,10 +26,11 @@ /* Implementation *************************************************************/ -CSound::CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), - void* arg, - const int iCtrlMIDIChannel ) : - CSoundBase ( "OpenSL", true, fpNewProcessCallback, arg, iCtrlMIDIChannel ) +CSound::CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), + void* arg, + const int iCtrlMIDIChannel, + const bool bNoAutoJackConnect ) : + CSoundBase ( "OpenSL", true, fpNewProcessCallback, arg, iCtrlMIDIChannel, bNoAutoJackConnect ) { } diff --git a/android/sound.h b/android/sound.h index 3baa0b15..955d3db7 100644 --- a/android/sound.h +++ b/android/sound.h @@ -35,9 +35,10 @@ class CSound : public CSoundBase { public: - CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), - void* arg, - const int iCtrlMIDIChannel ); + CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), + void* arg, + const int iCtrlMIDIChannel, + const bool bNoAutoJackConnect ); virtual ~CSound() {} virtual int Init ( const int iNewPrefMonoBufferSize ); diff --git a/linux/sound.cpp b/linux/sound.cpp index 57fe9bd4..7f51315a 100755 --- a/linux/sound.cpp +++ b/linux/sound.cpp @@ -87,73 +87,67 @@ void CSound::OpenJack() throw CGenErr ( tr ( "The Jack port registering failed." ) ); } - const char** ports; - // tell the JACK server that we are ready to roll if ( jack_activate ( pJackClient ) ) { throw CGenErr ( tr ( "Cannot activate the Jack client." ) ); } - // connect the ports, note: you cannot do this before - // the client is activated, because we cannot allow - // connections to be made to clients that are not - // running - - // try to connect physical input ports - if ( ( ports = jack_get_ports ( pJackClient, - NULL, - NULL, - JackPortIsPhysical | JackPortIsOutput ) ) != NULL ) + if ( !bNoAutoJackConnect ) { - if ( jack_connect ( pJackClient, ports[0], jack_port_name ( input_port_left ) ) ) + // connect the ports, note: you cannot do this before + // the client is activated, because we cannot allow + // connections to be made to clients that are not + // running + const char** ports; + + // try to connect physical input ports + if ( ( ports = jack_get_ports ( pJackClient, + NULL, + NULL, + JackPortIsPhysical | JackPortIsOutput ) ) != NULL ) { - throw CGenErr ( tr ( "Cannot connect the Jack input ports" ) ); - } - - // before connecting the second stereo channel, check if the input is not - // mono - -// TODO who checks if ports[1] actually exists??? I assume that if we have mono, the -// ports array is only one item long...? - - if ( ports[1] ) - { - if ( jack_connect ( pJackClient, ports[1], jack_port_name ( input_port_right ) ) ) + if ( jack_connect ( pJackClient, ports[0], jack_port_name ( input_port_left ) ) ) { throw CGenErr ( tr ( "Cannot connect the Jack input ports" ) ); } + + // before connecting the second stereo channel, check if the input is not + // mono + if ( ports[1] ) + { + if ( jack_connect ( pJackClient, ports[1], jack_port_name ( input_port_right ) ) ) + { + throw CGenErr ( tr ( "Cannot connect the Jack input ports" ) ); + } + } + + jack_free ( ports ); } - jack_free ( ports ); - } - - // try to connect physical output ports - if ( ( ports = jack_get_ports ( pJackClient, - NULL, - NULL, - JackPortIsPhysical | JackPortIsInput ) ) != NULL ) - { - if ( jack_connect ( pJackClient, jack_port_name ( output_port_left ), ports[0] ) ) + // try to connect physical output ports + if ( ( ports = jack_get_ports ( pJackClient, + NULL, + NULL, + JackPortIsPhysical | JackPortIsInput ) ) != NULL ) { - throw CGenErr ( tr ( "Cannot connect the Jack output ports." ) ); - } - - // before connecting the second stereo channel, check if the output is not - // mono - -// TODO who checks if ports[1] actually exists??? I assume that if we have mono, the -// ports array is only one item long...? - - if ( ports[1] ) - { - if ( jack_connect ( pJackClient, jack_port_name ( output_port_right ), ports[1] ) ) + if ( jack_connect ( pJackClient, jack_port_name ( output_port_left ), ports[0] ) ) { throw CGenErr ( tr ( "Cannot connect the Jack output ports." ) ); } - } - jack_free ( ports ); + // before connecting the second stereo channel, check if the output is not + // mono + if ( ports[1] ) + { + if ( jack_connect ( pJackClient, jack_port_name ( output_port_right ), ports[1] ) ) + { + throw CGenErr ( tr ( "Cannot connect the Jack output ports." ) ); + } + } + + jack_free ( ports ); + } } } diff --git a/linux/sound.h b/linux/sound.h index 019cb070..cb1940fe 100755 --- a/linux/sound.h +++ b/linux/sound.h @@ -59,10 +59,11 @@ class CSound : public CSoundBase { public: - CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), - void* arg, - const int iCtrlMIDIChannel ) : - CSoundBase ( "Jack", true, fpNewProcessCallback, arg, iCtrlMIDIChannel ), iJACKBufferSizeMono ( 0 ), + CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), + void* arg, + const int iCtrlMIDIChannel, + const bool bNoAutoJackConnect ) : + CSoundBase ( "Jack", true, fpNewProcessCallback, arg, iCtrlMIDIChannel, bNoAutoJackConnect ), iJACKBufferSizeMono ( 0 ), iJACKBufferSizeStero ( 0 ) { OpenJack(); } virtual ~CSound() { CloseJack(); } @@ -96,10 +97,11 @@ protected: class CSound : public CSoundBase { public: - CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* pParg ), - void* pParg, - const int iCtrlMIDIChannel ) : - CSoundBase ( "nosound", false, fpNewProcessCallback, pParg, iCtrlMIDIChannel ) {} + CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* pParg ), + void* pParg, + const int iCtrlMIDIChannel, + const bool bNoAutoJackConnect ) : + CSoundBase ( "nosound", false, fpNewProcessCallback, pParg, iCtrlMIDIChannel, bNoAutoJackConnect ) {} virtual ~CSound() {} }; #endif // WITH_SOUND diff --git a/mac/sound.cpp b/mac/sound.cpp index 206b814c..8b208b19 100755 --- a/mac/sound.cpp +++ b/mac/sound.cpp @@ -26,10 +26,11 @@ /* Implementation *************************************************************/ -CSound::CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), - void* arg, - const int iCtrlMIDIChannel ) : - CSoundBase ( "CoreAudio", true, fpNewProcessCallback, arg, iCtrlMIDIChannel ), +CSound::CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), + void* arg, + const int iCtrlMIDIChannel, + const bool bNoAutoJackConnect ) : + CSoundBase ( "CoreAudio", true, fpNewProcessCallback, arg, iCtrlMIDIChannel, bNoAutoJackConnect ), midiInPortRef ( static_cast ( NULL ) ) { // Apple Mailing Lists: Subject: GUI Apps should set kAudioHardwarePropertyRunLoop diff --git a/mac/sound.h b/mac/sound.h index 063f9e18..19adcf84 100755 --- a/mac/sound.h +++ b/mac/sound.h @@ -35,9 +35,10 @@ class CSound : public CSoundBase { public: - CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), - void* arg, - const int iCtrlMIDIChannel ); + CSound ( void (*fpNewProcessCallback) ( CVector& psData, void* arg ), + void* arg, + const int iCtrlMIDIChannel, + const bool bNoAutoJackConnect ); virtual int Init ( const int iNewPrefMonoBufferSize ); virtual void Start(); diff --git a/src/client.cpp b/src/client.cpp index f76dc98a..05a60e9d 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -28,7 +28,8 @@ /* Implementation *************************************************************/ CClient::CClient ( const quint16 iPortNumber, const QString& strConnOnStartupAddress, - const int iCtrlMIDIChannel ) : + const int iCtrlMIDIChannel, + const bool bNoAutoJackConnect ) : vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ), ChannelInfo (), vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ), @@ -51,7 +52,7 @@ CClient::CClient ( const quint16 iPortNumber, eAudioChannelConf ( CC_MONO ), bIsInitializationPhase ( true ), Socket ( &Channel, iPortNumber ), - Sound ( AudioCallback, this, iCtrlMIDIChannel ), + Sound ( AudioCallback, this, iCtrlMIDIChannel, bNoAutoJackConnect ), iAudioInFader ( AUD_FADER_IN_MIDDLE ), bReverbOnLeftChan ( false ), iReverbLevel ( 0 ), diff --git a/src/client.h b/src/client.h index 0608ad32..c3c05e6e 100755 --- a/src/client.h +++ b/src/client.h @@ -100,7 +100,8 @@ class CClient : public QObject public: CClient ( const quint16 iPortNumber, const QString& strConnOnStartupAddress, - const int iCtrlMIDIChannel ); + const int iCtrlMIDIChannel, + const bool bNoAutoJackConnect ); void Start(); void Stop(); diff --git a/src/main.cpp b/src/main.cpp index b043f29b..d4e42399 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,6 +51,7 @@ int main ( int argc, char** argv ) bool bDisconnectAllClients = false; bool bShowAnalyzerConsole = false; bool bCentServPingServerInList = false; + bool bNoAutoJackConnect = false; int iNumServerChannels = DEFAULT_USED_NUM_CHANNELS; int iCtrlMIDIChannel = INVALID_MIDI_CH; quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER; @@ -153,6 +154,18 @@ int main ( int argc, char** argv ) } + // Disabling auto Jack connections ------------------------------------- + if ( GetFlagArgument ( argv, + i, + "-j", + "--nojackconnect" ) ) + { + bNoAutoJackConnect = true; + tsConsole << "- disable auto Jack connections" << endl; + continue; + } + + // Show all registered servers in the server list ---------------------- // Undocumented debugging command line argument: Show all registered // servers in the server list regardless if a ping to the server is @@ -448,7 +461,8 @@ int main ( int argc, char** argv ) // actual client object CClient Client ( iPortNumber, strConnOnStartupAddress, - iCtrlMIDIChannel ); + iCtrlMIDIChannel, + bNoAutoJackConnect ); // load settings from init-file CSettings Settings ( &Client, strIniFileName ); @@ -575,6 +589,7 @@ QString UsageArguments ( char **argv ) " (central server only)\n" " -h, -?, --help this help text\n" " -i, --inifile initialization file name (client only)\n" + " -j, --nojackconnect disable auto Jack connections (client only)\n" " -l, --log enable logging, set file name\n" " -L, --licence a licence must be accepted on a new\n" " connection (server only)\n" diff --git a/src/soundbase.cpp b/src/soundbase.cpp index 40068850..91ed983e 100755 --- a/src/soundbase.cpp +++ b/src/soundbase.cpp @@ -30,12 +30,14 @@ CSoundBase::CSoundBase ( const QString& strNewSystemDriverTechniqueName, const bool bNewIsCallbackAudioInterface, void (*fpNewProcessCallback) ( CVector& psData, void* pParg ), void* pParg, - const int iNewCtrlMIDIChannel ) : + const int iNewCtrlMIDIChannel, + const bool bNewNoAutoJackConnect ) : fpProcessCallback ( fpNewProcessCallback ), pProcessCallbackArg ( pParg ), bRun ( false ), bIsCallbackAudioInterface ( bNewIsCallbackAudioInterface ), strSystemDriverTechniqueName ( strNewSystemDriverTechniqueName ), - iCtrlMIDIChannel ( iNewCtrlMIDIChannel ) + iCtrlMIDIChannel ( iNewCtrlMIDIChannel ), + bNoAutoJackConnect ( bNewNoAutoJackConnect ) { // initializations for the sound card names (default) lNumDevs = 1; diff --git a/src/soundbase.h b/src/soundbase.h index 82a8d185..81431709 100755 --- a/src/soundbase.h +++ b/src/soundbase.h @@ -51,7 +51,8 @@ public: const bool bNewIsCallbackAudioInterface, void (*fpNewProcessCallback) ( CVector& psData, void* pParg ), void* pParg, - const int iNewCtrlMIDIChannel ); + const int iNewCtrlMIDIChannel, + const bool bNewNoAutoJackConnect ); virtual int Init ( const int iNewPrefMonoBufferSize ); virtual void Start(); @@ -120,6 +121,7 @@ protected: bool bIsCallbackAudioInterface; QString strSystemDriverTechniqueName; int iCtrlMIDIChannel; + bool bNoAutoJackConnect; CVector vecsAudioSndCrdStereo; diff --git a/windows/sound.cpp b/windows/sound.cpp index 308ba367..ff861a74 100755 --- a/windows/sound.cpp +++ b/windows/sound.cpp @@ -449,10 +449,11 @@ void CSound::Stop() } } -CSound::CSound ( void (*fpNewCallback) ( CVector& psData, void* arg ), - void* arg, - const int iCtrlMIDIChannel ) : - CSoundBase ( "ASIO", true, fpNewCallback, arg, iCtrlMIDIChannel ), +CSound::CSound ( void (*fpNewCallback) ( CVector& psData, void* arg ), + void* arg, + const int iCtrlMIDIChannel, + const bool bNoAutoJackConnect) : + CSoundBase ( "ASIO", true, fpNewCallback, arg, iCtrlMIDIChannel, bNoAutoJackConnect ), vSelectedInputChannels ( NUM_IN_OUT_CHANNELS ), vSelectedOutputChannels ( NUM_IN_OUT_CHANNELS ), lNumInChan ( 0 ), diff --git a/windows/sound.h b/windows/sound.h index 0b887d93..f51ad398 100755 --- a/windows/sound.h +++ b/windows/sound.h @@ -46,9 +46,10 @@ class CSound : public CSoundBase { public: - CSound ( void (*fpNewCallback) ( CVector& psData, void* arg ), - void* arg, - const int ); + CSound ( void (*fpNewCallback) ( CVector& psData, void* arg ), + void* arg, + const int iCtrlMIDIChannel, + const bool bNoAutoJackConnect ); virtual ~CSound() { UnloadCurrentDriver(); } virtual int Init ( const int iNewPrefMonoBufferSize );