Changeset 671:59e319049464 in roaraudio


Ignore:
Timestamp:
08/27/08 14:12:59 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added roardsp_filter_ctl() and done roardsp_filter_init()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroardsp/filter.c

    r667 r671  
    3030 int (*  init      )(struct roardsp_filter * filter, struct roar_stream * stream, int id); 
    3131 int (*uninit      )(struct roardsp_filter * filter); 
     32 int (*ctl         )(struct roardsp_filter * filter, int cmd, void * data); 
    3233 int (*calc  [5][3])(struct roardsp_filter * filter, void * data, size_t samples); 
    3334} _roardsp_filterlist[] = { 
    34  {ROARDSP_FILTER_AMP, "AMP", NULL, NULL, { 
     35 {ROARDSP_FILTER_AMP, "AMP", NULL, NULL, NULL, { 
    3536           {NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}}, 
    36  {ROARDSP_FILTER_LOWP, "Lowpass", NULL, NULL, { 
     37 {ROARDSP_FILTER_LOWP, "Lowpass", NULL, NULL, NULL, { 
    3738           {NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}}, 
    38  {ROARDSP_FILTER_HIGHP, "Highpass", NULL, NULL, { 
     39 {ROARDSP_FILTER_HIGHP, "Highpass", NULL, NULL, NULL, { 
    3940           {NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}}, 
    40  {-1, NULL, NULL, NULL, {{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}} 
     41 {-1, NULL, NULL, NULL, NULL, { 
     42           {NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL},{NULL, NULL, NULL}}} 
    4143}; 
    4244 
     
    6466 
    6567int roardsp_filter_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id) { 
     68 struct _roardsp_filterlist * l = _roardsp_filterlist; 
     69 int bytes; 
     70 int (*calc)(struct roardsp_filter * filter, void * data, size_t samples) = NULL; 
     71 
    6672 if ( filter == NULL ) 
    6773  return -1; 
     
    7278 filter->bits     = stream->info.bits; 
    7379 
    74  return -1; 
     80 bytes            = stream->info.bits / 8; 
     81 
     82 while ( l->id != id ) 
     83  if ( l->id == -1 ) 
     84   return -1; 
     85 
     86 filter->uninit = l->uninit; 
     87 filter->ctl    = l->ctl; 
     88 
     89 if ( filter->channels < 3 ) 
     90  calc = l->calc[bytes][filter->channels]; 
     91 
     92 if ( calc == NULL ) 
     93  calc = l->calc[bytes][0]; // for n channels 
     94 
     95 if ( calc == NULL ) 
     96  return -1; 
     97 
     98 if ( l->init ) 
     99  return l->init(filter, stream, id); 
     100 
     101 return 0; 
    75102} 
    76103 
     
    101128} 
    102129 
     130int    roardsp_filter_ctl   (struct roardsp_filter * filter, int cmd, void * data) { 
     131 if ( filter == NULL ) 
     132  return -1; 
     133 
     134 if ( filter->ctl ) 
     135  return filter->ctl(filter, cmd, data); 
     136 
     137 return -1; 
     138} 
     139 
    103140//ll 
Note: See TracChangeset for help on using the changeset viewer.