source: packages/cm15/banshee/current/SOURCES/banshee-1.6.1-volume.patch @ 2747

Last change on this file since 2747 was 2747, checked in by lmcm, 7 years ago

Initial import. Added a couple of patches from upstream to fix several issues.

File size: 9.0 KB
  • libbanshee/banshee-player-pipeline.c

    From d0b1e1599581d80c7a044fadf3cb50b7eac33883 Mon Sep 17 00:00:00 2001
    From: Aaron Bockover <abockover@novell.com>
    Date: Fri, 14 May 2010 19:11:59 +0000
    Subject: [GStreamer] Don't track volume in preferences
    
    Added a new bp_supports_stream_volume API that returns whether or not
    the playbin element supports GST_TYPE_STREAM_VOLUME. If stream volumes
    are supported on the pipeline (which, for example, map to the system
    mixer), then don't load/save the volume from Banshee's preferences and
    instead only load/set volume on the pipeline itself so the application
    volume state is always in sync with the pipeline.
    
    This *should* fix bgo#613725, bgo#612362, and bgo#613726, though there
    may be some sort of inconsistency on some distributions as this fix will
    only apply for GStreamer 0.10.25 or newer (when the
    GST_TYPE_STREAM_VOLUME interface was introduced). If the case is that
    stream volume was supported internally on playbin2 before 0.10.25 adds
    this interface, there's no real way for us to know whether to trust the
    pipeline (system/mixer) volume or our internal software volume state.
    ---
    diff --git a/libbanshee/banshee-player-pipeline.c b/libbanshee/banshee-player-pipeline.c
    index 90b968d..d655df3 100644
    a b _bp_pipeline_construct (BansheePlayer *player) 
    267267    // source and decoder elements) based on source URI and stream content
    268268    player->playbin = gst_element_factory_make ("playbin2", "playbin");
    269269
     270    player->supports_stream_volume = FALSE;
     271#if BANSHEE_CHECK_GST_VERSION(0,10,25)
     272    player->supports_stream_volume = gst_element_implements_interface (
     273        player->playbin, GST_TYPE_STREAM_VOLUME);
     274#endif
     275
     276    bp_debug ("Stream volume supported: %s",
     277        player->supports_stream_volume ? "YES" : "NO");
     278
    270279#ifdef ENABLE_GAPLESS
    271280    // Connect a proxy about-to-finish callback that will generate a next-track-starting callback.
    272281    // This can be removed once playbin2 generates its own next-track signal.
  • libbanshee/banshee-player-private.h

    diff --git a/libbanshee/banshee-player-private.h b/libbanshee/banshee-player-private.h
    index 1b69d6f..3006201 100644
    a b  
    6464        (GST_VERSION_MAJOR == (major) && GST_VERSION_MINOR == (minor) && \
    6565            GST_VERSION_MICRO >= (micro)))
    6666
     67#if BANSHEE_CHECK_GST_VERSION(0,10,25)
     68#include <gst/interfaces/streamvolume.h>
     69#endif
    6770
    6871#ifdef WIN32
    6972// TODO Windows doesn't like the ... varargs
    struct BansheePlayer { 
    132135    gboolean buffering;
    133136    gchar *cdda_device;
    134137    gboolean in_gapless_transition;
     138    gboolean supports_stream_volume;
    135139   
    136140    // Video State
    137141    BpVideoDisplayContextType video_display_context_type;
  • libbanshee/banshee-player.c

    diff --git a/libbanshee/banshee-player.c b/libbanshee/banshee-player.c
    index cc22981..218aa76 100644
    a b  
    3131#include "banshee-player-cdda.h"
    3232#include "banshee-player-missing-elements.h"
    3333#include "banshee-player-replaygain.h"
    34 #if BANSHEE_CHECK_GST_VERSION(0,10,25)
    35 #include <gst/interfaces/streamvolume.h>
    36 #endif
    3734
    3835// ---------------------------------------------------------------------------
    3936// Private Functions
    bp_supports_gapless (BansheePlayer *player) 
    296293#endif //ENABLE_GAPLESS
    297294}
    298295
     296P_INVOKE gboolean
     297bp_supports_stream_volume (BansheePlayer *player)
     298{
     299    g_return_val_if_fail (IS_BANSHEE_PLAYER (player), FALSE);
     300    return player->supports_stream_volume;
     301}
     302
    299303P_INVOKE void
    300304bp_set_volume (BansheePlayer *player, gdouble volume)
    301305{
    302306    g_return_if_fail (IS_BANSHEE_PLAYER (player));
    303307    g_return_if_fail (GST_IS_ELEMENT (player->playbin));
    304308
    305 #if BANSHEE_CHECK_GST_VERSION(0,10,25)
    306     if (gst_element_implements_interface (player->playbin, GST_TYPE_STREAM_VOLUME))
    307       gst_stream_volume_set_volume (GST_STREAM_VOLUME (player->playbin), GST_STREAM_VOLUME_FORMAT_CUBIC, volume);
    308     else
    309       g_object_set (player->playbin, "volume", CLAMP (volume, 0.0, 1.0), NULL);
    310 #else
    311     g_object_set (player->playbin, "volume", CLAMP (volume, 0.0, 1.0), NULL);
    312 #endif
     309    if (bp_supports_stream_volume (player)) {
     310        #if BANSHEE_CHECK_GST_VERSION(0,10,25)
     311        gst_stream_volume_set_volume (GST_STREAM_VOLUME (player->playbin),
     312            GST_STREAM_VOLUME_FORMAT_CUBIC, volume);
     313        #endif
     314    } else {
     315        g_object_set (player->playbin, "volume", CLAMP (volume, 0.0, 1.0), NULL);
     316    }
     317
    313318    _bp_rgvolume_print_volume (player);
    314319}
    315320
    316321P_INVOKE gdouble
    317322bp_get_volume (BansheePlayer *player)
    318323{
     324    gdouble volume;
     325
    319326    g_return_val_if_fail (IS_BANSHEE_PLAYER (player), 0.0);
    320327    g_return_val_if_fail (GST_IS_ELEMENT (player->playbin), 0.0);
    321     gdouble volume;
    322 #if BANSHEE_CHECK_GST_VERSION(0,10,25)
    323     if (gst_element_implements_interface (player->playbin, GST_TYPE_STREAM_VOLUME))
    324       volume = gst_stream_volume_get_volume (GST_STREAM_VOLUME (player->playbin), GST_STREAM_VOLUME_FORMAT_CUBIC);
    325     else
    326       g_object_get (player->playbin, "volume", &volume, NULL);
    327 #else
    328     g_object_get (player->playbin, "volume", &volume, NULL);
    329 #endif
     328
     329    if (bp_supports_stream_volume (player)) {
     330        #if BANSHEE_CHECK_GST_VERSION(0,10,25)
     331        volume = gst_stream_volume_get_volume (GST_STREAM_VOLUME (player->playbin),
     332            GST_STREAM_VOLUME_FORMAT_CUBIC);
     333        #endif
     334    } else {
     335        g_object_get (player->playbin, "volume", &volume, NULL);
     336    }
     337
    330338    return volume;
    331339}
    332340
  • src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs

    diff --git a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
    index f17812d..7929f2a 100644
    a b namespace Banshee.GStreamer 
    7878        private uint GST_STREAM_ERROR = 0;
    7979
    8080        private HandleRef handle;
     81        private bool is_initialized;
    8182
    8283        private BansheePlayerEosCallback eos_callback;
    8384        private BansheePlayerErrorCallback error_callback;
    namespace Banshee.GStreamer 
    182183
    183184            OnStateChanged (PlayerState.Ready);
    184185
    185             Volume = (ushort)PlayerEngineService.VolumeSchema.Get ();
    186 
    187186            InstallPreferences ();
    188187            ReplayGainEnabled = ReplayGainEnabledSchema.Get ();
    189188            GaplessEnabled = GaplessEnabledSchema.Get ();
     189
     190            is_initialized = true;
     191
     192            if (!bp_supports_stream_volume (handle)) {
     193                Volume = (ushort)PlayerEngineService.VolumeSchema.Get ();
     194            }
    190195        }
    191196
    192197        public override void Dispose ()
    namespace Banshee.GStreamer 
    195200            base.Dispose ();
    196201            bp_destroy (handle);
    197202            handle = new HandleRef (this, IntPtr.Zero);
     203            is_initialized = false;
    198204        }
    199205
    200206        public override void Close (bool fullShutdown)
    namespace Banshee.GStreamer 
    517523        }
    518524
    519525        public override ushort Volume {
    520             get { return (ushort)Math.Round (bp_get_volume (handle) * 100.0); }
     526            get {
     527                return is_initialized
     528                    ? (ushort)Math.Round (bp_get_volume (handle) * 100.0)
     529                    : (ushort)0;
     530            }
    521531            set {
     532                if (!is_initialized) {
     533                    return;
     534                }
     535
    522536                bp_set_volume (handle, value / 100.0);
     537                if (!bp_supports_stream_volume (handle)) {
     538                    PlayerEngineService.VolumeSchema.Set ((int)value);
     539                }
     540
    523541                OnEventChanged (PlayerEvent.Volume);
    524542            }
    525543        }
    namespace Banshee.GStreamer 
    837855        private static extern bool bp_can_seek (HandleRef player);
    838856
    839857        [DllImport ("libbanshee.dll")]
     858        private static extern bool bp_supports_stream_volume (HandleRef player);
     859
     860        [DllImport ("libbanshee.dll")]
    840861        private static extern bool bp_set_position (HandleRef player, ulong time_ms);
    841862
    842863        [DllImport ("libbanshee.dll")]
  • src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedVolumeButton.cs

    diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedVolumeButton.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ConnectedVolumeButton.cs
    index f654244..0671ee3 100644
    a b namespace Banshee.Gui.Widgets 
    4040        public ConnectedVolumeButton () : base()
    4141        {
    4242            emit_lock = true;
    43             Volume = PlayerEngineService.VolumeSchema.Get ();
     43            Volume = ServiceManager.PlayerEngine.Volume;
    4444            emit_lock = false;
    4545            ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent, PlayerEvent.Volume);
    4646        }
    namespace Banshee.Gui.Widgets 
    5959
    6060        protected override void OnVolumeChanged ()
    6161        {
    62             PlayerEngineService.VolumeSchema.Set (Volume);
    63 
    6462            if (emit_lock) {
    6563                return;
    6664            }
Note: See TracBrowser for help on using the repository browser.