pulsesink: Fix occasional period of silence on resume
authorHenry Hoegelow <henry@hoegelow.com>
Tue, 27 Sep 2022 09:44:51 +0000 (09:44 +0000)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 12 Dec 2022 08:29:28 +0000 (08:29 +0000)
According to comment in gst_pulsering_stream_latency_cb, latency updates
happen every 100 ms. The code in gst_pulsering_stream_latency_cb does
not care about the actual state of the ringbuffer, pbuf->acquired or
not.
Thus, every 100 ms the ringbuf->segdone may be set, even though the
object itself might be in 'destroyed' state. On next
gst_pulseringbuffer_acquire the segdone is not touched, so playback may
resume with invalid/wrong segdone value. This finally leads to a period
of silence playing after resuming the pipeline.

The problem was found on 'not-yet-released'-hardware and so far was not
reproducible on desktop computer.

Removing the callback as long as the ringbuffer is not in 'acquired'
state solves the problem reliably on the hardware device that the issue
was detected on.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3082>

subprojects/gst-plugins-good/ext/pulse/pulsesink.c

index 723d8f9..c0ffff3 100644 (file)
@@ -323,6 +323,7 @@ gst_pulsering_destroy_stream (GstPulseRingBuffer * pbuf)
     pa_stream_set_write_callback (pbuf->stream, NULL, NULL);
     pa_stream_set_underflow_callback (pbuf->stream, NULL, NULL);
     pa_stream_set_overflow_callback (pbuf->stream, NULL, NULL);
+    pa_stream_set_latency_update_callback (pbuf->stream, NULL, NULL);
 
     pa_stream_unref (pbuf->stream);
     pbuf->stream = NULL;