mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-11 10:56:38 +00:00
systemclock: Use a flag while waiting for the async thread to start
Otherwise there can be spurious wakeups. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7994>
This commit is contained in:
parent
3cdc14df99
commit
37b9bfdd2e
1 changed files with 6 additions and 1 deletions
|
@ -571,6 +571,7 @@ ensure_entry_initialized (GstClockEntryImpl * entry_impl)
|
|||
struct _GstSystemClockPrivate
|
||||
{
|
||||
GThread *thread; /* thread for async notify */
|
||||
gboolean starting;
|
||||
gboolean stopping;
|
||||
|
||||
GList *entries;
|
||||
|
@ -875,6 +876,7 @@ gst_system_clock_async_thread (GstClock * clock)
|
|||
GST_CAT_DEBUG_OBJECT (GST_CAT_CLOCK, clock, "enter system clock thread");
|
||||
GST_SYSTEM_CLOCK_LOCK (clock);
|
||||
/* signal spinup */
|
||||
priv->starting = FALSE;
|
||||
GST_SYSTEM_CLOCK_BROADCAST (clock);
|
||||
/* now enter our (almost) infinite loop */
|
||||
while (!priv->stopping) {
|
||||
|
@ -1316,6 +1318,7 @@ gst_system_clock_start_async (GstSystemClock * clock)
|
|||
if (G_LIKELY (priv->thread != NULL))
|
||||
return TRUE; /* Thread already running. Nothing to do */
|
||||
|
||||
priv->starting = TRUE;
|
||||
priv->thread = g_thread_try_new ("GstSystemClock",
|
||||
(GThreadFunc) gst_system_clock_async_thread, clock, &error);
|
||||
|
||||
|
@ -1323,13 +1326,15 @@ gst_system_clock_start_async (GstSystemClock * clock)
|
|||
goto no_thread;
|
||||
|
||||
/* wait for it to spin up */
|
||||
GST_SYSTEM_CLOCK_WAIT (clock);
|
||||
while (priv->starting)
|
||||
GST_SYSTEM_CLOCK_WAIT (clock);
|
||||
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
no_thread:
|
||||
{
|
||||
priv->starting = FALSE;
|
||||
g_warning ("could not create async clock thread: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue