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>
This commit is contained in:
parent
44f984883f
commit
22b04fff6e
|
@ -10,7 +10,7 @@ cpp = meson.get_compiler('cpp')
|
||||||
|
|
||||||
gtkmm_dep = dependency('gtkmm-4.0', version : '>= 4.0', required : true)
|
gtkmm_dep = dependency('gtkmm-4.0', version : '>= 4.0', required : true)
|
||||||
sigcpp_dep = dependency('sigc++-2.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)
|
libpulse_dep = dependency('libpulse', version : '>= 5.0', required : true)
|
||||||
libpulsemlglib_dep = dependency('libpulse-mainloop-glib', version : '>= 0.9.16', 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('LOCALEDIR', localedir)
|
||||||
cdata.set_quoted('GLADE_FILE', join_paths(datadir, 'pavucontrol', 'pavucontrol.glade'))
|
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
|
# Now generate config.h from everything above
|
||||||
configure_file(output : 'config.h', configuration : cdata)
|
configure_file(output : 'config.h', configuration : cdata)
|
||||||
|
|
||||||
|
|
|
@ -76,9 +76,10 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
|
||||||
canRenameDevices(false),
|
canRenameDevices(false),
|
||||||
m_connected(false),
|
m_connected(false),
|
||||||
m_config_filename(NULL) {
|
m_config_filename(NULL) {
|
||||||
|
#ifdef HAVE_LIBCANBERRA
|
||||||
ca_context_create(&canberraContext);
|
ca_context_create(&canberraContext);
|
||||||
ca_context_set_driver(canberraContext, "pulse");
|
ca_context_set_driver(canberraContext, "pulse");
|
||||||
|
#endif
|
||||||
cardsVBox = x->get_widget<Gtk::Box>("cardsVBox");
|
cardsVBox = x->get_widget<Gtk::Box>("cardsVBox");
|
||||||
streamsVBox = x->get_widget<Gtk::Box>("streamsVBox");
|
streamsVBox = x->get_widget<Gtk::Box>("streamsVBox");
|
||||||
recsVBox = x->get_widget<Gtk::Box>("recsVBox");
|
recsVBox = x->get_widget<Gtk::Box>("recsVBox");
|
||||||
|
@ -271,8 +272,9 @@ finish:
|
||||||
g_free(i->second);
|
g_free(i->second);
|
||||||
clientNames.erase(i);
|
clientNames.erase(i);
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_LIBCANBERRA
|
||||||
ca_context_destroy(canberraContext);
|
ca_context_destroy(canberraContext);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_icon_name_default(Gtk::Image *i, const char *name) {
|
static void set_icon_name_default(Gtk::Image *i, const char *name) {
|
||||||
|
|
|
@ -29,7 +29,9 @@ class MainWindow;
|
||||||
# include <pulse/ext-device-restore.h>
|
# include <pulse/ext-device-restore.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBCANBERRA
|
||||||
#include <canberra.h>
|
#include <canberra.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
@ -118,7 +120,9 @@ public:
|
||||||
|
|
||||||
bool canRenameDevices;
|
bool canRenameDevices;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBCANBERRA
|
||||||
ca_context *canberraContext;
|
ca_context *canberraContext;
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void on_realize();
|
virtual void on_realize();
|
||||||
|
|
|
@ -24,7 +24,10 @@
|
||||||
|
|
||||||
#include "sinkwidget.h"
|
#include "sinkwidget.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBCANBERRA
|
||||||
#include <canberra.h>
|
#include <canberra.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAVE_EXT_DEVICE_RESTORE_API
|
#if HAVE_EXT_DEVICE_RESTORE_API
|
||||||
# include <pulse/format.h>
|
# include <pulse/format.h>
|
||||||
# include <pulse/ext-device-restore.h>
|
# include <pulse/ext-device-restore.h>
|
||||||
|
@ -111,7 +114,6 @@ SinkWidget* SinkWidget::create(MainWindow* mainWindow) {
|
||||||
void SinkWidget::executeVolumeUpdate() {
|
void SinkWidget::executeVolumeUpdate() {
|
||||||
pa_operation* o;
|
pa_operation* o;
|
||||||
char dev[64];
|
char dev[64];
|
||||||
int playing = 0;
|
|
||||||
|
|
||||||
if (!(o = pa_context_set_sink_volume_by_index(get_context(), index, &volume, NULL, NULL))) {
|
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"));
|
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);
|
snprintf(dev, sizeof(dev), "%lu", (unsigned long) index);
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBCANBERRA
|
||||||
|
int playing = 0;
|
||||||
ca_context_playing(mpMainWindow->canberraContext, 2, &playing);
|
ca_context_playing(mpMainWindow->canberraContext, 2, &playing);
|
||||||
if (playing)
|
if (playing)
|
||||||
return;
|
return;
|
||||||
|
@ -137,6 +141,7 @@ void SinkWidget::executeVolumeUpdate() {
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
ca_context_change_device(mpMainWindow->canberraContext, NULL);
|
ca_context_change_device(mpMainWindow->canberraContext, NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SinkWidget::onMuteToggleButton() {
|
void SinkWidget::onMuteToggleButton() {
|
||||||
|
|
Loading…
Reference in New Issue