[vlc-devel] [PATCH 4/4] directsound: clear the ring buffer ahead of the write pointer (fix #8860)
Ludovic Fauvet
etix at videolan.org
Sat Jul 20 01:50:52 CEST 2013
---
modules/audio_output/directx.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/modules/audio_output/directx.c b/modules/audio_output/directx.c
index 438ff12..c9ac97c 100644
--- a/modules/audio_output/directx.c
+++ b/modules/audio_output/directx.c
@@ -675,7 +675,7 @@ static int FillBuffer( audio_output_t *p_aout, block_t *p_buffer )
dsresult = IDirectSoundBuffer_Lock(
p_sys->p_dsbuffer, /* DS buffer */
p_aout->sys->i_write, /* Start offset */
- towrite, /* Number of bytes */
+ DS_BUF_SIZE / 3, /* Number of bytes */
&p_write_position, /* Address of lock start */
&l_bytes1, /* Count of bytes locked before wrap around */
&p_wrap_around, /* Buffer address (if wrap around) */
@@ -687,7 +687,7 @@ static int FillBuffer( audio_output_t *p_aout, block_t *p_buffer )
dsresult = IDirectSoundBuffer_Lock(
p_sys->p_dsbuffer,
p_aout->sys->i_write,
- towrite,
+ DS_BUF_SIZE / 3,
&p_write_position,
&l_bytes1,
&p_wrap_around,
@@ -714,10 +714,12 @@ static int FillBuffer( audio_output_t *p_aout, block_t *p_buffer )
p_sys->chans_to_reorder, p_sys->chan_table,
p_sys->format );
+ memset( p_write_position, 0, l_bytes1 );
i_size = ( p_buffer->i_buffer < l_bytes1 ) ? p_buffer->i_buffer : l_bytes1;
memcpy( p_write_position, p_buffer->p_buffer, i_size );
if( l_bytes1 < p_buffer->i_buffer)
{
+ memset( p_wrap_around, 0, l_bytes2 );
i_size = ( p_buffer->i_buffer - l_bytes1 < l_bytes2 ) ? p_buffer->i_buffer - l_bytes1 : l_bytes2;
memcpy( p_wrap_around, p_buffer->p_buffer + l_bytes1, i_size );
}
--
1.8.3.3
More information about the vlc-devel
mailing list