audio/jack: add JACK client audiodev

This commit adds a new audiodev backend to allow QEMU to use JACK as
both an audio sink and source.

Signed-off-by: Geoffrey McRae <geoff@hostfission.com>
Message-Id: <20200512101603.E3DB73A038E@moya.office.hostfission.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Geoffrey McRae
2020-04-29 15:53:58 +10:00
committed by Gerd Hoffmann
parent 2f097e1964
commit 2e44570321
6 changed files with 746 additions and 2 deletions

View File

@@ -28,3 +28,8 @@ common-obj-$(CONFIG_AUDIO_SDL) += sdl.mo
sdl.mo-objs = sdlaudio.o
sdl.mo-cflags := $(SDL_CFLAGS)
sdl.mo-libs := $(SDL_LIBS)
# jack module
common-obj-$(CONFIG_AUDIO_JACK) += jack.mo
jack.mo-objs = jackaudio.o
jack.mo-libs := $(JACK_LIBS)

View File

@@ -1969,6 +1969,7 @@ void audio_create_pdos(Audiodev *dev)
CASE(ALSA, alsa, Alsa);
CASE(COREAUDIO, coreaudio, Coreaudio);
CASE(DSOUND, dsound, );
CASE(JACK, jack, Jack);
CASE(OSS, oss, Oss);
CASE(PA, pa, Pa);
CASE(SDL, sdl, );

View File

@@ -330,6 +330,8 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev)
dev->u.coreaudio.TYPE);
case AUDIODEV_DRIVER_DSOUND:
return dev->u.dsound.TYPE;
case AUDIODEV_DRIVER_JACK:
return qapi_AudiodevJackPerDirectionOptions_base(dev->u.jack.TYPE);
case AUDIODEV_DRIVER_OSS:
return qapi_AudiodevOssPerDirectionOptions_base(dev->u.oss.TYPE);
case AUDIODEV_DRIVER_PA:

667
audio/jackaudio.c Normal file

File diff suppressed because it is too large Load Diff

17
configure vendored
View File

@@ -3629,6 +3629,22 @@ for drv in $audio_drv_list; do
oss_libs="$oss_lib"
;;
jack | try-jack)
if $pkg_config jack --exists; then
jack_libs=$($pkg_config jack --libs)
if test "$drv" = "try-jack"; then
audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack/jack/')
fi
else
if test "$drv" = "try-jack"; then
audio_drv_list=$(echo "$audio_drv_list" | sed -e 's/try-jack//')
else
error_exit "$drv check failed" \
"Make sure to have the $drv libs and headers installed."
fi
fi
;;
*)
echo "$audio_possible_drivers" | grep -q "\<$drv\>" || {
error_exit "Unknown driver '$drv' selected" \
@@ -6904,6 +6920,7 @@ echo "PULSE_LIBS=$pulse_libs" >> $config_host_mak
echo "COREAUDIO_LIBS=$coreaudio_libs" >> $config_host_mak
echo "DSOUND_LIBS=$dsound_libs" >> $config_host_mak
echo "OSS_LIBS=$oss_libs" >> $config_host_mak
echo "JACK_LIBS=$jack_libs" >> $config_host_mak
if test "$audio_win_int" = "yes" ; then
echo "CONFIG_AUDIO_WIN_INT=y" >> $config_host_mak
fi

View File

@@ -152,6 +152,55 @@
'*out': 'AudiodevPerDirectionOptions',
'*latency': 'uint32' } }
##
# @AudiodevJackPerDirectionOptions:
#
# Options of the JACK backend that are used for both playback and
# recording.
#
# @server-name: select from among several possible concurrent server instances
# (default: environment variable $JACK_DEFAULT_SERVER if set, else "default")
#
# @client-name: the client name to use. The server will modify this name to
# create a unique variant, if needed unless @exact-name is true (default: the
# guest's name)
#
# @connect-ports: if set, a regular expression of JACK client port name(s) to
# monitor for and automatically connect to
#
# @start-server: start a jack server process if one is not already present
# (default: false)
#
# @exact-name: use the exact name requested otherwise JACK automatically
# generates a unique one, if needed (default: false)
#
# Since: 5.1
##
{ 'struct': 'AudiodevJackPerDirectionOptions',
'base': 'AudiodevPerDirectionOptions',
'data': {
'*server-name': 'str',
'*client-name': 'str',
'*connect-ports': 'str',
'*start-server': 'bool',
'*exact-name': 'bool' } }
##
# @AudiodevJackOptions:
#
# Options of the JACK audio backend.
#
# @in: options of the capture stream
#
# @out: options of the playback stream
#
# Since: 5.1
##
{ 'struct': 'AudiodevJackOptions',
'data': {
'*in': 'AudiodevJackPerDirectionOptions',
'*out': 'AudiodevJackPerDirectionOptions' } }
##
# @AudiodevOssPerDirectionOptions:
#
@@ -297,11 +346,13 @@
#
# An enumeration of possible audio backend drivers.
#
# @jack: JACK audio backend (since 5.1)
#
# Since: 4.0
##
{ 'enum': 'AudiodevDriver',
'data': [ 'none', 'alsa', 'coreaudio', 'dsound', 'oss', 'pa', 'sdl',
'spice', 'wav' ] }
'data': [ 'none', 'alsa', 'coreaudio', 'dsound', 'jack', 'oss', 'pa',
'sdl', 'spice', 'wav' ] }
##
# @Audiodev:
@@ -327,6 +378,7 @@
'alsa': 'AudiodevAlsaOptions',
'coreaudio': 'AudiodevCoreaudioOptions',
'dsound': 'AudiodevDsoundOptions',
'jack': 'AudiodevJackOptions',
'oss': 'AudiodevOssOptions',
'pa': 'AudiodevPaOptions',
'sdl': 'AudiodevGenericOptions',