summaryrefslogtreecommitdiff
path: root/src
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 /src
parent44f984883fc6d29f26cae333661d5a0f47322956 (diff)
Make libcanberra optional
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>
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cc6
-rw-r--r--src/mainwindow.h4
-rw-r--r--src/sinkwidget.cc7
3 files changed, 14 insertions, 3 deletions
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() {