aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-02-05 17:04:00 -0600
committerCharles Kerr <charles.kerr@canonical.com>2014-02-05 17:04:00 -0600
commitdfd4f783102a0ca98b994fb80153e8accd3721ad (patch)
treebf9af5817d7fe48e9cdf237e94099dedf2efa581 /src
parenta75d4006a59c6e58e14d21fa6820a86f52d113cd (diff)
downloadayatana-indicator-datetime-dfd4f783102a0ca98b994fb80153e8accd3721ad.tar.gz
ayatana-indicator-datetime-dfd4f783102a0ca98b994fb80153e8accd3721ad.tar.bz2
ayatana-indicator-datetime-dfd4f783102a0ca98b994fb80153e8accd3721ad.zip
when playing a sound in canberra, don't use CA_PROP_EVENT_ID if caching failed
Diffstat (limited to 'src')
-rw-r--r--src/snap.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/snap.cpp b/src/snap.cpp
index 0d548b8..f2d075a 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -47,6 +47,7 @@ namespace
// arbitrary number, but we need a consistent id for play/cancel
const int32_t alarm_ca_id = 1;
+gboolean media_cached = FALSE;
ca_context *c_context = nullptr;
guint timeout_tag = 0;
@@ -69,6 +70,7 @@ ca_context* get_ca_context()
CA_PROP_MEDIA_FILENAME, filename,
CA_PROP_CANBERRA_CACHE_CONTROL, "permanent",
NULL);
+ media_cached = rv == CA_SUCCESS;
if (rv != CA_SUCCESS)
g_warning("Couldn't add '%s' to canberra cache: %s", filename, ca_strerror(rv));
}
@@ -101,7 +103,8 @@ void play_alarm_sound()
ca_proplist* props = nullptr;
ca_proplist_create(&props);
- ca_proplist_sets(props, CA_PROP_EVENT_ID, "alarm");
+ if (media_cached)
+ ca_proplist_sets(props, CA_PROP_EVENT_ID, "alarm");
ca_proplist_sets(props, CA_PROP_MEDIA_FILENAME, filename);
const auto rv = ca_context_play_full(context, alarm_ca_id, props, on_alarm_play_done, nullptr);
@@ -230,6 +233,7 @@ Snap::Snap()
Snap::~Snap()
{
+ media_cached = false;
g_clear_pointer(&c_context, ca_context_destroy);
}