зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1351378 - Add an --enable-audio-backends option. r=mhentges
This addresses the original intent of the bug report which asks for allowing sndio to be built on more than just OpenBSD. In addition of modifying the existing --enable-sndio to support this request, the option --enable-audio-backends was added which takes a list of possible backends to support per discussion in the bug report. For example specifying --enable-audio-backends=alsa,jack,pulseaudio,sndio allows for runtime selection of those four cubeb backends. If all four backends are available the user can specify `media.cubeb.backend` in `about:config` to force a specific backend. Removed superfluous set_define()s as libcubeb's moz.build does the necessary `DEFINES['...']` assignments for each backend. In addition logic for finer control of audio backend selection on Android was added. One can now specify aaudio, opensl or both (which is the default). Differential Revision: https://phabricator.services.mozilla.com/D141450
This commit is contained in:
Родитель
ab745eb4fb
Коммит
82b9d72e94
|
@ -766,7 +766,6 @@ system_headers = [
|
|||
'SIOUX.h',
|
||||
'size_t.h',
|
||||
'smime.h',
|
||||
'sndio.h',
|
||||
'someincludefile.h',
|
||||
'soundcard.h',
|
||||
'Sound.h',
|
||||
|
@ -1244,6 +1243,11 @@ if CONFIG['MOZ_JACK']:
|
|||
'jack/statistics.h',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_SNDIO']:
|
||||
system_headers += [
|
||||
'sndio.h',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_SYSTEM_JPEG']:
|
||||
system_headers += [
|
||||
'jpeglib.h',
|
||||
|
|
|
@ -23,7 +23,14 @@ if CONFIG['MOZ_ALSA']:
|
|||
]
|
||||
DEFINES['USE_ALSA'] = True
|
||||
|
||||
if CONFIG['MOZ_PULSEAUDIO'] or CONFIG['MOZ_JACK']:
|
||||
if (
|
||||
CONFIG["MOZ_PULSEAUDIO"]
|
||||
or CONFIG["MOZ_JACK"]
|
||||
or CONFIG["MOZ_AAUDIO"]
|
||||
or CONFIG["MOZ_OPENSL"]
|
||||
or CONFIG["MOZ_AUDIOUNIT_RUST"]
|
||||
or CONFIG["MOZ_WASAPI"]
|
||||
):
|
||||
SOURCES += [
|
||||
'cubeb_resampler.cpp',
|
||||
]
|
||||
|
@ -40,35 +47,33 @@ if CONFIG['MOZ_JACK']:
|
|||
]
|
||||
DEFINES['USE_JACK'] = True
|
||||
|
||||
if CONFIG['OS_ARCH'] in ('DragonFly', 'FreeBSD', 'SunOS'):
|
||||
if CONFIG['MOZ_OSS']:
|
||||
SOURCES += [
|
||||
'cubeb_oss.c',
|
||||
]
|
||||
DEFINES['USE_OSS'] = True
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'OpenBSD':
|
||||
if CONFIG['MOZ_SNDIO']:
|
||||
SOURCES += [
|
||||
'cubeb_sndio.c',
|
||||
]
|
||||
DEFINES['USE_SNDIO'] = True
|
||||
DEFINES['DISABLE_LIBSNDIO_DLOPEN'] = True
|
||||
if CONFIG['OS_ARCH'] == 'OpenBSD':
|
||||
DEFINES['DISABLE_LIBSNDIO_DLOPEN'] = True
|
||||
|
||||
if CONFIG['OS_TARGET'] == 'Darwin':
|
||||
if CONFIG['MOZ_AUDIOUNIT_RUST']:
|
||||
SOURCES += [
|
||||
'cubeb_audiounit.cpp',
|
||||
'cubeb_resampler.cpp'
|
||||
]
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||
SOURCES += [
|
||||
'cubeb_osx_run_loop.c',
|
||||
]
|
||||
DEFINES['USE_AUDIOUNIT'] = True
|
||||
if CONFIG['MOZ_AUDIOUNIT_RUST']:
|
||||
DEFINES['USE_AUDIOUNIT_RUST'] = True
|
||||
DEFINES['USE_AUDIOUNIT_RUST'] = True
|
||||
|
||||
if CONFIG['OS_TARGET'] == 'WINNT':
|
||||
if CONFIG['MOZ_WASAPI']:
|
||||
SOURCES += [
|
||||
'cubeb_resampler.cpp',
|
||||
'cubeb_wasapi.cpp',
|
||||
'cubeb_winmm.c',
|
||||
]
|
||||
|
@ -82,14 +87,17 @@ if CONFIG['OS_TARGET'] == 'WINNT':
|
|||
if CONFIG['CC_TYPE'] == 'clang-cl':
|
||||
CXXFLAGS += ['-Wno-macro-redefined'] # '_USE_MATH_DEFINES' : macro redefinition
|
||||
|
||||
if CONFIG['OS_TARGET'] == 'Android':
|
||||
SOURCES += ['cubeb_aaudio.cpp']
|
||||
SOURCES += ['cubeb_opensl.c']
|
||||
SOURCES += ['cubeb_resampler.cpp']
|
||||
if CONFIG['MOZ_AAUDIO'] or CONFIG['MOZ_OPENSL']:
|
||||
SOURCES += ['cubeb-jni.cpp']
|
||||
DEFINES['USE_OPENSL'] = True
|
||||
|
||||
if CONFIG['MOZ_AAUDIO']:
|
||||
SOURCES += ['cubeb_aaudio.cpp']
|
||||
DEFINES['USE_AAUDIO'] = True
|
||||
|
||||
if CONFIG['MOZ_OPENSL']:
|
||||
SOURCES += ['cubeb_opensl.c']
|
||||
DEFINES['USE_OPENSL'] = True
|
||||
|
||||
FINAL_LIBRARY = 'gkmedias'
|
||||
|
||||
if CONFIG['MOZ_ALSA']:
|
||||
|
|
|
@ -183,6 +183,139 @@ def midir_support(target, midir_linux_support):
|
|||
|
||||
set_config("MOZ_WEBMIDI_MIDIR_IMPL", midir_support)
|
||||
|
||||
# Enable various cubeb backends
|
||||
# ==============================================================
|
||||
@depends(target)
|
||||
def audio_backends_default(target):
|
||||
if target.os == "Android":
|
||||
return (
|
||||
"aaudio",
|
||||
"opensl",
|
||||
)
|
||||
elif target.os in ("DragonFly", "FreeBSD", "SunOS"):
|
||||
return ("oss",)
|
||||
elif target.os == "OpenBSD":
|
||||
return ("sndio",)
|
||||
elif target.os == "OSX":
|
||||
return ("audiounit",)
|
||||
elif target.os == "WINNT":
|
||||
return ("wasapi",)
|
||||
else:
|
||||
return ("pulseaudio",)
|
||||
|
||||
|
||||
option(
|
||||
"--enable-audio-backends",
|
||||
nargs="+",
|
||||
choices=(
|
||||
"aaudio",
|
||||
"alsa",
|
||||
"audiounit",
|
||||
"jack",
|
||||
"opensl",
|
||||
"oss",
|
||||
"pulseaudio",
|
||||
"sndio",
|
||||
"wasapi",
|
||||
),
|
||||
default=audio_backends_default,
|
||||
help="{Enable|Disable} various cubeb backends",
|
||||
)
|
||||
|
||||
|
||||
@depends("--enable-audio-backends", target)
|
||||
def imply_aaudio(values, target):
|
||||
if any("aaudio" in value for value in values) and target.os != "Android":
|
||||
die("Cannot enable AAudio on %s", target.os)
|
||||
return any("aaudio" in value for value in values) or None
|
||||
|
||||
|
||||
@depends("--enable-audio-backends", target)
|
||||
def imply_alsa(values, target):
|
||||
if (
|
||||
any("alsa" in value for value in values)
|
||||
and target.kernel != "Linux"
|
||||
and target.os != "FreeBSD"
|
||||
):
|
||||
die("Cannot enable ALSA on %s", target.os)
|
||||
return any("alsa" in value for value in values) or None
|
||||
|
||||
|
||||
@depends("--enable-audio-backends", target)
|
||||
def imply_audiounit(values, target):
|
||||
if (
|
||||
any("audiounit" in value for value in values)
|
||||
and target.os != "OSX"
|
||||
and target.kernel != "Darwin"
|
||||
):
|
||||
die("Cannot enable AudioUnit on %s", target.os)
|
||||
return any("audiounit" in value for value in values) or None
|
||||
|
||||
|
||||
@depends("--enable-audio-backends")
|
||||
def imply_jack(values):
|
||||
return any("jack" in value for value in values) or None
|
||||
|
||||
|
||||
@depends("--enable-audio-backends", target)
|
||||
def imply_opensl(values, target):
|
||||
if any("opensl" in value for value in values) and target.os != "Android":
|
||||
die("Cannot enable OpenSL on %s", target.os)
|
||||
return any("opensl" in value for value in values) or None
|
||||
|
||||
|
||||
@depends("--enable-audio-backends", target)
|
||||
def imply_oss(values, target):
|
||||
if any("oss" in value for value in values) and (
|
||||
target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
|
||||
):
|
||||
die("Cannot enable OSS on %s", target.os)
|
||||
return any("oss" in value for value in values) or None
|
||||
|
||||
|
||||
@depends("--enable-audio-backends", target)
|
||||
def imply_pulseaudio(values, target):
|
||||
if any("pulseaudio" in value for value in values) and (
|
||||
target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
|
||||
):
|
||||
die("Cannot enable PulseAudio on %s", target.os)
|
||||
return any("pulseaudio" in value for value in values) or None
|
||||
|
||||
|
||||
@depends("--enable-audio-backends", target)
|
||||
def imply_sndio(values, target):
|
||||
if any("sndio" in value for value in values) and (
|
||||
target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
|
||||
):
|
||||
die("Cannot enable sndio on %s", target.os)
|
||||
return any("sndio" in value for value in values) or None
|
||||
|
||||
|
||||
@depends("--enable-audio-backends", target)
|
||||
def imply_wasapi(values, target):
|
||||
if any("wasapi" in value for value in values) and target.os != "WINNT":
|
||||
die("Cannot enable WASAPI on %s", target.os)
|
||||
return any("wasapi" in value for value in values) or None
|
||||
|
||||
|
||||
set_config("MOZ_AAUDIO", imply_aaudio, when="--enable-audio-backends")
|
||||
|
||||
imply_option("--enable-alsa", imply_alsa, reason="--enable-audio-backends")
|
||||
|
||||
set_config("MOZ_AUDIOUNIT_RUST", imply_audiounit, when="--enable-audio-backends")
|
||||
|
||||
imply_option("--enable-jack", imply_jack, reason="--enable-audio-backends")
|
||||
|
||||
set_config("MOZ_OPENSL", imply_opensl, when="--enable-audio-backends")
|
||||
|
||||
set_config("MOZ_OSS", imply_oss, when="--enable-audio-backends")
|
||||
|
||||
imply_option("--enable-pulseaudio", imply_pulseaudio, reason="--enable-audio-backends")
|
||||
|
||||
imply_option("--enable-sndio", imply_sndio, reason="--enable-audio-backends")
|
||||
|
||||
set_config("MOZ_WASAPI", imply_wasapi, when="--enable-audio-backends")
|
||||
|
||||
# ALSA cubeb backend
|
||||
# ==============================================================
|
||||
option("--enable-alsa", env="MOZ_ALSA", help="Enable ALSA audio backend.")
|
||||
|
@ -196,7 +329,6 @@ def enable_alsa_or_midir_linux_support(alsa_enabled, midir_linux_support):
|
|||
pkg_check_modules("MOZ_ALSA", "alsa", when=enable_alsa_or_midir_linux_support)
|
||||
|
||||
set_config("MOZ_ALSA", True, when="--enable-alsa")
|
||||
set_define("MOZ_ALSA", True, when="--enable-alsa")
|
||||
|
||||
# JACK cubeb backend
|
||||
# ==============================================================
|
||||
|
@ -205,36 +337,26 @@ system_lib_option("--enable-jack", env="MOZ_JACK", help="Enable JACK audio backe
|
|||
jack = pkg_check_modules("MOZ_JACK", "jack", when="--enable-jack")
|
||||
|
||||
set_config("MOZ_JACK", depends_if(jack)(lambda _: True))
|
||||
set_define("MOZ_JACK", depends_if(jack)(lambda _: True))
|
||||
|
||||
# PulseAudio cubeb backend
|
||||
# ==============================================================
|
||||
@depends(target)
|
||||
def pulseaudio_default(target):
|
||||
return target.os not in ("WINNT", "OSX", "Android", "OpenBSD")
|
||||
|
||||
|
||||
option(
|
||||
"--enable-pulseaudio",
|
||||
env="MOZ_PULSEAUDIO",
|
||||
default=pulseaudio_default,
|
||||
help="{Enable|Disable} PulseAudio audio backend.",
|
||||
)
|
||||
|
||||
pulseaudio = pkg_check_modules("MOZ_PULSEAUDIO", "libpulse", when="--enable-pulseaudio")
|
||||
|
||||
set_config("MOZ_PULSEAUDIO", depends_if(pulseaudio)(lambda _: True))
|
||||
set_define("MOZ_PULSEAUDIO", depends_if(pulseaudio)(lambda _: True))
|
||||
|
||||
# AudioUnit cubeb Rust backend
|
||||
# sndio cubeb backend
|
||||
# ==============================================================
|
||||
@depends(target)
|
||||
def enable_audiounit_rust(target):
|
||||
return target.os == "OSX" and target.kernel == "Darwin"
|
||||
system_lib_option("--enable-sndio", env="MOZ_SNDIO", help="Enable sndio audio backend.")
|
||||
|
||||
sndio = pkg_check_modules("MOZ_SNDIO", "sndio", when="--enable-sndio")
|
||||
|
||||
set_config("MOZ_AUDIOUNIT_RUST", True, when=enable_audiounit_rust)
|
||||
set_define("MOZ_AUDIOUNIT_RUST", True, when=enable_audiounit_rust)
|
||||
set_config("MOZ_SNDIO", depends_if(sndio)(lambda _: True))
|
||||
|
||||
# Javascript engine
|
||||
# ==============================================================
|
||||
|
|
Загрузка…
Ссылка в новой задаче