[vlc-commits] Erase all the already read data in directsound buffer

Denis Charmet git at videolan.org
Wed Apr 16 22:48:39 CEST 2014


vlc | branch: master | Denis Charmet <typx at dinauz.org> | Wed Apr 16 22:43:57 2014 +0200| [6d1e90eeaf40509cb957f80b12611640bca1ffeb] | committer: Denis Charmet

Erase all the already read data in directsound buffer

Delays the apparition of #11145

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6d1e90eeaf40509cb957f80b12611640bca1ffeb
---

 modules/audio_output/directsound.c |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/modules/audio_output/directsound.c b/modules/audio_output/directsound.c
index cb986fe..3cca59c 100644
--- a/modules/audio_output/directsound.c
+++ b/modules/audio_output/directsound.c
@@ -175,26 +175,20 @@ static HRESULT FillBuffer( vlc_object_t *obj, aout_stream_sys_t *p_sys,
     unsigned long l_bytes1, l_bytes2;
     DWORD i_read;
     size_t i_size;
-    mtime_t i_buf;
+    mtime_t i_buf = towrite;
     HRESULT dsresult;
 
-    size_t toerase = p_sys->i_bytes_per_sample * p_sys->i_rate / 4;
-    mtime_t max = towrite;
-
+    /* Erase all the data already played */
     dsresult = IDirectSoundBuffer_GetCurrentPosition( p_sys->p_dsbuffer,
                                                       &i_read, NULL );
     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 )
             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 */
     dsresult = IDirectSoundBuffer_Lock(
            p_sys->p_dsbuffer,    /* DS buffer */



More information about the vlc-commits mailing list