From a8941ce3eb5bdc7d589afdb9133f721ef70bdcd2 Mon Sep 17 00:00:00 2001 From: faust3 Date: Tue, 15 Mar 2005 16:29:18 +0000 Subject: get_space fix by Florian Dietrich git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14948 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_dsound.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libao2/ao_dsound.c') diff --git a/libao2/ao_dsound.c b/libao2/ao_dsound.c index d004decbab..d8e743e3a1 100644 --- a/libao2/ao_dsound.c +++ b/libao2/ao_dsound.c @@ -115,6 +115,9 @@ static LPDIRECTSOUNDBUFFER hdsbuf = NULL; ///secondary direct sound buffer (stre static int buffer_size = 0; ///size in bytes of the direct sound buffer static int write_offset = 0; ///offset of the write cursor in the direct sound buffer static int min_free_space = 0; ///if the free space is below this value get_space() will return 0 + ///there will always be at least this amout of free space to prevent + ///get_space() from returning wrong values when buffer is 100% full. + ///will be replaced with nBlockAlign in init() static int device_num = 0; ///wanted device number static GUID device; ///guid of the device @@ -482,6 +485,7 @@ static int init(int rate, int channels, int format, int flags) dsbdesc.lpwfxFormat = (WAVEFORMATEX *)&wformat; buffer_size = dsbdesc.dwBufferBytes; write_offset = 0; + min_free_space = wformat.Format.nBlockAlign; ao_data.outburst = wformat.Format.nBlockAlign * 512; // create primary buffer and set its format @@ -579,7 +583,7 @@ static int get_space() // write_offset is the postion where we actually write the data to if(space > buffer_size)space -= buffer_size; // write_offset < play_offset if(space < min_free_space)return 0; - return space; + return space-min_free_space; } /** -- cgit v1.2.3