added command line argument for disabling auto jack connection (Ticket #49)

This commit is contained in:
Volker Fischer 2019-09-22 20:13:08 +02:00
parent 25d06b7e82
commit 81b5cf7861
14 changed files with 110 additions and 85 deletions

View file

@ -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

View file

@ -28,8 +28,9 @@
/* Implementation *************************************************************/
CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ),
void* arg,
const int iCtrlMIDIChannel ) :
CSoundBase ( "OpenSL", true, fpNewProcessCallback, arg, iCtrlMIDIChannel )
const int iCtrlMIDIChannel,
const bool bNoAutoJackConnect ) :
CSoundBase ( "OpenSL", true, fpNewProcessCallback, arg, iCtrlMIDIChannel, bNoAutoJackConnect )
{
}

View file

@ -37,7 +37,8 @@ class CSound : public CSoundBase
public:
CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ),
void* arg,
const int iCtrlMIDIChannel );
const int iCtrlMIDIChannel,
const bool bNoAutoJackConnect );
virtual ~CSound() {}
virtual int Init ( const int iNewPrefMonoBufferSize );

View file

@ -87,18 +87,19 @@ 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." ) );
}
if ( !bNoAutoJackConnect )
{
// 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,
@ -113,10 +114,6 @@ void CSound::OpenJack()
// 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 ) ) )
@ -141,10 +138,6 @@ void CSound::OpenJack()
// 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] ) )
@ -155,6 +148,7 @@ void CSound::OpenJack()
jack_free ( ports );
}
}
}
void CSound::CloseJack()

View file

@ -61,8 +61,9 @@ class CSound : public CSoundBase
public:
CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ),
void* arg,
const int iCtrlMIDIChannel ) :
CSoundBase ( "Jack", true, fpNewProcessCallback, arg, iCtrlMIDIChannel ), iJACKBufferSizeMono ( 0 ),
const int iCtrlMIDIChannel,
const bool bNoAutoJackConnect ) :
CSoundBase ( "Jack", true, fpNewProcessCallback, arg, iCtrlMIDIChannel, bNoAutoJackConnect ), iJACKBufferSizeMono ( 0 ),
iJACKBufferSizeStero ( 0 ) { OpenJack(); }
virtual ~CSound() { CloseJack(); }
@ -98,8 +99,9 @@ class CSound : public CSoundBase
public:
CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* pParg ),
void* pParg,
const int iCtrlMIDIChannel ) :
CSoundBase ( "nosound", false, fpNewProcessCallback, pParg, iCtrlMIDIChannel ) {}
const int iCtrlMIDIChannel,
const bool bNoAutoJackConnect ) :
CSoundBase ( "nosound", false, fpNewProcessCallback, pParg, iCtrlMIDIChannel, bNoAutoJackConnect ) {}
virtual ~CSound() {}
};
#endif // WITH_SOUND

View file

@ -28,8 +28,9 @@
/* Implementation *************************************************************/
CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ),
void* arg,
const int iCtrlMIDIChannel ) :
CSoundBase ( "CoreAudio", true, fpNewProcessCallback, arg, iCtrlMIDIChannel ),
const int iCtrlMIDIChannel,
const bool bNoAutoJackConnect ) :
CSoundBase ( "CoreAudio", true, fpNewProcessCallback, arg, iCtrlMIDIChannel, bNoAutoJackConnect ),
midiInPortRef ( static_cast<MIDIPortRef> ( NULL ) )
{
// Apple Mailing Lists: Subject: GUI Apps should set kAudioHardwarePropertyRunLoop

View file

@ -37,7 +37,8 @@ class CSound : public CSoundBase
public:
CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ),
void* arg,
const int iCtrlMIDIChannel );
const int iCtrlMIDIChannel,
const bool bNoAutoJackConnect );
virtual int Init ( const int iNewPrefMonoBufferSize );
virtual void Start();

View file

@ -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 ),

View file

@ -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();

View file

@ -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"

View file

@ -30,12 +30,14 @@ CSoundBase::CSoundBase ( const QString& strNewSystemDriverTechniqueName,
const bool bNewIsCallbackAudioInterface,
void (*fpNewProcessCallback) ( CVector<int16_t>& 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;

View file

@ -51,7 +51,8 @@ public:
const bool bNewIsCallbackAudioInterface,
void (*fpNewProcessCallback) ( CVector<int16_t>& 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<int16_t> vecsAudioSndCrdStereo;

View file

@ -451,8 +451,9 @@ void CSound::Stop()
CSound::CSound ( void (*fpNewCallback) ( CVector<int16_t>& psData, void* arg ),
void* arg,
const int iCtrlMIDIChannel ) :
CSoundBase ( "ASIO", true, fpNewCallback, arg, iCtrlMIDIChannel ),
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 ),

View file

@ -48,7 +48,8 @@ class CSound : public CSoundBase
public:
CSound ( void (*fpNewCallback) ( CVector<int16_t>& psData, void* arg ),
void* arg,
const int );
const int iCtrlMIDIChannel,
const bool bNoAutoJackConnect );
virtual ~CSound() { UnloadCurrentDriver(); }
virtual int Init ( const int iNewPrefMonoBufferSize );