Changeset 8:89686870362d in roaraudio
- Timestamp:
- 06/17/08 15:21:57 (16 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/basic.h
r0 r8 8 8 #define LIBROAR_BUFFER_SMALL 80 9 9 #define LIBROAR_BUFFER_MSGDATA LIBROAR_BUFFER_SMALL 10 #define _ROAR_MESSAGE_VERSION 0 10 11 11 12 struct roar_message { -
libroar/basic.c
r0 r8 113 113 } 114 114 115 #define _ROAR_MESS_BUF_LEN (1 /* cmd */ + 2 /* stream */ + 4 /* pos */ + 2 /* datalen */)115 #define _ROAR_MESS_BUF_LEN (1 /* version */ + 1 /* cmd */ + 2 /* stream */ + 4 /* pos */ + 2 /* datalen */) 116 116 int roar_send_message (struct roar_connection * con, struct roar_message * mes, char * data) { 117 117 char buf[_ROAR_MESS_BUF_LEN]; … … 119 119 ROAR_DBG("roar_send_message(*): try to send an request..."); 120 120 121 buf[0] = (unsigned char) mes->cmd; 122 *(uint16_t*)(buf+1) = ROAR_HOST2NET16(mes->stream); 123 *(uint32_t*)(buf+3) = ROAR_HOST2NET32(mes->pos); 124 *(uint16_t*)(buf+7) = ROAR_HOST2NET16(mes->datalen); 121 buf[0] = _ROAR_MESSAGE_VERSION; 122 buf[1] = (unsigned char) mes->cmd; 123 *(uint16_t*)(buf+2) = ROAR_HOST2NET16(mes->stream); 124 *(uint32_t*)(buf+4) = ROAR_HOST2NET32(mes->pos); 125 *(uint16_t*)(buf+8) = ROAR_HOST2NET16(mes->datalen); 125 126 126 127 if ( write(con->fh, buf, _ROAR_MESS_BUF_LEN) != _ROAR_MESS_BUF_LEN ) … … 148 149 ROAR_DBG("roar_recv_message(*): Got a header"); 149 150 150 mes->cmd = (unsigned char)buf[0]; 151 mes->stream = ROAR_NET2HOST16(*(uint16_t*)(buf+1)); 152 mes->pos = ROAR_NET2HOST32(*(uint32_t*)(buf+3)); 153 mes->datalen = ROAR_NET2HOST16(*(uint16_t*)(buf+7)); 151 if ( buf[0] != _ROAR_MESSAGE_VERSION ) 152 return -1; 153 154 mes->cmd = (unsigned char)buf[1]; 155 mes->stream = ROAR_NET2HOST16(*(uint16_t*)(buf+2)); 156 mes->pos = ROAR_NET2HOST32(*(uint32_t*)(buf+4)); 157 mes->datalen = ROAR_NET2HOST16(*(uint16_t*)(buf+8)); 154 158 155 159 ROAR_DBG("roar_recv_message(*): command=%i(%s)", mes->cmd,
Note: See TracChangeset
for help on using the changeset viewer.