diff --git a/agent/component.c b/agent/component.c index f369bf8997f7e3612e478affc4e6c16ea502e78b..a5c90960085ffab85a56a878bb42b37f803cfaa8 100644 --- a/agent/component.c +++ b/agent/component.c @@ -855,6 +855,8 @@ typedef struct { guint stream_id; guint component_id; guint component_socket_sources_age; + + GIOCondition condition; } ComponentSource; static gboolean @@ -984,6 +986,7 @@ static GSourceFuncs component_source_funcs = { * @component_id: The component's number * @pollable_stream: a #GPollableInputStream or #GPollableOutputStream to pass * to dispatched callbacks + * @condition: underlying socket condition to dispatch on * @cancellable: (allow-none): a #GCancellable, or %NULL * * Create a new #ComponentSource, a type of #GSource which proxies poll events @@ -1000,13 +1003,15 @@ static GSourceFuncs component_source_funcs = { * Returns: (transfer full): a new #ComponentSource; unref with g_source_unref() */ GSource * -component_input_source_new (NiceAgent *agent, guint stream_id, - guint component_id, GPollableInputStream *pollable_istream, +component_source_new (NiceAgent *agent, guint stream_id, + guint component_id, GObject *pollable_stream, + GIOCondition condition, GCancellable *cancellable) { ComponentSource *component_source; - g_assert (G_IS_POLLABLE_INPUT_STREAM (pollable_istream)); + g_assert (G_IS_POLLABLE_INPUT_STREAM (pollable_stream) || + G_IS_POLLABLE_OUTPUT_STREAM (pollable_stream)); component_source = (ComponentSource *) @@ -1014,7 +1019,7 @@ component_input_source_new (NiceAgent *agent, guint stream_id, g_source_set_name ((GSource *) component_source, "ComponentSource"); component_source->component_socket_sources_age = 0; - component_source->pollable_stream = g_object_ref (pollable_istream); + component_source->pollable_stream = g_object_ref (pollable_stream); g_weak_ref_init (&component_source->agent_ref, agent); component_source->stream_id = stream_id; component_source->component_id = component_id; diff --git a/agent/component.h b/agent/component.h index 143c212e22ea1e579c9c399ce4c977a4e8546a66..0c28d2e3053449352ddb304fcbf74ff66e80f085 100644 --- a/agent/component.h +++ b/agent/component.h @@ -237,9 +237,9 @@ void component_free_socket_sources (Component *component); GSource * -component_input_source_new (NiceAgent *agent, guint stream_id, - guint component_id, GPollableInputStream *pollable_istream, - GCancellable *cancellable); +component_source_new (NiceAgent *agent, guint stream_id, + guint component_id, GObject *pollable_istream, + GIOCondition condition, GCancellable *cancellable); GMainContext * component_dup_io_context (Component *component); diff --git a/agent/inputstream.c b/agent/inputstream.c index a6a678bfa644ace384c82b4adaf13beeae1d1908..5da3908bd1582216f1efc6eaa9cb9d4c345714ac 100644 --- a/agent/inputstream.c +++ b/agent/inputstream.c @@ -424,8 +424,8 @@ nice_input_stream_create_source (GPollableInputStream *stream, if (agent == NULL) goto dummy_source; - component_source = component_input_source_new (agent, priv->stream_id, - priv->component_id, stream, cancellable); + component_source = component_source_new (agent, priv->stream_id, + priv->component_id, G_OBJECT (stream), G_IO_IN, cancellable); g_object_unref (agent); diff --git a/agent/outputstream.c b/agent/outputstream.c index bf34c86bf7d53c7a23e3dc90104de12e3a70827d..cd0d493d2f192452e5cf341d00980d8f07337d5c 100644 --- a/agent/outputstream.c +++ b/agent/outputstream.c @@ -618,6 +618,15 @@ nice_output_stream_create_source (GPollableOutputStream *stream, g_source_set_dummy_callback (cancellable_source); g_source_add_child_source (component_source, cancellable_source); g_source_unref (cancellable_source); + } else if (!agent->reliable) { + /* UDP streams are almost always writeable. */ + GSource *child_source; + + child_source = component_source_new (agent, priv->stream_id, + priv->component_id, G_OBJECT (stream), G_IO_OUT, cancellable); + g_source_set_dummy_callback (child_source); + g_source_add_child_source (component_source, child_source); + g_source_unref (child_source); } done: