Changeset 220:abcf312e32d6 in roaraudio


Ignore:
Timestamp:
07/22/08 13:12:48 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added some basic support for vars in codecfilter_cmd's options

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/codecfilter_cmd.c

    r200 r220  
    22 
    33#include "roard.h" 
     4 
     5#define CMDMAXLEN 1024 
    46 
    57int cf_cmd_open(CODECFILTER_USERDATA_T * inst, int codec, 
     
    810 int socks[2]; 
    911 int execed = -1; 
     12 char cmd[CMDMAXLEN+1] = {0}; 
     13 char * tmp = NULL; 
     14 char   tb[CMDMAXLEN+1]; 
     15 char * o = filter->options; 
     16 int i; 
     17 
     18 if ( !o ) 
     19  return -1; 
     20 
     21 for (i = 0; i < CMDMAXLEN && *o != 0; i++, o++) { 
     22  if ( *o == '%' ) { 
     23//   printf("ol: *o='%c' (escape)\n", *o); 
     24   tmp = NULL; 
     25 
     26   o++; 
     27   if ( *o == 0 ) { 
     28    break; 
     29   } else if ( *o == 'R' ) { 
     30    tmp = tb; 
     31    snprintf(tb, CMDMAXLEN, "%i", g_sa->rate); 
     32   } else if ( *o == 'B' ) { 
     33    tmp = tb; 
     34    snprintf(tb, CMDMAXLEN, "%i", g_sa->bits); 
     35   } else if ( *o == 'C' ) { 
     36    tmp = tb; 
     37    snprintf(tb, CMDMAXLEN, "%i", g_sa->channels); 
     38   } 
     39 
     40//   printf("*o='%c', tmp=%p\n", *o, tmp); 
     41 
     42   if ( tmp ) { 
     43    for (; i < CMDMAXLEN && *tmp != 0; i++, tmp++) 
     44     cmd[i] = *tmp; 
     45    i--; 
     46   } 
     47  } else { 
     48//   printf("ol: *o='%c' (copy to cmd[i=%i])\n", *o, i); 
     49   cmd[i] = *o; 
     50  } 
     51 } 
     52 
     53 cmd[i+1] = 0; 
     54 
     55 printf("cmd='%s'\n", cmd); 
    1056 
    1157 if ( socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1 ) { 
     
    1359 } 
    1460 
    15  if ( lib_run_bg(filter->options, ((struct roar_stream*)info)->fh, socks[1], ROAR_STDERR, socks, 2) == -1 ) 
     61 if ( lib_run_bg(cmd, ((struct roar_stream*)info)->fh, socks[1], ROAR_STDERR, socks, 2) == -1 ) 
    1662  return -1; 
    1763 
Note: See TracChangeset for help on using the changeset viewer.