libpurple/mediamanager.c

changeset 37245
fc04ac95763d
parent 37237
9b40811c1329
parent 37244
cbc4db14444c
child 37421
ee3bd4532a33
--- a/libpurple/mediamanager.c	Tue Oct 06 21:29:51 2015 -0700
+++ b/libpurple/mediamanager.c	Thu Oct 08 13:21:41 2015 +0200
@@ -923,6 +923,7 @@
 	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) {
@@ -930,8 +931,8 @@
 		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);
@@ -953,9 +954,17 @@
 			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

mercurial