mirror of
https://github.com/mpv-player/mpv
synced 2025-04-19 13:47:06 +00:00
build: reimplement the OSS checks using a more declarative approach
The OSS checks were a big mess and quite buggy. This reimplementes them using a declarative approach and clearly distinguishing between the various OSS implementations. The code should now almost be auto-documenting. We currently support the following implementations of OSS: * platform-specific (with `sys/soundcard.h`) * SunAudio (default on NetBSD and useable on OpenBSD even if we have sndio support there). * 4Front (default on FreeBSD) Since now each OSS check also checks for the appropriate soundcard header, remove the old soundcard check. Many thanks to @bugmen0t for in depth info about all the BSDs. Check #380 and #359 for more info on this commit.
This commit is contained in:
parent
18345400c0
commit
fa620ffc95
@ -1,6 +1,8 @@
|
|||||||
from waftools.checks.generic import *
|
from waftools.checks.generic import *
|
||||||
|
from waflib import Utils
|
||||||
|
import os
|
||||||
|
|
||||||
__all__ = ["check_pthreads", "check_iconv", "check_lua", "check_oss"]
|
__all__ = ["check_pthreads", "check_iconv", "check_lua", "check_oss_4front"]
|
||||||
|
|
||||||
pthreads_program = load_fragment('pthreads.c')
|
pthreads_program = load_fragment('pthreads.c')
|
||||||
|
|
||||||
@ -72,56 +74,23 @@ def check_lua(ctx, dependency_identifier):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# from here on there is the OSS check.. just stop reading here unless you want
|
def __get_osslibdir():
|
||||||
# to die inside a little
|
|
||||||
def __fail_oss_check__(ctx):
|
|
||||||
ctx.define('PATH_DEV_DSP', '')
|
|
||||||
ctx.define('PATH_DEV_MIXER', '')
|
|
||||||
return False
|
|
||||||
|
|
||||||
def __get_osslibdir__():
|
|
||||||
from waflib import Utils
|
|
||||||
cmd = ['sh', '-c', '. /etc/oss.conf && echo $OSSLIBDIR']
|
cmd = ['sh', '-c', '. /etc/oss.conf && echo $OSSLIBDIR']
|
||||||
p = Utils.subprocess.Popen(cmd, stdin=Utils.subprocess.PIPE,
|
p = Utils.subprocess.Popen(cmd, stdin=Utils.subprocess.PIPE,
|
||||||
stdout=Utils.subprocess.PIPE,
|
stdout=Utils.subprocess.PIPE,
|
||||||
stderr=Utils.subprocess.PIPE)
|
stderr=Utils.subprocess.PIPE)
|
||||||
return p.communicate()[0].decode().rstrip()
|
return p.communicate()[0].decode().rstrip()
|
||||||
|
|
||||||
def __get_osscflags__():
|
def check_oss_4front(ctx, dependency_identifier):
|
||||||
import os
|
oss_libdir = __get_osslibdir()
|
||||||
osscflags = ''
|
|
||||||
osslibdir = __get_osslibdir__()
|
|
||||||
if osslibdir:
|
|
||||||
ossincdir = os.path.join(osslibdir, 'include')
|
|
||||||
soundcard_h = os.path.join(ossincdir, 'sys', 'soundcard.h')
|
|
||||||
if os.path.exists(soundcard_h):
|
|
||||||
osscflags = '-I{0}'.format(ossincdir)
|
|
||||||
return osscflags
|
|
||||||
|
|
||||||
def __check_oss_headers__(ctx, dependency_identifier):
|
soundcard_h = os.path.join(oss_libdir, "include/sys/soundcard.h")
|
||||||
fn = check_cc(fragment=load_fragment('oss_audio_header.c'),
|
include_dir = os.path.join(oss_libdir, "include")
|
||||||
use='soundcard', cflags=__get_osscflags__())
|
|
||||||
fn(ctx, dependency_identifier)
|
|
||||||
return True
|
|
||||||
|
|
||||||
def __check_oss_bsd__(ctxdependency_identifier):
|
fn = check_cc(header_name=soundcard_h,
|
||||||
# add the oss audio library through a check
|
defines=['PATH_DEV_DSP="/dev/dsp"',
|
||||||
ctx.define('PATH_DEV_DSP', '/dev/sound')
|
'PATH_DEV_MIXER="/dev/mixer"'],
|
||||||
if check_cc(lib='ossaudio')(ctx, dependency_identifier):
|
cflags='-I{0}'.format(include_dir),
|
||||||
return True
|
fragment=load_fragment('oss_audio.c'))
|
||||||
else:
|
|
||||||
return __fail_oss_check__(ctx)
|
|
||||||
|
|
||||||
def check_oss(ctx, dependency_identifier):
|
return fn(ctx, dependency_identifier)
|
||||||
func = check_cc(fragment=load_fragment('oss_audio.c'), use='soundcard',
|
|
||||||
cflags=__get_osscflags__())
|
|
||||||
if func(ctx, dependency_identifier):
|
|
||||||
ctx.define('PATH_DEV_DSP', '/dev/dsp')
|
|
||||||
ctx.define('PATH_DEV_MIXER', '/dev/mixer')
|
|
||||||
|
|
||||||
if ctx.env.DEST_OS in ['openbsd', 'netbsd']:
|
|
||||||
return __check_oss_bsd_library__(ctx, dependency_identifier)
|
|
||||||
else:
|
|
||||||
return __check_oss_headers__(ctx, dependency_identifier)
|
|
||||||
|
|
||||||
return __fail_oss_check__(ctx)
|
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
#if HAVE_SOUNDCARD_H
|
|
||||||
#include <soundcard.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAVE_SYS_SOUNDCARD_H
|
|
||||||
#include <sys/soundcard.h>
|
#include <sys/soundcard.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
return SNDCTL_DSP_SETFRAGMENT;
|
return SNDCTL_DSP_SETFRAGMENT;
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
#if HAVE_SOUNDCARD_H
|
|
||||||
#include <soundcard.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAVE_SYS_SOUNDCARD_H
|
|
||||||
#include <sys/soundcard.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef OPEN_SOUND_SYSTEM
|
|
||||||
int main(void) {{ return 0; }}
|
|
||||||
#else
|
|
||||||
#error Not the real thing
|
|
||||||
#endif
|
|
6
waftools/fragments/oss_audio_sunaudio.c
Normal file
6
waftools/fragments/oss_audio_sunaudio.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <soundcard.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
return SNDCTL_DSP_SETFRAGMENT;
|
||||||
|
}
|
||||||
|
|
40
wscript
40
wscript
@ -116,10 +116,6 @@ iconv support use --disable-iconv.",
|
|||||||
'desc': 'w32 priority API',
|
'desc': 'w32 priority API',
|
||||||
'deps_any': [ 'os-win32', 'os-cygwin'],
|
'deps_any': [ 'os-win32', 'os-cygwin'],
|
||||||
'func': check_true
|
'func': check_true
|
||||||
}, {
|
|
||||||
'name': 'soundcard',
|
|
||||||
'desc': 'soundcard.h',
|
|
||||||
'func': check_headers('soundcard.h', 'sys/soundcard.h')
|
|
||||||
}, {
|
}, {
|
||||||
'name': 'videoio',
|
'name': 'videoio',
|
||||||
'desc': 'videoio.h',
|
'desc': 'videoio.h',
|
||||||
@ -386,10 +382,36 @@ audio_output_features = [
|
|||||||
'desc': 'SDL (1.x)',
|
'desc': 'SDL (1.x)',
|
||||||
'deps_neg': [ 'sdl2' ],
|
'deps_neg': [ 'sdl2' ],
|
||||||
'func': check_pkg_config('sdl')
|
'func': check_pkg_config('sdl')
|
||||||
|
}, {
|
||||||
|
'name': 'oss-audio-native',
|
||||||
|
'desc': 'OSS (platform-specific OSS implementation)',
|
||||||
|
'func': check_cc(header_name='sys/soundcard.h',
|
||||||
|
defines=['PATH_DEV_DSP="/dev/dsp"',
|
||||||
|
'PATH_DEV_MIXER="/dev/mixer"'],
|
||||||
|
fragment=load_fragment('oss_audio.c')),
|
||||||
|
'groups' : [ 'oss-audio' ]
|
||||||
|
}, {
|
||||||
|
'name': 'oss-audio-sunaudio',
|
||||||
|
'desc': 'OSS (emulation on top of SunAudio)',
|
||||||
|
'func': check_cc(header_name='soundcard.h',
|
||||||
|
lib='ossaudio',
|
||||||
|
defines=['PATH_DEV_DSP="/dev/sound"',
|
||||||
|
'PATH_DEV_MIXER="/dev/mixer"'],
|
||||||
|
fragment=load_fragment('oss_audio_sunaudio.c')),
|
||||||
|
'deps_neg': [ 'oss-audio-native' ],
|
||||||
|
'groups' : [ 'oss-audio' ]
|
||||||
|
}, {
|
||||||
|
'name': 'oss-audio-4front',
|
||||||
|
'desc': 'OSS (implementation from opensound.com)',
|
||||||
|
'func': check_oss_4front,
|
||||||
|
'deps_neg': [ 'oss-audio-native', 'oss-audio-sunaudio' ],
|
||||||
|
'groups' : [ 'oss-audio' ]
|
||||||
}, {
|
}, {
|
||||||
'name': '--oss-audio',
|
'name': '--oss-audio',
|
||||||
'desc': 'OSS audio output',
|
'desc': 'OSS audio output',
|
||||||
'func': check_oss
|
'func': check_true,
|
||||||
|
'deps_any': [ 'oss-audio-native', 'oss-audio-sunaudio',
|
||||||
|
'oss-audio-4front' ]
|
||||||
}, {
|
}, {
|
||||||
'name': '--audio-select',
|
'name': '--audio-select',
|
||||||
'desc': 'audio select()',
|
'desc': 'audio select()',
|
||||||
@ -772,6 +794,14 @@ def configure(ctx):
|
|||||||
|
|
||||||
ctx.parse_dependencies(scripting_features)
|
ctx.parse_dependencies(scripting_features)
|
||||||
|
|
||||||
|
ctx.define('HAVE_SYS_SOUNDCARD_H',
|
||||||
|
'(HAVE_OSS_AUDIO_NATIVE || HAVE_OSS_AUDIO_4FRONT)',
|
||||||
|
quote=False)
|
||||||
|
|
||||||
|
ctx.define('HAVE_SOUNDCARD_H',
|
||||||
|
'HAVE_OSS_AUDIO_SUNAUDIO',
|
||||||
|
quote=False)
|
||||||
|
|
||||||
ctx.load('generators.headers')
|
ctx.load('generators.headers')
|
||||||
|
|
||||||
if not ctx.dependency_satisfied('build-date'):
|
if not ctx.dependency_satisfied('build-date'):
|
||||||
|
Loading…
Reference in New Issue
Block a user