aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2015-01-21 19:57:59 -0600
committerCharles Kerr <charles.kerr@canonical.com>2015-01-21 19:57:59 -0600
commitc5f2b60893cd8a34a285d5e57484b498890b93e1 (patch)
treed25825ca18cf7ecf971a55fd421efdfdeaa8a881
parentba986b6071161b7f3179dfb524f6c8c5d3ea23d1 (diff)
downloadayatana-indicator-datetime-c5f2b60893cd8a34a285d5e57484b498890b93e1.tar.gz
ayatana-indicator-datetime-c5f2b60893cd8a34a285d5e57484b498890b93e1.tar.bz2
ayatana-indicator-datetime-c5f2b60893cd8a34a285d5e57484b498890b93e1.zip
require an explicit role for the sound so that we can differentiate between eg 'alarm' and 'alert'
-rw-r--r--include/notifications/sound.h2
-rw-r--r--src/sound.cpp14
2 files changed, 10 insertions, 6 deletions
diff --git a/include/notifications/sound.h b/include/notifications/sound.h
index f5f549c..d08c2e7 100644
--- a/include/notifications/sound.h
+++ b/include/notifications/sound.h
@@ -41,7 +41,7 @@ namespace notifications {
class Sound
{
public:
- Sound(const std::string& uri, unsigned int volume, bool loop);
+ Sound(const std::string& role, const std::string& uri, unsigned int volume, bool loop);
~Sound();
private:
diff --git a/src/sound.cpp b/src/sound.cpp
index be0c4f1..a768a29 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -38,9 +38,11 @@ class Sound::Impl
{
public:
- Impl(const std::string& uri,
+ Impl(const std::string& role,
+ const std::string& uri,
unsigned int volume,
bool loop):
+ m_role(role),
m_uri(uri),
m_volume(volume),
m_loop(loop)
@@ -122,10 +124,11 @@ private:
feature = GST_PLUGIN_FEATURE_CAST(GST_ELEMENT_GET_CLASS(audio_sink)->elementfactory);
if (feature && g_strcmp0(gst_plugin_feature_get_name(feature), "pulsesink") == 0)
{
- std::string role_str("props,media.role=alarm");
- GstStructure *props = gst_structure_from_string(role_str.c_str(), nullptr);
+ auto role_str = g_strdup_printf("props,media.role=%s", self->m_role.c_str());
+ GstStructure *props = gst_structure_from_string(role_str, nullptr);
g_object_set(audio_sink, "stream-properties", props, nullptr);
gst_structure_free(props);
+ g_free(role_str);
}
gst_object_unref(audio_sink);
}
@@ -138,6 +141,7 @@ private:
****
***/
+ const std::string m_role;
const std::string m_uri;
const unsigned int m_volume;
const bool m_loop;
@@ -145,8 +149,8 @@ private:
GstElement* m_play = nullptr;
};
-Sound::Sound(const std::string& uri, unsigned int volume, bool loop):
- impl (new Impl(uri, volume, loop))
+Sound::Sound(const std::string& role, const std::string& uri, unsigned int volume, bool loop):
+ impl (new Impl(role, uri, volume, loop))
{
}