systemclock: Get rid of conditional unlocking of the clock entries
authorSebastian Dröge <sebastian@centricular.com>
Thu, 28 Nov 2024 13:49:24 +0000 (15:49 +0200)
committerBackport Bot <gitlab-backport-bot@gstreamer-foundation.org>
Mon, 2 Dec 2024 10:00:27 +0000 (10:00 +0000)
At every point it is known whether the entry needs to be unlocked or not.

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

subprojects/gstreamer/gst/gstsystemclock.c

index d593b62c7088fe411a5639d51dde781c13513c8f..5b130c1102f629981f1a0814766f4fd0ad2a9387 100644 (file)
@@ -871,7 +871,6 @@ gst_system_clock_async_thread (GstClock * clock)
   GstSystemClock *sysclock = GST_SYSTEM_CLOCK_CAST (clock);
   GstSystemClockPrivate *priv = sysclock->priv;
   GstClockReturn status;
-  gboolean entry_needs_unlock = FALSE;
 
   GST_CAT_DEBUG_OBJECT (GST_CAT_CLOCK, clock, "enter system clock thread");
   GST_SYSTEM_CLOCK_LOCK (clock);
@@ -904,7 +903,6 @@ gst_system_clock_async_thread (GstClock * clock)
 
     /* unlocked before the next loop iteration at latest */
     GST_SYSTEM_CLOCK_ENTRY_LOCK ((GstClockEntryImpl *) entry);
-    entry_needs_unlock = TRUE;
 
     /* set entry status to busy before we release the clock lock */
     status = GST_CLOCK_ENTRY_STATUS (entry);
@@ -915,7 +913,7 @@ gst_system_clock_async_thread (GstClock * clock)
       GST_CAT_DEBUG_OBJECT (GST_CAT_CLOCK, clock,
           "async entry %p unscheduled", entry);
       GST_SYSTEM_CLOCK_UNLOCK (clock);
-      goto next_entry;
+      goto unlock_entry_and_next_entry;
     }
 
     /* for periodic timers, status can be EARLY from a previous run */
@@ -946,12 +944,11 @@ gst_system_clock_async_thread (GstClock * clock)
         /* entry was unscheduled, move to the next */
         GST_CAT_DEBUG_OBJECT (GST_CAT_CLOCK, clock,
             "async entry %p unscheduled", entry);
-        goto next_entry;
+        goto unlock_entry_and_next_entry;
       case GST_CLOCK_OK:
       case GST_CLOCK_EARLY:
       {
         GST_SYSTEM_CLOCK_ENTRY_UNLOCK ((GstClockEntryImpl *) entry);
-        entry_needs_unlock = FALSE;
         /* entry timed out normally, fire the callback and move to the next
          * entry */
         GST_CAT_DEBUG_OBJECT (GST_CAT_CLOCK, clock, "async entry %p timed out",
@@ -997,11 +994,11 @@ gst_system_clock_async_thread (GstClock * clock)
             "strange result %d waiting for %p, skipping", res, entry);
         g_warning ("%s: strange result %d waiting for %p, skipping",
             GST_OBJECT_NAME (clock), res, entry);
-        goto next_entry;
+        goto unlock_entry_and_next_entry;
     }
+  unlock_entry_and_next_entry:
+    GST_SYSTEM_CLOCK_ENTRY_UNLOCK ((GstClockEntryImpl *) entry);
   next_entry:
-    if (entry_needs_unlock)
-      GST_SYSTEM_CLOCK_ENTRY_UNLOCK ((GstClockEntryImpl *) entry);
     GST_SYSTEM_CLOCK_LOCK (clock);
 
     /* we remove the current entry and unref it */