summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoruau <uau@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-12-01 01:39:39 +0000
committeruau <uau@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-12-01 01:39:39 +0000
commit7e5c327c5a2c49c135dd4a75a527b78655bbc1fd (patch)
tree0ce4c444b88f5dcf2f11a7b6cd3dbc16c3ff358a
parent32b9034e23cdbfe37ebe16b2e04dffb2fadaccfd (diff)
downloadmpv-7e5c327c5a2c49c135dd4a75a527b78655bbc1fd.tar.bz2
mpv-7e5c327c5a2c49c135dd4a75a527b78655bbc1fd.tar.xz
ao_null: Make duration of "buffered" audio constant
Choose the "buffer size" for the amount of audio the driver accepts so that it corresponds to about 0.2 seconds of playback based on the number of channels, sample size and samplerate. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25222 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--libao2/ao_null.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libao2/ao_null.c b/libao2/ao_null.c
index ae79a873e7..2f7aaeb656 100644
--- a/libao2/ao_null.c
+++ b/libao2/ao_null.c
@@ -50,14 +50,14 @@ static int control(int cmd,void *arg){
// return: 1=success 0=fail
static int init(int rate,int channels,int format,int flags){
- ao_data.buffersize= 16384*channels;
- ao_data.outburst=512*channels;
+ int samplesize = (format == AF_FORMAT_U8 || format == AF_FORMAT_S8) ? 1: 2;
+ ao_data.outburst = 256 * channels * samplesize;
+ // A "buffer" for about 0.2 seconds of audio
+ ao_data.buffersize = (int)(rate * 0.2 / 256 + 1) * ao_data.outburst;
ao_data.channels=channels;
ao_data.samplerate=rate;
ao_data.format=format;
- ao_data.bps=channels*rate;
- if (format != AF_FORMAT_U8 && format != AF_FORMAT_S8)
- ao_data.bps*=2;
+ ao_data.bps=channels*rate*samplesize;
buffer=0;
gettimeofday(&last_tv, 0);