adaptivedemux2: Always wake up loop thread on unpause
authorSeungha Yang <seungha@centricular.com>
Tue, 20 Sep 2022 15:26:38 +0000 (00:26 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 21 Sep 2022 09:26:22 +0000 (09:26 +0000)
Otherwise loop thread will sleep forever because
GstAdaptiveDemuxLoop.paused flag update is not signalled
when loop was marked as stopped already from other thread.

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

subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemuxutils.c

index 925f93583a21ff74539661a27cde4a3040abb236..b27e029248a2c262b3e94fbf367279feb1ac0a23 100644 (file)
@@ -318,21 +318,23 @@ gst_adaptive_demux_loop_pause_and_lock (GstAdaptiveDemuxLoop * loop)
 gboolean
 gst_adaptive_demux_loop_unlock_and_unpause (GstAdaptiveDemuxLoop * loop)
 {
+  gboolean stopped;
+
   g_main_context_pop_thread_default (loop->context);
   g_rec_mutex_unlock (&loop->context_lock);
 
   g_mutex_lock (&loop->lock);
   loop->paused = FALSE;
 
-  if (loop->stopped) {
-    g_mutex_unlock (&loop->lock);
-    return FALSE;
-  }
+  stopped = loop->stopped;
 
-  /* Wake up the loop to run again */
+  /* Wake up the loop to run again, regardless of stopped state */
   g_cond_broadcast (&loop->cond);
   g_mutex_unlock (&loop->lock);
 
+  if (stopped)
+    return FALSE;
+
   return TRUE;
 }