aboutsummaryrefslogtreecommitdiff
path: root/src/volume-control.vala
diff options
context:
space:
mode:
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 e50e8e6..c6db38c 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)
{
@@ -154,7 +163,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:
@@ -163,6 +173,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) {