mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-13 20:18:50 +03:00
notification sounds with miniaudio
This commit is contained in:
@@ -2,9 +2,19 @@
|
||||
#include <glibmm/ustring.h>
|
||||
#include <gdkmm/pixbuf.h>
|
||||
|
||||
#ifdef WITH_MINIAUDIO
|
||||
#include <miniaudio.h>
|
||||
#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
|
||||
};
|
||||
|
||||
@@ -1,11 +1,30 @@
|
||||
#include "notifier.hpp"
|
||||
#include <giomm/notification.h>
|
||||
|
||||
Notifier::Notifier() {}
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include <miniaudio.h>
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user