summaryrefslogtreecommitdiffstats
path: root/libao2
diff options
context:
space:
mode:
authorfaust3 <faust3@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-03-15 16:29:18 +0000
committerfaust3 <faust3@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-03-15 16:29:18 +0000
commita8941ce3eb5bdc7d589afdb9133f721ef70bdcd2 (patch)
tree6e4b01ba7ae4a055c7078bb261a11c2a618d8b17 /libao2
parenteb4815621a223876df9972ffc5a89f909e182c21 (diff)
downloadmpv-a8941ce3eb5bdc7d589afdb9133f721ef70bdcd2.tar.bz2
mpv-a8941ce3eb5bdc7d589afdb9133f721ef70bdcd2.tar.xz
get_space fix by Florian Dietrich <flodt8 at yahoo.de>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14948 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libao2')
-rw-r--r--libao2/ao_dsound.c6
1 files changed, 5 insertions, 1 deletions
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;
}
/**