Commit 673e299f authored by Olivier Crete's avatar Olivier Crete

Add function specifically to hook up the io_src to a socket

darcs-hash:20080426001748-3e2dc-e243944bbd3ef193acdecbcf423856bcbc06ca94.gz
parent 51492d41
...@@ -1759,41 +1759,50 @@ nice_agent_g_source_cb ( ...@@ -1759,41 +1759,50 @@ nice_agent_g_source_cb (
return TRUE; return TRUE;
} }
/*
* Attaches one socket handle to the main loop event context
*/
static void
priv_attach_stream_component_socket (NiceAgent *agent,
Stream *stream,
Component *component,
NiceUDPSocket *udp_socket,
GMainContext *context)
{
GIOChannel *io;
GSource *source;
IOCtx *ctx;
io = g_io_channel_unix_new (udp_socket->fileno);
/* note: without G_IO_ERR the glib mainloop goes into
* busyloop if errors are encountered */
source = g_io_create_watch (io, G_IO_IN | G_IO_ERR);
ctx = io_ctx_new (agent, stream, component, udp_socket);
g_source_set_callback (source, (GSourceFunc) nice_agent_g_source_cb,
ctx, (GDestroyNotify) io_ctx_free);
g_debug ("Attach source %p (stream %u).", source, stream->id);
g_source_attach (source, context);
component->gsources = g_slist_append (component->gsources, source);
}
/** /**
* Attaches socket handles of 'stream' to the main eventloop * Attaches socket handles of 'stream' to the main eventloop
* context. * context.
* *
*/ */
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 *context) GMainContext *context)
{ {
GSList *i; GSList *i;
for (i = component->sockets; i; i = i->next) { for (i = component->sockets; i; i = i->next)
NiceUDPSocket *udp_socket = i->data; priv_attach_stream_component_socket (agent, stream, component, i->data,
GIOChannel *io; context);
GSource *source;
IOCtx *ctx;
GSList *modified_list;
io = g_io_channel_unix_new (udp_socket->fileno);
/* note: without G_IO_ERR the glib mainloop goes into
* busyloop if errors are encountered */
source = g_io_create_watch (io, G_IO_IN | G_IO_ERR);
ctx = io_ctx_new (agent, stream, component, udp_socket);
g_source_set_callback (source, (GSourceFunc) nice_agent_g_source_cb,
ctx, (GDestroyNotify) io_ctx_free);
g_debug ("Attach source %p (stream %u).", source, stream->id);
g_source_attach (source, context);
modified_list = g_slist_append (component->gsources, source);
if (!modified_list) {
g_source_destroy (source);
return FALSE;
}
component->gsources = modified_list;
}
return TRUE; return TRUE;
} }
......
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