diff options
author | Michael Terry <michael.terry@canonical.com> | 2014-04-18 13:41:32 -0400 |
---|---|---|
committer | Michael Terry <michael.terry@canonical.com> | 2014-04-18 13:41:32 -0400 |
commit | d0c4fa8edbe45b99ee91d26f8fc5a16f08fa4c28 (patch) | |
tree | a1b2846ae4fa79d88c6eb2b3dcfe560204974380 /src | |
parent | d0852028e0b47a1e2116d789b57475d27adb2591 (diff) | |
download | ayatana-indicator-sound-d0c4fa8edbe45b99ee91d26f8fc5a16f08fa4c28.tar.gz ayatana-indicator-sound-d0c4fa8edbe45b99ee91d26f8fc5a16f08fa4c28.tar.bz2 ayatana-indicator-sound-d0c4fa8edbe45b99ee91d26f8fc5a16f08fa4c28.zip |
And make it so we update from an AS notification immediately if we haven't been messing with local volume recently
Diffstat (limited to 'src')
-rw-r--r-- | src/volume-control.vala | 13 |
1 files changed, 10 insertions, 3 deletions
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 } } |