[Git][pulseaudio/pavucontrol][master] Make libcanberra optional
Arun Raghavan (@arun)
gitlab at gitlab.freedesktop.org
Wed Apr 24 17:39:49 UTC 2024
Arun Raghavan pushed to branch master at PulseAudio / pavucontrol
Commits:
22b04fff by Adrian Ratiu at 2024-04-24T20:06:52+03:00
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 at collabora.com>
- - - - -
4 changed files:
- meson.build
- src/mainwindow.cc
- src/mainwindow.h
- src/sinkwidget.cc
Changes:
=====================================
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)
=====================================
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) {
=====================================
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();
=====================================
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() {
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pavucontrol/-/commit/22b04fff6e881b4e0a1b8344a6513bdf99a10c65
--
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pavucontrol/-/commit/22b04fff6e881b4e0a1b8344a6513bdf99a10c65
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20240424/a42eb02a/attachment-0001.htm>
More information about the pulseaudio-commits
mailing list