mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-25 07:26:29 +00:00
udpsink, multiudpsink: keep GCancellable fd around instead of re-creating it constantly
Otherwise we constantly create/close event file descriptors, every time we call g_socket_condition_timed_wait() or g_socket_send_message(s)(), i.e. a lot. Which is not particularly good for performance. Can't create GCancellable in ::start() here because it's used in client_new() which may be called via the add-client action signal which may be called before the element is up and running.
This commit is contained in:
parent
11bb21f3c2
commit
b33d30621c
2 changed files with 26 additions and 6 deletions
|
@ -373,6 +373,26 @@ gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass)
|
||||||
GST_DEBUG_CATEGORY_INIT (multiudpsink_debug, "multiudpsink", 0, "UDP sink");
|
GST_DEBUG_CATEGORY_INIT (multiudpsink_debug, "multiudpsink", 0, "UDP sink");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_multiudpsink_create_cancellable (GstMultiUDPSink * sink)
|
||||||
|
{
|
||||||
|
GPollFD pollfd;
|
||||||
|
|
||||||
|
sink->cancellable = g_cancellable_new ();
|
||||||
|
sink->made_cancel_fd = g_cancellable_make_pollfd (sink->cancellable, &pollfd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_multiudpsink_free_cancellable (GstMultiUDPSink * sink)
|
||||||
|
{
|
||||||
|
if (sink->made_cancel_fd) {
|
||||||
|
g_cancellable_release_fd (sink->cancellable);
|
||||||
|
sink->made_cancel_fd = FALSE;
|
||||||
|
}
|
||||||
|
g_object_unref (sink->cancellable);
|
||||||
|
sink->cancellable = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_multiudpsink_init (GstMultiUDPSink * sink)
|
gst_multiudpsink_init (GstMultiUDPSink * sink)
|
||||||
{
|
{
|
||||||
|
@ -400,7 +420,7 @@ gst_multiudpsink_init (GstMultiUDPSink * sink)
|
||||||
sink->send_duplicates = DEFAULT_SEND_DUPLICATES;
|
sink->send_duplicates = DEFAULT_SEND_DUPLICATES;
|
||||||
sink->multi_iface = g_strdup (DEFAULT_MULTICAST_IFACE);
|
sink->multi_iface = g_strdup (DEFAULT_MULTICAST_IFACE);
|
||||||
|
|
||||||
sink->cancellable = g_cancellable_new ();
|
gst_multiudpsink_create_cancellable (sink);
|
||||||
|
|
||||||
/* pre-allocate OutputVector, MapInfo and OutputMessage arrays
|
/* pre-allocate OutputVector, MapInfo and OutputMessage arrays
|
||||||
* for use in the render and render_list functions */
|
* for use in the render and render_list functions */
|
||||||
|
@ -522,9 +542,7 @@ gst_multiudpsink_finalize (GObject * object)
|
||||||
g_object_unref (sink->used_socket_v6);
|
g_object_unref (sink->used_socket_v6);
|
||||||
sink->used_socket_v6 = NULL;
|
sink->used_socket_v6 = NULL;
|
||||||
|
|
||||||
if (sink->cancellable)
|
gst_multiudpsink_free_cancellable (sink);
|
||||||
g_object_unref (sink->cancellable);
|
|
||||||
sink->cancellable = NULL;
|
|
||||||
|
|
||||||
g_free (sink->multi_iface);
|
g_free (sink->multi_iface);
|
||||||
sink->multi_iface = NULL;
|
sink->multi_iface = NULL;
|
||||||
|
@ -1845,8 +1863,8 @@ gst_multiudpsink_unlock_stop (GstBaseSink * bsink)
|
||||||
|
|
||||||
sink = GST_MULTIUDPSINK (bsink);
|
sink = GST_MULTIUDPSINK (bsink);
|
||||||
|
|
||||||
g_object_unref (sink->cancellable);
|
gst_multiudpsink_free_cancellable (sink);
|
||||||
sink->cancellable = g_cancellable_new ();
|
gst_multiudpsink_create_cancellable (sink);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,9 @@ struct _GstMultiUDPSink {
|
||||||
GstBaseSink parent;
|
GstBaseSink parent;
|
||||||
|
|
||||||
GSocket *used_socket, *used_socket_v6;
|
GSocket *used_socket, *used_socket_v6;
|
||||||
|
|
||||||
GCancellable *cancellable;
|
GCancellable *cancellable;
|
||||||
|
gboolean made_cancel_fd;
|
||||||
|
|
||||||
/* client management */
|
/* client management */
|
||||||
GMutex client_lock;
|
GMutex client_lock;
|
||||||
|
|
Loading…
Reference in a new issue