Changeset 5148:73d76a74be61 in roaraudio


Ignore:
Timestamp:
10/15/11 14:29:29 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

improved error handling some more, marked some stuff as obsolete

Location:
libroar
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • libroar/basic.c

    r5146 r5148  
    374374 
    375375int roar_wait_msg     (struct roar_connection * con, int16_t seq, int16_t seqmask) { 
     376 roar_err_set(ROAR_ERROR_NOSYS); 
    376377 return -1; 
    377378} 
     
    381382 
    382383 if ( con == NULL ) { 
     384  roar_err_set(ROAR_ERROR_FAULT); 
    383385  return -1; 
    384386 } 
     
    436438 
    437439int roar_debug_message_print (struct roar_message * mes) { 
    438  if ( mes == NULL ) 
    439   return -1; 
     440 roar_debug_warn_obsolete("roar_debug_message_print", NULL, NULL); 
     441 
     442 if ( mes == NULL ) { 
     443  roar_err_set(ROAR_ERROR_FAULT); 
     444  return -1; 
     445 } 
    440446 
    441447 ROAR_DBG("roar_debug_message_print(*): Command: %i", mes->cmd); 
     
    449455 
    450456int roar_debug_audio_info_print (struct roar_audio_info * info) { 
    451  if ( info == NULL ) 
    452   return -1; 
     457 if ( info == NULL ) { 
     458  roar_err_set(ROAR_ERROR_FAULT); 
     459  return -1; 
     460 } 
    453461 
    454462 ROAR_DBG("roar_debug_audio_info_print(*): Rate    : %i", info->rate); 
  • libroar/ctl.c

    r5145 r5148  
    325325 
    326326 if ( m->data[0] != 0 ) { 
    327   ROAR_ERR("roar_ctl_m2f(*): version %i not supported!", (int)m->data[0]); 
     327  ROAR_DBG("roar_ctl_m2f(*): version %i not supported!", (int)m->data[0]); 
     328  roar_err_set(ROAR_ERROR_NSVERSION); 
    328329  return -1; 
    329330 } 
  • libroar/file.c

    r5118 r5148  
    3636#include "libroar.h" 
    3737 
    38 #define BUFSIZE 8192 
    39 #define BUFMAX  65536 
     38#define BUFFERSIZE 8192 
     39#define BUFMAX     65536 
    4040 
    4141#ifdef ROAR_HAVE_IO_POSIX 
     
    9797#endif 
    9898 int len; 
    99  char buf[BUFSIZE]; 
     99 char buf[BUFFERSIZE]; 
    100100#if defined(__linux__) && defined(ROAR_HAVE_IPV4) 
    101101 int cork_new = 1, cork_old; 
     
    118118 // TODO: try mmap here! 
    119119 
    120  while ((len = read(in, buf, BUFSIZE)) > 0) 
     120 while ((len = read(in, buf, BUFFERSIZE)) > 0) 
    121121  r += write(out, buf, len); 
    122122 
     
    136136 int mmap_flags = 0; 
    137137 struct stat stat; 
     138 
     139 roar_debug_warn_obsolete("roar_file_map", NULL, NULL); 
    138140 
    139141 if ( mem == NULL || filename == NULL ) 
     
    183185 
    184186int     roar_file_unmap      (size_t len, void * mem) { 
     187 roar_debug_warn_obsolete("roar_file_unmap", NULL, NULL); 
     188 
    185189#ifdef ROAR_HAVE_MMAP 
    186190 return munmap(mem, len); 
     
    205209 int seek; 
    206210 int len; 
    207  char buf[BUFSIZE]; 
     211 char buf[BUFFERSIZE]; 
    208212 int rate = ROAR_RATE_DEFAULT, channels = ROAR_CHANNELS_DEFAULT, bits = ROAR_BITS_DEFAULT; 
    209213 struct roar_stream localstream[1]; 
     
    213217 ROAR_DBG("roar_file_play_full(*) = ?"); 
    214218 
    215  if ( !s ) 
     219 if ( s == NULL ) 
    216220  s = localstream; 
    217221 
    218  if ( !con ) 
    219   return -1; 
    220  
    221  if ( !file ) 
    222   return -1; 
    223  
    224  if ( exec && passfh ) 
    225   return -1; 
     222 if ( con == NULL ) { 
     223  roar_err_set(ROAR_ERROR_FAULT); 
     224  return -1; 
     225 } 
     226 
     227 if ( file == NULL ) { 
     228  roar_err_set(ROAR_ERROR_FAULT); 
     229  return -1; 
     230 } 
     231 
     232 if ( exec && passfh ) { 
     233  roar_err_set(ROAR_ERROR_INVAL); 
     234  return -1; 
     235 } 
    226236 
    227237#ifdef ROAR_TARGET_WIN32 
     
    230240 if ( (in = open(file, O_RDONLY, 0644)) == -1 ) { 
    231241#endif 
    232   return -1; 
    233  } 
    234  
    235  if ((len = read(in, buf, BUFSIZE)) < 1) { 
     242  roar_err_from_errno(); 
     243  return -1; 
     244 } 
     245 
     246 if ((len = read(in, buf, BUFFERSIZE)) < 1) { 
     247  roar_err_from_errno(); 
    236248  close(in); 
    237249  return -1; 
     
    245257 
    246258 if ( codec == -1 ) { 
    247   ROAR_ERR("roar_file_play_full(*): Unknown codec of file: %s", file); 
     259  ROAR_WARN("roar_file_play_full(*): Unknown codec of file: %s", file); 
    248260  close(in); 
     261  roar_err_set(ROAR_ERROR_BADMAGIC); 
    249262  return -1; 
    250263 } 
     
    256269 if ( exec ) { 
    257270  if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) { 
    258    ROAR_ERR("roar_file_play_full(*): Can not create new stream. This is realy BAD!"); 
     271   ROAR_DBG("roar_file_play_full(*): Can not create new stream. This is realy BAD!"); 
    259272   close(in); 
    260273   return -1; 
     
    262275 
    263276  if ( roar_stream_connect2(con, s, ROAR_DIR_PLAY, -1) == -1 ) { 
    264    ROAR_ERR("roar_file_play_full(*): Can not connect new stream to server."); 
     277   ROAR_DBG("roar_file_play_full(*): Can not connect new stream to server."); 
    265278   close(in); 
    266279   return -1; 
     
    268281 
    269282  if ( roar_stream_exec(con, s) == -1 ) { 
    270    ROAR_ERR("roar_file_play_full(*): Can not exec new stream on server."); 
     283   ROAR_DBG("roar_file_play_full(*): Can not exec new stream on server."); 
    271284   close(in); 
    272285   return -1; 
     
    275288  roar_libroar_nowarn(); 
    276289  if ( (out = roar_get_connection_fh(con)) == -1 ) { 
    277    ROAR_ERR("roar_file_play_full(*): Can not get socket of server connection for exec data transmition."); 
     290   ROAR_DBG("roar_file_play_full(*): Can not get socket of server connection for exec data transmition."); 
    278291   close(in); 
    279292   roar_libroar_warn(); 
     
    311324  close(out); 
    312325#else 
    313  while ((len = read(in, buf, BUFSIZE)) > 0) 
     326 while ((len = read(in, buf, BUFFERSIZE)) > 0) 
    314327  if ( send(out, buf, len, 0) != len ) 
    315328   break; 
     
    336349 return r; 
    337350#else 
     351 roar_err_set(ROAR_ERROR_NOSYS); 
    338352 return -1; 
    339353#endif 
     
    350364#endif 
    351365 
     366 roar_err_set(ROAR_ERROR_NODEV); 
    352367 return NULL; 
    353368} 
  • libroar/simple.c

    r5118 r5148  
    7373 struct roar_connection con; 
    7474 int ret; 
     75 int safe_error; 
    7576 
    7677 roar_debug_warn_sysio("roar_simple_stream_obj", NULL, NULL); 
     
    8384 
    8485 if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) { 
     86  safe_error = roar_error; 
    8587  roar_disconnect(&con); 
     88  roar_err_set(safe_error); 
    8689  return -1; 
    8790 } 
    8891 
    8992 if ( roar_stream_connect2(&con, s, dir, -1) == -1 ) { 
     93  safe_error = roar_error; 
    9094  roar_disconnect(&con); 
     95  roar_err_set(safe_error); 
    9196  return -1; 
    9297 } 
    9398 
    9499 if ( roar_stream_exec(&con, s) == -1 ) { 
     100  safe_error = roar_error; 
    95101  roar_disconnect(&con); 
     102  roar_err_set(safe_error); 
    96103  return -1; 
    97104 } 
     
    99106 roar_libroar_nowarn(); 
    100107 if ( (ret = roar_get_connection_fh(&con)) == -1 ) { 
     108  safe_error = roar_error; 
    101109  roar_libroar_warn(); 
    102110  roar_disconnect(&con); 
     111  roar_err_set(safe_error); 
    103112  return -1; 
    104113 } 
  • libroar/socket.c

    r5138 r5148  
    230230 
    231231 if ( (flags = fcntl(fh, F_GETFL, 0)) == -1 ) { 
     232  roar_err_from_errno(); 
    232233  ROAR_ERR("roar_socket_nonblock(fh=%i, state=%i): Can not read flags: %s", fh, state, strerror(errno)); 
    233234  ROAR_DBG("roar_socket_nonblock(fh=%i, state=%i) = -1", fh, state); 
     
    244245 
    245246 if ( fcntl(fh, F_SETFL, flags) == -1 ) { 
     247  roar_err_from_errno(); 
    246248  ROAR_ERR("roar_socket_nonblock(fh=%i, state=%i): Can not set flags: %s", fh, state, strerror(errno)); 
    247249  ROAR_DBG("roar_socket_nonblock(fh=%i, state=%i) = -1", fh, state); 
     
    269271 
    270272 if ( getsockname(fh, (struct sockaddr *)&socket_addr, &len) == -1 ) { 
     273  roar_err_from_errno(); 
    271274  return -1; 
    272275 } 
    273276 
    274277 if ( socket_addr.sin_family != AF_INET ) { 
     278  roar_err_set(ROAR_ERROR_TYPEMM); 
    275279  return -1; 
    276280 } 
     
    283287//  if ( mode_func(fh, (struct sockaddr *)&socket_addr, sizeof(struct sockaddr_in)) == -1 ) { 
    284288 if ( bind(n, (struct sockaddr *)&socket_addr, len) == -1 ) { 
     289  roar_err_from_errno(); 
    285290  close(n); 
    286291  return -1; 
  • libroar/stream.c

    r5145 r5148  
    6767 roar_stream_s2m(&ms, &m); 
    6868 
    69  if ( roar_req(con, &m, NULL) != 0 ) 
     69 if ( roar_req3(con, &m, NULL) != 0 ) 
    7070  return -1; 
    7171 
Note: See TracChangeset for help on using the changeset viewer.