[vlc-commits] DirectSound: use a new strategy for erasing the ring buffer
Ludovic Fauvet
git at videolan.org
Sun Sep 8 18:03:08 CEST 2013
vlc/vlc-2.1 | branch: master | Ludovic Fauvet <etix at videolan.org> | Sat Sep 7 21:53:07 2013 +0200| [44e5dccebda2f134cd406c7f50ad296e107bd0c6] | committer: Jean-Baptiste Kempf
DirectSound: use a new strategy for erasing the ring buffer
Close #9275 #9328
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 26651679f6c67440cb3d942491e170ba383f970c)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.1.git/?a=commit;h=44e5dccebda2f134cd406c7f50ad296e107bd0c6
---
modules/audio_output/directx.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/modules/audio_output/directx.c b/modules/audio_output/directx.c
index ed21c5c..fbcf0fc 100644
--- a/modules/audio_output/directx.c
+++ b/modules/audio_output/directx.c
@@ -691,7 +691,7 @@ static int FillBuffer( audio_output_t *p_aout, block_t *p_buffer )
{
aout_sys_t *p_sys = p_aout->sys;
- size_t towrite = (p_buffer)?p_buffer->i_buffer:DS_BUF_SIZE;
+ size_t towrite = (p_buffer)? p_buffer->i_buffer : DS_BUF_SIZE;
void *p_write_position, *p_wrap_around;
unsigned long l_bytes1, l_bytes2;
uint32_t i_read;
@@ -699,13 +699,18 @@ static int FillBuffer( audio_output_t *p_aout, block_t *p_buffer )
mtime_t i_buf;
HRESULT dsresult;
+ size_t toerase = p_sys->i_bytes_per_sample * p_sys->i_rate / 4;
+ mtime_t max = towrite;
+
if( IDirectSoundBuffer_GetCurrentPosition( p_aout->sys->p_dsbuffer, (LPDWORD) &i_read, NULL) == DS_OK )
{
- /* Compute the outer interval between the write and read pointers within the ring buffer */
- i_buf = (mtime_t)i_read - (mtime_t)p_aout->sys->i_write;
- if( i_buf <= 0 )
- i_buf += DS_BUF_SIZE;
+ max = (mtime_t)i_read - (mtime_t)p_aout->sys->i_write;
+ if( max <= 0 )
+ max += DS_BUF_SIZE;
}
+
+ if( towrite + toerase <= max )
+ i_buf = towrite + toerase;
else
i_buf = towrite;
More information about the vlc-commits
mailing list