1
0
mirror of https://github.com/uowuo/abaddon.git synced 2025-03-04 03:03:16 -05:00

refactor notification sounds cmake option

This commit is contained in:
ouwou 2023-03-10 19:15:03 -05:00
parent e3f6a1dcbd
commit 3f4ccefc78
4 changed files with 14 additions and 8 deletions

View File

@ -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 }}

View File

@ -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 ()

View File

@ -2,8 +2,8 @@
#include <glibmm/ustring.h>
#include <gdkmm/pixbuf.h>
#ifdef WITH_MINIAUDIO
#include <miniaudio.h>
#ifdef ENABLE_NOTIFICATION_SOUNDS
#include <miniaudio.h>
#endif
class Notifier {

View File

@ -5,7 +5,7 @@
#include <miniaudio.h>
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
}