Commit 42983937 authored by Olivier Crête's avatar Olivier Crête

component: Make child source handling cheaper

Instead of checking all sources, just get the answer from the main poll().
parent d48bd58e
......@@ -1023,8 +1023,22 @@ typedef struct {
GSList *socket_sources;
GIOCondition condition;
GIOCondition current_condition;
} ComponentSource;
static gboolean
component_child_cb (GSocket *socket,
GIOCondition condition,
gpointer user_data)
ComponentSource *component_source = user_data;
component_source->current_condition |= condition;
static gboolean
component_source_prepare (GSource *source, gint *timeout_)
......@@ -1033,6 +1047,8 @@ component_source_prepare (GSource *source, gint *timeout_)
Component *component;
GSList *parentl, *childl;
component_source->current_condition = 0;
agent = g_weak_ref_get (&component_source->agent_ref);
if (!agent)
return FALSE;
......@@ -1079,7 +1095,8 @@ component_source_prepare (GSource *source, gint *timeout_)
child_socket_source->source =
g_socket_create_source (child_socket_source->socket->fileno,
component_source->condition, NULL);
source_set_dummy_callback (child_socket_source->source);
g_source_set_callback (child_socket_source->source,
(GSourceFunc) component_child_cb, component_source, NULL);
g_source_add_child_source (source, child_socket_source->source);
g_source_unref (child_socket_source->source);
component_source->socket_sources =
......@@ -1125,34 +1142,10 @@ component_source_dispatch (GSource *source, GSourceFunc callback,
gpointer user_data)
ComponentSource *component_source = (ComponentSource *) source;
NiceAgent *agent;
Component *component;
GDatagramBasedSourceFunc func = (GDatagramBasedSourceFunc) callback;
GIOCondition condition;
agent = g_weak_ref_get (&component_source->agent_ref);
if (!agent) {
condition = G_IO_HUP;
goto done_unlocked;
/* Needed due to accessing the Component. */
agent_lock ();
if (!agent_find_component (agent,
component_source->stream_id, component_source->component_id, NULL,
&component)) {
condition = G_IO_HUP;
goto done;
condition = component_condition_check (component, G_IO_IN | G_IO_OUT);
agent_unlock_and_emit (agent);
g_object_unref (agent);
return func (component_source->datagram_based, condition, user_data);
return func (component_source->datagram_based,
component_source->current_condition, user_data);
static void
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