Changeset 5635:94450e5c67fc in roaraudio for roard


Ignore:
Timestamp:
08/24/12 15:26:43 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Added audio click to roard's libshout driver "shout".

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/driver_shout.c

    r5388 r5635  
    2727#ifdef ROAR_HAVE_LIBSHOUT 
    2828 
     29struct driver_shout { 
     30 shout_t * shout; 
     31 int blocking; 
     32}; 
     33 
    2934static int _driver_shout_usage_counter = 0; 
    3035 
    3136int     driver_shout_open_vio(struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream) { 
    32  char * s_server = NULL; 
    33  char * s_mount  = NULL; 
    34  char * s_user   = NULL; 
    35  char * s_pw     = NULL; 
     37 struct driver_shout * self = NULL; 
     38 const char * s_server = NULL; 
     39 const char * s_mount  = NULL; 
     40 const char * s_user   = NULL; 
     41 const char * s_pw     = NULL; 
    3642 int    s_port   = -1; 
    37  char * s_desc   = NULL; 
    38  char * s_genre  = NULL; 
    39  char * s_name   = NULL; 
    40  char * s_url    = NULL; 
     43 const char * s_desc   = NULL; 
     44 const char * s_genre  = NULL; 
     45 const char * s_name   = NULL; 
     46 const char * s_url    = NULL; 
    4147 int    s_public = 0; 
    4248 char * a; 
     
    198204 } 
    199205 
     206 self = roar_mm_malloc(sizeof(struct driver_shout)); 
     207 if ( self == NULL ) { 
     208  shout_close(shout); 
     209  return -1; 
     210 } 
     211 
     212 memset(self, 0, sizeof(struct driver_shout)); 
     213 self->shout = shout; 
     214 self->blocking = ROAR_SOCKET_BLOCK; 
     215 
    200216 memset(inst, 0, sizeof(struct roar_vio_calls)); 
    201217 inst->flags    = ROAR_VIO_FLAGS_NONE; 
    202218 inst->refc     = 1; 
    203  inst->inst     = (void*)shout; 
     219 inst->inst     = (void*)self; 
    204220 inst->write    = driver_shout_write; 
    205221 inst->close    = driver_shout_close; 
     
    210226 
    211227int     driver_shout_close(struct roar_vio_calls * vio) { 
    212  
    213  shout_close((shout_t *)vio->inst); 
     228 struct driver_shout * self = vio->inst; 
     229 
     230 shout_close(self->shout); 
     231 roar_mm_free(self); 
    214232 
    215233 if ( _driver_shout_usage_counter-- == 1 ) 
     
    220238 
    221239ssize_t driver_shout_write(struct roar_vio_calls * vio, void *buf, size_t count) { 
    222  if (shout_send((shout_t *)vio->inst, (unsigned char*)buf, count) != SHOUTERR_SUCCESS) 
     240 struct driver_shout * self = vio->inst; 
     241 
     242 if (shout_send(self->shout, (unsigned char*)buf, count) != SHOUTERR_SUCCESS) 
    223243  return -1; 
    224244 
     245 if ( self->blocking == ROAR_SOCKET_BLOCK ) 
     246  shout_sync(self->shout); 
     247 
    225248 return count; 
     249} 
     250 
     251int     driver_shout_ctl     (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) { 
     252 struct driver_shout * self = vio->inst; 
     253 
     254 switch (cmd) { 
     255  case ROAR_VIO_CTL_NONBLOCK: 
     256    self->blocking = *(const int*)data; 
     257    return 0; 
     258   break; 
     259  default: 
     260    roar_err_set(ROAR_ERROR_BADRQC); 
     261    return -1; 
     262   break; 
     263 } 
    226264} 
    227265 
Note: See TracChangeset for help on using the changeset viewer.