summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Ratiu <adrian.ratiu@collabora.com>2024-03-25 02:19:42 +0200
committerAdrian Ratiu <adrian.ratiu@collabora.com>2024-04-24 20:06:52 +0300
commit22b04fff6e881b4e0a1b8344a6513bdf99a10c65 (patch)
tree0debb0d118fe3d3ed25e6d5272c7d9d8ecb93bb4
parent44f984883fc6d29f26cae333661d5a0f47322956 (diff)
Make libcanberra optionalHEADmaster
libcanberra is an old abandoned project whose last release was well over a decade ago, despite getting some few fixes on its master branch since then, which are unreleased. My problem with libcanberra is that it can't be built on pure wayland systems (no X11 headers) which are becoming more common nowadays. It is the only thing keeping pavucontrol tied to X11, all other dependencies (eg gtk+) build fine on pure wayland. Since canberra is not a core part of the project, let's make it optional so pavucontrol can build & work on pure wayland systems. Ideally in the future libcanberra can be replaced with something else, however I don't have the bandwidth to take this on for now, so I'm just making it optional. Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
-rw-r--r--meson.build4
-rw-r--r--src/mainwindow.cc6
-rw-r--r--src/mainwindow.h4
-rw-r--r--src/sinkwidget.cc7
4 files changed, 17 insertions, 4 deletions
diff --git a/meson.build b/meson.build
index d6e410d..10384da 100644
--- a/meson.build
+++ b/meson.build
@@ -10,7 +10,7 @@ cpp = meson.get_compiler('cpp')
gtkmm_dep = dependency('gtkmm-4.0', version : '>= 4.0', required : true)
sigcpp_dep = dependency('sigc++-2.0', required : true)
-canberragtk_dep = dependency('libcanberra', version : '>= 0.16', required : true)
+canberragtk_dep = dependency('libcanberra', version : '>= 0.16', required : false)
libpulse_dep = dependency('libpulse', version : '>= 5.0', required : true)
libpulsemlglib_dep = dependency('libpulse-mainloop-glib', version : '>= 0.9.16', required : true)
@@ -41,6 +41,8 @@ cdata.set_quoted('GETTEXT_PACKAGE', 'pavucontrol')
cdata.set_quoted('LOCALEDIR', localedir)
cdata.set_quoted('GLADE_FILE', join_paths(datadir, 'pavucontrol', 'pavucontrol.glade'))
+cdata.set('HAVE_LIBCANBERRA', canberragtk_dep.found())
+
# Now generate config.h from everything above
configure_file(output : 'config.h', configuration : cdata)
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 9579dad..9bee3b1 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -76,9 +76,10 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
canRenameDevices(false),
m_connected(false),
m_config_filename(NULL) {
+#ifdef HAVE_LIBCANBERRA
ca_context_create(&canberraContext);
ca_context_set_driver(canberraContext, "pulse");
-
+#endif
cardsVBox = x->get_widget<Gtk::Box>("cardsVBox");
streamsVBox = x->get_widget<Gtk::Box>("streamsVBox");
recsVBox = x->get_widget<Gtk::Box>("recsVBox");
@@ -271,8 +272,9 @@ finish:
g_free(i->second);
clientNames.erase(i);
}
-
+#ifdef HAVE_LIBCANBERRA
ca_context_destroy(canberraContext);
+#endif
}
static void set_icon_name_default(Gtk::Image *i, const char *name) {
diff --git a/src/mainwindow.h b/src/mainwindow.h
index ca40a7b..dcbc2f0 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -29,7 +29,9 @@ class MainWindow;
# include <pulse/ext-device-restore.h>
#endif
+#ifdef HAVE_LIBCANBERRA
#include <canberra.h>
+#endif
#include <unordered_map>
@@ -118,7 +120,9 @@ public:
bool canRenameDevices;
+#ifdef HAVE_LIBCANBERRA
ca_context *canberraContext;
+#endif
protected:
virtual void on_realize();
diff --git a/src/sinkwidget.cc b/src/sinkwidget.cc
index 1cbc1c3..0af4957 100644
--- a/src/sinkwidget.cc
+++ b/src/sinkwidget.cc
@@ -24,7 +24,10 @@
#include "sinkwidget.h"
+#ifdef HAVE_LIBCANBERRA
#include <canberra.h>
+#endif
+
#if HAVE_EXT_DEVICE_RESTORE_API
# include <pulse/format.h>
# include <pulse/ext-device-restore.h>
@@ -111,7 +114,6 @@ SinkWidget* SinkWidget::create(MainWindow* mainWindow) {
void SinkWidget::executeVolumeUpdate() {
pa_operation* o;
char dev[64];
- int playing = 0;
if (!(o = pa_context_set_sink_volume_by_index(get_context(), index, &volume, NULL, NULL))) {
show_error(this, _("pa_context_set_sink_volume_by_index() failed"));
@@ -122,6 +124,8 @@ void SinkWidget::executeVolumeUpdate() {
snprintf(dev, sizeof(dev), "%lu", (unsigned long) index);
+#ifdef HAVE_LIBCANBERRA
+ int playing = 0;
ca_context_playing(mpMainWindow->canberraContext, 2, &playing);
if (playing)
return;
@@ -137,6 +141,7 @@ void SinkWidget::executeVolumeUpdate() {
NULL);
ca_context_change_device(mpMainWindow->canberraContext, NULL);
+#endif
}
void SinkWidget::onMuteToggleButton() {