summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Beland <nicolas@inogeni.com>2023-03-01 16:26:20 -0500
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2023-03-03 09:39:26 +0000
commit32336c897ce885108c7e3667981ea8bde4a8740a (patch)
tree51236be6c2b4239ec7fd7d607b8713452995ca4f
parentbab780f419b111494c1648399b3cf0f86f3d3d6a (diff)
alsasink: Fix stall when going from PLAYING to NULL (stucked at PAUSED) with uac1 gadget
This happened with a uac1 gadget which for some reason does not behave nicely. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4104>
-rw-r--r--subprojects/gst-plugins-base/ext/alsa/gstalsasink.c6
-rw-r--r--subprojects/gst-plugins-base/ext/alsa/gstalsasink.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/subprojects/gst-plugins-base/ext/alsa/gstalsasink.c b/subprojects/gst-plugins-base/ext/alsa/gstalsasink.c
index 1728213fb8..b5a70a9a5f 100644
--- a/subprojects/gst-plugins-base/ext/alsa/gstalsasink.c
+++ b/subprojects/gst-plugins-base/ext/alsa/gstalsasink.c
@@ -259,6 +259,7 @@ gst_alsasink_init (GstAlsaSink * alsasink)
alsasink->is_paused = FALSE;
alsasink->after_paused = FALSE;
alsasink->hw_support_pause = FALSE;
+ alsasink->stop_streaming_threads = FALSE;
g_mutex_init (&alsasink->alsa_lock);
g_mutex_init (&alsasink->delay_lock);
@@ -1061,6 +1062,8 @@ gst_alsasink_write (GstAudioSink * asink, gpointer data, guint length)
GST_ALSA_SINK_LOCK (asink);
while (cptr > 0) {
+ if (alsa->stop_streaming_threads)
+ goto write_error;
/* start by doing a blocking wait for free space. Set the timeout
* to 4 times the period time */
err = snd_pcm_wait (alsa->handle, (4 * alsa->period_time / 1000));
@@ -1169,6 +1172,7 @@ gst_alsasink_pause (GstAudioSink * asink)
CHECK (snd_pcm_pause (alsa->handle, 1), pause_error);
GST_DEBUG_OBJECT (alsa, "pause done");
alsa->is_paused = TRUE;
+ alsa->stop_streaming_threads = TRUE;
GST_ALSA_SINK_UNLOCK (asink);
} else {
gst_alsasink_stop (asink);
@@ -1200,6 +1204,7 @@ gst_alsasink_resume (GstAudioSink * asink)
GST_ALSA_SINK_UNLOCK (asink);
}
+ alsa->stop_streaming_threads = FALSE;
return;
resume_error:
@@ -1225,6 +1230,7 @@ gst_alsasink_stop (GstAudioSink * asink)
GST_DEBUG_OBJECT (alsa, "prepare");
CHECK (snd_pcm_prepare (alsa->handle), prepare_error);
GST_DEBUG_OBJECT (alsa, "stop done");
+ alsa->stop_streaming_threads = TRUE;
GST_ALSA_SINK_UNLOCK (asink);
return;
diff --git a/subprojects/gst-plugins-base/ext/alsa/gstalsasink.h b/subprojects/gst-plugins-base/ext/alsa/gstalsasink.h
index 35efa888e0..e444311c80 100644
--- a/subprojects/gst-plugins-base/ext/alsa/gstalsasink.h
+++ b/subprojects/gst-plugins-base/ext/alsa/gstalsasink.h
@@ -77,6 +77,7 @@ struct _GstAlsaSink {
gboolean is_paused;
gboolean after_paused;
gboolean hw_support_pause;
+ gboolean stop_streaming_threads;
snd_pcm_sframes_t pos_in_buffer;
GMutex alsa_lock;