[banshee/stable-1.6] Separate mutexes for video and rpgain (bmc#1115)



commit c08c9ce1182e4b6cf059207f2bbf8c907b200167
Author: Aaron Bockover <abockover novell com>
Date:   Thu Jul 22 16:55:57 2010 -0400

    Separate mutexes for video and rpgain (bmc#1115)
    
    This fixes a possible deadlock that is very evident on MeeGo. The
    replaygain and video portions of the pipeline where for some (bad)
    reason sharing the same mutex, causing deadlocks at time.

 libbanshee/banshee-player-private.h    |    3 ++-
 libbanshee/banshee-player-replaygain.c |    6 +++---
 libbanshee/banshee-player-video.c      |   16 ++++++++--------
 libbanshee/banshee-player.c            |   13 +++++++++----
 4 files changed, 22 insertions(+), 16 deletions(-)
---
diff --git a/libbanshee/banshee-player-private.h b/libbanshee/banshee-player-private.h
index 50f901a..fee63d7 100644
--- a/libbanshee/banshee-player-private.h
+++ b/libbanshee/banshee-player-private.h
@@ -129,7 +129,8 @@ struct BansheePlayer {
     gint equalizer_status;
     
     // Pipeline/Playback State
-    GMutex *mutex;
+    GMutex *video_mutex;
+    GMutex *replaygain_mutex;
     GstState target_state;
     guint iterate_timeout_id;
     gboolean buffering;
diff --git a/libbanshee/banshee-player-replaygain.c b/libbanshee/banshee-player-replaygain.c
index 8c870f1..615dbab 100644
--- a/libbanshee/banshee-player-replaygain.c
+++ b/libbanshee/banshee-player-replaygain.c
@@ -90,12 +90,12 @@ pad_block_cb (GstPad *srcPad, gboolean blocked, gpointer user_data) {
     // The pad_block_cb can get triggered multiple times, on different threads.
     // Lock around the link/unlink code, so we don't end up going through here
     // with inconsistent state.
-    g_mutex_lock (player->mutex);
+    g_mutex_lock (player->replaygain_mutex);
 
     if ((player->replaygain_enabled && player->rgvolume_in_pipeline) ||
         (!player->replaygain_enabled && !player->rgvolume_in_pipeline)) {
         // The pipeline is already in the correct state.  Unblock the pad, and return.
-        g_mutex_unlock (player->mutex);
+        g_mutex_unlock (player->replaygain_mutex);
         if (gst_pad_is_blocked (srcPad)) {
             gst_pad_set_blocked_async (srcPad, FALSE, &pad_block_cb, player);
         }
@@ -135,7 +135,7 @@ pad_block_cb (GstPad *srcPad, gboolean blocked, gpointer user_data) {
     }
 
     // Our state is now consistent
-    g_mutex_unlock (player->mutex);
+    g_mutex_unlock (player->replaygain_mutex);
 
     if (gst_pad_is_blocked (srcPad)) {
         gst_pad_set_blocked_async (srcPad, FALSE, &pad_block_cb, player);
diff --git a/libbanshee/banshee-player-video.c b/libbanshee/banshee-player-video.c
index f34dc21..d5d9330 100644
--- a/libbanshee/banshee-player-video.c
+++ b/libbanshee/banshee-player-video.c
@@ -86,10 +86,10 @@ bp_video_sink_element_added (GstBin *videosink, GstElement *element, BansheePlay
 {
     g_return_if_fail (IS_BANSHEE_PLAYER (player));
 
-    #ifdef GDK_WINDOWING_X11
-    g_mutex_lock (player->mutex);
+    #if defined(GDK_WINDOWING_X11) || defined(GDK_WINDOWING_WIN32)
+    g_mutex_lock (player->video_mutex);
     bp_video_find_xoverlay (player);
-    g_mutex_unlock (player->mutex);    
+    g_mutex_unlock (player->video_mutex);
     #endif
 }
 
@@ -106,9 +106,9 @@ bp_video_bus_element_sync_message (GstBus *bus, GstMessage *message, BansheePlay
         return;
     }
 
-    g_mutex_lock (player->mutex);
+    g_mutex_lock (player->video_mutex);
     found_xoverlay = bp_video_find_xoverlay (player);
-    g_mutex_unlock (player->mutex);
+    g_mutex_unlock (player->video_mutex);
 
     if (found_xoverlay) {
         gst_x_overlay_set_xwindow_id (player->xoverlay, player->video_window_xid);
@@ -240,15 +240,15 @@ bp_video_window_expose (BansheePlayer *player, GdkWindow *window, gboolean direc
         return;
     }
    
-    g_mutex_lock (player->mutex);
+    g_mutex_lock (player->video_mutex);
    
     if (player->xoverlay == NULL && !bp_video_find_xoverlay (player)) {
-        g_mutex_unlock (player->mutex);
+        g_mutex_unlock (player->video_mutex);
         return;
     }
     
     gst_object_ref (player->xoverlay);
-    g_mutex_unlock (player->mutex);
+    g_mutex_unlock (player->video_mutex);
 
     gst_x_overlay_set_xwindow_id (player->xoverlay, player->video_window_xid);
     gst_x_overlay_expose (player->xoverlay);
diff --git a/libbanshee/banshee-player.c b/libbanshee/banshee-player.c
index ad56bfb..5fabe3d 100644
--- a/libbanshee/banshee-player.c
+++ b/libbanshee/banshee-player.c
@@ -98,8 +98,12 @@ bp_destroy (BansheePlayer *player)
 {
     g_return_if_fail (IS_BANSHEE_PLAYER (player));
     
-    if (player->mutex != NULL) {
-        g_mutex_free (player->mutex);
+    if (player->video_mutex != NULL) {
+        g_mutex_free (player->video_mutex);
+    }
+
+    if (player->replaygain_mutex != NULL) {
+        g_mutex_free (player->replaygain_mutex);
     }
     
     if (player->cdda_device != NULL) {
@@ -122,8 +126,9 @@ bp_new ()
 {
     BansheePlayer *player = g_new0 (BansheePlayer, 1);
     
-    player->mutex = g_mutex_new ();
-    
+    player->video_mutex = g_mutex_new ();
+    player->replaygain_mutex = g_mutex_new ();
+
     return player;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]