Changeset 2375:7f8c3646bbc3 in roaraudio


Ignore:
Timestamp:
08/16/09 01:53:15 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

call set-volume callback on stream start

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroarsndio/stream.c

    r2358 r2375  
    3434#include "libroarsndio.h" 
    3535 
     36// this is void because we do not care about if this failed... 
     37static void send_vol_event (struct sio_hdl * hdl) { 
     38 int channels; 
     39 struct roar_mixer_settings mixer; 
     40 int i; 
     41 unsigned vol; 
     42 
     43 // in case of no event handler we do not send the event at all ;) 
     44 if ( hdl->on_vol == NULL ) 
     45  return; 
     46 
     47 if ( roar_get_vol(&(hdl->con), roar_stream_get_id(&(hdl->stream)), &mixer, &channels) == -1 ) 
     48  return; 
     49 
     50 ROAR_DBG("send_vol_event(*): channels=%i", channels); 
     51 
     52 switch (channels) { 
     53  case 1: 
     54    ROAR_DBG("send_vol_event(*): mixer.scale=%i, mixer.mixer={%i,...}", mixer.scale, mixer.mixer[0]); 
     55    vol  = mixer.mixer[0] * SIO_MAXVOL; 
     56    vol /= mixer.scale; 
     57    ROAR_DBG("send_vol_event(*): vol=%u", vol); 
     58   break; 
     59  case 2: 
     60    vol = (mixer.mixer[0] + mixer.mixer[1]) * SIO_MAXVOL / mixer.scale / 2; 
     61   break; 
     62  default: 
     63    vol = 0; 
     64    for (i = 0; i < channels; i++) 
     65     vol += mixer.mixer[i]; 
     66 
     67    vol /= channels; 
     68    vol *= SIO_MAXVOL; 
     69    vol /= mixer.scale; 
     70   break; 
     71 } 
     72 
     73 ROAR_DBG("send_vol_event(*): vol=%u", vol); 
     74 hdl->on_vol(hdl->on_vol_arg, vol); 
     75} 
     76 
    3677#define _i(x) (hdl->info.x) 
    3778int    sio_start  (struct sio_hdl * hdl) { 
     
    5899  return 0; 
    59100 } 
     101 
     102 send_vol_event(hdl); 
    60103#else 
    61104 if ( roar_stream_new_by_id(&(hdl->stream), -1) == -1 ) 
     
    65108  return 0; 
    66109 } 
     110 
     111 // FIXME: this does not work in this case 
     112 //send_vol_event(hdl); 
    67113#endif 
    68114 
Note: See TracChangeset for help on using the changeset viewer.