Changeset 5467:30f989510eb4 in roaraudio


Ignore:
Timestamp:
03/31/12 04:19:09 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

make use of seq-numbers in v2 messages

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/basic.h

    r5465 r5467  
    104104int roar_set_connection_version(struct roar_connection * con, int version); 
    105105 
     106int16_t roar_message_genseq(struct roar_connection * con, int is_client); 
     107 
    106108int roar_sync         (struct roar_connection * con); 
    107109int roar_wait_msg     (struct roar_connection * con, int16_t seq, int16_t seqmask); 
  • libroar/basic.c

    r5465 r5467  
    460460 memset(con, 0, sizeof(struct roar_connection)); 
    461461 con->refc        = 1; 
    462  con->flags       = ROAR_CON_FLAGS_NONE; 
     462 con->flags       = ROAR_CON_FLAGS_ISCLIENT; 
    463463 con->version     = _ROAR_MESSAGE_VERSION; 
    464464 con->cb_userdata = NULL; 
     
    655655} 
    656656 
     657int16_t roar_message_genseq(struct roar_connection * con, int is_client) { 
     658 static int16_t store = 0; 
     659 int16_t ret = 0; 
     660 
     661 ret = store++; 
     662 
     663 if ( is_client == -1 ) { 
     664  if ( con != NULL ) { 
     665   is_client = con->flags & ROAR_CON_FLAGS_ISCLIENT ? 1 : 0; 
     666  } 
     667 } 
     668 
     669 if ( is_client == -1 ) 
     670  is_client = 1; 
     671 
     672 ret |= 0x8000U; 
     673 if ( !is_client ) 
     674  ret -= 0x8000U; 
     675 
     676 return ret; 
     677} 
     678 
    657679int roar_sync         (struct roar_connection * con) { 
    658680 // wait for any non-client reqs 
  • libroar/proto.c

    r5465 r5467  
    231231    } 
    232232    mes->datalen = ROAR_NET2HOST16(*(uint16_t*)(bufptr+0)); 
    233     mes->seq     = ROAR_NET2HOST16(*(uint16_t*)(bufptr+1)); 
     233    mes->seq     = ROAR_NET2HOST16(*(uint16_t*)(bufptr+2)); 
    234234   break; 
    235235 } 
     
    321321  mes->version = con->version; 
    322322 
     323 if ( mes->version == 2 ) { 
     324  mes->seq = roar_message_genseq(con, -1); 
     325 } 
     326 
    323327 return roar_vreq2(vio, mes, data, errorframe); 
    324328} 
Note: See TracChangeset for help on using the changeset viewer.