audio: Add sndio backend
PATCH v3 1/1 audio: Add sndio backend
sndio is the native API used by OpenBSD, although it has been ported to other *BSD's and Linux (packages for Ubuntu, Debian, Void, Arch, etc.).
---
References to the previous patch versions and related discussions are here:
https://marc.info/?l=qemu-devel&m=163973393011543 (v2)
https://marc.info/?l=qemu-devel&m=163626248712444 (initial patch)
Here are the changes between v2 and v3 of this patch:
- fixed of typos in file-names in MAINTAINERS
- added Gerd Hoffmann to the M: entry in MAINTAINERS
- added missin S: entry in MAINTAINERS
- removed unused #include "qemu-common.h"
- bumped "Since:" version to 7.2 in qapi/audio.json
- regenerated scripts/meson-buildoptions.sh
- implement buffer_get_free() method, introduced by commit 9833438ef624155de879d4ed57ecfcd3464a0bbe
audio: restore mixing-engine playback buffer size
Running "make update-buildoptions" triggered unrelated changes of scripts/meson-buildoptions.sh, that I removed from the commit as they are not related to sndio.
Tested on OpenBSD, still works as expected :-)
Regards,
Alexandre
MAINTAINERS | 7 + audio/audio.c | 1 + audio/audio_template.h | 2 + audio/meson.build | 1 + audio/sndioaudio.c | 565 ++++++++++++++++++++++++++++++++++ meson.build | 9 +- meson_options.txt | 4 +- qapi/audio.json | 25 +- qemu-options.hx | 16 + scripts/meson-buildoptions.sh | 7 +- 10 files changed, 632 insertions(+), 5 deletions(-) create mode 100644 audio/sndioaudio.c
MAINTAINERS +7 -0
@@ -2438,6 +2438,7 @@ X: audio/jackaudio.c X: audio/ossaudio.c X: audio/paaudio.c X: audio/sdlaudio.c +X: audio/sndioaudio.c X: audio/spiceaudio.c F: qapi/audio.json
@@ -2482,6 +2483,12 @@ R: Thomas Huth <[email protected]> S: Odd Fixes F: audio/sdlaudio.c +Sndio Audio backend +M: Gerd Hoffmann <[email protected]> +R: Alexandre Ratchov <[email protected]> +S: Odd Fixes +F: audio/sndioaudio.c + Block layer core M: Kevin Wolf <[email protected]> M: Hanna Reitz <[email protected]>
audio/audio.c +1 -0
@@ -2029,6 +2029,7 @@ void audio_create_pdos(Audiodev *dev)CASE (OSS , oss, Oss);CASE (PA , pa, Pa);CASE (SDL , sdl, Sdl); + CASE(SNDIO, sndio, ); CASE(SPICE, spice, ); CASE(WAV, wav, );
audio/audio_template.h +2 -0
@@ -336,6 +336,8 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev)return qapi_AudiodevPaPerDirectionOptions_base (dev->u.pa.TYPE);case AUDIODEV_DRIVER_SDL :return qapi_AudiodevSdlPerDirectionOptions_base (dev->u.sdl.TYPE); +case AUDIODEV_DRIVER_SNDIO : +return dev->u.sndio.TYPE;case AUDIODEV_DRIVER_SPICE :return dev->u.spice.TYPE;case AUDIODEV_DRIVER_WAV :
audio/meson.build +1 -0
@@ -17,6 +17,7 @@ foreach m : [ ['pa', pulse, files('paaudio.c')], ['sdl', sdl, files('sdlaudio.c')], ['jack', jack, files('jackaudio.c')], + ['sndio', sndio, files('sndioaudio.c')], ['spice', spice, files('spiceaudio.c')] ] if m[1].found()
audio/sndioaudio.c new file +565 -0
565 lines not on this page · raw message
meson.build +8 -1
@@ -681,6 +681,11 @@ if not get_option('jack').auto() or have_system jack = dependency('jack', required: get_option('jack'), method: 'pkg-config', kwargs: static_kwargs) endif +sndio = not_found +if not get_option('sndio').auto() or have_system + sndio = dependency('sndio', required: get_option('sndio'), + method: 'pkg-config', kwargs: static_kwargs) +endif spice_protocol = not_found if not get_option('spice_protocol').auto() or have_system
@@ -1597,6 +1602,7 @@ if have_system 'oss': oss.found(), 'pa': pulse.found(), 'sdl': sdl.found(), + 'sndio': sndio.found(), } foreach k, v: audio_drivers_available config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
@@ -1604,7 +1610,7 @@ if have_system # Default to native drivers first, OSS second, SDL third audio_drivers_priority = \ - [ 'pa', 'coreaudio', 'dsound', 'oss' ] + \ + [ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \ (targetos == 'linux' ? [] : [ 'sdl' ]) audio_drivers_default = [] foreach k: audio_drivers_priority
@@ -3928,6 +3934,7 @@ if vnc.found() endif if targetos not in ['darwin', 'haiku', 'windows'] summary_info += {'OSS support': oss} + summary_info += {'sndio support': sndio} elif targetos == 'darwin' summary_info += {'CoreAudio support': coreaudio} elif targetos == 'windows'
meson_options.txt +3 -1
@@ -21,7 +21,7 @@ option('tls_priority', type : 'string', value : 'NORMAL', option('default_devices', type : 'boolean', value : true, description: 'Include a default selection of devices in emulators') option('audio_drv_list', type: 'array', value: ['default'], - choices: ['alsa', 'coreaudio', 'default', 'dsound', 'jack', 'oss', 'pa', 'sdl'], + choices: ['alsa', 'coreaudio', 'default', 'dsound', 'jack', 'oss', 'pa', 'sdl', 'sndio'], description: 'Set audio driver list') option('block_drv_rw_whitelist', type : 'string', value : '', description: 'set block driver read-write whitelist (by default affects only QEMU, not tools like qemu-img)')
@@ -240,6 +240,8 @@ option('oss', type: 'feature', value: 'auto', description: 'OSS sound support') option('pa', type: 'feature', value: 'auto', description: 'PulseAudio sound support') +option('sndio', type: 'feature', value: 'auto', + description: 'sndio sound support') option('vhost_kernel', type: 'feature', value: 'auto', description: 'vhost kernel backend support')
qapi/audio.json +24 -1
@@ -106,6 +106,28 @@ '*out': 'AudiodevAlsaPerDirectionOptions', '*threshold': 'uint32' } } +## +# @AudiodevSndioOptions: +# +# Options of the sndio audio backend. +# +# @in: options of the capture stream +# +# @out: options of the playback stream +# +# @dev: the name of the sndio device to use (default 'default') +# +# @latency: play buffer size (in microseconds) +# +# Since: 7.2 +## +{ 'struct': 'AudiodevSndioOptions', + 'data': { + '*in': 'AudiodevPerDirectionOptions', + '*out': 'AudiodevPerDirectionOptions', + '*dev': 'str', + '*latency': 'uint32'} } + ## # @AudiodevCoreaudioPerDirectionOptions: #
@@ -387,7 +409,7 @@ ## { 'enum': 'AudiodevDriver', 'data': [ 'none', 'alsa', 'coreaudio', 'dbus', 'dsound', 'jack', 'oss', 'pa', - 'sdl', 'spice', 'wav' ] } + 'sdl', 'sndio', 'spice', 'wav' ] } ## # @Audiodev:
@@ -418,5 +440,6 @@ 'oss': 'AudiodevOssOptions', 'pa': 'AudiodevPaOptions', 'sdl': 'AudiodevSdlOptions', + 'sndio': 'AudiodevSndioOptions', 'spice': 'AudiodevGenericOptions', 'wav': 'AudiodevWavOptions' } }
qemu-options.hx +16 -0
@@ -767,6 +767,9 @@ DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, "-audiodev sdl,id=id[,prop[=value][,...]]\n" " in|out.buffer-count= number of buffers\n" #endif +#ifdef CONFIG_AUDIO_SNDIO + "-audiodev sndio,id=id[,prop[=value][,...]]\n" +#endif #ifdef CONFIG_SPICE "-audiodev spice,id=id[,prop[=value][,...]]\n" #endif
@@ -933,6 +936,19 @@ SRST ``in|out.buffer-count=count`` Sets the count of the buffers. +``-audiodev sndio,id=id[,prop[=value][,...]]`` + Creates a backend using SNDIO. This backend is available on + OpenBSD and most other Unix-like systems. + + Sndio specific options are: + + ``in|out.dev=device`` + Specify the sndio device to use for input and/or output. Default + is ``default``. + + ``in|out.latency=usecs`` + Sets the desired period length in microseconds. + ``-audiodev spice,id=id[,prop[=value][,...]]`` Creates a backend that sends audio through SPICE. This backend requires ``-spice`` and automatically selected in that case, so
scripts/meson-buildoptions.sh +5 -2
@@ -1,7 +1,7 @@ # This file is generated by meson-buildoptions.py, do not edit! meson_options_help() { - printf "%s\n" ' --audio-drv-list=CHOICES Set audio driver list [default] (choices:' - printf "%s\n" ' alsa/coreaudio/default/dsound/jack/oss/pa/sdl)' + printf "%s\n" ' --audio-drv-list=CHOICES Set audio driver list [default] (choices: alsa/co' + printf "%s\n" ' reaudio/default/dsound/jack/oss/pa/sdl/sndio)' printf "%s\n" ' --block-drv-ro-whitelist=VALUE' printf "%s\n" ' set block driver read-only whitelist (by default' printf "%s\n" ' affects only QEMU, not tools like qemu-img)'
@@ -144,6 +144,7 @@ meson_options_help() { printf "%s\n" ' slirp-smbd use smbd (at path --smbd=*) in slirp networking' printf "%s\n" ' smartcard CA smartcard emulation support' printf "%s\n" ' snappy snappy compression support' + printf "%s\n" ' sndio sndio sound support' printf "%s\n" ' sparse sparse checker' printf "%s\n" ' spice Spice server support' printf "%s\n" ' spice-protocol Spice protocol support'
@@ -393,6 +394,8 @@ _meson_option_parse() { --disable-smartcard) printf "%s" -Dsmartcard=disabled ;; --enable-snappy) printf "%s" -Dsnappy=enabled ;; --disable-snappy) printf "%s" -Dsnappy=disabled ;; + --enable-sndio) printf "%s" -Dsndio=enabled ;; + --disable-sndio) printf "%s" -Dsndio=disabled ;; --enable-sparse) printf "%s" -Dsparse=enabled ;; --disable-sparse) printf "%s" -Dsparse=disabled ;; --sphinx-build=*) quote_sh "-Dsphinx_build=$2" ;;
Signature · 1 line
2.37.2
Am 07.09.22 um 15:23 schrieb Alexandre Ratchov:
Quoted 46 lines
sndio is the native API used by OpenBSD, although it has been ported to other *BSD's and Linux (packages for Ubuntu, Debian, Void, Arch, etc.).
Signed-off-by Brad Smith<[email protected]>Signed-off-by Alexandre Ratchov<[email protected]>---
References to the previous patch versions and related discussions are here:
https://marc.info/?l=qemu-devel&m=163973393011543 (v2)
https://marc.info/?l=qemu-devel&m=163626248712444 (initial patch)Here are the changes between v2 and v3 of this patch:
- fixed of typos in file-names in
MAINTAINERS
- added Gerd Hoffmann to the M: entry inMAINTAINERS
- added missin S: entry inMAINTAINERS
- removed unused #include "qemu-common.h"
- bumped "Since:" version to 7.2 inqapi/audio.json
- regeneratedscripts/meson-buildoptions.sh
- implementbuffer_get_free()method, introduced by commit9833438ef624155de879d4ed57ecfcd3464a0bbeaudio: restore mixing-engine playback buffer size
Running "make update-buildoptions" triggered unrelated changes of
scripts/meson-buildoptions.sh, that I removed from the commit as they are not related to sndio.Tested on OpenBSD, still works as expected :-)
Regards,
AlexandreMAINTAINERS | 7 + audio/audio.c | 1 + audio/audio_template.h | 2 + audio/meson.build | 1 + audio/sndioaudio.c | 565 ++++++++++++++++++++++++++++++++++ meson.build | 9 +- meson_options.txt | 4 +- qapi/audio.json | 25 +- qemu-options.hx | 16 + scripts/meson-buildoptions.sh | 7 +- 10 files changed, 632 insertions(+), 5 deletions(-)
Quoted 2 lines
create mode 100644
audio/sndioaudio.c
Tested again on Linux.
Quoted 50 lines · Volker Rümelin
Am 07.09.22 um 15:23 schrieb Alexandre Ratchov:
Quoted 45 lines
sndio is the native API used by OpenBSD, although it has been ported to other *BSD's and Linux (packages for Ubuntu, Debian, Void, Arch, etc.).
Signed-off-by Brad Smith<[email protected]>Signed-off-by Alexandre Ratchov<[email protected]>---
References to the previous patch versions and related discussions are here:
https://marc.info/?l=qemu-devel&m=163973393011543 (v2)
https://marc.info/?l=qemu-devel&m=163626248712444 (initial patch)Here are the changes between v2 and v3 of this patch:
- fixed of typos in file-names in
MAINTAINERS
- added Gerd Hoffmann to the M: entry inMAINTAINERS
- added missin S: entry inMAINTAINERS
- removed unused #include "qemu-common.h"
- bumped "Since:" version to 7.2 inqapi/audio.json
- regeneratedscripts/meson-buildoptions.sh
- implementbuffer_get_free()method, introduced by commit9833438ef624155de879d4ed57ecfcd3464a0bbeaudio: restore mixing-engine playback buffer size
Running "make update-buildoptions" triggered unrelated changes of
scripts/meson-buildoptions.sh, that I removed from the commit as they are not related to sndio.Tested on OpenBSD, still works as expected :-)
Regards,
AlexandreMAINTAINERS | 7 +
audio/audio.c | 1 + audio/audio_template.h | 2 +
audio/meson.build | 1 +
audio/sndioaudio.c | 565 ++++++++++++++++++++++++++++++++++ meson.build | 9 +-
meson_options.txt | 4 +-
qapi/audio.json | 25 +-
qemu-options.hx | 16 +scripts/meson-buildoptions.sh| 7 +-Quoted 3 lines
10 files changed, 632 insertions(+), 5 deletions(-)create mode 100644
audio/sndioaudio.c
Quoted 4 lines
Tested again on Linux.
Reviewed-by Volker Rümelin <[email protected]>Tested-by Volker Rümelin <[email protected]>
ping.