[banshee] [libbanshee] Make the volume slider smooth with PulseAudio



commit 29dfe2c474b06e5e2794c7965880476502802638
Author: Arun Raghavan <arun raghavan collabora co uk>
Date:   Wed Mar 17 17:41:34 2010 +0000

    [libbanshee] Make the volume slider smooth with PulseAudio
    
    PulseAudio maps linear stream volumes to "actual" volumes as a cubic
    function. This change reflects that in the volume slider, making it feel
    more natural. This also makes the slider values correspond to other
    apps, such as GNOME volume preferences.
    
    Ref: https://tango.0pointer.de/pipermail/pulseaudio-discuss/2009-May/003898.html
    
    Signed-off-by: Gabriel Burt <gabriel burt gmail com>

 libbanshee/banshee-player.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/libbanshee/banshee-player.c b/libbanshee/banshee-player.c
index 28266aa..d304ce8 100644
--- a/libbanshee/banshee-player.c
+++ b/libbanshee/banshee-player.c
@@ -31,6 +31,9 @@
 #include "banshee-player-cdda.h"
 #include "banshee-player-missing-elements.h"
 #include "banshee-player-replaygain.h"
+#if GST_CHECK_VERSION(0,10,25)
+#include <gst/interfaces/streamvolume.h>
+#endif
 
 // ---------------------------------------------------------------------------
 // Private Functions
@@ -299,7 +302,14 @@ bp_set_volume (BansheePlayer *player, gdouble volume)
     g_return_if_fail (IS_BANSHEE_PLAYER (player));
     g_return_if_fail (GST_IS_ELEMENT (player->playbin));
 
+#if GST_CHECK_VERSION(0,10,25)
+    if (gst_element_implements_interface (player->playbin, GST_TYPE_STREAM_VOLUME))
+      gst_stream_volume_set_volume (GST_STREAM_VOLUME (player->playbin), GST_STREAM_VOLUME_FORMAT_CUBIC, volume);
+    else
+      g_object_set (player->playbin, "volume", CLAMP (volume, 0.0, 1.0), NULL);
+#else
     g_object_set (player->playbin, "volume", CLAMP (volume, 0.0, 1.0), NULL);
+#endif
     _bp_rgvolume_print_volume (player);
 }
 
@@ -309,7 +319,14 @@ bp_get_volume (BansheePlayer *player)
     g_return_val_if_fail (IS_BANSHEE_PLAYER (player), 0.0);
     g_return_val_if_fail (GST_IS_ELEMENT (player->playbin), 0.0);
     gdouble volume;
+#if GST_CHECK_VERSION(0,10,25)
+    if (gst_element_implements_interface (player->playbin, GST_TYPE_STREAM_VOLUME))
+      volume = gst_stream_volume_get_volume (GST_STREAM_VOLUME (player->playbin), GST_STREAM_VOLUME_FORMAT_CUBIC);
+    else
+      g_object_get (player->playbin, "volume", &volume, NULL);
+#else
     g_object_get (player->playbin, "volume", &volume, NULL);
+#endif
     return volume;
 }
 



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