From 70c052cc76898a8d07ac4619ffe208f22ae35c55 Mon Sep 17 00:00:00 2001 From: Yaroslav Isakov Date: Thu, 9 Jul 2020 16:35:14 +0200 Subject: [PATCH] Make libcanberra optional It is the only X11 dep in RawTherapee, so here is an option to compile without libcanberra. This will completely disables sounds for long operations on Linux, but canberra is enabled by default. --- CMakeLists.txt | 6 +++++- rtgui/soundman.cc | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b7cf35099..076e1b817 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -493,7 +493,11 @@ endif() # Check for libcanberra-gtk3 (sound events on Linux): if(UNIX AND (NOT APPLE)) - pkg_check_modules(CANBERRA-GTK REQUIRED libcanberra-gtk3) + option(USE_LIBCANBERRA "Build with libcanberra" ON) + if(USE_LIBCANBERRA) + pkg_check_modules(CANBERRA-GTK REQUIRED libcanberra-gtk3) + add_definitions(-DUSE_CANBERRA) + endif() endif() if(WITH_MYFILE_MMAP) diff --git a/rtgui/soundman.cc b/rtgui/soundman.cc index a4cf5337b..d038ffd72 100644 --- a/rtgui/soundman.cc +++ b/rtgui/soundman.cc @@ -26,7 +26,7 @@ #include #endif -#ifdef __linux__ +#if defined(__linux__) && defined(USE_CANBERRA) #include #endif @@ -67,7 +67,7 @@ void SoundManager::playSoundAsync(const Glib::ustring &sound) wchar_t *wfilename = (wchar_t*)g_utf8_to_utf16 (sound.c_str(), -1, NULL, NULL, NULL); PlaySoundW(wfilename, NULL, sndParam); g_free( wfilename ); -#elif defined(__linux__) +#elif defined(__linux__) && defined(USE_CANBERRA) ca_context_play(ca_gtk_context_get(), 0, CA_PROP_EVENT_ID, sound.c_str(), CA_PROP_MEDIA_FILENAME, sound.c_str(), NULL); #endif }