From d0c4fa8edbe45b99ee91d26f8fc5a16f08fa4c28 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Fri, 18 Apr 2014 13:41:32 -0400 Subject: And make it so we update from an AS notification immediately if we haven't been messing with local volume recently --- src/volume-control.vala | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/volume-control.vala') diff --git a/src/volume-control.vala b/src/volume-control.vala index ebca606..2a10917 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -532,8 +532,15 @@ public class VolumeControl : Object private void start_account_service_volume_timer() { - stop_account_service_volume_timer(); - _accountservice_volume_timer = Timeout.add_seconds (1, accountservice_volume_changed_timeout); + if (_accountservice_volume_timer == 0) { + // If we haven't been messing with local volume recently, apply immediately. + if (_local_volume_timer == 0 && !set_volume_internal (_account_service_volume)) { + return; + } + // Else check again in another second if needed. + // (if AS is throwing us lots of notifications, we update at most once a second) + _accountservice_volume_timer = Timeout.add_seconds (1, accountservice_volume_changed_timeout); + } } private void stop_account_service_volume_timer() @@ -547,7 +554,7 @@ public class VolumeControl : Object bool accountservice_volume_changed_timeout () { _accountservice_volume_timer = 0; - set_volume_internal (_account_service_volume); + start_account_service_volume_timer (); return false; // G_SOURCE_REMOVE } } -- cgit v1.2.3