[banshee] libbanshee: Correctly detect sink volume control (bgo#644648)



commit 550b3be2e24583092730e4fd53c32942a8aace90
Author: Sjoerd Simons <sjoerd luon net>
Date:   Sun Mar 13 14:13:55 2011 +0000

    libbanshee: Correctly detect sink volume control (bgo#644648)
    
    If an element is used as an audiosink which detects and dynamically
    plugs the actual sink element, then we can only detect sink volume
    support after this has happened. To trigger this, simply set the sink
    state to READY, which should open the resources and thus load the actual
    audio sink.
    
    Signed-off-by: Gabriel Burt <gabriel burt gmail com>

 libbanshee/banshee-player-pipeline.c |   22 +++++++++++++++++-----
 libbanshee/banshee-player-private.h  |    1 +
 2 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/libbanshee/banshee-player-pipeline.c b/libbanshee/banshee-player-pipeline.c
index d98c165..c1635e5 100644
--- a/libbanshee/banshee-player-pipeline.c
+++ b/libbanshee/banshee-player-pipeline.c
@@ -327,6 +327,16 @@ _bp_pipeline_construct (BansheePlayer *player)
     
     g_return_val_if_fail (audiosink != NULL, FALSE);
 
+    // Set the profile to "music and movies" (gst-plugins-good 0.10.3)
+    if (g_object_class_find_property (G_OBJECT_GET_CLASS (audiosink), "profile")) {
+        g_object_set (G_OBJECT (audiosink), "profile", 1, NULL);
+    }
+
+    /* Set the audio sink to READY so it can autodetect the right sink element
+     * if needed, as this allows us to correctly determine whether it has a
+     * volume */
+    gst_element_set_state (audiosink, GST_STATE_READY);
+
     // See if the audiosink has a 'volume' property.  If it does, we assume it saves and restores
     // its volume information - and that we shouldn't
     player->audiosink_has_volume = FALSE;
@@ -342,10 +352,6 @@ _bp_pipeline_construct (BansheePlayer *player)
     bp_debug ("Audiosink has volume: %s",
         player->audiosink_has_volume ? "YES" : "NO");
         
-    // Set the profile to "music and movies" (gst-plugins-good 0.10.3)
-    if (g_object_class_find_property (G_OBJECT_GET_CLASS (audiosink), "profile")) {
-        g_object_set (G_OBJECT (audiosink), "profile", 1, NULL);
-    }
     
     // Create a custom audio sink bin that will hold the real primary sink
     player->audiobin = gst_bin_new ("audiobin");
@@ -392,7 +398,7 @@ _bp_pipeline_construct (BansheePlayer *player)
         gst_element_link_many (audiosinkqueue, player->volume, audiosink, NULL);
     }
     player->before_rgvolume = player->volume;
-    player->after_rgvolume = audiosink;
+    player->after_rgvolume = player->audiosink = audiosink;
     player->rgvolume_in_pipeline = FALSE;
     _bp_replaygain_pipeline_rebuild (player);
 
@@ -431,6 +437,12 @@ _bp_pipeline_destroy (BansheePlayer *player)
     if (GST_IS_ELEMENT (player->playbin)) {
         player->target_state = GST_STATE_NULL;
         gst_element_set_state (player->playbin, GST_STATE_NULL);
+
+        // The audiosink was set READY early to detect sink volume control in
+        // case it is out of sync with the playbin state ensure it's in NULL now
+        if (player->audiosink != NULL && GST_STATE (player->audiosink) != GST_STATE_NULL)
+          gst_element_set_state (player->audiosink, GST_STATE_NULL);
+
         gst_object_unref (GST_OBJECT (player->playbin));
     }
     
diff --git a/libbanshee/banshee-player-private.h b/libbanshee/banshee-player-private.h
index 4d9bf44..8525ee0 100644
--- a/libbanshee/banshee-player-private.h
+++ b/libbanshee/banshee-player-private.h
@@ -136,6 +136,7 @@ struct BansheePlayer {
     GstElement *preamp;
     GstElement *volume;
     GstElement *rgvolume;
+    GstElement *audiosink;
 
     GstElement *before_rgvolume;
     GstElement *after_rgvolume;



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