diff --git a/dom/midi/AlsaCompatibility.cpp b/dom/midi/AlsaCompatibility.cpp new file mode 100644 index 0000000000000..7d247d766d779 --- /dev/null +++ b/dom/midi/AlsaCompatibility.cpp @@ -0,0 +1,35 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/Assertions.h" + +// The code in this file is a workaround for building with ALSA versions prior +// to 1.0.29. The snd_pcm_sw_params_set_tstamp_type() and +// snd_pcm_sw_params_get_tstamp_type() functions are missing from those versions +// and we need them for the alsa crate which in turn is a dependency of the +// midir crate. The functions are not actually used so we provide dummy +// implementations that return an error. This file can be safely removed when +// the Linux sysroot will be updated to Debian 9 (or higher) +#include + +#if (SND_LIB_MAJOR == 1) && (SND_LIB_MINOR == 0) && (SND_LIB_SUBMINOR < 29) + +extern "C" { + +int snd_pcm_sw_params_set_tstamp_type(void) { + MOZ_CRASH( + "The replacement for snd_pcm_sw_params_set_tstamp_type() should never be " + "called"); + return -1; +} + +int snd_pcm_sw_params_get_tstamp_type(void) { + MOZ_CRASH( + "The replacement for snd_pcm_sw_params_get_tstamp_type() should never be " + "called"); + return -1; +} +} + +#endif diff --git a/dom/midi/moz.build b/dom/midi/moz.build index 11723dcfad5ad..97d51875ee8f0 100644 --- a/dom/midi/moz.build +++ b/dom/midi/moz.build @@ -55,6 +55,9 @@ UNIFIED_SOURCES = [ include("/ipc/chromium/chromium-config.mozbuild") +if CONFIG["OS_TARGET"] == "Linux": + UNIFIED_SOURCES += ["AlsaCompatibility.cpp"] + FINAL_LIBRARY = "xul" LOCAL_INCLUDES += [ "/dom/base", diff --git a/media/libcubeb/src/moz.build b/media/libcubeb/src/moz.build index d411172ee7fa7..2c803de900b96 100644 --- a/media/libcubeb/src/moz.build +++ b/media/libcubeb/src/moz.build @@ -92,7 +92,9 @@ if CONFIG['OS_TARGET'] == 'Android': FINAL_LIBRARY = 'gkmedias' -CFLAGS += CONFIG['MOZ_ALSA_CFLAGS'] +if CONFIG['MOZ_ALSA']: + CFLAGS += CONFIG['MOZ_ALSA_CFLAGS'] + CFLAGS += CONFIG['MOZ_JACK_CFLAGS'] CFLAGS += CONFIG['MOZ_PULSEAUDIO_CFLAGS'] diff --git a/taskcluster/docker/debian-build/Dockerfile b/taskcluster/docker/debian-build/Dockerfile index 7998f34ee9686..21be89973c0b3 100644 --- a/taskcluster/docker/debian-build/Dockerfile +++ b/taskcluster/docker/debian-build/Dockerfile @@ -15,7 +15,8 @@ RUN /usr/local/sbin/setup_packages.sh $TASKCLUSTER_ROOT_URL $DOCKER_IMAGE_PACKAG # libc6-i386 and lib32gcc1 are needed for wine. # libdbus-glib-1-2 and libgtk-3-0 are needed to run xpcshell during the build. # lib32atomic1, lib32stdc++6 and lib32z1 are needed to run some 32-bits -# spidermonkey tests. +# spidermonkey tests. libasound2 is needed to run xpcshell after we introduced +# the dependencies on alsa via Web MIDI. RUN apt-get update && \ apt-get dist-upgrade && \ apt-get install \ @@ -30,6 +31,7 @@ RUN apt-get update && \ 'lib32gcc(1|-s1)$' \ lib32stdc++6 \ lib32z1 \ + libasound2 \ libc6-i386 \ libdbus-glib-1-2 \ libgtk-3-0 \ diff --git a/taskcluster/scripts/misc/build-sysroot.sh b/taskcluster/scripts/misc/build-sysroot.sh index 0945055e298a8..7cfb8ba1ac901 100755 --- a/taskcluster/scripts/misc/build-sysroot.sh +++ b/taskcluster/scripts/misc/build-sysroot.sh @@ -31,6 +31,7 @@ esac packages=" linux-libc-dev + libasound2-dev libstdc++-${gcc_version}-dev libdbus-glib-1-dev libdrm-dev diff --git a/toolkit/moz.configure b/toolkit/moz.configure index 4782fcbe94ee5..ad6f2e57d359d 100644 --- a/toolkit/moz.configure +++ b/toolkit/moz.configure @@ -171,12 +171,23 @@ imply_option("--enable-replace-malloc", dmd, when=compile_environment) # ALSA cubeb backend # ============================================================== -system_lib_option("--enable-alsa", env="MOZ_ALSA", help="Enable ALSA audio backend.") +@depends(target) +def alsa_default_check(target): + return target.kernel == "Linux" and target.os != "Android" + + +option("--enable-alsa", env="MOZ_ALSA", help="Enable ALSA audio backend.") + + +@depends("--enable-alsa", alsa_default_check) +def enable_alsa_or_alsa_default_check(alsa_enabled, alsa_default_check): + return alsa_enabled or alsa_default_check + -alsa = pkg_check_modules("MOZ_ALSA", "alsa", when="--enable-alsa") +pkg_check_modules("MOZ_ALSA", "alsa", when=enable_alsa_or_alsa_default_check) -set_config("MOZ_ALSA", depends_if(alsa)(lambda _: True)) -set_define("MOZ_ALSA", depends_if(alsa)(lambda _: True)) +set_config("MOZ_ALSA", True, when="--enable-alsa") +set_define("MOZ_ALSA", True, when="--enable-alsa") # JACK cubeb backend # ==============================================================