Changeset 5377:72f1d48ff502 in roaraudio for libroar


Ignore:
Timestamp:
12/23/11 22:09:58 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Removed legacy functions (Closes: #130):

  • roar_vio_init_calls(),
  • roar_vio_set_inst(),
  • roar_vio_set_fh() and roar_vio_get_fh(),
  • roar_simple_new_stream_obj().
Location:
libroar
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libroar/simple.c

    r5296 r5377  
    3636#include "libroar.h" 
    3737 
    38 static int roar_simple_stream_obj  (struct roar_stream * s, uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec, const char * server, int dir, const char * name, int mixer) _LIBROAR_ATTR_DEPRECATED; 
     38static int roar_simple_stream_obj  (struct roar_stream * s, uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec, const char * server, int dir, const char * name, int mixer); 
    3939 
    4040int roar_simple_connect (struct roar_connection * con, const char * server, const char * name) { 
     
    136136} 
    137137 
    138 int roar_simple_new_stream_obj (struct roar_connection * con, struct roar_stream * s, uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec, int dir, int mixer) { 
    139  struct roar_libroar_config * config = roar_libroar_get_config(); 
    140  char file[80] = {0}; 
    141  int fh = -1, listen = -1; 
    142  static int count = 0; 
    143  int    type = ROAR_SOCKET_TYPE_UNIX; 
    144  int    port = 0; 
    145 #if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_LIBDNET) 
    146  int    opt  = 1; 
    147 #endif 
    148 #ifdef ROAR_HAVE_IPV4 
    149  struct sockaddr_in   socket_addr; 
    150  socklen_t            len            = sizeof(struct sockaddr_in); 
    151 #else 
    152  struct sockaddr      socket_addr; 
    153  socklen_t            len            = sizeof(struct sockaddr); 
    154 #endif 
    155 #ifdef ROAR_HAVE_SELECT 
    156  int confh; 
    157  fd_set fds; 
    158  struct timeval timeout = {10, 0}; 
    159  struct roar_message    mes; 
    160 #endif 
    161 #ifdef ROAR_HAVE_UNIX 
    162  int socks[2]; // for socketpair() 
    163 #endif 
    164  
    165  // make valgrind happy 
    166  memset(&socket_addr, 0, sizeof(socket_addr)); 
    167 #ifdef ROAR_HAVE_SELECT 
    168  memset(&mes,         0, sizeof(mes)); 
    169 #endif 
    170  
    171  roar_debug_warn_sysio("roar_simple_new_stream_obj", "roar_vio_simple_new_stream_obj", NULL); 
    172  
    173  if ( config != NULL ) { 
    174   if ( config->workaround.workarounds & ROAR_LIBROAR_CONFIG_WAS_USE_EXECED ) { 
    175    return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir, mixer); 
    176   } 
    177  } 
    178  
    179 #ifdef ROAR_HAVE_BSDSOCKETS 
    180  roar_libroar_nowarn(); 
    181  if ( getsockname(roar_get_connection_fh(con), (struct sockaddr *)&socket_addr, &len) == -1 ) { 
    182   roar_libroar_warn(); 
    183   return -1; 
    184  } 
    185  roar_libroar_warn(); 
    186 #else 
    187  return -1; 
    188 #endif 
    189  
    190  if ( len == 0 ) { 
    191 #ifdef ROAR_OS_OPENBSD 
    192   ROAR_WARN("roar_simple_new_stream_obj(*): Unknown address family: guess AF_UNIX because OS is OpenBSD"); 
    193   ((struct sockaddr*)&socket_addr)->sa_family = AF_UNIX; 
    194 #else 
    195   return -1; 
    196 #endif 
    197  } 
    198  
    199  switch (((struct sockaddr*)&socket_addr)->sa_family) { 
    200 #ifdef ROAR_HAVE_UNIX 
    201   case AF_UNIX:   type = ROAR_SOCKET_TYPE_UNIX; break; 
    202 #endif 
    203 #ifdef ROAR_HAVE_IPV4 
    204   case AF_INET:   type = ROAR_SOCKET_TYPE_INET; break; 
    205 #endif 
    206 #ifdef ROAR_HAVE_LIBDNET 
    207   case AF_DECnet: type = ROAR_SOCKET_TYPE_DECNET; break; 
    208 #endif 
    209   default: 
    210     return -1; 
    211    break; 
    212  } 
    213  
    214  if ( type == ROAR_SOCKET_TYPE_DECNET ) { 
    215   if ( roar_socket_get_local_nodename() ) { 
    216    snprintf(file, 24, "%s::roar$TMP%04x%02x", roar_socket_get_local_nodename(), getpid(), count++); 
    217   } else { 
    218    return -1; 
    219   } 
    220 #ifdef ROAR_HAVE_IPV4 
    221  } else { 
    222   strncpy(file, inet_ntoa(socket_addr.sin_addr), sizeof(file) - 1); 
    223 #endif 
    224  } 
    225  
    226  if ( type != ROAR_SOCKET_TYPE_UNIX ) { 
    227   if ( (listen = roar_socket_listen(type, file, port)) == -1 ) { 
    228    return -1; 
    229   } 
    230  } 
    231  
    232  if ( type == ROAR_SOCKET_TYPE_INET ) { 
    233 #ifdef ROAR_HAVE_IPV4 
    234   len = sizeof(struct sockaddr_in); 
    235   setsockopt(listen, SOL_SOCKET, SO_REUSEADDR, (void*)&opt, sizeof(int)); 
    236  
    237   if ( getsockname(listen, (struct sockaddr *)&socket_addr, &len) == -1 ) { 
    238    return -1; 
    239   } 
    240   port = ROAR_NET2HOST16(socket_addr.sin_port); 
    241   ROAR_DBG("roar_simple_new_stream_obj(*): port=%i", port); 
    242 #else 
    243   return -1; 
    244 #endif 
    245  } else if ( type == ROAR_SOCKET_TYPE_DECNET ) { 
    246 #ifdef ROAR_HAVE_LIBDNET 
    247   len = sizeof(struct sockaddr_in); 
    248   setsockopt(listen, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int)); 
    249 #else 
    250   return -1; 
    251 #endif 
    252  } 
    253  
    254  if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) { 
    255   return -1; 
    256  } 
    257  
    258  if ( roar_stream_connect(con, s, dir, mixer) == -1 ) { 
    259   return -1; 
    260  } 
    261  
    262  if ( type != ROAR_SOCKET_TYPE_UNIX ) { 
    263 #ifdef ROAR_HAVE_SELECT 
    264   if ( roar_stream_connect_to_ask(con, s, type, file, port) != -1 ) { 
    265  
    266    FD_ZERO(&fds); 
    267    FD_SET(listen, &fds); 
    268  
    269    confh = roar_get_connection_fh(con); 
    270  
    271    if ( confh != -1 ) { 
    272     FD_SET(confh, &fds); 
    273    } 
    274  
    275    if ( select((confh > listen ? confh : listen) + 1, &fds, NULL, NULL, &timeout) < 1 ) { 
    276     close(listen); 
    277  
    278     // we don't need to check the content as we know it failed... 
    279     if ( roar_recv_message(con, &mes, NULL) == -1 ) 
    280      return -1; 
    281  
    282     if ( roar_kick(con, ROAR_OT_STREAM, s->id) == -1 ) 
    283      return -1; 
    284  
    285     return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir, mixer); 
    286    } 
    287  
    288    if ( FD_ISSET(listen, &fds) ) { 
    289     if ( (fh = accept(listen, NULL, NULL)) != -1 ) { 
    290      /* errr, do we need we any error handling here? */ 
    291     } 
    292  
    293     if ( roar_recv_message(con, &mes, NULL) == -1 ) { 
    294      if ( fh != -1 ) 
    295       close(fh); 
    296      fh = -1; 
    297     } else if ( mes.cmd != ROAR_CMD_OK ) { 
    298      if ( fh != -1 ) 
    299       close(fh); 
    300      fh = -1; 
    301     } 
    302    } else { 
    303     // we don't need to check the content as we know it failed... 
    304     if ( roar_recv_message(con, &mes, NULL) == -1 ) { 
    305      close(listen); 
    306      return -1; 
    307     } 
    308  
    309     if ( mes.cmd != ROAR_CMD_OK ) { 
    310      close(listen); 
    311      if ( roar_kick(con, ROAR_OT_STREAM, s->id) == -1 ) 
    312       return -1; 
    313  
    314      return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir, mixer); 
    315     } else { // seems like we have a positive reply. So we retry the listen socket: 
    316      FD_ZERO(&fds); 
    317      FD_SET(listen, &fds); 
    318      timeout.tv_sec = 0; 
    319      timeout.tv_usec = 128000L; 
    320      fh = -1; 
    321      if ( select(listen + 1, &fds, NULL, NULL, &timeout) > 0 ) { 
    322       if ( (fh = accept(listen, NULL, NULL)) == -1 ) { 
    323        close(listen); 
    324        if ( roar_kick(con, ROAR_OT_STREAM, s->id) == -1 ) 
    325         return -1; 
    326  
    327        return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir, mixer); 
    328       } 
    329      } 
    330     } 
    331    } 
    332   } 
    333  
    334   close(listen); 
    335 #else 
    336   return -1; 
    337 #endif 
    338  } else { // this is type == ROAR_SOCKET_TYPE_UNIX 
    339 #ifdef ROAR_HAVE_UNIX 
    340   if ( socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1 ) { 
    341    roar_kick(con, ROAR_OT_STREAM, s->id); // we do not need to check for errors 
    342                                           // as we return -1 in both whys 
    343    return -1; 
    344   } 
    345  
    346   if ( roar_stream_passfh(con, s, socks[0]) == -1 ) { 
    347    roar_kick(con, ROAR_OT_STREAM, s->id); // we do not need to check for errors 
    348                                           // as we return -1 anyway. 
    349    close(socks[0]); 
    350    close(socks[1]); 
    351    return -1; 
    352   } 
    353  
    354   close(socks[0]); 
    355   fh = socks[1]; 
    356 #else 
    357   roar_kick(con, ROAR_OT_STREAM, s->id); 
    358   return -1; 
    359 #endif 
    360  } 
    361  
    362 /* 
    363  if ( type == ROAR_SOCKET_TYPE_UNIX ) { 
    364   unlink(file); 
    365  } 
    366 */ 
    367  
    368  if ( fh != -1 ) { 
    369   if ( dir == ROAR_DIR_PLAY ) { 
    370    (void)ROAR_SHUTDOWN(fh, SHUT_RD); 
    371   } else if ( dir == ROAR_DIR_MONITOR || dir == ROAR_DIR_RECORD ) { 
    372    (void)ROAR_SHUTDOWN(fh, SHUT_WR); 
    373   } 
    374  } 
    375  
    376  s->fh = fh; 
    377  
    378  return fh; 
    379 } 
    380  
    381  
    382138int roar_simple_play_file(const char * file, const char * server, const char * name) { 
    383139 roar_vs_t * vss; 
  • libroar/vio.c

    r5375 r5377  
    4545#endif 
    4646 
    47 int roar_vio_init_calls (struct roar_vio_calls * calls) { 
    48  roar_debug_warn_obsolete("roar_vio_init_calls", "roar_vio_clear_calls", NULL); 
    49  
    50 #ifdef _CAN_OPERATE 
    51  if ( calls == NULL ) { 
    52   roar_err_set(ROAR_ERROR_FAULT); 
    53   return -1; 
    54  } 
    55  
    56  memset((void*)calls, 0, sizeof(struct roar_vio_calls)); 
    57  
    58  calls->read     = roar_vio_basic_read; 
    59  calls->write    = roar_vio_basic_write; 
    60  calls->lseek    = roar_vio_basic_lseek; 
    61  calls->sync     = roar_vio_basic_sync; 
    62  calls->ctl      = roar_vio_basic_ctl; 
    63  calls->close    = roar_vio_basic_close; 
    64  
    65  return 0; 
    66 #else 
    67  return -1; 
    68 #endif 
    69 } 
    70  
    7147int roar_vio_clear_calls (struct roar_vio_calls * calls) { 
    7248 if ( calls == NULL ) { 
     
    8056} 
    8157 
    82 int roar_vio_set_inst (struct roar_vio_calls * vio, void * inst) { 
    83  if ( vio == NULL ) { 
    84   roar_err_set(ROAR_ERROR_FAULT); 
    85   return -1; 
    86  } 
    87  
    88  vio->inst = inst; 
    89  
    90  return 0; 
    91 } 
    92  
    93 int roar_vio_set_fh   (struct roar_vio_calls * vio, int fh) { 
    94  return roar_vio_set_inst(vio, (void*)(ROAR_INSTINT)(fh + 1)); 
    95 } 
    96  
    97 int roar_vio_get_fh   (struct roar_vio_calls * vio) { 
     58static int roar_vio_get_fh   (struct roar_vio_calls * vio) { 
    9859 if ( vio == NULL ) { 
    9960  roar_err_set(ROAR_ERROR_FAULT); 
     
    287248 
    288249// converters: 
    289 int     roar_vio_open_file     (struct roar_vio_calls * calls, const char * filename, int flags, mode_t mode) { 
    290  struct roar_vio_defaults def; 
    291  
    292  roar_debug_warn_obsolete("roar_vio_open_file", "roar_vio_open_dstr", NULL); 
    293  
    294  if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_FILE, flags, mode) == -1 ) 
    295   return -1; 
    296  
    297  def.d.file = filename; 
    298  
    299  return roar_vio_open_default(calls, &def, NULL); 
    300 } 
    301  
    302250int     roar_vio_open_fh       (struct roar_vio_calls * calls, int fh) { 
    303251 if ( calls == NULL ) { 
     
    306254 } 
    307255 
    308  roar_libroar_nowarn(); 
    309  if ( roar_vio_init_calls(calls) == -1 ) { 
    310   roar_libroar_warn(); 
    311   return -1; 
    312  } 
    313  roar_libroar_warn(); 
    314  
    315  return roar_vio_set_fh(calls, fh); 
     256 memset((void*)calls, 0, sizeof(struct roar_vio_calls)); 
     257 
     258 calls->read     = roar_vio_basic_read; 
     259 calls->write    = roar_vio_basic_write; 
     260 calls->lseek    = roar_vio_basic_lseek; 
     261 calls->sync     = roar_vio_basic_sync; 
     262 calls->ctl      = roar_vio_basic_ctl; 
     263 calls->close    = roar_vio_basic_close; 
     264 
     265 calls->inst     = (void*)(ROAR_INSTINT)(fh + 1); 
     266 
     267 return 0; 
    316268} 
    317269 
  • libroar/vio_stream.c

    r5289 r5377  
    157157} 
    158158 
     159static int _roar_simple_new_stream_obj (struct roar_connection * con, struct roar_stream * s, uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec, int dir, int mixer) { 
     160 struct roar_libroar_config * config = roar_libroar_get_config(); 
     161 char file[80] = {0}; 
     162 int fh = -1, listen = -1; 
     163 static int count = 0; 
     164 int    type = ROAR_SOCKET_TYPE_UNIX; 
     165 int    port = 0; 
     166#if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_LIBDNET) 
     167 int    opt  = 1; 
     168#endif 
     169#ifdef ROAR_HAVE_IPV4 
     170 struct sockaddr_in   socket_addr; 
     171 socklen_t            len            = sizeof(struct sockaddr_in); 
     172#else 
     173 struct sockaddr      socket_addr; 
     174 socklen_t            len            = sizeof(struct sockaddr); 
     175#endif 
     176#ifdef ROAR_HAVE_SELECT 
     177 int confh; 
     178 fd_set fds; 
     179 struct timeval timeout = {10, 0}; 
     180 struct roar_message    mes; 
     181#endif 
     182#ifdef ROAR_HAVE_UNIX 
     183 int socks[2]; // for socketpair() 
     184#endif 
     185 
     186 // make valgrind happy 
     187 memset(&socket_addr, 0, sizeof(socket_addr)); 
     188#ifdef ROAR_HAVE_SELECT 
     189 memset(&mes,         0, sizeof(mes)); 
     190#endif 
     191 
     192 if ( config != NULL ) { 
     193  if ( config->workaround.workarounds & ROAR_LIBROAR_CONFIG_WAS_USE_EXECED ) { 
     194   return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir, mixer); 
     195  } 
     196 } 
     197 
     198#ifdef ROAR_HAVE_BSDSOCKETS 
     199 roar_libroar_nowarn(); 
     200 if ( getsockname(roar_get_connection_fh(con), (struct sockaddr *)&socket_addr, &len) == -1 ) { 
     201  roar_libroar_warn(); 
     202  return -1; 
     203 } 
     204 roar_libroar_warn(); 
     205#else 
     206 return -1; 
     207#endif 
     208 
     209 if ( len == 0 ) { 
     210#ifdef ROAR_OS_OPENBSD 
     211  ROAR_WARN("roar_simple_new_stream_obj(*): Unknown address family: guess AF_UNIX because OS is OpenBSD"); 
     212  ((struct sockaddr*)&socket_addr)->sa_family = AF_UNIX; 
     213#else 
     214  return -1; 
     215#endif 
     216 } 
     217 
     218 switch (((struct sockaddr*)&socket_addr)->sa_family) { 
     219#ifdef ROAR_HAVE_UNIX 
     220  case AF_UNIX:   type = ROAR_SOCKET_TYPE_UNIX; break; 
     221#endif 
     222#ifdef ROAR_HAVE_IPV4 
     223  case AF_INET:   type = ROAR_SOCKET_TYPE_INET; break; 
     224#endif 
     225#ifdef ROAR_HAVE_LIBDNET 
     226  case AF_DECnet: type = ROAR_SOCKET_TYPE_DECNET; break; 
     227#endif 
     228  default: 
     229    return -1; 
     230   break; 
     231 } 
     232 
     233 if ( type == ROAR_SOCKET_TYPE_DECNET ) { 
     234  if ( roar_socket_get_local_nodename() ) { 
     235   snprintf(file, 24, "%s::roar$TMP%04x%02x", roar_socket_get_local_nodename(), getpid(), count++); 
     236  } else { 
     237   return -1; 
     238  } 
     239#ifdef ROAR_HAVE_IPV4 
     240 } else { 
     241  strncpy(file, inet_ntoa(socket_addr.sin_addr), sizeof(file) - 1); 
     242#endif 
     243 } 
     244 
     245 if ( type != ROAR_SOCKET_TYPE_UNIX ) { 
     246  if ( (listen = roar_socket_listen(type, file, port)) == -1 ) { 
     247   return -1; 
     248  } 
     249 } 
     250 
     251 if ( type == ROAR_SOCKET_TYPE_INET ) { 
     252#ifdef ROAR_HAVE_IPV4 
     253  setsockopt(listen, SOL_SOCKET, SO_REUSEADDR, (void*)&opt, sizeof(int)); 
     254 
     255  len = sizeof(struct sockaddr_in); 
     256  if ( getsockname(listen, (struct sockaddr *)&socket_addr, &len) == -1 ) { 
     257   return -1; 
     258  } 
     259  port = ROAR_NET2HOST16(socket_addr.sin_port); 
     260  ROAR_DBG("roar_simple_new_stream_obj(*): port=%i", port); 
     261#else 
     262  return -1; 
     263#endif 
     264 } else if ( type == ROAR_SOCKET_TYPE_DECNET ) { 
     265#ifdef ROAR_HAVE_LIBDNET 
     266  setsockopt(listen, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int)); 
     267#else 
     268  return -1; 
     269#endif 
     270 } 
     271 
     272 if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) { 
     273  return -1; 
     274 } 
     275 
     276 if ( roar_stream_connect(con, s, dir, mixer) == -1 ) { 
     277  return -1; 
     278 } 
     279 
     280 if ( type != ROAR_SOCKET_TYPE_UNIX ) { 
     281#ifdef ROAR_HAVE_SELECT 
     282  if ( roar_stream_connect_to_ask(con, s, type, file, port) != -1 ) { 
     283 
     284   FD_ZERO(&fds); 
     285   FD_SET(listen, &fds); 
     286 
     287   confh = roar_get_connection_fh(con); 
     288 
     289   if ( confh != -1 ) { 
     290    FD_SET(confh, &fds); 
     291   } 
     292 
     293   if ( select((confh > listen ? confh : listen) + 1, &fds, NULL, NULL, &timeout) < 1 ) { 
     294    close(listen); 
     295 
     296    // we don't need to check the content as we know it failed... 
     297    if ( roar_recv_message(con, &mes, NULL) == -1 ) 
     298     return -1; 
     299 
     300    if ( roar_kick(con, ROAR_OT_STREAM, s->id) == -1 ) 
     301     return -1; 
     302 
     303    return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir, mixer); 
     304   } 
     305 
     306   if ( FD_ISSET(listen, &fds) ) { 
     307    if ( (fh = accept(listen, NULL, NULL)) != -1 ) { 
     308     /* errr, do we need we any error handling here? */ 
     309    } 
     310 
     311    if ( roar_recv_message(con, &mes, NULL) == -1 ) { 
     312     if ( fh != -1 ) 
     313      close(fh); 
     314     fh = -1; 
     315    } else if ( mes.cmd != ROAR_CMD_OK ) { 
     316     if ( fh != -1 ) 
     317      close(fh); 
     318     fh = -1; 
     319    } 
     320   } else { 
     321    // we don't need to check the content as we know it failed... 
     322    if ( roar_recv_message(con, &mes, NULL) == -1 ) { 
     323     close(listen); 
     324     return -1; 
     325    } 
     326 
     327    if ( mes.cmd != ROAR_CMD_OK ) { 
     328     close(listen); 
     329     if ( roar_kick(con, ROAR_OT_STREAM, s->id) == -1 ) 
     330      return -1; 
     331 
     332     return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir, mixer); 
     333    } else { // seems like we have a positive reply. So we retry the listen socket: 
     334     FD_ZERO(&fds); 
     335     FD_SET(listen, &fds); 
     336     timeout.tv_sec = 0; 
     337     timeout.tv_usec = 128000L; 
     338     fh = -1; 
     339     if ( select(listen + 1, &fds, NULL, NULL, &timeout) > 0 ) { 
     340      if ( (fh = accept(listen, NULL, NULL)) == -1 ) { 
     341       close(listen); 
     342       if ( roar_kick(con, ROAR_OT_STREAM, s->id) == -1 ) 
     343        return -1; 
     344 
     345       return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir, mixer); 
     346      } 
     347     } 
     348    } 
     349   } 
     350  } 
     351 
     352  close(listen); 
     353#else 
     354  return -1; 
     355#endif 
     356 } else { // this is type == ROAR_SOCKET_TYPE_UNIX 
     357#ifdef ROAR_HAVE_UNIX 
     358  if ( socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1 ) { 
     359   roar_kick(con, ROAR_OT_STREAM, s->id); // we do not need to check for errors 
     360                                          // as we return -1 in both whys 
     361   return -1; 
     362  } 
     363 
     364  if ( roar_stream_passfh(con, s, socks[0]) == -1 ) { 
     365   roar_kick(con, ROAR_OT_STREAM, s->id); // we do not need to check for errors 
     366                                          // as we return -1 anyway. 
     367   close(socks[0]); 
     368   close(socks[1]); 
     369   return -1; 
     370  } 
     371 
     372  close(socks[0]); 
     373  fh = socks[1]; 
     374#else 
     375  roar_kick(con, ROAR_OT_STREAM, s->id); 
     376  return -1; 
     377#endif 
     378 } 
     379 
     380 if ( fh != -1 ) { 
     381  if ( dir == ROAR_DIR_PLAY ) { 
     382   (void)ROAR_SHUTDOWN(fh, SHUT_RD); 
     383  } else if ( dir == ROAR_DIR_MONITOR || dir == ROAR_DIR_RECORD ) { 
     384   (void)ROAR_SHUTDOWN(fh, SHUT_WR); 
     385  } 
     386 } 
     387 
     388 s->fh = fh; 
     389 
     390 return fh; 
     391} 
     392 
    159393int     roar_vio_simple_new_stream_obj (struct roar_vio_calls * calls, 
    160394                                        struct roar_connection * con, 
     
    175409  s = &stream; 
    176410 
    177  roar_libroar_nowarn(); 
    178  if ( (fh = roar_simple_new_stream_obj(con, s, rate, channels, bits, codec, dir, mixer)) == -1 ) { 
    179   roar_libroar_warn(); 
     411 if ( (fh = _roar_simple_new_stream_obj(con, s, rate, channels, bits, codec, dir, mixer)) == -1 ) { 
    180412  ROAR_DBG("roar_vio_simple_new_stream_obj(*) = -1"); 
    181413  return -1; 
    182414 } 
    183  roar_libroar_warn(); 
    184415 
    185416 ROAR_DBG("roar_vio_simple_new_stream_obj(*): fh=%i", fh); 
  • libroar/vio_winsock.c

    r5278 r5377  
    3737 
    3838#ifdef ROAR_TARGET_WIN32 
     39 
     40static int _get_fh(struct roar_vio_calls * vio) { 
     41 int fh; 
     42 
     43 if ( roar_vio_ctl(vio, ROAR_VIO_CTL_GET_FH, &fh) == -1 ) 
     44  return -1; 
     45 
     46 return fh; 
     47} 
     48 
    3949ssize_t roar_vio_winsock_read    (struct roar_vio_calls * vio, void *buf, size_t count) { 
    40  return recv(roar_vio_get_fh(vio), buf, count, 0); 
     50 return recv(_get_fh(vio), buf, count, 0); 
    4151} 
    4252 
    4353ssize_t roar_vio_winsock_write   (struct roar_vio_calls * vio, void *buf, size_t count) { 
    44  return send(roar_vio_get_fh(vio), buf, count, 0); 
     54 return send(_get_fh(vio), buf, count, 0); 
    4555} 
    4656 
     
    6979  case ROAR_VIO_CTL_GET_SELECT_READ_FH: 
    7080  case ROAR_VIO_CTL_GET_SELECT_WRITE_FH: 
    71     ROAR_DBG("roar_vio_winsock_ctl(vio=%p, cmd=ROAR_VIO_CTL_GET_SELECT_*FH(0x%.8x), data=%p) = 0 // fh=%i", vio, cmd, data, roar_vio_get_fh(vio)); 
    72     *(int*)data = roar_vio_get_fh(vio); 
     81    ROAR_DBG("roar_vio_winsock_ctl(vio=%p, cmd=ROAR_VIO_CTL_GET_SELECT_*FH(0x%.8x), data=%p) = 0 // fh=%i", vio, cmd, data, _get_fh(vio)); 
     82    *(int*)data = _get_fh(vio); 
    7383    return 0; 
    7484   break; 
     
    7888   break; 
    7989  case ROAR_VIO_CTL_ACCEPT: 
    80     tmp = accept(roar_vio_get_fh(vio), NULL, 0); 
     90    tmp = accept(_get_fh(vio), NULL, 0); 
    8191    if ( tmp == -1 ) 
    8292     return -1; 
     
    116126    } 
    117127 
    118     return shutdown(roar_vio_get_fh(vio), tmp); 
     128    return shutdown(_get_fh(vio), tmp); 
    119129   break; 
    120130 } 
     
    126136int     roar_vio_winsock_close   (struct roar_vio_calls * vio) { 
    127137 
    128  closesocket(roar_vio_get_fh(vio)); 
     138 closesocket(_get_fh(vio)); 
    129139 
    130140 return 0; 
Note: See TracChangeset for help on using the changeset viewer.