Changeset 17:411717cefded in roaraudio


Ignore:
Timestamp:
06/19/08 22:51:13 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

now we can change the volume, but it will not work if you set it... haha...

Files:
11 edited

Legend:

Unmodified
Added
Removed
  • TODO

    r16 r17  
    66 * add a lot other things 
    77 * add code to handle streams with more than ROAR_MAX_CHANNELS channels 
     8 * fix byte-order bug in *_set_vol() and *_kick() 
     9 * get the volume changing code working 
  • include/libroar/ctl.h

    r0 r17  
    3030int roar_kick         (struct roar_connection * con, int type, int id); 
    3131 
     32int roar_set_vol      (struct roar_connection * con, int id, struct roar_mixer_settings * mixer, int channels); 
     33 
    3234// filter... 
    3335int roar_ctl_f2m      (struct roar_message * m, unsigned char   filter, unsigned char   cmp, uint32_t   id); 
  • include/roaraudio/audio.h

    r16 r17  
    5757#define ROAR_MAX_CHANNELS         64 
    5858 
     59#define ROAR_SET_VOL_ALL           1 
     60#define ROAR_SET_VOL_ONE           2 
     61 
    5962struct roar_audio_info { 
    6063 unsigned int rate; 
     
    6568 
    6669struct roar_mixer_settings { 
    67  unsigned      channels; 
     70 //unsigned      channels; 
    6871 roar_intm16   scale; 
    6972 roar_intm16   mixer[ROAR_MAX_CHANNELS]; 
  • include/roaraudio/proto.h

    r0 r17  
    3333#define ROAR_CMD_KICK          18 
    3434 
     35#define ROAR_CMD_SET_VOL       19 
    3536 
    3637#define ROAR_CMD_OK           254 
  • libroar/ctl.c

    r0 r17  
    117117int roar_kick         (struct roar_connection * con, int type, int id) { 
    118118 struct roar_message m; 
    119  uint16_t * info = m.data; 
     119 uint16_t * info = (uint16_t *) m.data; 
    120120 
    121121 m.cmd     = ROAR_CMD_KICK; 
     
    123123 info[0] = type; 
    124124 info[1] = id; 
     125 
     126 if ( roar_req(con, &m, NULL) == -1 ) 
     127  return -1; 
     128 
     129 if ( m.cmd != ROAR_CMD_OK ) 
     130  return -1; 
     131 
     132 return 0; 
     133} 
     134 
     135int roar_set_vol      (struct roar_connection * con, int id, struct roar_mixer_settings * mixer, int channels) { 
     136 struct roar_message m; 
     137 uint16_t * info = (uint16_t *) m.data; 
     138 int i; 
     139 
     140 m.cmd     = ROAR_CMD_SET_VOL; 
     141 m.datalen = (3 + channels) * 2; 
     142 info[0] = 0; 
     143 info[1] = id; 
     144 info[2] = ROAR_SET_VOL_ALL; 
     145 
     146 for (i = 0; i < channels; i++) 
     147  info[i+3] = mixer->mixer[i]; 
    125148 
    126149 if ( roar_req(con, &m, NULL) == -1 ) 
     
    261284 
    262285 strncpy(c->name, (m->data)+cur+1, m->data[cur]); 
    263  c->name[m->data[cur]] = 0; 
     286 c->name[(int)m->data[cur]] = 0; 
    264287 
    265288 return 0; 
  • libroaresd/esdctl.c

    r0 r17  
    277277int esd_set_stream_pan( int esd, int stream_id, 
    278278                        int left_scale, int right_scale ) { 
    279  return -1; 
     279 struct roar_connection con; 
     280 struct roar_mixer_settings mixer; 
     281 
     282 con.fh = esd; 
     283 
     284 mixer.mixer[0] = left_scale; 
     285 mixer.mixer[1] = right_scale; 
     286 
     287 ROAR_DBG("esd_set_stream_pan(esd=%i, stream_id=%i, left_scale=%i, right_scale=%i) = ?",  
     288                esd, stream_id, left_scale, right_scale); 
     289 
     290 return roar_set_vol(&con, stream_id, &mixer, 2); 
    280291} 
    281292 
  • roard/commands.c

    r0 r17  
    2222  {ROAR_CMD_GET_STREAM,   "GET_STREAM",   req_on_get_stream}, 
    2323  {ROAR_CMD_KICK,         "KICK",         req_on_kick}, 
     24  {ROAR_CMD_SET_VOL,      "SET_VOL",      req_on_set_vol}, 
    2425 
    2526  {ROAR_CMD_ADD_DATA,     "ADD_DATA",     req_on_add_data}, 
  • roard/include/req.h

    r0 r17  
    3131int req_on_kick        (int client, struct roar_message * mes, char * data); 
    3232 
     33int req_on_set_vol     (int client, struct roar_message * mes, char * data); 
     34 
    3335int req_on_add_data    (int client, struct roar_message * mes, char * data); 
    3436 
  • roard/mixer.c

    r16 r17  
    118118 
    119119int change_vol_8bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set) { 
    120  char * in = input, out = output; 
     120 char * in = input, * out = output; 
    121121 int    i; 
    122122 int    s; 
     
    136136 
    137137int change_vol_16bit (void * output, void * input, int samples, int channels, struct roar_mixer_settings * set) { 
    138  int16_t * in = input, out = output; 
     138 int16_t * in = input, * out = output; 
    139139 int       i; 
    140140 int       s; 
  • roard/req.c

    r0 r17  
    222222 
    223223int req_on_kick (int client, struct roar_message * mes, char * data) { 
    224  uint16_t * info = mes->data; 
     224 uint16_t * info = (uint16_t *) mes->data; 
    225225 
    226226 if ( mes->datalen != 4 ) 
     
    241241} 
    242242 
     243int req_on_set_vol (int client, struct roar_message * mes, char * data) { 
     244 uint16_t * info = (uint16_t *) mes->data; 
     245 int stream; 
     246 struct roar_stream_server * s; 
     247 int i; 
     248 int chans; 
     249 
     250 ROAR_DBG("req_on_set_vol(*) = ?"); 
     251 ROAR_DBG("req_on_set_vol(*): mes->datalen=%i", mes->datalen); 
     252 
     253 if ( mes->datalen < (4*2) ) 
     254  return -1; 
     255 
     256 if ( info[0] != 0 ) // version 
     257  return -1; 
     258 
     259 stream = info[1]; 
     260 ROAR_DBG("req_on_set_vol(*): stream=%i", stream); 
     261 
     262 // TODO: change this code. 
     263 //       we should not directly change the stream object but use some stream_*()-func 
     264 //       for that job. 
     265 
     266 if ( stream < 0 || stream >= ROAR_STREAMS_MAX ) 
     267  return -1; 
     268 
     269 s = g_streams[stream]; 
     270 
     271 if ( s == NULL ) 
     272  return -1; 
     273 
     274 ROAR_DBG("req_on_set_vol(*): s=%p", s); 
     275 
     276 if ( info[2] == ROAR_SET_VOL_ALL ) { 
     277  chans = (mes->datalen/2) - 3; 
     278  ROAR_DBG("req_on_set_vol(*): mode is ROAR_SET_VOL_ALL, channes=%i", chans); 
     279 
     280  if ( chans >= ROAR_MAX_CHANNELS ) 
     281   return -1; 
     282 
     283  for (i = 0; i < chans; i++) { 
     284   s->mixer.mixer[i] = info[i+3]; 
     285   ROAR_DBG("req_on_set_vol(*): channel %i: %i", i, info[i+3]); 
     286  } 
     287 
     288  ROAR_DBG("req_on_set_vol(*): mixer changed!"); 
     289 
     290 } else if ( info[2] == ROAR_SET_VOL_ONE ) { 
     291  ROAR_DBG("req_on_set_vol(*): mode is ROAR_SET_VOL_ONE"); 
     292  if ( info[3] >= ROAR_MAX_CHANNELS ) 
     293   return -1; 
     294 
     295  s->mixer.mixer[info[3]] = info[4]; 
     296 } else { 
     297  return -1; 
     298 } 
     299 
     300 mes->cmd     = ROAR_CMD_OK; 
     301 mes->datalen = 0; 
     302 
     303 return 0; 
     304} 
    243305 
    244306int req_on_add_data (int client, struct roar_message * mes, char * data) { 
  • roard/streams.c

    r16 r17  
    312312  } 
    313313 
     314  if ( change_vol(rest, info->bits, rest, 8*outlen / info->bits, info->channels, &(((struct roar_stream_server*)g_streams[id])->mixer)) == -1 ) 
     315   return -1; 
     316 
    314317  // we habe outlen bytes more... 
    315318  todo    -= outlen; 
Note: See TracChangeset for help on using the changeset viewer.