identity/clocksync: Also provide system clock if sync=false

identity should provide when sync=true. Don't provide when sync=false.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/630

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/690>
This commit is contained in:
Bing Song 2020-11-02 17:43:42 +08:00 committed by GStreamer Merge Bot
parent 146b2ddf50
commit e5e27010c8
2 changed files with 52 additions and 3 deletions

View file

@ -171,7 +171,6 @@ gst_clock_sync_init (GstClockSync * clocksync)
clocksync->sync = DEFAULT_SYNC;
g_cond_init (&clocksync->blocked_cond);
GST_OBJECT_FLAG_SET (clocksync, GST_ELEMENT_FLAG_PROVIDE_CLOCK);
GST_OBJECT_FLAG_SET (clocksync, GST_ELEMENT_FLAG_REQUIRE_CLOCK);
}
@ -180,10 +179,31 @@ gst_clock_sync_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstClockSync *clocksync = GST_CLOCKSYNC (object);
GstMessage *clock_message = NULL;
gboolean sync;
switch (prop_id) {
case PROP_SYNC:
clocksync->sync = g_value_get_boolean (value);
sync = g_value_get_boolean (value);
GST_OBJECT_LOCK (clocksync);
if (sync != clocksync->sync) {
clocksync->sync = sync;
if (sync) {
GST_OBJECT_FLAG_SET (clocksync, GST_ELEMENT_FLAG_PROVIDE_CLOCK);
clock_message =
gst_message_new_clock_provide (GST_OBJECT_CAST (clocksync),
gst_system_clock_obtain (), TRUE);
} else {
GST_OBJECT_FLAG_UNSET (clocksync, GST_ELEMENT_FLAG_PROVIDE_CLOCK);
clock_message =
gst_message_new_clock_lost (GST_OBJECT_CAST (clocksync),
gst_system_clock_obtain ());
}
}
GST_OBJECT_UNLOCK (clocksync);
if (clock_message)
gst_element_post_message (GST_ELEMENT_CAST (clocksync), clock_message);
break;
case PROP_TS_OFFSET:
clocksync->ts_offset = g_value_get_int64 (value);
@ -540,5 +560,10 @@ gst_clocksync_change_state (GstElement * element, GstStateChange transition)
static GstClock *
gst_clocksync_provide_clock (GstElement * element)
{
GstClockSync *clocksync = GST_CLOCKSYNC (element);
if (!clocksync->sync)
return NULL;
return gst_system_clock_obtain ();
}

View file

@ -347,7 +347,6 @@ gst_identity_init (GstIdentity * identity)
gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM_CAST (identity), TRUE);
GST_OBJECT_FLAG_SET (identity, GST_ELEMENT_FLAG_PROVIDE_CLOCK);
GST_OBJECT_FLAG_SET (identity, GST_ELEMENT_FLAG_REQUIRE_CLOCK);
}
@ -860,6 +859,8 @@ gst_identity_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstIdentity *identity;
GstMessage *clock_message = NULL;
gboolean sync;
identity = GST_IDENTITY (object);
@ -889,7 +890,25 @@ gst_identity_set_property (GObject * object, guint prop_id,
identity->datarate = g_value_get_int (value);
break;
case PROP_SYNC:
identity->sync = g_value_get_boolean (value);
sync = g_value_get_boolean (value);
GST_OBJECT_LOCK (identity);
if (sync != identity->sync) {
identity->sync = sync;
if (sync) {
GST_OBJECT_FLAG_SET (identity, GST_ELEMENT_FLAG_PROVIDE_CLOCK);
clock_message =
gst_message_new_clock_provide (GST_OBJECT_CAST (identity),
gst_system_clock_obtain (), TRUE);
} else {
GST_OBJECT_FLAG_UNSET (identity, GST_ELEMENT_FLAG_PROVIDE_CLOCK);
clock_message =
gst_message_new_clock_lost (GST_OBJECT_CAST (identity),
gst_system_clock_obtain ());
}
}
GST_OBJECT_UNLOCK (identity);
if (clock_message)
gst_element_post_message (GST_ELEMENT_CAST (identity), clock_message);
break;
case PROP_TS_OFFSET:
identity->ts_offset = g_value_get_int64 (value);
@ -1186,5 +1205,10 @@ gst_identity_change_state (GstElement * element, GstStateChange transition)
static GstClock *
gst_identity_provide_clock (GstElement * element)
{
GstIdentity *identity = GST_IDENTITY (element);
if (!identity->sync)
return NULL;
return gst_system_clock_obtain ();
}