diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2013-10-24 03:46:33 +0000 |
---|---|---|
committer | Tarmac <Unknown> | 2013-10-24 03:46:33 +0000 |
commit | d12eb5690956a3e5fb35e56a151822bd8a819358 (patch) | |
tree | 85b398e58e0f1960a3daf501ec9066fe78c6a42a | |
parent | c31f5da3fcb7e9b0cf3c3356cdf5f4eed7a226ac (diff) | |
parent | 91a91a9bda0df197f04d0d59ee2fbf0da225dd42 (diff) | |
download | ayatana-indicator-sound-d12eb5690956a3e5fb35e56a151822bd8a819358.tar.gz ayatana-indicator-sound-d12eb5690956a3e5fb35e56a151822bd8a819358.tar.bz2 ayatana-indicator-sound-d12eb5690956a3e5fb35e56a151822bd8a819358.zip |
When we can't connect to pulse, wait a moment before retrying. Fixes: https://bugs.launchpad.net/bugs/1244010.
Approved by Lars Uebernickel, PS Jenkins bot.
-rw-r--r-- | src/volume-control.vala | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/volume-control.vala b/src/volume-control.vala index 18c407f..4ca9537 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -27,6 +27,8 @@ public class VolumeControl : Object /* this is static to ensure it being freed after @context (loop does not have ref counting) */ private static PulseAudio.GLibMainLoop loop; + private uint _reconnect_timer = 0; + private PulseAudio.Context context; private bool _mute = true; private double _volume = 0.0; @@ -49,6 +51,13 @@ public class VolumeControl : Object this.reconnect_to_pulse (); } + ~VolumeControl () + { + if (_reconnect_timer != 0) { + Source.remove (_reconnect_timer); + } + } + /* PulseAudio logic*/ private void context_events_cb (Context c, Context.SubscriptionEventType t, uint32 index) { @@ -152,7 +161,8 @@ public class VolumeControl : Object case Context.State.FAILED: case Context.State.TERMINATED: - this.reconnect_to_pulse (); + if (_reconnect_timer == 0) + _reconnect_timer = Timeout.add_seconds (2, reconnect_timeout); break; default: @@ -161,6 +171,13 @@ public class VolumeControl : Object } } + bool reconnect_timeout () + { + _reconnect_timer = 0; + reconnect_to_pulse (); + return false; // G_SOURCE_REMOVE + } + void reconnect_to_pulse () { if (this.ready) { |