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 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.github/workflows/ci.yml') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 893248e..745a6e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: with: cond: ${{ matrix.mindeps == true }} if_true: | - cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} -DUSE_LIBHANDY=OFF + cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} -DUSE_LIBHANDY=OFF -DUSE_MINIAUDIO=OFF cmake --build build if_false: | cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} -- cgit v1.2.3 From 3f4ccefc78e31a306c48149253c592be3e663a26 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 10 Mar 2023 19:15:03 -0500 Subject: refactor notification sounds cmake option --- .github/workflows/ci.yml | 2 +- CMakeLists.txt | 10 ++++++++-- src/notifications/notifier.hpp | 4 ++-- src/notifications/notifier_gio.cpp | 6 +++--- 4 files changed, 14 insertions(+), 8 deletions(-) (limited to '.github/workflows/ci.yml') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 745a6e6..9b20f04 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: with: cond: ${{ matrix.mindeps == true }} if_true: | - cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} -DUSE_LIBHANDY=OFF -DUSE_MINIAUDIO=OFF + cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} -DUSE_LIBHANDY=OFF -DENABLE_NOTIFICATION_SOUNDS=OFF cmake --build build if_false: | cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} diff --git a/CMakeLists.txt b/CMakeLists.txt index dc08b6c..a3af60f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") option(USE_LIBHANDY "Enable features that require libhandy (default)" ON) option(USE_KEYCHAIN "Store the token in the keychain (default)" ON) -option(USE_MINIAUDIO "Enable features that require miniaudio (default)" ON) +option(ENABLE_NOTIFICATION_SOUNDS "Enable notification sounds (default)" ON) find_package(nlohmann_json REQUIRED) find_package(CURL) @@ -125,7 +125,13 @@ if (USE_KEYCHAIN) endif () endif () +if (${ENABLE_NOTIFICATION_SOUNDS}) + set(USE_MINIAUDIO TRUE) + target_compile_definitions(abaddon PRIVATE ENABLE_NOTIFICATION_SOUNDS) +else () + set(USE_MINIAUDIO FALSE) +endif () + if (USE_MINIAUDIO) target_include_directories(abaddon PUBLIC subprojects/miniaudio) - target_compile_definitions(abaddon PRIVATE WITH_MINIAUDIO) endif () diff --git a/src/notifications/notifier.hpp b/src/notifications/notifier.hpp index 869b918..987b123 100644 --- a/src/notifications/notifier.hpp +++ b/src/notifications/notifier.hpp @@ -2,8 +2,8 @@ #include #include -#ifdef WITH_MINIAUDIO -#include +#ifdef ENABLE_NOTIFICATION_SOUNDS + #include #endif class Notifier { diff --git a/src/notifications/notifier_gio.cpp b/src/notifications/notifier_gio.cpp index f09b002..e5335d0 100644 --- a/src/notifications/notifier_gio.cpp +++ b/src/notifications/notifier_gio.cpp @@ -5,7 +5,7 @@ #include Notifier::Notifier() { -#ifdef WITH_MINIAUDIO +#ifdef ENABLE_NOTIFICATION_SOUNDS if (ma_engine_init(nullptr, &m_engine) != MA_SUCCESS) { printf("failed to initialize miniaudio engine\n"); } @@ -13,7 +13,7 @@ Notifier::Notifier() { } Notifier::~Notifier() { -#ifdef WITH_MINIAUDIO +#ifdef ENABLE_NOTIFICATION_SOUNDS ma_engine_uninit(&m_engine); #endif } @@ -34,7 +34,7 @@ void Notifier::Notify(const Glib::ustring &title, const Glib::ustring &text, con g_object_unref(icon); g_object_unref(file); -#ifdef WITH_MINIAUDIO +#ifdef ENABLE_NOTIFICATION_SOUNDS ma_engine_play_sound(&m_engine, Abaddon::Get().GetResPath("/sound/message.mp3").c_str(), nullptr); #endif } -- cgit v1.2.3