[vlc-devel] [PATCH 3/4] directsound: remove broken notification support

Ludovic Fauvet etix at videolan.org
Wed Jul 24 13:01:00 CEST 2013


The original code was non-working because the notication was never
setup correctly and resulted in a DSERR_INVALIDCALL. A proper fix
would look like:

         if( sys->p_notify )
         {
+            IDirectSoundBuffer_Stop( aout->sys->p_dsbuffer );
             DSBPOSITIONNOTIFY notif = {.dwOffset = aout->sys->i_write, .hEventNotify = sys->hnotify_evt } ;
             if( IDirectSoundNotify_SetNotificationPositions( sys->p_notify, 1, &notif ) ==  DS_OK )
             {
+                IDirectSoundBuffer_Play( aout->sys->p_dsbuffer, 0, 0, DSBPLAY_LOOPING );
                 WaitForSingleObject( sys->hnotify_evt, INFINITE );
                 IDirectSoundBuffer_Stop( aout->sys->p_dsbuffer );
             }

But fixing it makes the problem worse since the notification is setup
too late and thus the buffer will replay a full loop of the back
buffer during a drain.
---
 modules/audio_output/directx.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/modules/audio_output/directx.c b/modules/audio_output/directx.c
index 0ab2d40..79bbb90 100644
--- a/modules/audio_output/directx.c
+++ b/modules/audio_output/directx.c
@@ -875,30 +875,10 @@ static void Close(vlc_object_t *obj)
 
 static void Flush ( audio_output_t * aout, bool drain )
 {
-    aout_sys_t *sys = aout->sys;
-    size_t read;
-    if( drain )
-    {
-        if( sys->p_notify )
-        {
-            DSBPOSITIONNOTIFY notif = {.dwOffset = aout->sys->i_write, .hEventNotify = sys->hnotify_evt } ;
-            if( IDirectSoundNotify_SetNotificationPositions( sys->p_notify, 1, &notif ) ==  DS_OK )
-            {
-                WaitForSingleObject( sys->hnotify_evt, INFINITE );
-                IDirectSoundBuffer_Stop( aout->sys->p_dsbuffer );
-            }
-        }
-        else
-        {
-            IDirectSoundBuffer_Stop( aout->sys->p_dsbuffer );
-        }
-    }
-    else
-    {
-        IDirectSoundBuffer_Stop( aout->sys->p_dsbuffer );
+    IDirectSoundBuffer_Stop( aout->sys->p_dsbuffer );
+    if( !drain )
         IDirectSoundBuffer_SetCurrentPosition( aout->sys->p_dsbuffer,
                                                aout->sys->i_write );
-    }
 }
 
 static void Pause( audio_output_t * aout, bool pause, mtime_t date )
-- 
1.8.3.3




More information about the vlc-devel mailing list