summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-03-04 13:45:35 (GMT)
committerOlivier CrĂȘte <olivier.crete@collabora.com>2014-04-15 23:49:28 (GMT)
commit479c2ee31506fb7ccd3ded300f57cfb45fdd4e76 (patch)
tree9cb0e9c4bba84e1501fed0daa98582f4cb5fe641
parentfe79ad767de92f6a6adcca92e41ce68a0dad8db8 (diff)
downloadlibnice-479c2ee31506fb7ccd3ded300f57cfb45fdd4e76.tar.gz
libnice-479c2ee31506fb7ccd3ded300f57cfb45fdd4e76.tar.xz
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.
-rw-r--r--agent/component.c13
-rw-r--r--agent/component.h6
-rw-r--r--agent/inputstream.c4
-rw-r--r--agent/outputstream.c9
4 files changed, 23 insertions, 9 deletions
diff --git a/agent/component.c b/agent/component.c
index f369bf8..a5c9096 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 143c212..0c28d2e 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 a6a678b..5da3908 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 bf34c86..cd0d493 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: