Commit 16e9b357 authored by Olivier Crete's avatar Olivier Crete

Store the main context for io callbacks in the component too

darcs-hash:20080426002304-3e2dc-8d4c50ebb32da09af48c07e26a3a19c568731daa.gz
parent 21ec700e
...@@ -107,8 +107,7 @@ static guint signals[N_SIGNALS]; ...@@ -107,8 +107,7 @@ static guint signals[N_SIGNALS];
static gboolean priv_attach_stream_component (NiceAgent *agent, static gboolean priv_attach_stream_component (NiceAgent *agent,
Stream *stream, Stream *stream,
Component *component, Component *component);
GMainContext *ctx);
static void priv_detach_stream_component (Stream *stream, Component *component); static void priv_detach_stream_component (Stream *stream, Component *component);
Stream *agent_find_stream (NiceAgent *agent, guint stream_id) Stream *agent_find_stream (NiceAgent *agent, guint stream_id)
...@@ -1767,13 +1766,15 @@ static void ...@@ -1767,13 +1766,15 @@ static void
priv_attach_stream_component_socket (NiceAgent *agent, priv_attach_stream_component_socket (NiceAgent *agent,
Stream *stream, Stream *stream,
Component *component, Component *component,
NiceUDPSocket *udp_socket, NiceUDPSocket *udp_socket)
GMainContext *context)
{ {
GIOChannel *io; GIOChannel *io;
GSource *source; GSource *source;
IOCtx *ctx; IOCtx *ctx;
if (!component->ctx)
return;
io = g_io_channel_unix_new (udp_socket->fileno); io = g_io_channel_unix_new (udp_socket->fileno);
/* note: without G_IO_ERR the glib mainloop goes into /* note: without G_IO_ERR the glib mainloop goes into
* busyloop if errors are encountered */ * busyloop if errors are encountered */
...@@ -1782,7 +1783,7 @@ priv_attach_stream_component_socket (NiceAgent *agent, ...@@ -1782,7 +1783,7 @@ priv_attach_stream_component_socket (NiceAgent *agent,
g_source_set_callback (source, (GSourceFunc) nice_agent_g_source_cb, g_source_set_callback (source, (GSourceFunc) nice_agent_g_source_cb,
ctx, (GDestroyNotify) io_ctx_free); ctx, (GDestroyNotify) io_ctx_free);
g_debug ("Attach source %p (stream %u).", source, stream->id); g_debug ("Attach source %p (stream %u).", source, stream->id);
g_source_attach (source, context); g_source_attach (source, component->ctx);
component->gsources = g_slist_append (component->gsources, source); component->gsources = g_slist_append (component->gsources, source);
} }
...@@ -1795,14 +1796,12 @@ priv_attach_stream_component_socket (NiceAgent *agent, ...@@ -1795,14 +1796,12 @@ priv_attach_stream_component_socket (NiceAgent *agent,
static gboolean static gboolean
priv_attach_stream_component (NiceAgent *agent, priv_attach_stream_component (NiceAgent *agent,
Stream *stream, Stream *stream,
Component *component, Component *component)
GMainContext *context)
{ {
GSList *i; GSList *i;
for (i = component->sockets; i; i = i->next) for (i = component->sockets; i; i = i->next)
priv_attach_stream_component_socket (agent, stream, component, i->data, priv_attach_stream_component_socket (agent, stream, component, i->data);
context);
return TRUE; return TRUE;
} }
...@@ -1854,14 +1853,18 @@ nice_agent_attach_recv ( ...@@ -1854,14 +1853,18 @@ nice_agent_attach_recv (
priv_detach_stream_component (stream, component); priv_detach_stream_component (stream, component);
ret = TRUE; ret = TRUE;
component->g_source_io_cb = NULL;
if (func != NULL) if (func && ctx) {
ret = priv_attach_stream_component (agent, stream, component, ctx);
if (ret)
component->g_source_io_cb = func; component->g_source_io_cb = func;
component->data = data; component->data = data;
component->ctx = ctx;
priv_attach_stream_component (agent, stream, component);
} else {
component->g_source_io_cb = NULL;
component->data = NULL;
component->ctx = NULL;
}
done: done:
g_mutex_unlock (agent->mutex); g_mutex_unlock (agent->mutex);
......
...@@ -89,6 +89,8 @@ struct _Component ...@@ -89,6 +89,8 @@ struct _Component
NiceCandidate *restart_candidate; /**< for storing active remote candidate during a restart */ NiceCandidate *restart_candidate; /**< for storing active remote candidate during a restart */
NiceAgentRecvFunc g_source_io_cb; /**< function called on io cb */ NiceAgentRecvFunc g_source_io_cb; /**< function called on io cb */
gpointer data; /**< data passed to the io function */ gpointer data; /**< data passed to the io function */
GMainContext *ctx; /**< context for data callbacks for this
component */
}; };
Component * Component *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment