[vlc-commits] aout: move aout stream stop callback...

Rémi Denis-Courmont git at videolan.org
Wed Jul 17 20:45:24 CEST 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jul 17 21:38:39 2019 +0300| [d85d95ccf4d4b8ee3e6bac714fdacd79a77e7f0f] | committer: Rémi Denis-Courmont

aout: move aout stream stop callback...

...into to aout_stream_t.
This is much simpler and provides type safety.

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

 modules/audio_output/directsound.c |  4 ++--
 modules/audio_output/mmdevice.c    | 10 +---------
 modules/audio_output/mmdevice.h    |  6 +++++-
 modules/audio_output/wasapi.c      |  3 ++-
 modules/audio_output/winstore.c    | 10 +---------
 5 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/modules/audio_output/directsound.c b/modules/audio_output/directsound.c
index 9d06bd29df..02d8ad2e5e 100644
--- a/modules/audio_output/directsound.c
+++ b/modules/audio_output/directsound.c
@@ -46,7 +46,6 @@ static int  Open( vlc_object_t * );
 static void Close( vlc_object_t * );
 static HRESULT StreamStart( aout_stream_t *, audio_sample_format_t *,
                             const GUID * );
-static HRESULT StreamStop( aout_stream_t * );
 static int ReloadDirectXDevices( const char *, char ***, char *** );
 static void * PlayedDataEraser( void * );
 /* Speaker setup override options list */
@@ -91,7 +90,7 @@ vlc_module_begin ()
 
     add_submodule()
         set_capability( "aout stream", 30 )
-        set_callbacks( StreamStart, StreamStop )
+        set_callbacks( StreamStart, NULL )
 vlc_module_end ()
 
 typedef struct aout_stream_sys
@@ -869,6 +868,7 @@ static HRESULT StreamStart( aout_stream_t *s,
     s->play = StreamPlay;
     s->pause = StreamPause;
     s->flush = StreamFlush;
+    s->stop = StreamStop;
     return S_OK;
 error:
     free( sys );
diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 70563acad9..2aa3af01dc 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -1106,14 +1106,6 @@ static int aout_stream_Start(void *func, bool forced, va_list ap)
     return SUCCEEDED(*hr) ? VLC_SUCCESS : VLC_EGENERIC;
 }
 
-static void aout_stream_Stop(void *func, va_list ap)
-{
-    aout_stream_stop_t stop = func;
-    aout_stream_t *s = va_arg(ap, aout_stream_t *);
-
-    stop(s);
-}
-
 static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
 {
     aout_sys_t *sys = aout->sys;
@@ -1238,7 +1230,7 @@ static void Stop(audio_output_t *aout)
     assert(sys->stream != NULL);
 
     EnterMTA();
-    vlc_module_unload(sys->module, aout_stream_Stop, sys->stream);
+    aout_stream_Stop(sys->stream);
     LeaveMTA();
 
     vlc_object_delete(sys->stream);
diff --git a/modules/audio_output/mmdevice.h b/modules/audio_output/mmdevice.h
index c027367ec8..ef2bb0ebd4 100644
--- a/modules/audio_output/mmdevice.h
+++ b/modules/audio_output/mmdevice.h
@@ -36,6 +36,7 @@ struct aout_stream
     struct vlc_object_t obj;
     void *sys;
 
+    HRESULT (*stop)(aout_stream_t *);
     HRESULT (*time_get)(aout_stream_t *, vlc_tick_t *);
     HRESULT (*play)(aout_stream_t *, block_t *);
     HRESULT (*pause)(aout_stream_t *, bool);
@@ -60,7 +61,10 @@ typedef HRESULT (*aout_stream_start_t)(aout_stream_t *s,
 /**
  * Destroys an audio output stream.
  */
-typedef HRESULT (*aout_stream_stop_t)(aout_stream_t *);
+static inline HRESULT aout_stream_Stop(aout_stream_t *s)
+{
+    return (s->stop)(s);
+}
 
 static inline HRESULT aout_stream_TimeGet(aout_stream_t *s, vlc_tick_t *delay)
 {
diff --git a/modules/audio_output/wasapi.c b/modules/audio_output/wasapi.c
index 310e90e09d..4f5ef0fd1d 100644
--- a/modules/audio_output/wasapi.c
+++ b/modules/audio_output/wasapi.c
@@ -631,6 +631,7 @@ static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict pfmt,
     s->play = Play;
     s->pause = Pause;
     s->flush = Flush;
+    s->stop = Stop;
     return S_OK;
 error:
     CoTaskMemFree(pwf_mix);
@@ -646,5 +647,5 @@ vlc_module_begin()
     set_capability("aout stream", 50)
     set_category(CAT_AUDIO)
     set_subcategory(SUBCAT_AUDIO_AOUT)
-    set_callbacks(Start, Stop)
+    set_callbacks(Start, NULL)
 vlc_module_end()
diff --git a/modules/audio_output/winstore.c b/modules/audio_output/winstore.c
index 6b9610ddea..5a6f873ae2 100644
--- a/modules/audio_output/winstore.c
+++ b/modules/audio_output/winstore.c
@@ -219,14 +219,6 @@ static int aout_stream_Start(void *func, bool forced, va_list ap)
     return SUCCEEDED(*hr) ? VLC_SUCCESS : VLC_EGENERIC;
 }
 
-static void aout_stream_Stop(void *func, va_list ap)
-{
-    aout_stream_stop_t stop = func;
-    aout_stream_t *s = va_arg(ap, aout_stream_t *);
-
-    stop(s);
-}
-
 static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
 {
     aout_sys_t *sys = aout->sys;
@@ -262,7 +254,7 @@ static void Stop(audio_output_t *aout)
     assert (sys->stream != NULL);
 
     EnterMTA();
-    vlc_module_unload(sys->module, aout_stream_Stop, sys->stream);
+    aout_stream_Stop(sys->stream);
     LeaveMTA();
 
     vlc_object_delete(sys->stream);



More information about the vlc-commits mailing list