summaryrefslogtreecommitdiff
path: root/libbanshee
diff options
context:
space:
mode:
authorChristopher James Halse Rogers <chrishr@src.gnome.org>2010-03-14 14:00:52 +1100
committerChristopher James Halse Rogers <chrishr@src.gnome.org>2010-03-14 14:00:52 +1100
commit2e33a4d5747ebc62c0f23012b074b6e5ac9188ee (patch)
treef970cb5f4ba64d68bd155d505a3ab03a22f1808d /libbanshee
parent27a024b1314cf516297f2a1c30372f0f0803fb28 (diff)
Handle volume changes from outside Banshee.
When using PulseAudio, users can modify the stream volume behind Banshee's back with the volume control applet. Hook up playbin2's notify::volume signal to keep Banshee's volume widget and gconf setting in sync
Diffstat (limited to 'libbanshee')
-rw-r--r--libbanshee/banshee-player-pipeline.c15
-rw-r--r--libbanshee/banshee-player-private.h2
-rw-r--r--libbanshee/banshee-player.c11
3 files changed, 27 insertions, 1 deletions
diff --git a/libbanshee/banshee-player-pipeline.c b/libbanshee/banshee-player-pipeline.c
index 376300a46..90b968d4a 100644
--- a/libbanshee/banshee-player-pipeline.c
+++ b/libbanshee/banshee-player-pipeline.c
@@ -234,6 +234,19 @@ static void bp_about_to_finish_callback (GstElement *playbin, BansheePlayer *pla
}
#endif //ENABLE_GAPLESS
+static void bp_volume_changed_callback (GstElement *playbin, GParamSpec *spec, BansheePlayer *player)
+{
+ g_return_if_fail (IS_BANSHEE_PLAYER (player));
+ g_return_if_fail (GST_IS_ELEMENT (playbin));
+
+ gdouble volume;
+ g_object_get (G_OBJECT (playbin), "volume", &volume, NULL);
+
+ if (player->volume_changed_cb != NULL) {
+ player->volume_changed_cb (player, volume);
+ }
+}
+
// ---------------------------------------------------------------------------
// Internal Functions
// ---------------------------------------------------------------------------
@@ -262,6 +275,8 @@ _bp_pipeline_construct (BansheePlayer *player)
g_return_val_if_fail (player->playbin != NULL, FALSE);
+ g_signal_connect (player->playbin, "notify::volume", G_CALLBACK (bp_volume_changed_callback), player);
+
// Try to find an audio sink, prefer gconf, which typically is set to auto these days,
// fall back on auto, which should work on windows, and as a last ditch, try alsa
audiosink = gst_element_factory_make ("gconfaudiosink", "audiosink");
diff --git a/libbanshee/banshee-player-private.h b/libbanshee/banshee-player-private.h
index 1edd37566..f3f01b7f2 100644
--- a/libbanshee/banshee-player-private.h
+++ b/libbanshee/banshee-player-private.h
@@ -79,6 +79,7 @@ typedef void (* BansheePlayerVisDataCallback) (BansheePlayer *player, gint
typedef void (* BansheePlayerNextTrackStartingCallback) (BansheePlayer *player);
typedef void (* BansheePlayerAboutToFinishCallback) (BansheePlayer *player);
typedef GstElement * (* BansheePlayerVideoPipelineSetupCallback) (BansheePlayer *player, GstBus *bus);
+typedef void (* BansheePlayerVolumeChangedCallback) (BansheePlayer *player, gdouble new_volume);
typedef enum {
BP_VIDEO_DISPLAY_CONTEXT_UNSUPPORTED = 0,
@@ -98,6 +99,7 @@ struct BansheePlayer {
BansheePlayerNextTrackStartingCallback next_track_starting_cb;
BansheePlayerAboutToFinishCallback about_to_finish_cb;
BansheePlayerVideoPipelineSetupCallback video_pipeline_setup_cb;
+ BansheePlayerVolumeChangedCallback volume_changed_cb;
// Pipeline Elements
GstElement *playbin;
diff --git a/libbanshee/banshee-player.c b/libbanshee/banshee-player.c
index 2c0cfb094..cd74ed303 100644
--- a/libbanshee/banshee-player.c
+++ b/libbanshee/banshee-player.c
@@ -308,7 +308,16 @@ P_INVOKE gdouble
bp_get_volume (BansheePlayer *player)
{
g_return_val_if_fail (IS_BANSHEE_PLAYER (player), 0.0);
- return player->current_volume;
+ g_return_val_if_fail (GST_IS_ELEMENT (player->playbin), 0.0);
+ gdouble volume;
+ g_object_get (player->playbin, "volume", &volume, NULL);
+ return volume;
+}
+
+P_INVOKE void
+bp_set_volume_changed_callback (BansheePlayer *player, BansheePlayerVolumeChangedCallback cb)
+{
+ SET_CALLBACK (volume_changed_cb);
}
P_INVOKE gboolean