From c5f2b60893cd8a34a285d5e57484b498890b93e1 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 21 Jan 2015 19:57:59 -0600 Subject: require an explicit role for the sound so that we can differentiate between eg 'alarm' and 'alert' --- include/notifications/sound.h | 2 +- src/sound.cpp | 14 +++++++++----- 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)) { } -- cgit v1.2.3