Commit 6d1e90ee authored by Denis Charmet's avatar Denis Charmet

Erase all the already read data in directsound buffer

Delays the apparition of #11145
parent 8d5e04c0
...@@ -175,26 +175,20 @@ static HRESULT FillBuffer( vlc_object_t *obj, aout_stream_sys_t *p_sys, ...@@ -175,26 +175,20 @@ static HRESULT FillBuffer( vlc_object_t *obj, aout_stream_sys_t *p_sys,
unsigned long l_bytes1, l_bytes2; unsigned long l_bytes1, l_bytes2;
DWORD i_read; DWORD i_read;
size_t i_size; size_t i_size;
mtime_t i_buf; mtime_t i_buf = towrite;
HRESULT dsresult; HRESULT dsresult;
size_t toerase = p_sys->i_bytes_per_sample * p_sys->i_rate / 4; /* Erase all the data already played */
mtime_t max = towrite;
dsresult = IDirectSoundBuffer_GetCurrentPosition( p_sys->p_dsbuffer, dsresult = IDirectSoundBuffer_GetCurrentPosition( p_sys->p_dsbuffer,
&i_read, NULL ); &i_read, NULL );
if( dsresult == DS_OK ) if( dsresult == DS_OK )
{ {
max = (mtime_t)i_read - (mtime_t)p_sys->i_write; int64_t max = (int64_t)i_read - (int64_t)p_sys->i_write;
if( max <= 0 ) if( max <= 0 )
max += DS_BUF_SIZE; max += DS_BUF_SIZE;
i_buf = max;
} }
if( towrite + toerase <= max )
i_buf = towrite + toerase;
else
i_buf = towrite;
/* Before copying anything, we have to lock the buffer */ /* Before copying anything, we have to lock the buffer */
dsresult = IDirectSoundBuffer_Lock( dsresult = IDirectSoundBuffer_Lock(
p_sys->p_dsbuffer, /* DS buffer */ p_sys->p_dsbuffer, /* DS buffer */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment