[rhythmbox] Emit volume-changed from player backends when sink volume is changed
- From: Jonathan Matthew <jmatthew src gnome org>
- To: svn-commits-list gnome org
- Subject: [rhythmbox] Emit volume-changed from player backends when sink volume is changed
- Date: Tue, 21 Apr 2009 22:10:56 -0400 (EDT)
commit 9a826df0c8658561974f291ec3cc656e6aa81197
Author: Jonathan Matthew <jonathan d14n org>
Date: Wed Apr 22 11:34:47 2009 +1000
Emit volume-changed from player backends when sink volume is changed
notify::volume is emitted on a streaming thread, so we need to use
an idle handler to marshal it to the main thread.
---
backends/gstreamer/rb-player-gst-xfade.c | 22 ++++++++++++++++++++++
backends/gstreamer/rb-player-gst.c | 22 ++++++++++++++++++++++
2 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/backends/gstreamer/rb-player-gst-xfade.c b/backends/gstreamer/rb-player-gst-xfade.c
index 185d626..e0e8806 100644
--- a/backends/gstreamer/rb-player-gst-xfade.c
+++ b/backends/gstreamer/rb-player-gst-xfade.c
@@ -2564,6 +2564,24 @@ tick_timeout (RBPlayerGstXFade *player)
return TRUE;
}
+static gboolean
+emit_volume_changed_idle (RBPlayerGstXFade *player)
+{
+ _rb_player_emit_volume_changed (RB_PLAYER (player), player->priv->cur_volume);
+ return FALSE;
+}
+
+static void
+stream_volume_changed (GObject *element, GParamSpec *pspec, RBPlayerGstXFade *player)
+{
+ double v;
+
+ g_object_get (element, "volume", &v, NULL);
+ player->priv->cur_volume = v;
+
+ g_idle_add ((GSourceFunc) emit_volume_changed_idle, player);
+}
+
/*
* output sink + adder pipeline:
*
@@ -2728,6 +2746,10 @@ start_sink_locked (RBPlayerGstXFade *player, GList **messages, GError **error)
}
g_object_set (player->priv->volume_handler, "volume", player->priv->cur_volume, NULL);
+ g_signal_connect_object (player->priv->volume_handler,
+ "notify::volume",
+ G_CALLBACK (stream_volume_changed),
+ player, 0);
sr = gst_element_set_state (player->priv->silencebin, GST_STATE_PLAYING);
diff --git a/backends/gstreamer/rb-player-gst.c b/backends/gstreamer/rb-player-gst.c
index b19ce1e..29823d9 100644
--- a/backends/gstreamer/rb-player-gst.c
+++ b/backends/gstreamer/rb-player-gst.c
@@ -1009,6 +1009,23 @@ rb_player_gst_playing (RBPlayer *player)
return mp->priv->playing;
}
+static gboolean
+emit_volume_changed_idle (RBPlayerGst *mp)
+{
+ _rb_player_emit_volume_changed (RB_PLAYER (mp), mp->priv->cur_volume);
+ return FALSE;
+}
+
+static void
+stream_volume_changed (GObject *element, GParamSpec *pspec, RBPlayerGst *mp)
+{
+ gdouble v;
+ g_object_get (element, "volume", &v, NULL);
+ mp->priv->cur_volume = v;
+
+ g_idle_add ((GSourceFunc) emit_volume_changed_idle, mp);
+}
+
static void
find_volume_handler (RBPlayerGst *mp)
{
@@ -1025,6 +1042,11 @@ find_volume_handler (RBPlayerGst *mp)
if (mp->priv->volume_handler == NULL) {
mp->priv->volume_handler = g_object_ref (mp->priv->playbin);
}
+
+ g_signal_connect_object (mp->priv->volume_handler,
+ "notify::volume",
+ G_CALLBACK (stream_volume_changed),
+ mp, 0);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]