Skip to content

Commit

Permalink
Bug 1728436 - Added libasound2 dependency to the sysroot r=glandium
Browse files Browse the repository at this point in the history
This is required to build the midir crate on Linux. The Dockerfile change is
needed to run the just built xpcshell executable on the build host.

Differential Revision: https://phabricator.services.mozilla.com/D124641
  • Loading branch information
gabrielesvelto committed Dec 21, 2021
1 parent ee6325f commit 2793748
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 6 deletions.
35 changes: 35 additions & 0 deletions dom/midi/AlsaCompatibility.cpp
Original file line number Diff line number Diff line change
@@ -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 <alsa/asoundlib.h>

#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
3 changes: 3 additions & 0 deletions dom/midi/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion media/libcubeb/src/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down
4 changes: 3 additions & 1 deletion taskcluster/docker/debian-build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -30,6 +31,7 @@ RUN apt-get update && \
'lib32gcc(1|-s1)$' \
lib32stdc++6 \
lib32z1 \
libasound2 \
libc6-i386 \
libdbus-glib-1-2 \
libgtk-3-0 \
Expand Down
1 change: 1 addition & 0 deletions taskcluster/scripts/misc/build-sysroot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ esac

packages="
linux-libc-dev
libasound2-dev
libstdc++-${gcc_version}-dev
libdbus-glib-1-dev
libdrm-dev
Expand Down
19 changes: 15 additions & 4 deletions toolkit/moz.configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ==============================================================
Expand Down

0 comments on commit 2793748

Please sign in to comment.