netclientclock: bind socket before querying local address

Fails on windows otherwise.

https://bugzilla.gnome.org/show_bug.cgi?id=697608
This commit is contained in:
Tim-Philipp Müller 2013-04-09 10:17:45 +01:00
parent e2f2ee3582
commit 6e5405e9ce

View file

@ -346,6 +346,7 @@ gst_net_client_clock_start (GstNetClientClock * self)
{
GSocketAddress *servaddr;
GSocketAddress *myaddr;
GSocketAddress *anyaddr;
GInetAddress *inetaddr;
GSocket *socket;
GError *error = NULL;
@ -359,6 +360,16 @@ gst_net_client_clock_start (GstNetClientClock * self)
if (socket == NULL)
goto no_socket;
GST_DEBUG_OBJECT (self, "binding socket");
inetaddr = g_inet_address_new_any (G_SOCKET_FAMILY_IPV4);
anyaddr = g_inet_socket_address_new (inetaddr, 0);
g_socket_bind (socket, anyaddr, TRUE, &error);
g_object_unref (anyaddr);
g_object_unref (inetaddr);
if (error != NULL)
goto bind_error;
/* check address we're bound to, mostly for debugging purposes */
myaddr = g_socket_get_local_address (socket, &error);
@ -403,6 +414,13 @@ no_socket:
g_error_free (error);
return FALSE;
}
bind_error:
{
GST_ERROR_OBJECT (self, "bind failed: %s", error->message);
g_error_free (error);
g_object_unref (socket);
return FALSE;
}
getsockname_error:
{
GST_ERROR_OBJECT (self, "get_local_address() failed: %s", error->message);