summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.com>2021-08-24 15:27:32 -0400
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-09-20 18:06:44 +0000
commit3607c617a52ee7d9b3f0cfb86042e4850f70fdf6 (patch)
treef661ec37a26a837cf58d66d070e57818d3ee6cac
parent7b76c97de92a65cc8347c855cc89af517ad2e8f9 (diff)
downloadgstreamer-plugins-base-3607c617a52ee7d9b3f0cfb86042e4850f70fdf6.tar.gz
alsasink: Allow stop() function to happen during failing writes
In ALSA, there is possible temporary failures that may require a retry, though in certain situation, this may leak to the write() function holding on a lock forever preventing the pipeline from going to pause or stop. Fix this by shortly dropping the lock between retries. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1261>
-rw-r--r--ext/alsa/gstalsasink.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/alsa/gstalsasink.c b/ext/alsa/gstalsasink.c
index 6d7278825..eab405974 100644
--- a/ext/alsa/gstalsasink.c
+++ b/ext/alsa/gstalsasink.c
@@ -1075,12 +1075,18 @@ gst_alsasink_write (GstAudioSink * asink, gpointer data, guint length)
if (err < 0) {
GST_DEBUG_OBJECT (asink, "Write error: %s (%d)", snd_strerror (err), err);
if (err == -EAGAIN) {
- continue;
+ /* will continue out of the if/else group */
} else if (err == -ENODEV) {
goto device_disappeared;
} else if (xrun_recovery (alsa, alsa->handle, err) < 0) {
goto write_error;
}
+
+ /* Unlock so that _reset() can run and break an otherwise infinit loop
+ * here */
+ GST_ALSA_SINK_UNLOCK (asink);
+ g_thread_yield ();
+ GST_ALSA_SINK_LOCK (asink);
continue;
} else if (err == 0 && alsa->hw_support_pause) {
/* We might be already paused, if so, just bail */