audio/jack: add JACK client audiodev
PATCH v8 1/1 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.
--- audio/Makefile.objs | 5 + audio/audio.c | 1 + audio/audio_template.h | 2 + audio/jackaudio.c | 677 +++++++++++++++++++++++++++++++++++++++++ configure | 17 ++ qapi/audio.json | 56 +++- 6 files changed, 756 insertions(+), 2 deletions(-) create mode 100644 audio/jackaudio.c
audio/Makefile.objs +5 -0
@@ -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)
audio/audio.c +1 -0
@@ -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, );
audio/audio_template.h +2 -0
@@ -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 :
audio/jackaudio.c new file +677 -0
677 lines not on this page · raw message
configure +17 -0
@@ -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
qapi/audio.json +54 -2
77 lines not on this page · raw message
Signature · 1 line
2.20.1
Quoted 4 lines · Geoffrey McRae
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 <[email protected]>
Quoted 9 lines
--- audio/Makefile.objs | 5 + audio/audio.c | 1 + audio/audio_template.h | 2 + audio/jackaudio.c | 677 +++++++++++++++++++++++++++++++++++++++++ configure | 17 ++ qapi/audio.json | 56 +++- 6 files changed, 756 insertions(+), 2 deletions(-) create mode 100644 audio/jackaudio.c
Cool! Out of interest, which emulated audio device do you use and have you had issues with buffer sizes/latency?
I haven't reviewed in depth but in general this looks good.
audio/jackaudio.c line 51
Quoted 4 lines
audio/jackaudio.c new file +4
-0+typedef struct QJackBuffer { + int channels; + int frames; + _Atomic(int) used;
stdatomic.h isn't used directly in QEMU. Can you use "qemu/atomic.h" instead?
audio/jackaudio.c line 132
Quoted 5 lines
audio/jackaudio.c new file +5
-0+static inline int qjack_buffer_used (QJackBuffer *buffer) +{ +assert (buffer->data); +return atomic_load_explicit (&buffer->used, memory_order_relaxed); +}
Is this function used?
Quoted 16 lines · Stefan Hajnoczi
Quoted 4 lines · Geoffrey McRae
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 <[email protected]>Quoted 10 lines
--- audio/Makefile.objs | 5 + audio/audio.c | 1 + audio/audio_template.h | 2 + audio/jackaudio.c | 677 +++++++++++++++++++++++++++++++++++++++++ configure | 17 ++ qapi/audio.json | 56 +++- 6 files changed, 756 insertions(+), 2 deletions(-) create mode 100644 audio/jackaudio.c
Quoted 2 lines
Cool! Out of interest, which emulated audio device do you use and have you had issues with buffer sizes/latency?
I now use the ICH9 device, however, I had buffer size issues with usbaudio.
Quoted 10 lines
I haven't reviewed in depth but in general this looks good.
audio/jackaudio.c line 51
Quoted 4 lines
audio/jackaudio.c new file +4
-0+typedef struct QJackBuffer { + int channels; + int frames; + _Atomic(int) used;
stdatomic.hisn't used directly in QEMU. Can you use "qemu/atomic.h" instead?
Sure.
Quoted 8 lines
audio/jackaudio.c line 132
Quoted 6 lines
audio/jackaudio.c new file +5
-0+static inline int qjack_buffer_used (QJackBuffer *buffer) +{ +assert (buffer->data); +return atomic_load_explicit (&buffer->used, memory_order_relaxed); +}Is this function used?
Nope, left behind from a prior implementation, I will remove it.
Quoted 12 lines · Geoffrey McRae
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 <[email protected]>---
+++
b/qapi/audio.jsonqapi/audio.json +1
-0@@ -152,6 +152,55 @@ '*out': 'AudiodevPerDirectionOptions', '*latency': 'uint32' } } +##
qapi/audio.json line 165
Quoted 10 lines
qapi/audio.json +10
-0+# @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
Minor typos: @exact_name does not match...
qapi/audio.json line 171
Quoted 6 lines
qapi/audio.json +6
-0+# 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 lready present
already
qapi/audio.json line 175
Quoted 4 lines
qapi/audio.json +4
-0+# (default: false) +# +# @exact-name: use the exact name requested otherwise JACK automatically +# generates a unique one, if needed (default: false)
...the actual parameter @exact-name.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org