From e3cec790e72af21793fada09b1554f76c195121d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 30 Jan 2015 08:57:03 -0600 Subject: Track output mode --- src/service.vala | 8 ++++++++ src/volume-control.vala | 8 ++++++++ 2 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index fb56215..ba77ae8 100644 --- a/src/service.vala +++ b/src/service.vala @@ -270,6 +270,7 @@ public class IndicatorSound.Service: Object { private bool check_sync_notification = false; private bool support_sync_notification = false; + private string last_output_notification = "multimedia"; void update_sync_notification () { if (!check_sync_notification) { @@ -283,6 +284,13 @@ public class IndicatorSound.Service: Object { if (!support_sync_notification) return; + /* Suppress notifications of volume changes if it is because the + output stream changed. */ + var oldoutput = this.last_output_notification; + this.last_output_notification = this.volume_control.stream; + if (oldoutput != this.last_output_notification) + return; + var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction; if (shown_action != null && shown_action.get_state().get_boolean()) return; diff --git a/src/volume-control.vala b/src/volume-control.vala index bf97021..62cb2d0 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -54,6 +54,14 @@ public class VolumeControl : Object private bool _pulse_use_stream_restore = false; private uint32 _active_sink_input = -1; private string[] _valid_roles = {"multimedia", "alert", "alarm", "phone"}; + public string stream { + get { + if (_active_sink_input < 0 || _active_sink_input >= _valid_roles.length) + return "multimedia"; + else + return _valid_roles[_active_sink_input]; + } + } private string? _objp_role_multimedia = null; private string? _objp_role_alert = null; private string? _objp_role_alarm = null; -- cgit v1.2.3 From 6feea025512a572179b041bd5c02d44b1f57adce Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 2 Feb 2015 17:03:16 -0600 Subject: Watch for double updates from notifications. Supress them --- src/service.vala | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index ba77ae8..da6b824 100644 --- a/src/service.vala +++ b/src/service.vala @@ -271,6 +271,7 @@ public class IndicatorSound.Service: Object { private bool check_sync_notification = false; private bool support_sync_notification = false; private string last_output_notification = "multimedia"; + private string last_volume_notification = 0; void update_sync_notification () { if (!check_sync_notification) { @@ -291,6 +292,12 @@ public class IndicatorSound.Service: Object { if (oldoutput != this.last_output_notification) return; + /* Supress updates that don't change the value */ + var oldvolume = this.last_volume_notification; + this.last_volume_notification = volume_control.volume; + if (oldvolume == this.last_volume_notification) + return; + var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction; if (shown_action != null && shown_action.get_state().get_boolean()) return; -- cgit v1.2.3 From 47e8a6dbd878ed69aebc7a268b9d74e9dde014f6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Feb 2015 08:24:44 -0600 Subject: Incorrect type --- src/service.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index da6b824..22cb1c6 100644 --- a/src/service.vala +++ b/src/service.vala @@ -271,7 +271,7 @@ public class IndicatorSound.Service: Object { private bool check_sync_notification = false; private bool support_sync_notification = false; private string last_output_notification = "multimedia"; - private string last_volume_notification = 0; + private double last_volume_notification = 0; void update_sync_notification () { if (!check_sync_notification) { -- cgit v1.2.3 From 85b5b397ae74fd08d66e89ee3ee132520ccb1d0d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Feb 2015 08:50:31 -0600 Subject: Making sure to record the output and volume for each invocation --- src/service.vala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index 22cb1c6..c942fc7 100644 --- a/src/service.vala +++ b/src/service.vala @@ -285,16 +285,18 @@ public class IndicatorSound.Service: Object { if (!support_sync_notification) return; - /* Suppress notifications of volume changes if it is because the - output stream changed. */ + /* Update our volume and output */ var oldoutput = this.last_output_notification; this.last_output_notification = this.volume_control.stream; - if (oldoutput != this.last_output_notification) - return; - /* Supress updates that don't change the value */ var oldvolume = this.last_volume_notification; this.last_volume_notification = volume_control.volume; + + /* Suppress notifications of volume changes if it is because the + output stream changed. */ + if (oldoutput != this.last_output_notification) + return; + /* Supress updates that don't change the value */ if (oldvolume == this.last_volume_notification) return; -- cgit v1.2.3 From c6002f571882de3b7bf3d3a6a2045272d818b4db Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Feb 2015 08:52:58 -0600 Subject: Compare doubles with an accuracy range --- src/service.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/service.vala b/src/service.vala index c942fc7..b07f267 100644 --- a/src/service.vala +++ b/src/service.vala @@ -297,7 +297,7 @@ public class IndicatorSound.Service: Object { if (oldoutput != this.last_output_notification) return; /* Supress updates that don't change the value */ - if (oldvolume == this.last_volume_notification) + if (GLib.Math.fabs(oldvolume - this.last_volume_notification) < 0.01) return; var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction; -- cgit v1.2.3