aboutsummaryrefslogtreecommitdiff
path: root/src/volume-control.vala
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-10-23 21:55:56 -0500
committerCharles Kerr <charles.kerr@canonical.com>2013-10-23 21:55:56 -0500
commit91a91a9bda0df197f04d0d59ee2fbf0da225dd42 (patch)
tree21d421937a31da72953bcc996ad73fd9f14aefba /src/volume-control.vala
parent88f0c9e8995f921a36c28ad95f607574f20b7da0 (diff)
downloadayatana-indicator-sound-91a91a9bda0df197f04d0d59ee2fbf0da225dd42.tar.gz
ayatana-indicator-sound-91a91a9bda0df197f04d0d59ee2fbf0da225dd42.tar.bz2
ayatana-indicator-sound-91a91a9bda0df197f04d0d59ee2fbf0da225dd42.zip
when we fail to connect to pulse, wait a moment before retrying.
Diffstat (limited to 'src/volume-control.vala')
-rw-r--r--src/volume-control.vala19
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) {