summaryrefslogtreecommitdiff
path: root/libbanshee
diff options
context:
space:
mode:
authorAaron Bockover <abockover@novell.com>2010-05-14 15:11:59 -0400
committerAaron Bockover <abockover@novell.com>2010-05-14 15:55:03 -0400
commit9fbf2085d8a867906e8e7615aed01096f2be6b51 (patch)
tree6c285dd533959ccc72baa184ea47ea10415d4303 /libbanshee
parent53b84899d797378031cb8b50fc843adc3ec1ed40 (diff)
[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.
Diffstat (limited to 'libbanshee')
-rw-r--r--libbanshee/banshee-player-pipeline.c9
-rw-r--r--libbanshee/banshee-player-private.h4
-rw-r--r--libbanshee/banshee-player.c48
3 files changed, 41 insertions, 20 deletions
diff --git a/libbanshee/banshee-player-pipeline.c b/libbanshee/banshee-player-pipeline.c
index 1d877c45d..c95208f90 100644
--- a/libbanshee/banshee-player-pipeline.c
+++ b/libbanshee/banshee-player-pipeline.c
@@ -292,6 +292,15 @@ _bp_pipeline_construct (BansheePlayer *player)
// source and decoder elements) based on source URI and stream content
player->playbin = gst_element_factory_make ("playbin2", "playbin");
+ player->supports_stream_volume = FALSE;
+#if BANSHEE_CHECK_GST_VERSION(0,10,25)
+ player->supports_stream_volume = gst_element_implements_interface (
+ player->playbin, GST_TYPE_STREAM_VOLUME);
+#endif
+
+ bp_debug ("Stream volume supported: %s",
+ player->supports_stream_volume ? "YES" : "NO");
+
#ifdef ENABLE_GAPLESS
// Connect a proxy about-to-finish callback that will generate a next-track-starting callback.
// This can be removed once playbin2 generates its own next-track signal.
diff --git a/libbanshee/banshee-player-private.h b/libbanshee/banshee-player-private.h
index 66ee2a778..cca6b6387 100644
--- a/libbanshee/banshee-player-private.h
+++ b/libbanshee/banshee-player-private.h
@@ -69,6 +69,9 @@
(GST_VERSION_MAJOR == (major) && GST_VERSION_MINOR == (minor) && \
GST_VERSION_MICRO >= (micro)))
+#if BANSHEE_CHECK_GST_VERSION(0,10,25)
+#include <gst/interfaces/streamvolume.h>
+#endif
#ifdef WIN32
#define bp_debug(x) banshee_log_debug ("player", x)
@@ -145,6 +148,7 @@ struct BansheePlayer {
gboolean buffering;
gchar *cdda_device;
gboolean in_gapless_transition;
+ gboolean supports_stream_volume;
// Video State
BpVideoDisplayContextType video_display_context_type;
diff --git a/libbanshee/banshee-player.c b/libbanshee/banshee-player.c
index 4b3ade58a..406bf9473 100644
--- a/libbanshee/banshee-player.c
+++ b/libbanshee/banshee-player.c
@@ -33,9 +33,6 @@
#include "banshee-player-cdda.h"
#include "banshee-player-missing-elements.h"
#include "banshee-player-replaygain.h"
-#if BANSHEE_CHECK_GST_VERSION(0,10,25)
-#include <gst/interfaces/streamvolume.h>
-#endif
// ---------------------------------------------------------------------------
// Private Functions
@@ -256,37 +253,48 @@ bp_supports_gapless (BansheePlayer *player)
#endif //ENABLE_GAPLESS
}
+P_INVOKE gboolean
+bp_supports_stream_volume (BansheePlayer *player)
+{
+ g_return_val_if_fail (IS_BANSHEE_PLAYER (player), FALSE);
+ return player->supports_stream_volume;
+}
+
P_INVOKE void
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 BANSHEE_CHECK_GST_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
+ if (bp_supports_stream_volume (player)) {
+ #if BANSHEE_CHECK_GST_VERSION(0,10,25)
+ gst_stream_volume_set_volume (GST_STREAM_VOLUME (player->playbin),
+ GST_STREAM_VOLUME_FORMAT_CUBIC, volume);
+ #endif
+ } else {
+ g_object_set (player->playbin, "volume", CLAMP (volume, 0.0, 1.0), NULL);
+ }
+
_bp_rgvolume_print_volume (player);
}
P_INVOKE gdouble
bp_get_volume (BansheePlayer *player)
{
- gdouble volume;
+ gdouble volume;
+
g_return_val_if_fail (IS_BANSHEE_PLAYER (player), 0.0);
g_return_val_if_fail (GST_IS_ELEMENT (player->playbin), 0.0);
-#if BANSHEE_CHECK_GST_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
+
+ if (bp_supports_stream_volume (player)) {
+ #if BANSHEE_CHECK_GST_VERSION(0,10,25)
+ volume = gst_stream_volume_get_volume (GST_STREAM_VOLUME (player->playbin),
+ GST_STREAM_VOLUME_FORMAT_CUBIC);
+ #endif
+ } else {
+ g_object_get (player->playbin, "volume", &volume, NULL);
+ }
+
return volume;
}