Mercurial > mplayer.hg
diff libao2/ao_sdl.c @ 3095:981a9e5118ce
interface to libao2 changed ao_plugin added
author | anders |
---|---|
date | Sat, 24 Nov 2001 05:21:22 +0000 |
parents | e7d98f8f9459 |
children | b9ee2d8d7279 |
line wrap: on
line diff
--- a/libao2/ao_sdl.c Sat Nov 24 02:05:06 2001 +0000 +++ b/libao2/ao_sdl.c Sat Nov 24 05:21:22 2001 +0000 @@ -29,13 +29,6 @@ LIBAO_EXTERN(sdl) -// there are some globals: -// ao_samplerate -// ao_channels -// ao_format -// ao_bps -// ao_outburst -// ao_buffersize extern int verbose; @@ -150,6 +143,10 @@ setenv("SDL_AUDIODRIVER", ao_subdevice, 1); printf("SDL: using %s audio driver\n", ao_subdevice); } + + ao_data.bps=(channels+1)*rate; + if(format != AFMT_U8 && format != AFMT_S8) + ao_data.bps*=2; /* The desired audio format (see SDL_AudioSpec) */ switch(format) { @@ -205,7 +202,7 @@ } if(verbose) printf("SDL: buf size = %d\n",aspec.size); - if(ao_buffersize==-1) ao_buffersize=aspec.size; + if(ao_data.buffersize==-1) ao_data.buffersize=aspec.size; /* unsilence audio, if callback is ready */ SDL_PauseAudio(0); @@ -278,9 +275,9 @@ #endif } -// return: how many unplayed bytes are in the buffer -static int get_delay(){ - return buffered_bytes + ao_buffersize; +// return: delay in seconds between first and last sample in buffer +static float get_delay(){ + return (float)(buffered_bytes + ao_data.buffersize)/(float)ao_data.bps; }