added -j argument to set the jack name
This commit is contained in:
parent
d111f339a6
commit
57758986e7
2 changed files with 12 additions and 4 deletions
|
@ -45,6 +45,7 @@ CAmpSwitch::CAmpSwitch(int argc, char *argv[])
|
||||||
m_pipe[0] = -1;
|
m_pipe[0] = -1;
|
||||||
m_pipe[1] = -1;
|
m_pipe[1] = -1;
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
|
m_jackname = "Ampswitch";
|
||||||
m_client = NULL;
|
m_client = NULL;
|
||||||
m_port = NULL;
|
m_port = NULL;
|
||||||
m_samplerate = 0;
|
m_samplerate = 0;
|
||||||
|
@ -56,6 +57,7 @@ CAmpSwitch::CAmpSwitch(int argc, char *argv[])
|
||||||
|
|
||||||
struct option longoptions[] =
|
struct option longoptions[] =
|
||||||
{
|
{
|
||||||
|
{"jack-name", required_argument, NULL, 'j'},
|
||||||
{"on-command", required_argument, NULL, 'n'},
|
{"on-command", required_argument, NULL, 'n'},
|
||||||
{"off-command", required_argument, NULL, 'f'},
|
{"off-command", required_argument, NULL, 'f'},
|
||||||
{"switch-time", required_argument, NULL, 's'},
|
{"switch-time", required_argument, NULL, 's'},
|
||||||
|
@ -65,12 +67,16 @@ CAmpSwitch::CAmpSwitch(int argc, char *argv[])
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* shortoptions = "n:f:s:t:kh";
|
const char* shortoptions = "j:n:f:s:t:kh";
|
||||||
int c;
|
int c;
|
||||||
int optionindex = 0;
|
int optionindex = 0;
|
||||||
while ((c = getopt_long(argc, argv, shortoptions, longoptions, &optionindex)) != -1)
|
while ((c = getopt_long(argc, argv, shortoptions, longoptions, &optionindex)) != -1)
|
||||||
{
|
{
|
||||||
if (c == 'n')
|
if (c == 'j')
|
||||||
|
{
|
||||||
|
m_jackname = optarg;
|
||||||
|
}
|
||||||
|
else if (c == 'n')
|
||||||
{
|
{
|
||||||
m_oncommand = optarg;
|
m_oncommand = optarg;
|
||||||
}
|
}
|
||||||
|
@ -218,6 +224,7 @@ void CAmpSwitch::PrintHelpMessage()
|
||||||
"\n"
|
"\n"
|
||||||
" options:\n"
|
" options:\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
" -j, --jack-name name of the jack client\n"
|
||||||
" -n, --on-command command to execute when switching on\n"
|
" -n, --on-command command to execute when switching on\n"
|
||||||
" -f, --off-command command to execute when switching off\n"
|
" -f, --off-command command to execute when switching off\n"
|
||||||
" -s, --switch-time minimum number of seconds between switches\n"
|
" -s, --switch-time minimum number of seconds between switches\n"
|
||||||
|
@ -243,7 +250,7 @@ void CAmpSwitch::Connect()
|
||||||
bool CAmpSwitch::JackConnect()
|
bool CAmpSwitch::JackConnect()
|
||||||
{
|
{
|
||||||
//try to connect to jackd
|
//try to connect to jackd
|
||||||
m_client = jack_client_open("Ampswitch", JackNoStartServer, NULL);
|
m_client = jack_client_open(m_jackname, JackNoStartServer, NULL);
|
||||||
if (m_client == NULL)
|
if (m_client == NULL)
|
||||||
{
|
{
|
||||||
printf("ERROR: Unable to connect to jack\n");
|
printf("ERROR: Unable to connect to jack\n");
|
||||||
|
@ -287,7 +294,7 @@ bool CAmpSwitch::JackConnect()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Connected to jack\n");
|
printf("Connected to jack with name %s\n", m_jackname);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ class CAmpSwitch
|
||||||
int m_pipe[2];
|
int m_pipe[2];
|
||||||
|
|
||||||
bool m_connected;
|
bool m_connected;
|
||||||
|
const char* m_jackname;
|
||||||
jack_client_t* m_client;
|
jack_client_t* m_client;
|
||||||
jack_port_t* m_port;
|
jack_port_t* m_port;
|
||||||
int m_samplerate;
|
int m_samplerate;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue