clocksync: Remove handoff signals

They're not really useful on this element and were just a leftover from
identity.

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

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/443>
This commit is contained in:
Sebastian Dröge 2020-04-22 10:26:45 +03:00
parent c09f797231
commit 687c65994e
3 changed files with 3 additions and 120 deletions
plugins/elements
tests/check/elements

View file

@ -52,25 +52,15 @@
GST_DEBUG_CATEGORY_STATIC (gst_clock_sync_debug); GST_DEBUG_CATEGORY_STATIC (gst_clock_sync_debug);
#define GST_CAT_DEFAULT gst_clock_sync_debug #define GST_CAT_DEFAULT gst_clock_sync_debug
/* ClockSync signals and args */ /* ClockSync args */
enum
{
SIGNAL_HANDOFF,
SIGNAL_HANDOFF_LIST,
/* FILL ME */
LAST_SIGNAL
};
#define DEFAULT_SYNC TRUE #define DEFAULT_SYNC TRUE
#define DEFAULT_TS_OFFSET 0 #define DEFAULT_TS_OFFSET 0
#define DEFAULT_SIGNAL_HANDOFFS FALSE
enum enum
{ {
PROP_0, PROP_0,
PROP_SYNC, PROP_SYNC,
PROP_TS_OFFSET, PROP_TS_OFFSET
PROP_SIGNAL_HANDOFFS,
}; };
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
@ -109,8 +99,6 @@ static gboolean gst_clock_sync_src_query (GstPad * pad, GstObject * parent,
static GstStateChangeReturn gst_clocksync_change_state (GstElement * element, static GstStateChangeReturn gst_clocksync_change_state (GstElement * element,
GstStateChange transition); GstStateChange transition);
static guint gst_clocksync_signals[LAST_SIGNAL] = { 0 };
static void static void
gst_clock_sync_class_init (GstClockSyncClass * klass) gst_clock_sync_class_init (GstClockSyncClass * klass)
{ {
@ -133,43 +121,6 @@ gst_clock_sync_class_init (GstClockSyncClass * klass)
"Timestamp offset in nanoseconds for synchronisation, negative for earlier sync", "Timestamp offset in nanoseconds for synchronisation, negative for earlier sync",
G_MININT64, G_MAXINT64, DEFAULT_TS_OFFSET, G_MININT64, G_MAXINT64, DEFAULT_TS_OFFSET,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstClockSync::signal-handoffs
*
* If set to %TRUE, the clocksync will emit a handoff signal when handling a buffer.
* When set to %FALSE, no signal will be emitted, which might improve performance.
*/
g_object_class_install_property (gobject_class, PROP_SIGNAL_HANDOFFS,
g_param_spec_boolean ("signal-handoffs",
"Signal handoffs", "Send a signal before pushing the buffer",
DEFAULT_SIGNAL_HANDOFFS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstClockSync::handoff:
* @clocksync: the clocksync instance
* @buffer: the buffer that just has been received
* @pad: the pad that received it
*
* This signal gets emitted before passing the buffer downstream.
*/
gst_clocksync_signals[SIGNAL_HANDOFF] =
g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstClockSyncClass, handoff), NULL, NULL,
NULL, G_TYPE_NONE, 1, GST_TYPE_BUFFER | G_SIGNAL_TYPE_STATIC_SCOPE);
/**
* GstClockSync::handoff-list:
* @clocksync: the clocksync instance
* @buffer_list: the buffer list that just has been received
* @pad: the pad that received it
*
* This signal gets emitted before passing the buffer list downstream.
*/
gst_clocksync_signals[SIGNAL_HANDOFF_LIST] =
g_signal_new ("handoff-list", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstClockSyncClass, handoff_list),
NULL, NULL, NULL, G_TYPE_NONE, 1,
GST_TYPE_BUFFER_LIST | G_SIGNAL_TYPE_STATIC_SCOPE);
gstelement_class->change_state = gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_clocksync_change_state); GST_DEBUG_FUNCPTR (gst_clocksync_change_state);
@ -213,7 +164,6 @@ gst_clock_sync_init (GstClockSync * clocksync)
GST_PAD_SET_PROXY_CAPS (clocksync->srcpad); GST_PAD_SET_PROXY_CAPS (clocksync->srcpad);
gst_element_add_pad (GST_ELEMENT (clocksync), clocksync->srcpad); gst_element_add_pad (GST_ELEMENT (clocksync), clocksync->srcpad);
clocksync->signal_handoffs = DEFAULT_SIGNAL_HANDOFFS;
clocksync->ts_offset = DEFAULT_TS_OFFSET; clocksync->ts_offset = DEFAULT_TS_OFFSET;
clocksync->sync = DEFAULT_SYNC; clocksync->sync = DEFAULT_SYNC;
g_cond_init (&clocksync->blocked_cond); g_cond_init (&clocksync->blocked_cond);
@ -232,9 +182,6 @@ gst_clock_sync_set_property (GObject * object, guint prop_id,
case PROP_TS_OFFSET: case PROP_TS_OFFSET:
clocksync->ts_offset = g_value_get_int64 (value); clocksync->ts_offset = g_value_get_int64 (value);
break; break;
case PROP_SIGNAL_HANDOFFS:
clocksync->signal_handoffs = g_value_get_boolean (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -254,9 +201,6 @@ gst_clock_sync_get_property (GObject * object, guint prop_id,
case PROP_TS_OFFSET: case PROP_TS_OFFSET:
g_value_set_int64 (value, clocksync->ts_offset); g_value_set_int64 (value, clocksync->ts_offset);
break; break;
case PROP_SIGNAL_HANDOFFS:
g_value_set_boolean (value, clocksync->signal_handoffs);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -413,9 +357,6 @@ gst_clock_sync_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
} }
} }
if (clocksync->signal_handoffs)
g_signal_emit (clocksync, gst_clocksync_signals[SIGNAL_HANDOFF], 0, buf);
/* Forward the buffer */ /* Forward the buffer */
return gst_pad_push (clocksync->srcpad, buf); return gst_pad_push (clocksync->srcpad, buf);
} }
@ -457,10 +398,6 @@ gst_clock_sync_chain_list (GstPad * pad, GstObject * parent,
} }
} }
if (clocksync->signal_handoffs)
g_signal_emit (clocksync, gst_clocksync_signals[SIGNAL_HANDOFF_LIST], 0,
buffer_list);
/* Forward the buffer list */ /* Forward the buffer list */
done: done:
return gst_pad_push_list (clocksync->srcpad, buffer_list); return gst_pad_push_list (clocksync->srcpad, buffer_list);

View file

@ -51,8 +51,6 @@ struct _GstClockSync
/*< private >*/ /*< private >*/
GstPad *sinkpad, *srcpad; GstPad *sinkpad, *srcpad;
gboolean signal_handoffs;
GstSegment segment; GstSegment segment;
GstClockID clock_id; GstClockID clock_id;
gboolean flushing; gboolean flushing;
@ -65,13 +63,9 @@ struct _GstClockSync
GstClockTime upstream_latency; GstClockTime upstream_latency;
}; };
struct _GstClockSyncClass struct _GstClockSyncClass
{ {
GstElementClass parent_class; GstElementClass parent_class;
/* signals */
void (*handoff) (GstElement *element, GstBuffer *buf);
void (*handoff_list) (GstElement *element, GstBufferList *buffer_list);
}; };
GType gst_clock_sync_get_type (void); GType gst_clock_sync_get_type (void);

View file

@ -58,53 +58,6 @@ GST_START_TEST (test_one_buffer)
GST_END_TEST; GST_END_TEST;
static void
handoff_func (GstElement * clocksync, GstBuffer * buf, GstBuffer ** ret)
{
(void) clocksync;
*ret = buf;
}
GST_START_TEST (test_signal_handoffs)
{
GstHarness *h = gst_harness_new_parse ("clocksync sync=false name=c");
GstBuffer *buffer_in;
GstBuffer *buffer_signaled = NULL;
GstElement *c = gst_bin_get_by_name (GST_BIN (h->element), "c");
gst_harness_set_src_caps_str (h, "mycaps");
/* connect to the handoff signal */
g_signal_connect (c, "handoff", G_CALLBACK (handoff_func), &buffer_signaled);
/* first, turn off signal-handoffs */
g_object_set (c, "signal-handoffs", FALSE, NULL);
/* then push a buffer */
buffer_in = gst_buffer_new_and_alloc (4);
fail_unless_equals_int (GST_FLOW_OK, gst_harness_push (h, buffer_in));
/* verify that we got no buffer signaled */
fail_unless (buffer_signaled == NULL);
/* now turn on signal-handoffs */
g_object_set (c, "signal-handoffs", TRUE, NULL);
/* then push another buffer */
buffer_in = gst_buffer_new_and_alloc (4);
fail_unless_equals_int (GST_FLOW_OK, gst_harness_push (h, buffer_in));
/* verify the buffer signaled is equal to the one pushed in */
fail_unless (buffer_signaled == buffer_in);
ASSERT_BUFFER_REFCOUNT (buffer_signaled, "buffer", 1);
/* cleanup */
gst_object_unref (c);
gst_harness_teardown (h);
}
GST_END_TEST;
GST_START_TEST (test_sync_on_timestamp) GST_START_TEST (test_sync_on_timestamp)
{ {
/* the reason to use the queue in front of the clocksync element /* the reason to use the queue in front of the clocksync element
@ -223,7 +176,6 @@ clocksync_suite (void)
suite_add_tcase (s, tc_chain); suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_one_buffer); tcase_add_test (tc_chain, test_one_buffer);
tcase_add_test (tc_chain, test_signal_handoffs);
tcase_add_test (tc_chain, test_sync_on_timestamp); tcase_add_test (tc_chain, test_sync_on_timestamp);
tcase_add_test (tc_chain, test_stopping_element_unschedules_sync); tcase_add_test (tc_chain, test_stopping_element_unschedules_sync);
tcase_add_test (tc_chain, test_no_sync_on_timestamp); tcase_add_test (tc_chain, test_no_sync_on_timestamp);