aboutsummaryrefslogtreecommitdiff
path: root/src/snap.cpp
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-02-05 08:36:31 -0600
committerCharles Kerr <charles.kerr@canonical.com>2014-02-05 08:36:31 -0600
commitb96ba1beb969e7116881137d326967b48044845b (patch)
tree184a5647b0b6a3366486d9d94fe3af3f33a21dc6 /src/snap.cpp
parent98eb9efebeadf69fc73613c6764a97f6f8163ec4 (diff)
downloadayatana-indicator-datetime-b96ba1beb969e7116881137d326967b48044845b.tar.gz
ayatana-indicator-datetime-b96ba1beb969e7116881137d326967b48044845b.tar.bz2
ayatana-indicator-datetime-b96ba1beb969e7116881137d326967b48044845b.zip
bugfix: when closing the snap decision, ensure there's not a timeout waiting to loop the ringtone
Diffstat (limited to 'src/snap.cpp')
-rw-r--r--src/snap.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/snap.cpp b/src/snap.cpp
index a64f358..0d548b8 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -48,6 +48,7 @@ namespace
const int32_t alarm_ca_id = 1;
ca_context *c_context = nullptr;
+guint timeout_tag = 0;
ca_context* get_ca_context()
{
@@ -80,6 +81,7 @@ void play_alarm_sound();
gboolean play_alarm_sound_idle (gpointer)
{
+ timeout_tag = 0;
play_alarm_sound();
return G_SOURCE_REMOVE;
}
@@ -87,8 +89,8 @@ gboolean play_alarm_sound_idle (gpointer)
void on_alarm_play_done (ca_context* /*context*/, uint32_t /*id*/, int rv, void* /*user_data*/)
{
// wait one second, then play it again
- if (rv == CA_SUCCESS)
- g_timeout_add_seconds (1, play_alarm_sound_idle, nullptr);
+ if ((rv == CA_SUCCESS) && (timeout_tag == 0))
+ timeout_tag = g_timeout_add_seconds (1, play_alarm_sound_idle, nullptr);
}
void play_alarm_sound()
@@ -118,6 +120,12 @@ void stop_alarm_sound()
if (rv != CA_SUCCESS)
g_warning("Failed to cancel alarm sound: %s", ca_strerror(rv));
}
+
+ if (timeout_tag != 0)
+ {
+ g_source_remove(timeout_tag);
+ timeout_tag = 0;
+ }
}
/**