Changeset 3869:c63e1367041c in roaraudio for libroar/basic.c


Ignore:
Timestamp:
05/19/10 22:14:22 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

fixed long outstanding Con vs. VIO bug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/basic.c

    r3836 r3869  
    231231 memset(con, 0, sizeof(struct roar_connection)); 
    232232 
    233  con->__fh = fh; 
     233 con->flags = ROAR_CON_FLAGS_FH; 
     234 con->__fh  = fh; 
     235 
     236 if ( roar_vio_open_fh_socket(&(con->viocon), fh) != -1 ) 
     237  con->flags |= ROAR_CON_FLAGS_VIO; 
    234238 
    235239 roar_errno = ROAR_ERROR_NONE; 
     
    238242 
    239243int roar_get_connection_fh (struct roar_connection * con) { 
    240  roar_debug_warn_sysio("roar_get_connection_fh", "roar_get_connection_vio", NULL); 
     244 roar_debug_warn_sysio("roar_get_connection_fh", "roar_get_connection_vio2", NULL); 
    241245 
    242246 if ( con == NULL ) 
    243247  return -1; 
    244248 
     249 if ( !(con->flags & ROAR_CON_FLAGS_FH) ) 
     250  return -1; 
     251 
    245252 return con->__fh; 
    246253} 
    247254 
    248255int roar_get_connection_vio (struct roar_connection * con, struct roar_vio_calls * vio) { 
     256 roar_debug_warn_obsolete("roar_get_connection_vio", "roar_get_connection_vio2", NULL); 
     257 
    249258 if ( con == NULL || vio == NULL ) 
    250259  return -1; 
    251260 
     261 if ( !(con->flags & ROAR_CON_FLAGS_FH) ) 
     262  return -1; 
     263 
    252264 return roar_vio_open_fh_socket(vio, con->__fh); 
    253265} 
    254266 
     267struct roar_vio_calls * roar_get_connection_vio2 (struct roar_connection * con) { 
     268 if ( con == NULL ) 
     269  return NULL; 
     270 
     271 if ( con->flags & ROAR_CON_FLAGS_VIO ) 
     272  return &(con->viocon); 
     273 
     274// TODO: try to open the VIO. 
     275 
     276 return NULL; 
     277} 
     278 
    255279int roar_disconnect (struct roar_connection * con) { 
    256  struct roar_vio_calls vio; 
     280 struct roar_vio_calls * vio; 
    257281 struct roar_message m; 
    258282 
     
    264288 roar_req(con, &m, NULL); 
    265289 
    266  if ( roar_get_connection_vio(con, &vio) != -1 ) { 
    267   roar_vio_close(&vio); 
     290 if ( (vio = roar_get_connection_vio2(con)) != NULL ) { 
     291  roar_vio_close(vio); 
    268292 } 
    269293 
     
    329353#define _ROAR_MESS_BUF_LEN (1 /* version */ + 1 /* cmd */ + 2 /* stream */ + 4 /* pos */ + 2 /* datalen */) 
    330354int roar_send_message (struct roar_connection * con, struct roar_message * mes, char * data) { 
    331  struct roar_vio_calls vio; 
    332  
    333  if ( roar_get_connection_vio(con, &vio) == -1 ) 
    334   return -1; 
    335  
    336  return roar_vsend_message(&vio, mes, data); 
     355 struct roar_vio_calls * vio; 
     356 
     357 if ( (vio = roar_get_connection_vio2(con)) == NULL ) 
     358  return -1; 
     359 
     360 return roar_vsend_message(vio, mes, data); 
    337361} 
    338362 
     
    369393 
    370394int roar_recv_message (struct roar_connection * con, struct roar_message * mes, char ** data) { 
    371  struct roar_vio_calls vio; 
    372  
    373  if ( roar_get_connection_vio(con, &vio) == -1 ) 
    374   return -1; 
    375  
    376  return roar_vrecv_message(&vio, mes, data); 
     395 struct roar_vio_calls * vio; 
     396 
     397 if ( (vio = roar_get_connection_vio2(con)) == NULL ) 
     398  return -1; 
     399 
     400 return roar_vrecv_message(vio, mes, data); 
    377401} 
    378402 
     
    464488 
    465489int roar_req (struct roar_connection * con, struct roar_message * mes, char ** data) { 
    466  struct roar_vio_calls vio; 
    467  
    468  if ( roar_get_connection_vio(con, &vio) == -1 ) 
    469   return -1; 
    470  
    471  return roar_vreq(&vio, mes, data); 
     490 struct roar_vio_calls * vio; 
     491 
     492 if ( (vio = roar_get_connection_vio2(con)) == NULL ) 
     493  return -1; 
     494 
     495 return roar_vreq(vio, mes, data); 
    472496} 
    473497 
Note: See TracChangeset for help on using the changeset viewer.