aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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) {