summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-07-24 10:18:56 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-01-14 18:46:32 -0800
commite47512b23dfbabb106dfa2be335405b95a23e192 (patch)
tree55695cd71c5953238d65d76bf056f32140c9da23 /src
parent38f7a693753292564099a70ad4a272bbe1d67ed0 (diff)
parseargs: fix --use-jack
This changes --use-jack PORT to expect a single port in its argument, since popt doesn't really support what was being attempted. Instead, to specify multiple JACK ports, you just repeat --use-jack PORTN N times, e.g: --use-jack system:capture_1 --use-jack system:capture_2 This way we don't get into the business of parsing multiple ports from a single argument, and picking which separator to use. It appears JACK port names don't have any reserved characters, judging from the API docs and a brief perusal of the code. So we couldn't even pick a bulletproof separator if we wanted to. Fixes https://github.com/recordmydesktop/recordmydesktop/issues/8 Jack support is totally untested in my fork so it's largely as-inherited still.
Diffstat (limited to 'src')
-rw-r--r--src/rmd_jack.c8
-rw-r--r--src/rmd_parseargs.c28
2 files changed, 14 insertions, 22 deletions
diff --git a/src/rmd_jack.c b/src/rmd_jack.c
index 13239bb..a4227fc 100644
--- a/src/rmd_jack.c
+++ b/src/rmd_jack.c
@@ -88,11 +88,9 @@ static int rmdSetupPorts(JackData *jdata)
memset(jdata->portbuf, 0, sizeof(jack_default_audio_sample_t *) * jdata->nports);
for (int i = 0; i < jdata->nports; i++) {
- char name[64];//recordMyDesktop:input_n<64 is enough for full name
- char num[8];
- strcpy(name, "input_");
- snprintf(num, 8, "%d", i + 1);
- strcat(name, num);
+ char name[64];
+
+ snprintf(name, sizeof(name), "input_%d", i + 1);
jdata->ports[i] = jack_port_register( jdata->client,
name,
diff --git a/src/rmd_parseargs.c b/src/rmd_parseargs.c
index fcf73af..272d43e 100644
--- a/src/rmd_parseargs.c
+++ b/src/rmd_parseargs.c
@@ -192,9 +192,9 @@ boolean rmdParseArgs(int argc, char **argv, ProgArgs *arg_return)
"SOUND_DEVICE" },
{ "use-jack", '\0',
- POPT_ARG_STRING | RMD_USE_JACK_EXTRA_FLAG, &arg_return->x, RMD_ARG_USE_JACK,
- "Record audio from the specified list of space-separated jack ports.",
- "port1 port2... portn" },
+ POPT_ARG_STRING | RMD_USE_JACK_EXTRA_FLAG, 0, RMD_ARG_USE_JACK,
+ "Record audio from the specified jack port (repeat flag for multiple ports, max 100).",
+ "JACK_PORT" },
{ "no-sound", '\0',
POPT_ARG_NONE, &arg_return->nosound, 0,
@@ -305,7 +305,7 @@ boolean rmdParseArgs(int argc, char **argv, ProgArgs *arg_return)
// Parse the arguments
while ((arg_id = poptGetNextOpt(popt_context)) > 0) {
- char *arg = poptGetOptArg(popt_context);
+ const char *arg = poptGetOptArg(popt_context);
// Most arguments are handled completely by libpopt but we
// handle some by ourself, namely those in this switch case
@@ -355,23 +355,17 @@ boolean rmdParseArgs(int argc, char **argv, ProgArgs *arg_return)
case RMD_ARG_USE_JACK:
{
- arg_return->jack_nports = 0;
-
- while (arg) {
-
+ if (arg && arg_return->jack_nports < RMD_MAX_JACK_PORTS) {
+ /* since JACK port names seem to have no reserved chars, to
+ * specify multiple ports one must simply specify --use-jack
+ * for each port.
+ */
+ arg_return->jack_port_names[arg_return->jack_nports] = strdup(arg);
arg_return->jack_nports++;
-
- arg_return->jack_port_names[arg_return->jack_nports - 1] = malloc(strlen(arg) + 1);
- strcpy(arg_return->jack_port_names[arg_return->jack_nports - 1], arg);
-
- arg = poptGetOptArg(popt_context);
- }
-
- if (arg_return->jack_nports > 0) {
arg_return->use_jack = 1;
} else {
fprintf(stderr,
- "Argument Usage: --use-jack port1 port2... portn\n");
+ "Argument Usage: --use-jack port1 [--use-jack port2]...\n");
success = FALSE;
}
© All Rights Reserved