[vlc-devel] [PATCH 3/4] aout: pulse: add FlushLocked

Thomas Guillem thomas at gllm.fr
Wed Jan 30 12:28:12 CET 2019


And move it up.

cf. next commits.
---
 modules/audio_output/pulse.c | 45 ++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 20 deletions(-)

diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 5075dd92ce..4ddc3ba7c8 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -482,6 +482,30 @@ static void *data_convert(block_t **pp)
     return block->p_buffer;
 }
 
+static void FlushLocked(audio_output_t *aout, bool wait)
+{
+    aout_sys_t *sys = aout->sys;
+    pa_stream *s = sys->stream;
+    pa_operation *op;
+
+    if (wait)
+    {
+        op = pa_stream_drain(s, NULL, NULL);
+
+        /* XXX: Loosy drain emulation.
+         * See #18141: drain callback is never received */
+        vlc_tick_t delay;
+        if (TimeGet(aout, &delay) == 0 && delay <= VLC_TICK_FROM_SEC(5))
+            vlc_tick_sleep(delay);
+    }
+    else
+        op = pa_stream_flush(s, NULL, NULL);
+    if (op != NULL)
+        pa_operation_unref(op);
+    sys->last_date = VLC_TICK_INVALID;
+    stream_stop(s, aout);
+}
+
 /**
  * Queue one audio frame to the playback stream
  */
@@ -553,28 +577,9 @@ static void Pause(audio_output_t *aout, bool paused, vlc_tick_t date)
 static void Flush(audio_output_t *aout, bool wait)
 {
     aout_sys_t *sys = aout->sys;
-    pa_stream *s = sys->stream;
-    pa_operation *op;
 
     pa_threaded_mainloop_lock(sys->mainloop);
-
-    if (wait)
-    {
-        op = pa_stream_drain(s, NULL, NULL);
-
-        /* XXX: Loosy drain emulation.
-         * See #18141: drain callback is never received */
-        vlc_tick_t delay;
-        if (TimeGet(aout, &delay) == 0 && delay <= VLC_TICK_FROM_SEC(5))
-            vlc_tick_sleep(delay);
-    }
-    else
-        op = pa_stream_flush(s, NULL, NULL);
-    if (op != NULL)
-        pa_operation_unref(op);
-    sys->last_date = VLC_TICK_INVALID;
-    stream_stop(s, aout);
-
+    FlushLocked(aout, wait);
     pa_threaded_mainloop_unlock(sys->mainloop);
 }
 
-- 
2.20.1



More information about the vlc-devel mailing list