/pidgin/main: cbc4db14444c: Don't require appsink be drained in ...

Jakub Adam <[email protected]>
Newsgroups gmane.comp.gnome.gaim.cvs
Message-ID <[email protected]>
Changeset: cbc4db14444c91f4f4b03aa1b228c2d51dacea6b
Author:	 Jakub Adam <[email protected]>
Date:	 2015-10-08 12:50 +0200
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/cbc4db14444c

Description:

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.

diffstat:

 libpurple/mediamanager.c |  17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (42 lines):

diff --git a/libpurple/mediamanager.c b/libpurple/mediamanager.c
--- 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

_______________________________________________
Commits mailing list
[email protected]
https://pidgin.im/cgi-bin/mailman/listinfo/commits
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.