jack: Initial shot at a JACK audio target.

http://jackaudio.org/

Fixes Bugzilla #2163.
(with several more commits following to improve this code.)
This commit is contained in:
Ryan C. Gordon
2017-06-08 13:27:58 -04:00
parent cb591ee611
commit d9039f2396
10 changed files with 763 additions and 1 deletions

View File

@@ -279,6 +279,8 @@ set_option(SDL_DLOPEN "Use dlopen for shared object loading" ${SDL_DLOP
set_option(OSS "Support the OSS audio API" ${UNIX_SYS})
set_option(ALSA "Support the ALSA audio API" ${UNIX_SYS})
dep_option(ALSA_SHARED "Dynamically load ALSA audio support" ON "ALSA" OFF)
set_option(JACK "Support the JACK audio API" ${UNIX_SYS})
dep_option(JACK_SHARED "Dynamically load JACK audio support" ON "JACK" OFF)
set_option(ESD "Support the Enlightened Sound Daemon" ${UNIX_SYS})
dep_option(ESD_SHARED "Dynamically load ESD audio support" ON "ESD" OFF)
set_option(PULSEAUDIO "Use PulseAudio" ${UNIX_SYS})
@@ -895,6 +897,7 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID)
endif()
CheckOSS()
CheckALSA()
CheckJACK()
CheckPulseAudio()
CheckESD()
CheckARTS()

View File

@@ -158,6 +158,36 @@ macro(CheckPulseAudio)
endif()
endmacro()
# Requires:
# - PkgCheckModules
# Optional:
# - JACK_SHARED opt
# - HAVE_DLOPEN opt
macro(CheckJACK)
if(JACK)
pkg_check_modules(PKG_JACK jack)
if(PKG_JACK_FOUND)
set(HAVE_JACK TRUE)
file(GLOB JACK_SOURCES ${SDL2_SOURCE_DIR}/src/audio/jack/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${JACK_SOURCES})
set(SDL_AUDIO_DRIVER_JACK 1)
list(APPEND EXTRA_CFLAGS ${PKG_JACK_CFLAGS})
if(JACK_SHARED)
if(NOT HAVE_DLOPEN)
message_warn("You must have SDL_LoadObject() support for dynamic JACK audio loading")
else()
FindLibraryAndSONAME("jack")
set(SDL_AUDIO_DRIVER_JACK_DYNAMIC "\"${JACK_LIB_SONAME}\"")
set(HAVE_JACK_SHARED TRUE)
endif()
else()
list(APPEND EXTRA_LDFLAGS ${PKG_JACK_LDFLAGS})
endif()
set(HAVE_SDL_AUDIO TRUE)
endif()
endif()
endmacro()
# Requires:
# - PkgCheckModules
# Optional:

120
configure vendored
View File

@@ -658,10 +658,10 @@ X_PRE_LIBS
X_CFLAGS
XMKMF
ARTSCONFIG
PKG_CONFIG
ESD_LIBS
ESD_CFLAGS
ESD_CONFIG
PKG_CONFIG
ALSA_LIBS
ALSA_CFLAGS
POW_LIB
@@ -806,6 +806,8 @@ with_alsa_prefix
with_alsa_inc_prefix
enable_alsatest
enable_alsa_shared
enable_jack
enable_jack_shared
enable_esd
with_esd_prefix
with_esd_exec_prefix
@@ -1535,6 +1537,8 @@ Optional Features:
--enable-alsa support the ALSA audio API [[default=yes]]
--disable-alsatest Do not try to compile and run a test Alsa program
--enable-alsa-shared dynamically load ALSA audio support [[default=yes]]
--enable-jack use JACK audio [[default=yes]]
--enable-jack-shared dynamically load JACK audio support [[default=yes]]
--enable-esd support the Enlightened Sound Daemon [[default=yes]]
--disable-esdtest Do not try to compile and run a test ESD program
--enable-esd-shared dynamically load ESD audio support [[default=yes]]
@@ -17870,6 +17874,119 @@ _ACEOF
fi
}
CheckJACK()
{
# Check whether --enable-jack was given.
if test "${enable_jack+set}" = set; then :
enableval=$enable_jack;
else
enable_jack=yes
fi
if test x$enable_audio = xyes -a x$enable_jack = xyes; then
audio_jack=no
JACK_REQUIRED_VERSION=0.125
# Extract the first word of "pkg-config", so it can be a program name with args.
set dummy pkg-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_PKG_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
case $PKG_CONFIG in
[\\/]* | ?:[\\/]*)
ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
;;
esac
fi
PKG_CONFIG=$ac_cv_path_PKG_CONFIG
if test -n "$PKG_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
$as_echo "$PKG_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for JACK $JACK_REQUIRED_VERSION support" >&5
$as_echo_n "checking for JACK $JACK_REQUIRED_VERSION support... " >&6; }
if test x$PKG_CONFIG != xno; then
if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $JACK_REQUIRED_VERSION jack; then
JACK_CFLAGS=`$PKG_CONFIG --cflags jack`
JACK_LIBS=`$PKG_CONFIG --libs jack`
audio_jack=yes
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $audio_jack" >&5
$as_echo "$audio_jack" >&6; }
if test x$audio_jack = xyes; then
# Check whether --enable-jack-shared was given.
if test "${enable_jack_shared+set}" = set; then :
enableval=$enable_jack_shared;
else
enable_jack_shared=yes
fi
jack_lib=`find_lib "libjack.so.*" "$JACK_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`
$as_echo "#define SDL_AUDIO_DRIVER_JACK 1" >>confdefs.h
SOURCES="$SOURCES $srcdir/src/audio/jack/*.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $JACK_CFLAGS"
if test x$have_loadso != xyes && \
test x$enable_jack_shared = xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic JACK audio loading" >&5
$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic JACK audio loading" >&2;}
fi
if test x$have_loadso = xyes && \
test x$enable_jack_shared = xyes && test x$jack_lib != x; then
echo "-- dynamic libjack -> $jack_lib"
cat >>confdefs.h <<_ACEOF
#define SDL_AUDIO_DRIVER_JACK_DYNAMIC "$jack_lib"
_ACEOF
SUMMARY_audio="${SUMMARY_audio} jack(dynamic)"
case "$host" in
# On Solaris, jack must be linked deferred explicitly
# to prevent undefined symbol failures.
*-*-solaris*)
JACK_LIBS=`echo $JACK_LIBS | sed 's/\-l/-Wl,-l/g'`
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-zdeferred $JACK_LIBS -Wl,-znodeferred"
esac
else
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $JACK_LIBS"
SUMMARY_audio="${SUMMARY_audio} jack"
fi
have_audio=yes
fi
fi
}
CheckESD()
{
# Check whether --enable-esd was given.
@@ -23264,6 +23381,7 @@ case "$host" in
CheckOSS
CheckALSA
CheckPulseAudio
CheckJACK
CheckARTSC
CheckESD
CheckNAS

View File

@@ -839,6 +839,63 @@ AC_HELP_STRING([--enable-alsa-shared], [dynamically load ALSA audio support [[de
fi
}
dnl Find JACK Audio
CheckJACK()
{
AC_ARG_ENABLE(jack,
AC_HELP_STRING([--enable-jack], [use JACK audio [[default=yes]]]),
, enable_jack=yes)
if test x$enable_audio = xyes -a x$enable_jack = xyes; then
audio_jack=no
JACK_REQUIRED_VERSION=0.125
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
AC_MSG_CHECKING(for JACK $JACK_REQUIRED_VERSION support)
if test x$PKG_CONFIG != xno; then
if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $JACK_REQUIRED_VERSION jack; then
JACK_CFLAGS=`$PKG_CONFIG --cflags jack`
JACK_LIBS=`$PKG_CONFIG --libs jack`
audio_jack=yes
fi
fi
AC_MSG_RESULT($audio_jack)
if test x$audio_jack = xyes; then
AC_ARG_ENABLE(jack-shared,
AC_HELP_STRING([--enable-jack-shared], [dynamically load JACK audio support [[default=yes]]]),
, enable_jack_shared=yes)
jack_lib=[`find_lib "libjack.so.*" "$JACK_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
AC_DEFINE(SDL_AUDIO_DRIVER_JACK, 1, [ ])
SOURCES="$SOURCES $srcdir/src/audio/jack/*.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $JACK_CFLAGS"
if test x$have_loadso != xyes && \
test x$enable_jack_shared = xyes; then
AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic JACK audio loading])
fi
if test x$have_loadso = xyes && \
test x$enable_jack_shared = xyes && test x$jack_lib != x; then
echo "-- dynamic libjack -> $jack_lib"
AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_JACK_DYNAMIC, "$jack_lib", [ ])
SUMMARY_audio="${SUMMARY_audio} jack(dynamic)"
case "$host" in
# On Solaris, jack must be linked deferred explicitly
# to prevent undefined symbol failures.
*-*-solaris*)
JACK_LIBS=`echo $JACK_LIBS | sed 's/\-l/-Wl,-l/g'`
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-zdeferred $JACK_LIBS -Wl,-znodeferred"
esac
else
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $JACK_LIBS"
SUMMARY_audio="${SUMMARY_audio} jack"
fi
have_audio=yes
fi
fi
}
dnl Find the ESD includes and libraries
CheckESD()
{
@@ -3035,6 +3092,7 @@ case "$host" in
CheckOSS
CheckALSA
CheckPulseAudio
CheckJACK
CheckARTSC
CheckESD
CheckNAS

View File

@@ -205,6 +205,8 @@
#cmakedefine SDL_AUDIO_DRIVER_ANDROID @SDL_AUDIO_DRIVER_ANDROID@
#cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@
#cmakedefine SDL_AUDIO_DRIVER_ALSA_DYNAMIC @SDL_AUDIO_DRIVER_ALSA_DYNAMIC@
#cmakedefine SDL_AUDIO_DRIVER_JACK @SDL_AUDIO_DRIVER_JACK@
#cmakedefine SDL_AUDIO_DRIVER_JACK_DYNAMIC @SDL_AUDIO_DRIVER_JACK_DYNAMIC@
#cmakedefine SDL_AUDIO_DRIVER_ARTS @SDL_AUDIO_DRIVER_ARTS@
#cmakedefine SDL_AUDIO_DRIVER_ARTS_DYNAMIC @SDL_AUDIO_DRIVER_ARTS_DYNAMIC@
#cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO @SDL_AUDIO_DRIVER_PULSEAUDIO@

View File

@@ -204,6 +204,8 @@
/* Enable various audio drivers */
#undef SDL_AUDIO_DRIVER_ALSA
#undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
#undef SDL_AUDIO_DRIVER_JACK
#undef SDL_AUDIO_DRIVER_JACK_DYNAMIC
#undef SDL_AUDIO_DRIVER_ARTS
#undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
#undef SDL_AUDIO_DRIVER_PULSEAUDIO

View File

@@ -101,6 +101,9 @@ static const AudioBootStrap *const bootstrap[] = {
#if SDL_AUDIO_DRIVER_EMSCRIPTEN
&EMSCRIPTENAUDIO_bootstrap,
#endif
#if SDL_AUDIO_DRIVER_JACK
&JACK_bootstrap,
#endif
#if SDL_AUDIO_DRIVER_DISK
&DISKAUDIO_bootstrap,
#endif
@@ -723,6 +726,7 @@ SDL_RunAudio(void *devicep)
return 0;
}
/* !!! FIXME: this needs to deal with device spec changes. */
/* The general capture thread function */
static int SDLCALL
SDL_CaptureAudio(void *devicep)

View File

@@ -182,6 +182,7 @@ typedef struct AudioBootStrap
/* Not all of these are available in a given build. Use #ifdefs, etc. */
extern AudioBootStrap PULSEAUDIO_bootstrap;
extern AudioBootStrap ALSA_bootstrap;
extern AudioBootStrap JACK_bootstrap;
extern AudioBootStrap SNDIO_bootstrap;
extern AudioBootStrap NETBSDAUDIO_bootstrap;
extern AudioBootStrap DSP_bootstrap;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,41 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef _SDL_jackaudio_h
#define _SDL_jackaudio_h
#include <jack/jack.h>
#include "../SDL_sysaudio.h"
/* Hidden "this" pointer for the audio functions */
#define _THIS SDL_AudioDevice *this
struct SDL_PrivateAudioData
{
SDL_sem *iosem;
float *iobuffer;
const char **devports;
jack_port_t **sdlports;
};
#endif /* _SDL_jackaudio_h */
/* vi: set ts=4 sw=4 expandtab: */