summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2010-12-05 19:56:51 +0000
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2010-12-05 19:56:51 +0000
commitb65cfc3e2a43bd3af403ede70ecb4e2838979406 (patch)
treecabc835504018aedfa90d059e7d882453a256304
parentca3b450d1269c3fa1a1254fd25978edd1cfe1c06 (diff)
Ensure CodecsUpdated is always called when needed
For a CM calling SupportedCodecs after local codecs have been set is only expected to contain the intersection of the remote codecs with the existing set of codecs. Specifically it's unexpected for codecs to change their parameters. This means there is a race when remote codecs are updated and at the same time the local codecs are updated, as telepathy-farsight tried to ensure to only send a set of codecs once (via either SupportedCodecs, CodecsUpdated or Ready). To fix this always call CodecsUpdated when the list of codecs has changed after the initial set of codecs was sent.
-rw-r--r--telepathy-farsight/stream.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/telepathy-farsight/stream.c b/telepathy-farsight/stream.c
index ebb2c01..82f8e6c 100644
--- a/telepathy-farsight/stream.c
+++ b/telepathy-farsight/stream.c
@@ -2274,8 +2274,6 @@ _tf_stream_try_sending_codecs (TfStream *stream)
GList *item = NULL;
GPtrArray *tpcodecs = NULL;
- gboolean sent_codecs = FALSE;
-
DEBUG (stream, "called (send_local:%d send_supported:%d)",
stream->priv->send_local_codecs, stream->priv->send_supported_codecs);
@@ -2307,7 +2305,7 @@ _tf_stream_try_sending_codecs (TfStream *stream)
-1, tpcodecs, async_method_callback, "Media.StreamHandler::Ready",
NULL, (GObject *) stream);
stream->priv->send_local_codecs = FALSE;
- sent_codecs = TRUE;
+ goto out;
}
if (stream->priv->send_supported_codecs)
@@ -2320,12 +2318,17 @@ _tf_stream_try_sending_codecs (TfStream *stream)
-1, tpcodecs, async_method_callback,
"Media.StreamHandler::SupportedCodecs", NULL, (GObject *) stream);
stream->priv->send_supported_codecs = FALSE;
- sent_codecs = TRUE;
+
+ /* Fallthrough to potentially call CodecsUpdated as CMs assume
+ * SupportedCodecs will only give the intersection of the already sent
+ * (if any) local codecs, not any updates */
}
- if (!sent_codecs &&
- !fs_codec_list_are_equal (fscodecs, stream->priv->last_sent_codecs))
+ /* Only send updates if there was something to update (iotw we sent codecs
+ * before) or our list changed */
+ if (stream->priv->last_sent_codecs != NULL
+ && !fs_codec_list_are_equal (fscodecs, stream->priv->last_sent_codecs))
{
tpcodecs = fs_codecs_to_tp (stream, fscodecs);
@@ -2336,6 +2339,7 @@ _tf_stream_try_sending_codecs (TfStream *stream)
"Media.StreamHandler::CodecsUpdated", NULL, (GObject *) stream);
}
+out:
if (tpcodecs)
g_boxed_free (TP_ARRAY_TYPE_MEDIA_STREAM_HANDLER_CODEC_LIST, tpcodecs);
fs_codec_list_destroy (stream->priv->last_sent_codecs);