summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Adam <jakub.adam@ktknet.cz>2015-10-08 12:50:16 +0200
committerJakub Adam <jakub.adam@ktknet.cz>2015-10-08 12:50:16 +0200
commit89b490e92fa523432cf98491f6455d9dd0178984 (patch)
treec7aa6a330772c545d0210e8325a51a0bff8445e1
parent42ea17625cc7dd334928eea0f223c10d5e6a8b44 (diff)
downloadpidgin-89b490e92fa523432cf98491f6455d9dd0178984.tar.gz
Don't require appsink be drained in appsink_readable
When appsink_readable was entered, it kept invoking the read callback as long as there were some unread data available. This may have led to infinite loop when the application decided it wasn't convenient to read the whole input buffer just now. This change removes the while loop and if some data are left in the buffer, appsink_readable returns TRUE in order to be scheduled again. Control returns to the main loop and another events get a chance to be processed.
-rw-r--r--libpurple/mediamanager.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/libpurple/mediamanager.c b/libpurple/mediamanager.c
index b78df04e37..0013f31916 100644
--- a/libpurple/mediamanager.c
+++ b/libpurple/mediamanager.c
@@ -948,6 +948,7 @@ appsink_readable (gpointer user_data)
gpointer cb_data;
guint *cb_token_ptr = &info->readable_cb_token;
guint cb_token = *cb_token_ptr;
+ gboolean run_again = FALSE;
g_mutex_lock (&manager->priv->appdata_mutex);
if (cb_token == 0 || cb_token != *cb_token_ptr) {
@@ -955,8 +956,8 @@ appsink_readable (gpointer user_data)
g_mutex_unlock (&manager->priv->appdata_mutex);
return FALSE;
}
- /* We need to signal readable until there are no more samples */
- while (info->callbacks.readable &&
+
+ if (info->callbacks.readable &&
(info->num_samples > 0 || info->current_sample != NULL)) {
readable_cb = info->callbacks.readable;
media = g_weak_ref_get (&info->media_ref);
@@ -978,9 +979,17 @@ appsink_readable (gpointer user_data)
return FALSE;
}
}
- info->readable_cb_token = 0;
+
+ /* Do we still have samples? Schedule appsink_readable again. We break here
+ * so that other events get a chance to be processed too. */
+ if (info->num_samples > 0 || info->current_sample != NULL) {
+ run_again = TRUE;
+ } else {
+ info->readable_cb_token = 0;
+ }
+
g_mutex_unlock (&manager->priv->appdata_mutex);
- return FALSE;
+ return run_again;
}
static void