diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-12-29 02:06:54 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-12-29 02:06:54 -0500 |
commit | d2ff7112aac4f65106b99a92fb5f3492e7e5a827 (patch) | |
tree | 76fbf7b9cdd60ad0dd20fe3ab0c9ee70e21e1de6 | |
parent | 15d94ba4ae53863df04e8200e04dcf65db0c0396 (diff) | |
download | abaddon-portaudio-d2ff7112aac4f65106b99a92fb5f3492e7e5a827.tar.gz abaddon-portaudio-d2ff7112aac4f65106b99a92fb5f3492e7e5a827.zip |
add notification sounds only to windows
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/notifications/notifier_fallback.cpp | 30 | ||||
-rw-r--r-- | src/notifications/notifier_null.cpp | 9 | ||||
-rw-r--r-- | src/settings.hpp | 3 |
4 files changed, 33 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6804671..05ee200 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,7 +83,7 @@ endif () if (NOT WIN32) target_sources(abaddon PRIVATE src/notifications/notifier_gio.cpp) else () - target_sources(abaddon PRIVATE src/notifications/notifier_null.cpp) + target_sources(abaddon PRIVATE src/notifications/notifier_fallback.cpp) endif () if (IXWebSocket_LIBRARIES) diff --git a/src/notifications/notifier_fallback.cpp b/src/notifications/notifier_fallback.cpp new file mode 100644 index 0000000..00e9d4a --- /dev/null +++ b/src/notifications/notifier_fallback.cpp @@ -0,0 +1,30 @@ +#include "notifier.hpp" + +/* no actual notifications, just sounds + GNotification has no win32 backend, and WinToast uses headers msys2 doesnt provide + maybe it can be LoadLibrary'd in :s +*/ + +Notifier::Notifier() { +#ifdef ENABLE_NOTIFICATION_SOUNDS + if (ma_engine_init(nullptr, &m_engine) != MA_SUCCESS) { + printf("failed to initialize miniaudio engine\n"); + } +#endif +} + +Notifier::~Notifier() { +#ifdef ENABLE_NOTIFICATION_SOUNDS + ma_engine_uninit(&m_engine); +#endif +} + +void Notifier::Notify(const Glib::ustring &id, const Glib::ustring &title, const Glib::ustring &text, const Glib::ustring &default_action, const std::string &icon_path) { +#ifdef ENABLE_NOTIFICATION_SOUNDS + if (Abaddon::Get().GetSettings().NotificationsPlaySound) { + ma_engine_play_sound(&m_engine, Abaddon::Get().GetResPath("/sound/message.mp3").c_str(), nullptr); + } +#endif +} + +void Notifier::Withdraw(const Glib::ustring &id) {} diff --git a/src/notifications/notifier_null.cpp b/src/notifications/notifier_null.cpp deleted file mode 100644 index 1da99fd..0000000 --- a/src/notifications/notifier_null.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "notifier.hpp" - -Notifier::Notifier() {} - -Notifier::~Notifier() {} - -void Notifier::Notify(const Glib::ustring &id, const Glib::ustring &title, const Glib::ustring &text, const Glib::ustring &default_action, const std::string &icon_path) {} - -void Notifier::Withdraw(const Glib::ustring &id) {} diff --git a/src/settings.hpp b/src/settings.hpp index 419734c..42f4838 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -47,10 +47,11 @@ public: // [notifications] #ifdef _WIN32 bool NotificationsEnabled { false }; + bool NotificationsPlaySound { false }; #else bool NotificationsEnabled { true }; -#endif bool NotificationsPlaySound { true }; +#endif // [voice] #ifdef WITH_RNNOISE |