Bug 1351378 - Expose sndio as an option for Linux and FreeBSD. r?glandium draft
authorJan Beich <jbeich@FreeBSD.org>
Sun, 21 Aug 2016 15:28:00 +0000
changeset 779054 b59651dbe91b1d6e95b3ff82f4bb73f20f0e4d2f
parent 779052 fd296333c16255231d869fe1e294582f2740f2be
push id105645
push userbmo:jbeich@FreeBSD.org
push dateSun, 08 Apr 2018 21:29:27 +0000
reviewersglandium
bugs1351378
milestone61.0a1
Bug 1351378 - Expose sndio as an option for Linux and FreeBSD. r?glandium MozReview-Commit-ID: 6ri8EMjJdyy
config/system-headers.mozbuild
media/libcubeb/gtest/moz.build
media/libcubeb/src/moz.build
toolkit/library/moz.build
toolkit/moz.configure
--- a/config/system-headers.mozbuild
+++ b/config/system-headers.mozbuild
@@ -763,17 +763,16 @@ system_headers = [
     'shlobj.h',
     'shsign.h',
     'sigcontext.h',
     'signal.h',
     'SimpleGameSound.h',
     'SIOUX.h',
     'size_t.h',
     'smime.h',
-    'sndio.h',
     'someincludefile.h',
     'soundcard.h',
     'Sound.h',
     'soundtouch/SoundTouchFactory.h',
     'soundtouch/SoundTouch.h',
     'spawn.h',
     'sqlite3.h',
     'sslerr.h',
@@ -1235,16 +1234,21 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'andr
     ]
 
 if CONFIG['MOZ_JACK']:
     system_headers += [
         'jack/jack.h',
         'jack/statistics.h',
     ]
 
+if CONFIG['MOZ_SNDIO']:
+    system_headers += [
+        'sndio.h',
+    ]
+
 if CONFIG['MOZ_SYSTEM_JPEG']:
     system_headers += [
         'jpeglib.h',
     ]
 
 if CONFIG['MOZ_LIBAV_FFT']:
     system_headers += [
         'libavcodec/avfft.h',
--- a/media/libcubeb/gtest/moz.build
+++ b/media/libcubeb/gtest/moz.build
@@ -62,17 +62,17 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'coco
         '-framework AudioUnit',
         '-framework CoreAudio',
     ]
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'uikit':
     OS_LIBS += [
       '-framework CoreFoundation',
       '-framework AudioToolbox',
     ]
-elif CONFIG['OS_TARGET'] == 'OpenBSD':
+elif CONFIG['MOZ_SNDIO']:
     OS_LIBS += [
         'sndio',
     ]
 else:
     OS_LIBS += CONFIG['MOZ_ALSA_LIBS']
     OS_LIBS += CONFIG['MOZ_PULSEAUDIO_LIBS']
 
 if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
--- a/media/libcubeb/src/moz.build
+++ b/media/libcubeb/src/moz.build
@@ -39,17 +39,17 @@ if CONFIG['MOZ_JACK']:
     SOURCES += [
         'cubeb_jack.cpp',
     ]
     USE_LIBS += [
         'speex',
     ]
     DEFINES['USE_JACK'] = True
 
-if CONFIG['OS_ARCH'] == 'OpenBSD':
+if CONFIG['MOZ_SNDIO']:
     SOURCES += [
         'cubeb_sndio.c',
     ]
     DEFINES['USE_SNDIO'] = True
 
 if CONFIG['OS_TARGET'] == 'Darwin':
     SOURCES += [
         'cubeb_audiounit.cpp',
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -253,17 +253,17 @@ if CONFIG['MOZ_ALSA']:
 if CONFIG['HAVE_CLOCK_MONOTONIC']:
     OS_LIBS += CONFIG['REALTIME_LIBS']
 
 OS_LIBS += CONFIG['ICONV_LIBS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'uikit'):
     OS_LIBS += CONFIG['TK_LIBS']
 
-if CONFIG['OS_ARCH'] == 'OpenBSD':
+if CONFIG['MOZ_SNDIO']:
     OS_LIBS += [
         'sndio',
     ]
 
 if CONFIG['MOZ_ENABLE_DBUS']:
     OS_LIBS += CONFIG['MOZ_DBUS_GLIB_LIBS']
 
 if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -84,16 +84,40 @@ def pulseaudio_default(target):
 option('--enable-pulseaudio', env='MOZ_PULSEAUDIO', default=pulseaudio_default,
        help='Enable 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))
 
+# SNDIO cubeb backend
+# ==============================================================
+
+@depends(target)
+def sndio_default(target):
+    return target.os == 'OpenBSD'
+
+option('--enable-sndio', env='MOZ_SNDIO', default=sndio_default,
+       help='Enable SNDIO audio backend.')
+
+# TODO: inherit CPPFLAGS from old-configure.in
+have_sndio = check_header('sndio.h', when='--enable-sndio')
+
+@depends('--enable-sndio', have_sndio)
+def sndio(value, have_sndio):
+    if bool(value):
+        if have_sndio:
+            return True
+        else:
+            die("sndio audio backend requires development headers")
+
+set_config('MOZ_SNDIO', sndio)
+set_define('MOZ_SNDIO', sndio)
+
 # Javascript engine
 # ==============================================================
 include('../js/moz.configure')
 
 
 # Rust
 # ==============================================================
 include('../build/moz.configure/rust.configure',