mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
dynudpsink: keep GCancellable fd around instead of re-creating it constantly
And create it only when starting the element.
This commit is contained in:
parent
b33d30621c
commit
2e5df10ed9
2 changed files with 27 additions and 7 deletions
|
@ -162,7 +162,6 @@ gst_dynudpsink_init (GstDynUDPSink * sink)
|
|||
|
||||
sink->used_socket = NULL;
|
||||
sink->used_socket_v6 = NULL;
|
||||
sink->cancellable = g_cancellable_new ();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -172,10 +171,6 @@ gst_dynudpsink_finalize (GObject * object)
|
|||
|
||||
sink = GST_DYNUDPSINK (object);
|
||||
|
||||
if (sink->cancellable)
|
||||
g_object_unref (sink->cancellable);
|
||||
sink->cancellable = NULL;
|
||||
|
||||
if (sink->socket)
|
||||
g_object_unref (sink->socket);
|
||||
sink->socket = NULL;
|
||||
|
@ -372,6 +367,26 @@ gst_dynudpsink_get_property (GObject * object, guint prop_id, GValue * value,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_dynudpsink_create_cancellable (GstDynUDPSink * sink)
|
||||
{
|
||||
GPollFD pollfd;
|
||||
|
||||
sink->cancellable = g_cancellable_new ();
|
||||
sink->made_cancel_fd = g_cancellable_make_pollfd (sink->cancellable, &pollfd);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_dynudpsink_free_cancellable (GstDynUDPSink * 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;
|
||||
}
|
||||
|
||||
/* create a socket for sending to remote machine */
|
||||
static gboolean
|
||||
gst_dynudpsink_start (GstBaseSink * bsink)
|
||||
|
@ -381,6 +396,8 @@ gst_dynudpsink_start (GstBaseSink * bsink)
|
|||
|
||||
udpsink = GST_DYNUDPSINK (bsink);
|
||||
|
||||
gst_dynudpsink_create_cancellable (udpsink);
|
||||
|
||||
udpsink->external_socket = FALSE;
|
||||
|
||||
if (udpsink->socket) {
|
||||
|
@ -552,6 +569,8 @@ gst_dynudpsink_stop (GstBaseSink * bsink)
|
|||
udpsink->used_socket_v6 = NULL;
|
||||
}
|
||||
|
||||
gst_dynudpsink_free_cancellable (udpsink);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -574,8 +593,8 @@ gst_dynudpsink_unlock_stop (GstBaseSink * bsink)
|
|||
|
||||
udpsink = GST_DYNUDPSINK (bsink);
|
||||
|
||||
g_object_unref (udpsink->cancellable);
|
||||
udpsink->cancellable = g_cancellable_new ();
|
||||
gst_dynudpsink_free_cancellable (udpsink);
|
||||
gst_dynudpsink_create_cancellable (udpsink);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ struct _GstDynUDPSink {
|
|||
/* the socket in use */
|
||||
GSocket *used_socket, *used_socket_v6;
|
||||
gboolean external_socket;
|
||||
gboolean made_cancel_fd;
|
||||
GCancellable *cancellable;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue