mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 18:50:48 +00:00
net: keep GCancellable fd around instead of re-creating it constantly
Just create the cancellable fd once and keep it around instead of creating/closing it for every single packet. Since we spend most time waiting for packets, an fd is alloced and in use pretty much all the time anyway.
This commit is contained in:
parent
19e5356afd
commit
d71f5c7d73
2 changed files with 15 additions and 0 deletions
|
@ -94,6 +94,7 @@ struct _GstNetClientClockPrivate
|
|||
GSocket *socket;
|
||||
GSocketAddress *servaddr;
|
||||
GCancellable *cancel;
|
||||
gboolean made_cancel_fd;
|
||||
|
||||
GstClockTime timeout_expiration;
|
||||
GstClockTime roundtrip_limit;
|
||||
|
@ -612,6 +613,7 @@ gst_net_client_clock_start (GstNetClientClock * self)
|
|||
GSocket *socket;
|
||||
GError *error = NULL;
|
||||
GSocketFamily family;
|
||||
GPollFD dummy_pollfd;
|
||||
|
||||
g_return_val_if_fail (self->priv->address != NULL, FALSE);
|
||||
g_return_val_if_fail (self->priv->servaddr == NULL, FALSE);
|
||||
|
@ -659,6 +661,9 @@ gst_net_client_clock_start (GstNetClientClock * self)
|
|||
g_object_unref (myaddr);
|
||||
|
||||
self->priv->cancel = g_cancellable_new ();
|
||||
self->priv->made_cancel_fd =
|
||||
g_cancellable_make_pollfd (self->priv->cancel, &dummy_pollfd);
|
||||
|
||||
self->priv->socket = socket;
|
||||
self->priv->servaddr = G_SOCKET_ADDRESS (servaddr);
|
||||
|
||||
|
@ -721,6 +726,9 @@ gst_net_client_clock_stop (GstNetClientClock * self)
|
|||
g_thread_join (self->priv->thread);
|
||||
self->priv->thread = NULL;
|
||||
|
||||
if (self->priv->made_cancel_fd)
|
||||
g_cancellable_release_fd (self->priv->cancel);
|
||||
|
||||
g_object_unref (self->priv->cancel);
|
||||
self->priv->cancel = NULL;
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ struct _GstNetTimeProviderPrivate
|
|||
|
||||
GSocket *socket;
|
||||
GCancellable *cancel;
|
||||
gboolean made_cancel_fd;
|
||||
};
|
||||
|
||||
static gboolean gst_net_time_provider_start (GstNetTimeProvider * bself);
|
||||
|
@ -274,6 +275,7 @@ gst_net_time_provider_start (GstNetTimeProvider * self)
|
|||
{
|
||||
GSocketAddress *socket_addr, *bound_addr;
|
||||
GInetAddress *inet_addr;
|
||||
GPollFD dummy_pollfd;
|
||||
GSocket *socket;
|
||||
GError *err = NULL;
|
||||
int port;
|
||||
|
@ -328,6 +330,8 @@ gst_net_time_provider_start (GstNetTimeProvider * self)
|
|||
|
||||
self->priv->socket = socket;
|
||||
self->priv->cancel = g_cancellable_new ();
|
||||
self->priv->made_cancel_fd =
|
||||
g_cancellable_make_pollfd (self->priv->cancel, &dummy_pollfd);
|
||||
|
||||
self->priv->thread = g_thread_try_new ("GstNetTimeProvider",
|
||||
gst_net_time_provider_thread, self, &err);
|
||||
|
@ -380,6 +384,9 @@ gst_net_time_provider_stop (GstNetTimeProvider * self)
|
|||
g_thread_join (self->priv->thread);
|
||||
self->priv->thread = NULL;
|
||||
|
||||
if (self->priv->made_cancel_fd)
|
||||
g_cancellable_release_fd (self->priv->cancel);
|
||||
|
||||
g_object_unref (self->priv->cancel);
|
||||
self->priv->cancel = NULL;
|
||||
|
||||
|
|
Loading…
Reference in a new issue