Re: [PATCH] librygel-renderer: Allow underlying player to notify on volume changes



On Sa, 2013-10-05 at 22:26 +0200, Richard Röjfors wrote:

Thanks! We usually prefer receiving patches using bugzilla, though :)

Currently there is no notification support on volume.
The last set value of the volume (via upnp) is cached in
rygel-rendering-control. But if the volume of the underlying renderer can
be changed in another way, for instance on a local UI. Such change is not
picked up by rygel-rendering-control and any control point would not be
aware of the volume change.

This patch adds notification support for volume.

Signed-off-by: Richard Röjfors <richard rojfors gmail com>
---
diff --git a/src/librygel-renderer/rygel-rendering-control.vala 
b/src/librygel-renderer/rygel-rendering-control.vala
index bbbca37..01e727b 100644
--- a/src/librygel-renderer/rygel-rendering-control.vala
+++ b/src/librygel-renderer/rygel-rendering-control.vala
@@ -92,6 +92,8 @@ internal class Rygel.RenderingControl : Service {
         action_invoked["GetVolume"].connect (this.get_volume_cb);
         action_invoked["SetVolume"].connect (this.set_volume_cb);
 
+        this.player.notify["volume"].connect (this.notify_volume_cb);
+
         this._mute = this.player.volume == 0;
         this._volume = Volume.to_percentage (this.player.volume);
     }
@@ -273,4 +275,20 @@ internal class Rygel.RenderingControl : Service {
 
         action.return ();
     }
+
+    private void notify_volume_cb (Object player, ParamSpec p) {
+        this._volume = Volume.to_percentage (this.player.volume);
+
+        if (this._mute && this.player.volume > 0) {
+            // We are not muted anymore...
+            this._mute = false;
+            this.changelog.log_with_channel ("Mute",
+                                             "0",
+                                             "Master");
+        }
+
+        this.changelog.log_with_channel ("Volume",
+                                         this.volume.to_string (),
+                                         "Master");
+    }
 }

_______________________________________________
rygel-list mailing list
rygel-list gnome org
https://mail.gnome.org/mailman/listinfo/rygel-list




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