[rhythmbox] Add volume-changed signal to RBPlayer interface



commit 0cab7562d4e3f9927558e5f4c21b0e79ebafb97d
Author: Jonathan Matthew <jonathan d14n org>
Date:   Wed Apr 22 11:32:54 2009 +1000

    Add volume-changed signal to RBPlayer interface
    
    This is used to provide notification of changes to the stream volume,
    such as when the pulseaudio stream volume is changed externally.
---
 backends/rb-player.c |   33 +++++++++++++++++++++++++++++++++
 backends/rb-player.h |    3 +++
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/backends/rb-player.c b/backends/rb-player.c
index c7008ee..2d65f22 100644
--- a/backends/rb-player.c
+++ b/backends/rb-player.c
@@ -42,6 +42,7 @@ enum {
 	TICK,
 	EVENT,
 	PLAYING_STREAM,
+	VOLUME_CHANGED,
 	LAST_SIGNAL
 };
 
@@ -230,6 +231,24 @@ rb_player_interface_init (RBPlayerIface *iface)
 			      G_TYPE_NONE,
 			      1,
 			      G_TYPE_POINTER);
+	/**
+	 * RBPlayer::volume-changed:
+	 * @player: the #RBPlayer
+	 * @volume: the new volume level
+	 *
+	 * The 'volume-changed' signal is emitted when the output stream volume is
+	 * changed externally.
+	 */
+	signals[VOLUME_CHANGED] =
+		g_signal_new ("volume-changed",
+			      G_TYPE_FROM_INTERFACE (iface),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (RBPlayerIface, volume_changed),
+			      NULL, NULL,
+			      g_cclosure_marshal_VOID__FLOAT,
+			      G_TYPE_NONE,
+			      1,
+			      G_TYPE_FLOAT);
 }
 
 GType
@@ -625,6 +644,20 @@ _rb_player_emit_playing_stream (RBPlayer *player, gpointer stream_data)
 	g_signal_emit (player, signals[PLAYING_STREAM], 0, stream_data);
 }
 
+/**
+ * _rb_player_emit_volume_changed:
+ * @player: a #RBPlayer implementation
+ * @volume: the new volume level
+ *
+ * Emits the 'volume-changed' signal to indicate the output stream
+ * volume has been changed.  To be used by implementations only.
+ */
+void
+_rb_player_emit_volume_changed (RBPlayer *player, float volume)
+{
+	g_signal_emit (player, signals[VOLUME_CHANGED], 0, volume);
+}
+
 GQuark
 rb_player_error_quark (void)
 {
diff --git a/backends/rb-player.h b/backends/rb-player.h
index 67723f9..634ddab 100644
--- a/backends/rb-player.h
+++ b/backends/rb-player.h
@@ -119,6 +119,8 @@ struct _RBPlayerIface
 	void		(*event)		(RBPlayer *player,
 						 gpointer stream_data,
 						 gpointer data);
+	void		(*volume_changed)	(RBPlayer *player,
+						 float volume);
 };
 
 GType		rb_player_get_type   (void);
@@ -160,6 +162,7 @@ void	_rb_player_emit_error (RBPlayer *player, gpointer stream_data, GError *erro
 void	_rb_player_emit_tick (RBPlayer *player, gpointer stream_data, long elapsed, long duration);
 void	_rb_player_emit_event (RBPlayer *player, gpointer stream_data, const char *name, gpointer data);
 void	_rb_player_emit_playing_stream (RBPlayer *player, gpointer stream_data);
+void	_rb_player_emit_volume_changed (RBPlayer *player, float volume);
 
 G_END_DECLS
 



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