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



commit c36582d51435e4afdcbd10ab4d5002b1fa7cb7ab
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      |   14 +++++++-------
 libbanshee/banshee-player.c            |   13 +++++++++----
 4 files changed, 21 insertions(+), 15 deletions(-)
---
diff --git a/libbanshee/banshee-player-private.h b/libbanshee/banshee-player-private.h
index 42c73b8..5286daf 100644
--- a/libbanshee/banshee-player-private.h
+++ b/libbanshee/banshee-player-private.h
@@ -143,7 +143,8 @@ struct BansheePlayer {
     gint equalizer_status;
     
     // Pipeline/Playback State
-    GMutex *mutex;
+    GMutex *video_mutex;
+    GMutex *replaygain_mutex;
     GstState target_state;
     gboolean buffering;
     gchar *cdda_device;
diff --git a/libbanshee/banshee-player-replaygain.c b/libbanshee/banshee-player-replaygain.c
index c9e92ee..43caa6b 100644
--- a/libbanshee/banshee-player-replaygain.c
+++ b/libbanshee/banshee-player-replaygain.c
@@ -94,12 +94,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);
         }
@@ -139,7 +139,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 e092095..4b5937c 100644
--- a/libbanshee/banshee-player-video.c
+++ b/libbanshee/banshee-player-video.c
@@ -91,9 +91,9 @@ bp_video_sink_element_added (GstBin *videosink, GstElement *element, BansheePlay
     g_return_if_fail (IS_BANSHEE_PLAYER (player));
 
     #if defined(GDK_WINDOWING_X11) || defined(GDK_WINDOWING_WIN32)
-    g_mutex_lock (player->mutex);
+    g_mutex_lock (player->video_mutex);
     bp_video_find_xoverlay (player);
-    g_mutex_unlock (player->mutex);    
+    g_mutex_unlock (player->video_mutex);
     #endif
 }
 
@@ -110,9 +110,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);
@@ -319,15 +319,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 5a4cc9d..0c1c1ac 100644
--- a/libbanshee/banshee-player.c
+++ b/libbanshee/banshee-player.c
@@ -58,8 +58,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) {
@@ -82,8 +86,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]