Commit 479c2ee3 authored by Philip Withnall's avatar Philip Withnall Committed by Olivier Crête

agent: Fix GSource dispatches for UDP NiceOutputStreams

The GSource created by g_pollable_output_stream_create_source() on a
NiceOutputStream would never have been dispatched, due to not having any
poll events (or anything else); it only works for TCP streams because of
a GCancellable child source which is triggered by the TCP code.

Fix that by making ComponentSource suitable for G_IO_IN and G_IO_OUT
again, and adding that as a child source for UDP output stream GSources.
parent fe79ad76
...@@ -855,6 +855,8 @@ typedef struct { ...@@ -855,6 +855,8 @@ typedef struct {
guint stream_id; guint stream_id;
guint component_id; guint component_id;
guint component_socket_sources_age; guint component_socket_sources_age;
GIOCondition condition;
} ComponentSource; } ComponentSource;
static gboolean static gboolean
...@@ -984,6 +986,7 @@ static GSourceFuncs component_source_funcs = { ...@@ -984,6 +986,7 @@ static GSourceFuncs component_source_funcs = {
* @component_id: The component's number * @component_id: The component's number
* @pollable_stream: a #GPollableInputStream or #GPollableOutputStream to pass * @pollable_stream: a #GPollableInputStream or #GPollableOutputStream to pass
* to dispatched callbacks * to dispatched callbacks
* @condition: underlying socket condition to dispatch on
* @cancellable: (allow-none): a #GCancellable, or %NULL * @cancellable: (allow-none): a #GCancellable, or %NULL
* *
* Create a new #ComponentSource, a type of #GSource which proxies poll events * Create a new #ComponentSource, a type of #GSource which proxies poll events
...@@ -1000,13 +1003,15 @@ static GSourceFuncs component_source_funcs = { ...@@ -1000,13 +1003,15 @@ static GSourceFuncs component_source_funcs = {
* Returns: (transfer full): a new #ComponentSource; unref with g_source_unref() * Returns: (transfer full): a new #ComponentSource; unref with g_source_unref()
*/ */
GSource * GSource *
component_input_source_new (NiceAgent *agent, guint stream_id, component_source_new (NiceAgent *agent, guint stream_id,
guint component_id, GPollableInputStream *pollable_istream, guint component_id, GObject *pollable_stream,
GIOCondition condition,
GCancellable *cancellable) GCancellable *cancellable)
{ {
ComponentSource *component_source; 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 = component_source =
(ComponentSource *) (ComponentSource *)
...@@ -1014,7 +1019,7 @@ component_input_source_new (NiceAgent *agent, guint stream_id, ...@@ -1014,7 +1019,7 @@ component_input_source_new (NiceAgent *agent, guint stream_id,
g_source_set_name ((GSource *) component_source, "ComponentSource"); g_source_set_name ((GSource *) component_source, "ComponentSource");
component_source->component_socket_sources_age = 0; 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); g_weak_ref_init (&component_source->agent_ref, agent);
component_source->stream_id = stream_id; component_source->stream_id = stream_id;
component_source->component_id = component_id; component_source->component_id = component_id;
......
...@@ -237,9 +237,9 @@ void ...@@ -237,9 +237,9 @@ void
component_free_socket_sources (Component *component); component_free_socket_sources (Component *component);
GSource * GSource *
component_input_source_new (NiceAgent *agent, guint stream_id, component_source_new (NiceAgent *agent, guint stream_id,
guint component_id, GPollableInputStream *pollable_istream, guint component_id, GObject *pollable_istream,
GCancellable *cancellable); GIOCondition condition, GCancellable *cancellable);
GMainContext * GMainContext *
component_dup_io_context (Component *component); component_dup_io_context (Component *component);
......
...@@ -424,8 +424,8 @@ nice_input_stream_create_source (GPollableInputStream *stream, ...@@ -424,8 +424,8 @@ nice_input_stream_create_source (GPollableInputStream *stream,
if (agent == NULL) if (agent == NULL)
goto dummy_source; goto dummy_source;
component_source = component_input_source_new (agent, priv->stream_id, component_source = component_source_new (agent, priv->stream_id,
priv->component_id, stream, cancellable); priv->component_id, G_OBJECT (stream), G_IO_IN, cancellable);
g_object_unref (agent); g_object_unref (agent);
......
...@@ -618,6 +618,15 @@ nice_output_stream_create_source (GPollableOutputStream *stream, ...@@ -618,6 +618,15 @@ nice_output_stream_create_source (GPollableOutputStream *stream,
g_source_set_dummy_callback (cancellable_source); g_source_set_dummy_callback (cancellable_source);
g_source_add_child_source (component_source, cancellable_source); g_source_add_child_source (component_source, cancellable_source);
g_source_unref (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: done:
......
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