Changeset 4333:d10f93a61265 in roaraudio


Ignore:
Timestamp:
09/10/10 00:32:17 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

finaly added support to do a filtered stream list

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/ctl.h

    r4332 r4333  
    5050 
    5151int roar_list         (struct roar_connection * con, int * items,   int max, int cmd); 
     52int roar_list_filtered(struct roar_connection * con, int * items,   int max, int cmd, unsigned char filter, unsigned char cmp, uint32_t id); 
    5253 
    5354/* 
  • include/roaraudio/proto.h

    r4331 r4333  
    118118#define ROAR_CTL_CMP_ANY      ROAR_CTL_FILTER_ANY 
    119119#define ROAR_CTL_CMP_EQ       1 
    120 #define ROAR_CTL_CMP_NE       1 
     120#define ROAR_CTL_CMP_NE       2 
    121121 
    122122// auth types... 
  • libroar/ctl.c

    r4332 r4333  
    134134} 
    135135 
     136int roar_list_filtered(struct roar_connection * con, int * items,   int max, int cmd, unsigned char filter, unsigned char cmp, uint32_t id) { 
     137 struct roar_message m; 
     138 
     139 memset(&m, 0, sizeof(struct roar_message)); // make valgrind happy! 
     140 
     141 roar_ctl_f2m(&m, filter, cmp, id); 
     142 m.cmd = cmd; 
     143 
     144 if ( roar_req(con, &m, NULL) == -1 ) 
     145  return -1; 
     146 
     147 return roar_ctl_m2ia(&m, items, max); 
     148} 
     149 
    136150int roar_list         (struct roar_connection * con, int * items,   int max, int cmd) { 
    137  struct roar_message m; 
    138  
    139  memset(&m, 0, sizeof(struct roar_message)); // make valgrind happy! 
    140  
    141  roar_ctl_f2m_any(&m); 
    142  m.cmd = cmd; 
    143  
    144  if ( roar_req(con, &m, NULL) == -1 ) 
    145   return -1; 
    146  
    147  return roar_ctl_m2ia(&m, items, max); 
     151 return roar_list_filtered(con, items, max, cmd, ROAR_CTL_FILTER_ANY, ROAR_CTL_CMP_ANY, ROAR_CTL_FILTER_ANY); 
    148152} 
    149153 
     
    310314 
    311315int roar_filter_match (const unsigned cmp, const uint32_t a, const uint32_t b) { 
    312  switch (cmd) { 
     316 switch (cmp) { 
    313317  case ROAR_CTL_CMP_ANY: 
    314318    return 1; 
  • roard/req.c

    r4330 r4333  
    633633 int streams[ROAR_STREAMS_MAX]; 
    634634 int i, c = 0; 
     635 int match; 
    635636 
    636637 if ( roar_ctl_m2f(mes, &filter, &cmp, &id) == -1 ) 
    637638  return -1; 
    638639 
    639  // TODO: add code to support filter 
    640  if ( filter != ROAR_CTL_FILTER_ANY ) 
    641   return -1; 
    642  
    643640 for (i = 0; i < ROAR_STREAMS_MAX; i++) { 
    644   if ( g_streams[i] != NULL ) { 
     641  if ( g_streams[i] == NULL ) 
     642   continue; 
     643 
     644  match = 0; 
     645 
     646  switch (filter) { 
     647   case ROAR_CTL_FILTER_ANY: 
     648     match = 1; 
     649    break; 
     650   case ROAR_CTL_FILTER_DIR: 
     651     match = roar_filter_match(cmp, id, ROAR_STREAM(g_streams[i])->dir); 
     652    break; 
     653   default: // unsupported filter... 
     654     return -1; 
     655    break; 
     656  } 
     657 
     658  if ( match ) 
    645659   streams[c++] = i; 
    646   } 
    647660 } 
    648661 
Note: See TracChangeset for help on using the changeset viewer.