Changeset 3737:e79803f4911d in roaraudio


Ignore:
Timestamp:
04/26/10 13:55:19 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added clients_new_from_fh(), converted some code to use the function

Location:
roard
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • roard/clients.c

    r3713 r3737  
    9191} 
    9292 
     93int clients_new_from_fh(int fh, int proto, int byteorder, int update_nnode) { 
     94 struct roar_client * c; 
     95 int client; 
     96 
     97 if ( fh == -1 ) 
     98  return -1; 
     99 
     100 if ( proto != ROAR_PROTO_ROARAUDIO || byteorder != ROAR_BYTEORDER_NETWORK ) 
     101  return -1; 
     102 
     103 if ( (client = clients_new()) == -1 ) 
     104  return -1; 
     105 
     106 if ( clients_set_fh(client, fh) == -1 ) { 
     107  clients_delete(client); 
     108  return -1; 
     109 } 
     110 
     111 if ( update_nnode ) { 
     112  if ( clients_get(client, &c) != -1 ) { 
     113   if ( roar_nnode_free(&(c->nnode)) != -1 ) { 
     114    roar_nnode_new_from_fh(&(c->nnode), fh, 1); 
     115   } 
     116  } 
     117 } 
     118 
     119 return 0; 
     120} 
     121 
    93122int clients_delete (int id) { 
    94123 int i; 
  • roard/include/client.h

    r3517 r3737  
    5252// basic functions 
    5353 
    54 int clients_init      (void); 
    55 int clients_free      (void); 
    56 int clients_new       (void); 
    57 int clients_delete    (int id); 
    58 int clients_set_fh    (int id, int    fh); 
    59 int clients_set_pid   (int id, int    pid); 
    60 int clients_set_uid   (int id, int    uid); 
    61 int clients_set_gid   (int id, int    gid); 
    62 int clients_set_name  (int id, char * name); 
    63 int clients_set_proto (int id, int    proto); 
    64 int clients_get       (int id, struct roar_client ** client); 
    65 int clients_get_fh    (int id); 
     54int clients_init       (void); 
     55int clients_free       (void); 
     56int clients_new        (void); 
     57int clients_new_from_fh(int fh, int proto, int byteorder, int update_nnode); 
     58int clients_delete     (int id); 
     59int clients_set_fh     (int id, int    fh); 
     60int clients_set_pid    (int id, int    pid); 
     61int clients_set_uid    (int id, int    uid); 
     62int clients_set_gid    (int id, int    gid); 
     63int clients_set_name   (int id, char * name); 
     64int clients_set_proto  (int id, int    proto); 
     65int clients_get        (int id, struct roar_client ** client); 
     66int clients_get_fh     (int id); 
    6667 
    6768// network functions 
  • roard/req.c

    r3734 r3737  
    291291 
    292292int req_on_passfh      (int client, struct roar_message * mes, char * data) { 
    293  struct roar_client * c; 
    294293 int sock = clients_get_fh(client); 
    295294 int16_t * d = (int16_t*)mes->data; 
     
    351350  lsock->proto  = d[2]; 
    352351 } else { 
    353   if ( d[2] != ROAR_PROTO_ROARAUDIO ) // protocol 
    354    return -1; 
    355  
    356   if ( d[3] != ROAR_BYTEORDER_NETWORK ) // byte order 
    357    return -1; 
    358  
    359   if ( (client = clients_new()) == -1 ) 
    360    return -1; 
    361  
    362   if ( clients_set_fh(client, fh) == -1 ) { 
    363    clients_delete(client); 
    364    return -1; 
    365   } 
    366  
    367   if ( clients_get(client, &c) != -1 ) { 
    368    roar_nnode_new_from_fh(&(c->nnode), fh, 1); 
    369   } 
     352  if ( clients_new_from_fh(fh, d[2], d[3], 1) == -1 ) 
     353   return -1; 
    370354 } 
    371355 
  • roard/roard.c

    r3733 r3737  
    15631563#endif 
    15641564  } else if ( strcmp(k, "--client-fh") == 0 ) { 
    1565    if ( clients_set_fh(clients_new(), atoi(argv[++i])) == -1 ) { 
     1565   if ( clients_new_from_fh(atoi(argv[++i]), ROAR_PROTO_ROARAUDIO, ROAR_BYTEORDER_NETWORK, 1) == -1 ) { 
    15661566    ROAR_ERR("main(*): Can not set client's fh"); 
    15671567    return 1; 
Note: See TracChangeset for help on using the changeset viewer.