From fbbfdc9606b9105a5559147c70a0bb0a8a7b1039 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 6 Mar 2023 20:45:10 -0500 Subject: notification sounds with miniaudio --- src/notifications/notifier.hpp | 10 ++++++++++ src/notifications/notifier_gio.cpp | 21 ++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/notifications/notifier.hpp b/src/notifications/notifier.hpp index 48e881f..9007dc8 100644 --- a/src/notifications/notifier.hpp +++ b/src/notifications/notifier.hpp @@ -2,9 +2,19 @@ #include #include +#ifdef WITH_MINIAUDIO +#include +#endif + class Notifier { public: Notifier(); + ~Notifier(); void Notify(const Glib::ustring &title, const Glib::ustring &text, const Glib::ustring &default_action); + +private: +#ifdef WITH_MINIAUDIO + ma_engine m_engine; +#endif }; diff --git a/src/notifications/notifier_gio.cpp b/src/notifications/notifier_gio.cpp index 6106114..f28735c 100644 --- a/src/notifications/notifier_gio.cpp +++ b/src/notifications/notifier_gio.cpp @@ -1,11 +1,30 @@ #include "notifier.hpp" #include -Notifier::Notifier() {} +#define MINIAUDIO_IMPLEMENTATION +#include + +Notifier::Notifier() { +#ifdef WITH_MINIAUDIO + if (ma_engine_init(nullptr, &m_engine) != MA_SUCCESS) { + printf("failed to initialize miniaudio engine\n"); + } +#endif +} + +Notifier::~Notifier() { +#ifdef WITH_MINIAUDIO + ma_engine_uninit(&m_engine); +#endif +} void Notifier::Notify(const Glib::ustring &title, const Glib::ustring &text, const Glib::ustring &default_action) { auto n = Gio::Notification::create(title); n->set_body(text); n->set_default_action(default_action); Abaddon::Get().GetApp()->send_notification(n); + +#ifdef WITH_MINIAUDIO + ma_engine_play_sound(&m_engine, Abaddon::Get().GetResPath("/sound/message.mp3").c_str(), nullptr); +#endif } -- cgit v1.2.3