systemclock: Fix deadlock on clock_nanosleep
authorPieter Willem Jordaan <pieterwjordaanpc@gmail.com>
Wed, 31 Mar 2021 19:13:45 +0000 (21:13 +0200)
committerPieter Willem Jordaan <pieterwjordaanpc@gmail.com>
Wed, 31 Mar 2021 19:16:36 +0000 (21:16 +0200)
Always use the monotonic clock's diff and end time for clock_nanosleep to have predictable behaviour even with other clock types.

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

gst/gstsystemclock.c

index 61d4d51..665da53 100644 (file)
@@ -966,7 +966,7 @@ gst_system_clock_id_wait_jitter_unlocked (GstClock * clock,
         /* In order to provide more accurate wait, we will use BLOCKING
            clock_nanosleep for any deadlines at or below 500us */
         struct timespec end;
-        GST_TIME_TO_TIMESPEC (entryt, end);
+        GST_TIME_TO_TIMESPEC (mono_ts * 1000 + diff, end);
         GST_SYSTEM_CLOCK_ENTRY_UNLOCK ((GstClockEntryImpl *) entry);
         waitret =
             clock_nanosleep (CLOCK_MONOTONIC, TIMER_ABSTIME, &end, NULL) == 0;