diff options
author | enselic <enselic@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2009-01-10 11:57:10 +0000 |
---|---|---|
committer | enselic <enselic@f606c939-3180-4ac9-a4b8-4b8779d57d0a> | 2009-01-10 11:57:10 +0000 |
commit | 74dae024903ee922c4863b44b9860f99a8bbfdab (patch) | |
tree | ac1ac42784ccbd8d72424abd11e12db366026b05 /recordmydesktop | |
parent | fc7f2f1b2aa271bed2fa9130e4a0c9b4a4034cbb (diff) |
src/rmd_types.h: Make ProgArgs::jack_port_names a fixed size
100-element array.
src/rmd_initialize_data.c: Reset ProgArgs::jack_port_names using
memset().
src/rmd_parseargs.c: With ProgArgs::jack_port_names as a fixed size
array we can read the --use-jack options in a single pass which makes
the code more libpopt migration friendly.
git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@588 f606c939-3180-4ac9-a4b8-4b8779d57d0a
Diffstat (limited to 'recordmydesktop')
-rw-r--r-- | recordmydesktop/src/rmd_initialize_data.c | 3 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_parseargs.c | 25 | ||||
-rw-r--r-- | recordmydesktop/src/rmd_types.h | 4 |
3 files changed, 16 insertions, 16 deletions
diff --git a/recordmydesktop/src/rmd_initialize_data.c b/recordmydesktop/src/rmd_initialize_data.c index 6754f7b..dec594f 100644 --- a/recordmydesktop/src/rmd_initialize_data.c +++ b/recordmydesktop/src/rmd_initialize_data.c @@ -214,7 +214,6 @@ void SetupDefaultArgs(ProgArgs *args) { args->noframe = 0; args->jack_nports = 0; args->jack_ringbuffer_secs = 3.0; - args->jack_port_names = NULL; args->zerocompression = 1; args->no_quick_subsample = 1; args->cursor_color = 1; @@ -236,6 +235,8 @@ void SetupDefaultArgs(ProgArgs *args) { args->display = NULL; } + memset(args->jack_port_names, 0, sizeof(args->jack_port_names)); + args->device = (char *) malloc(strlen(DEFAULT_AUDIO_DEVICE) + 1); strcpy(args->device, DEFAULT_AUDIO_DEVICE); diff --git a/recordmydesktop/src/rmd_parseargs.c b/recordmydesktop/src/rmd_parseargs.c index f0b3dcc..cb039a1 100644 --- a/recordmydesktop/src/rmd_parseargs.c +++ b/recordmydesktop/src/rmd_parseargs.c @@ -478,23 +478,20 @@ boolean ParseArgs(int argc, char **argv, ProgArgs *arg_return) { #ifdef HAVE_LIBJACK int k=i+1; arg_return->jack_nports=0; - while((k<argc)&&(argv[k][0]!='-')){ + while((k<argc)&&(argv[k][0]!='-')&&k-i-1<RMD_MAX_JACK_PORTS){ arg_return->jack_nports++; - k++; - } - if(arg_return->jack_nports>0){ - arg_return->jack_port_names=malloc(sizeof(char*)* - arg_return->jack_nports); - for(k=i+1;k<i+1+arg_return->jack_nports;k++){ - arg_return->jack_port_names[k-i-1]= - malloc(strlen(argv[k])+1); - strcpy(arg_return->jack_port_names[k-i-1], - argv[k]); - } - i+=arg_return->jack_nports; + + arg_return->jack_port_names[k-i-1]=malloc(strlen(argv[k])+1); + strcpy(arg_return->jack_port_names[k-i-1],argv[k]); + arg_return->use_jack=1; + + k++; } - else{ + + i+=arg_return->jack_nports; + + if (arg_return->jack_nports==0) { fprintf(stderr,"Argument Usage: --use-jack port1" " port2... portn\n"); return FALSE; diff --git a/recordmydesktop/src/rmd_types.h b/recordmydesktop/src/rmd_types.h index 3324760..629f43d 100644 --- a/recordmydesktop/src/rmd_types.h +++ b/recordmydesktop/src/rmd_types.h @@ -83,6 +83,8 @@ typedef int boolean; #define TRUE (!FALSE) #endif +#define RMD_MAX_JACK_PORTS (100) + // Forward declarations typedef struct _ProgData ProgData; @@ -149,7 +151,7 @@ typedef struct _ProgArgs{ //(do not add a .number postfix) int use_jack; //record audio with jack unsigned int jack_nports; - char **jack_port_names; + char *jack_port_names[RMD_MAX_JACK_PORTS]; float jack_ringbuffer_secs; }ProgArgs; |