Changeset 1319:acdd2e21951b in roaraudio


Ignore:
Timestamp:
03/21/09 04:01:57 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

big steps in direction to vio roar_connection object, roar_*_message() and roar_req() now use temp. VIO objects

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/basic.h

    r1315 r1319  
    7171int roar_req          (struct roar_connection * con, struct roar_message * mes, char ** data); 
    7272 
     73int roar_vsend_message(struct roar_vio_calls * vio, struct roar_message * mes, char *  data); 
     74int roar_vrecv_message(struct roar_vio_calls * vio, struct roar_message * mes, char ** data); 
     75int roar_vreq         (struct roar_vio_calls * vio, struct roar_message * mes, char ** data); 
     76 
    7377int roar_debug_message_print (struct roar_message * mes); 
    7478 
  • libroar/basic.c

    r1315 r1319  
    247247#define _ROAR_MESS_BUF_LEN (1 /* version */ + 1 /* cmd */ + 2 /* stream */ + 4 /* pos */ + 2 /* datalen */) 
    248248int roar_send_message (struct roar_connection * con, struct roar_message * mes, char * data) { 
     249 struct roar_vio_calls vio; 
     250 
     251 if ( roar_vio_open_fh_socket(&vio, con->fh) == -1 ) 
     252  return -1; 
     253 
     254 return roar_vsend_message(&vio, mes, data); 
     255} 
     256 
     257int roar_vsend_message(struct roar_vio_calls * vio, struct roar_message * mes, char *  data) { 
    249258 char buf[_ROAR_MESS_BUF_LEN]; 
    250259 
     
    259268 *(uint16_t*)(buf+8) = ROAR_HOST2NET16(mes->datalen); 
    260269 
    261  if ( ROAR_NETWORK_WRITE(con->fh, buf, _ROAR_MESS_BUF_LEN) != _ROAR_MESS_BUF_LEN ) { 
     270 if ( roar_vio_write(vio, buf, _ROAR_MESS_BUF_LEN) != _ROAR_MESS_BUF_LEN ) { 
    262271  roar_errno = ROAR_ERROR_PIPE; 
    263272  return -1; 
     
    265274 
    266275 if ( mes->datalen != 0 ) { 
    267   if ( ROAR_NETWORK_WRITE(con->fh, data == NULL ? mes->data : data, mes->datalen) != mes->datalen ) { 
     276  if ( roar_vio_write(vio, data == NULL ? mes->data : data, mes->datalen) != mes->datalen ) { 
    268277   roar_errno = ROAR_ERROR_PIPE; 
    269278   return -1; 
     
    278287 
    279288int roar_recv_message (struct roar_connection * con, struct roar_message * mes, char ** data) { 
     289 struct roar_vio_calls vio; 
     290 
     291 if ( roar_vio_open_fh_socket(&vio, con->fh) == -1 ) 
     292  return -1; 
     293 
     294 return roar_vrecv_message(&vio, mes, data); 
     295} 
     296 
     297int roar_vrecv_message(struct roar_vio_calls * vio, struct roar_message * mes, char ** data) { 
    280298 char buf[_ROAR_MESS_BUF_LEN]; 
    281299 
     
    287305  *data = NULL; 
    288306 
    289  if ( ROAR_NETWORK_READ(con->fh, buf, _ROAR_MESS_BUF_LEN) != _ROAR_MESS_BUF_LEN ) { 
     307 if ( roar_vio_read(vio, buf, _ROAR_MESS_BUF_LEN) != _ROAR_MESS_BUF_LEN ) { 
    290308  roar_errno = ROAR_ERROR_PROTO; 
    291309  return -1; 
     
    315333 
    316334 if ( mes->datalen <= LIBROAR_BUFFER_MSGDATA ) { 
    317   if ( ROAR_NETWORK_READ(con->fh, mes->data, mes->datalen) == mes->datalen ) { 
     335  if ( roar_vio_read(vio, mes->data, mes->datalen) == mes->datalen ) { 
    318336   ROAR_DBG("roar_recv_message(*): Got data!"); 
    319337   ROAR_DBG("roar_recv_message(*) = 0"); 
     
    340358  } 
    341359 
    342   if ( ROAR_NETWORK_READ(con->fh, *data, mes->datalen) == mes->datalen ) { 
     360  if ( roar_vio_read(vio, *data, mes->datalen) == mes->datalen ) { 
    343361   ROAR_DBG("roar_recv_message(*): Got data!"); 
    344362   ROAR_DBG("roar_recv_message(*) = 0"); 
     
    356374 
    357375int roar_req (struct roar_connection * con, struct roar_message * mes, char ** data) { 
    358  if ( roar_send_message(con, mes, data ? *data : NULL) != 0 ) 
     376 struct roar_vio_calls vio; 
     377 
     378 if ( roar_vio_open_fh_socket(&vio, con->fh) == -1 ) 
     379  return -1; 
     380 
     381 return roar_vreq(&vio, mes, data); 
     382} 
     383 
     384int roar_vreq         (struct roar_vio_calls * vio, struct roar_message * mes, char ** data) { 
     385 if ( roar_vsend_message(vio, mes, data ? *data : NULL) != 0 ) 
    359386  return -1; 
    360387 
     
    362389  free(*data); 
    363390 
    364  return roar_recv_message(con, mes, data); 
     391 return roar_vrecv_message(vio, mes, data); 
    365392} 
    366393 
  • libroar/vio.c

    r1314 r1319  
    7979 
    8080ssize_t roar_vio_read (struct roar_vio_calls * vio, void *buf, size_t count) { 
     81 ROAR_DBG("roar_vio_read(vio=%p, buf=%p, count=%u) = ?", vio, buf, (unsigned int)count); 
     82 
    8183 if ( vio == NULL ) 
    8284  return -1; 
Note: See TracChangeset for help on using the changeset viewer.