audio: Add sndio backend
PATCH v2 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.).
---
Thank you for the reviews and all the comments. Here's a second diff with all the suggested changes:
- Replace ISC license by SPDX-License-Identifier header
- Fix units (milli- vs micro-) in comment about SNDIO_LATENCY_US
- Drop outdated comment about the "size" argument of sndio_get_buffer_out()
- Fix AUDIO_FORMAT_U32 handling (missing "break" statement)
- Set {read,write] methods to audio_generic_{read,write} (fixes craches)
- Check if backend is enabled in sndio_poll_event()
- Use https://sndio.org in description
- Mark options as available after 7.0 release (instead of 6.2)
- Describe sndio-specific options (dev, latency) in qemu-options.hx
- Add myself as reviewer to MAINTAINERS
- Style fixes: no space after function names, use 4-space indent
- Don't use "return foo()" if foo() returns void
- Include backend to audio_drivers_priority[]
Tested on OpenBSD, works as expected!
MAINTAINERS | 5 + audio/audio.c | 1 + audio/audio_template.h | 2 + audio/meson.build | 1 + audio/sndioaudio.c | 555 +++++++++++++++++++++++++++++++++++++++++ meson.build | 9 +- meson_options.txt | 4 +- qapi/audio.json | 25 +- qemu-options.hx | 16 ++ tests/vm/freebsd | 3 + 10 files changed, 618 insertions(+), 3 deletions(-) create mode 100644 audio/sndioaudio.c
MAINTAINERS +5 -0
@@ -2307,6 +2307,7 @@ X: audio/jackaudio.c X: audio/ossaudio.c X: audio/paaudio.c X: audio/sdlaudio.c +X: audio/sndio.c X: audio/spiceaudio.c F: qapi/audio.json
@@ -2349,6 +2350,10 @@ R: Thomas Huth <[email protected]> S: Odd Fixes F: audio/sdlaudio.c +Sndio Audio backend +R: Alexandre Ratchov <[email protected]> +F: audio/sndio.c + Block layer core M: Kevin Wolf <[email protected]> M: Hanna Reitz <[email protected]>
audio/audio.c +1 -0
@@ -2005,6 +2005,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
@@ -337,6 +337,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 +555 -0
555 lines not on this page · raw message
meson.build +8 -1
@@ -554,6 +554,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
@@ -1311,6 +1316,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)
@@ -1318,7 +1324,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
@@ -3385,6 +3391,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
@@ -13,7 +13,7 @@ option('sphinx_build', type : 'string', value : '', 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('fuzzing_engine', type : 'string', value : '', description: 'fuzzing engine library for OSS-Fuzz')
@@ -184,6 +184,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_user_blk_server', type: 'feature', value: 'auto', description: 'build vhost-user-blk server')
qapi/audio.json +24 -1
@@ -105,6 +105,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.0 +## +{ 'struct': 'AudiodevSndioOptions', + 'data': { + '*in': 'AudiodevPerDirectionOptions', + '*out': 'AudiodevPerDirectionOptions', + '*dev': 'str', + '*latency': 'uint32'} } + ## # @AudiodevCoreaudioPerDirectionOptions: #
@@ -387,7 +409,7 @@ ## { 'enum': 'AudiodevDriver', 'data': [ 'none', 'alsa', 'coreaudio', 'dsound', 'jack', 'oss', 'pa', - 'sdl', 'spice', 'wav' ] } + 'sdl', 'sndio', 'spice', 'wav' ] } ## # @Audiodev:
@@ -417,5 +439,6 @@ 'oss': 'AudiodevOssOptions', 'pa': 'AudiodevPaOptions', 'sdl': 'AudiodevSdlOptions', + 'sndio': 'AudiodevSndioOptions', 'spice': 'AudiodevGenericOptions', 'wav': 'AudiodevWavOptions' } }
qemu-options.hx +16 -0
@@ -657,6 +657,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
@@ -820,6 +823,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
tests/vm/freebsd +3 -0
@@ -63,6 +63,9 @@ class FreeBSDVM(basevm.BaseVM): # libs: migration "zstd", + + # libs: sndio + "sndio", ] # TODO: Enable gnutls again once FreeBSD's libtasn1 got fixed
Signature · 1 line
2.34.0
Hi Alexandre,
Quoted 37 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]>---
Thank you for the reviews and all the comments. Here's a second diff with all the suggested changes:
- Replace ISC license by SPDX-License-Identifier header
- Fix units (milli- vs micro-) in comment aboutSNDIO_LATENCY_US
- Drop outdated comment about the "size" argument ofsndio_get_buffer_out()
- FixAUDIO_FORMAT_U32handling (missing "break" statement)
- Set {read,write] methods to audio_generic_{read,write} (fixes craches)
- Check if backend is enabled insndio_poll_event()
- Use https://sndio.org in description
- Mark options as available after 7.0 release (instead of 6.2)
- Describe sndio-specific options (dev, latency) in qemu-options.hx
- Add myself as reviewer toMAINTAINERS
- Style fixes: no space after function names, use 4-space indent
- Don't use "returnfoo()" iffoo()returns void
- Include backend to audio_drivers_priority[]Tested on OpenBSD, works as expected!
MAINTAINERS | 5 + audio/audio.c | 1 + audio/audio_template.h | 2 + audio/meson.build | 1 + audio/sndioaudio.c | 555 +++++++++++++++++++++++++++++++++++++++++ meson.build | 9 +- meson_options.txt | 4 +- qapi/audio.json | 25 +- qemu-options.hx | 16 ++ tests/vm/freebsd | 3 + 10 files changed, 618 insertions(+), 3 deletions(-)
Quoted 1 line
create mode 100644
audio/sndioaudio.c
Tested on Linux.
Hi Alexandre,
Quoted 26 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]>---
Thank you for the reviews and all the comments. Here's a second diff with all the suggested changes:
- Replace ISC license by SPDX-License-Identifier header
- Fix units (milli- vs micro-) in comment aboutSNDIO_LATENCY_US
- Drop outdated comment about the "size" argument ofsndio_get_buffer_out()
- FixAUDIO_FORMAT_U32handling (missing "break" statement)
- Set {read,write] methods to audio_generic_{read,write} (fixes craches)
- Check if backend is enabled insndio_poll_event()
- Usehttps://sndio.org in description
- Mark options as available after 7.0 release (instead of 6.2)
- Describe sndio-specific options (dev, latency) in qemu-options.hx
- Add myself as reviewer toMAINTAINERS
- Style fixes: no space after function names, use 4-space indent
- Don't use "returnfoo()" iffoo()returns void
- Include backend to audio_drivers_priority[]Tested on OpenBSD, works as expected!
Quoted 7 lines
MAINTAINERS | 5 + audio/audio.c | 1 + audio/audio_template.h | 2 + audio/meson.build | 1 + audio/sndioaudio.c | 555 +++++++++++++++++++++++++++++++++++++++++ meson.build | 9 +- meson_options.txt | 4 +-
I just noticed you changed meson_options.txt but you forgot to regenerate scripts/meson-buildoptions.sh with make update-buildoptions in your build directory. See docs/devel/build-system.rst.
And I'm still convinced you should CC all maintainers of the files this patch changes.
With best regards,
Volker
Quoted 5 lines
qapi/audio.json | 25 +- qemu-options.hx | 16 ++ tests/vm/freebsd | 3 + 10 files changed, 618 insertions(+), 3 deletions(-)
Quoted 37 lines · Volker Rümelin
Hi Alexandre,
Quoted 27 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]>---
Thank you for the reviews and all the comments. Here's a second diff with all the suggested changes:
- Replace ISC license by SPDX-License-Identifier header
- Fix units (milli- vs micro-) in comment aboutSNDIO_LATENCY_US
- Drop outdated comment about the "size" argument ofsndio_get_buffer_out()
- FixAUDIO_FORMAT_U32handling (missing "break" statement)
- Set {read,write] methods to audio_generic_{read,write} (fixes craches)
- Check if backend is enabled insndio_poll_event()
- Usehttps://sndio.org in description
- Mark options as available after 7.0 release (instead of 6.2)
- Describe sndio-specific options (dev, latency) in qemu-options.hx
- Add myself as reviewer toMAINTAINERS
- Style fixes: no space after function names, use 4-space indent
- Don't use "returnfoo()" iffoo()returns void
- Include backend to audio_drivers_priority[]Tested on OpenBSD, works as expected!
Quoted 7 lines
MAINTAINERS | 5 +
audio/audio.c | 1 +
audio/audio_template.h| 2 +
audio/meson.build | 1 +
audio/sndioaudio.c | 555 +++++++++++++++++++++++++++++++++++++++++ meson.build | 9 +-
meson_options.txt | 4 +-
Quoted 1 line
I just noticed you changed meson_options.txt but you forgot to regenerate
scripts/meson-buildoptions.shwith make update-buildoptions in your build directory. Seedocs/devel/build-system.rst.
My bad. That was me. We were discussing the diff before Alexandre posted it. I was not sure if the auto-generated file should be touched.
Quoted 12 lines
And I'm still convinced you should CC all maintainers of the files this patch changes.
With best regards,
VolkerQuoted 5 lines
qapi/audio.json | 25 +-
qemu-options.hx | 16 ++
tests/vm/freebsd | 3 +10 files changed, 618 insertions(+), 3 deletions(-)
Quoted 52 lines · On Freitag, 17. Dezember 2021 10:38:32 CET Alexandre Ratchov wrote:
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]>---
Thank you for the reviews and all the comments. Here's a second diff with all the suggested changes:
- Replace ISC license by SPDX-License-Identifier header
- Fix units (milli- vs micro-) in comment aboutSNDIO_LATENCY_US
- Drop outdated comment about the "size" argument ofsndio_get_buffer_out()
- FixAUDIO_FORMAT_U32handling (missing "break" statement)
- Set {read,write] methods to audio_generic_{read,write} (fixes craches)
- Check if backend is enabled insndio_poll_event()
- Use https://sndio.org in description
- Mark options as available after 7.0 release (instead of 6.2)
- Describe sndio-specific options (dev, latency) in qemu-options.hx
- Add myself as reviewer toMAINTAINERS
- Style fixes: no space after function names, use 4-space indent
- Don't use "returnfoo()" iffoo()returns void
- Include backend to audio_drivers_priority[]Tested on OpenBSD, works as expected!
MAINTAINERS | 5 + audio/audio.c | 1 + audio/audio_template.h | 2 + audio/meson.build | 1 + audio/sndioaudio.c | 555 +++++++++++++++++++++++++++++++++++++++++ meson.build | 9 +- meson_options.txt | 4 +- qapi/audio.json | 25 +- qemu-options.hx | 16 ++ tests/vm/freebsd | 3 + 10 files changed, 618 insertions(+), 3 deletions(-) create mode 100644 audio/sndioaudio.cMAINTAINERS +1
-0@@ -2307,6 +2307,7 @@ X: audio/jackaudio.c X: audio/ossaudio.c X: audio/paaudio.c X: audio/sdlaudio.c +X: audio/sndio.c X: audio/spiceaudio.c F: qapi/audio.json
MAINTAINERS R: Thomas Huth <[email protected]> · line 2356
Quoted 7 lines
MAINTAINERS +4
-0@@ -2349,6 +2350,10 @@ R: Thomas Huth <[email protected]> S: Odd Fixes F: audio/sdlaudio.c +Sndio Audio backend +R: Alexandre Ratchov <[email protected]> +F: audio/sndio.c +
Thanks Alexandre for volunteering as reviewer!
Gerd, would it be OK to set you as maintainer for now until new maintainer(s) adopt audio sections? Or should this start with "S: Orphan" instead?
Best regards,
Christian Schoenebeck
Quoted 68 lines · On Montag, 20. Dezember 2021 16:41:31 CET Christian Schoenebeck wrote:
Quoted 56 lines · On Freitag, 17. Dezember 2021 10:38:32 CET Alexandre Ratchov wrote:
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]>---
Thank you for the reviews and all the comments. Here's a second diff with all the suggested changes:
- Replace ISC license by SPDX-License-Identifier header
- Fix units (milli- vs micro-) in comment aboutSNDIO_LATENCY_US
- Drop outdated comment about the "size" argument ofsndio_get_buffer_out()
- FixAUDIO_FORMAT_U32handling (missing "break" statement)
- Set {read,write] methods to audio_generic_{read,write} (fixes craches)
- Check if backend is enabled insndio_poll_event()
- Use https://sndio.org in description
- Mark options as available after 7.0 release (instead of 6.2)
- Describe sndio-specific options (dev, latency) in qemu-options.hx
- Add myself as reviewer toMAINTAINERS
- Style fixes: no space after function names, use 4-space indent
- Don't use "returnfoo()" iffoo()returns void
- Include backend to audio_drivers_priority[]Tested on OpenBSD, works as expected!
MAINTAINERS | 5 + audio/audio.c | 1 + audio/audio_template.h | 2 + audio/meson.build | 1 + audio/sndioaudio.c | 555 +++++++++++++++++++++++++++++++++++++++++ meson.build | 9 +- meson_options.txt | 4 +- qapi/audio.json | 25 +- qemu-options.hx | 16 ++ tests/vm/freebsd | 3 + 10 files changed, 618 insertions(+), 3 deletions(-) create mode 100644 audio/sndioaudio.cMAINTAINERS +1
-0@@ -2307,6 +2307,7 @@ X: audio/jackaudio.c X: audio/ossaudio.c X: audio/paaudio.c X: audio/sdlaudio.c +X: audio/sndio.cX:
audio/spiceaudio.c
F:qapi/audio.jsonMAINTAINERS R: Thomas Huth <[email protected]> · line 2357
Quoted 8 lines
MAINTAINERS +4
-0@@ -2349,6 +2350,10 @@ R: Thomas Huth <[email protected]> S: Odd Fixes F: audio/sdlaudio.c +Sndio Audio backend +R: Alexandre Ratchov <[email protected]> +F: audio/sndio.c +Thanks Alexandre for volunteering as reviewer!
Quoted 3 lines
Gerd, would it be OK to set you as maintainer for now until new maintainer(s) adopt audio sections? Or should this start with "S: Orphan" instead?
Alexandre, if Gerd does not reply in a week or so, then please add "S: Orphan" to MAINTAINERS for now to make it clear that there is no maintainer for sndio yet to increase the chance for somebody to adopt it.
From Volker's response I assume you will be posting a v3 anyway.
If nobody takes care to queue your patch then let me know. Maybe I can push it through my queue this time, provided that there are enough reviews. I also saw your patch just by coincidence BTW, so please CC maintainers of affected files as suggested by Volker.
Best regards,
Christian Schoenebeck
Quoted 16 lines · Christian Schoenebeck
Quoted 15 lines · On Freitag, 17. Dezember 2021 10:38:32 CET Alexandre Ratchov wrote:
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.).
MAINTAINERS +1
-0@@ -2307,6 +2307,7 @@ X: audio/jackaudio.c X: audio/ossaudio.c X: audio/paaudio.c X: audio/sdlaudio.c +X: audio/sndio.c X: audio/spiceaudio.c F: qapi/audio.json
Quoted 7 lines
MAINTAINERS R: Thomas Huth <[email protected]> · line 2355
Quoted 7 lines
MAINTAINERS +3
-0@@ -2349,6 +2350,10 @@ R: Thomas Huth <[email protected]> S: Odd Fixes F: audio/sdlaudio.c +Sndio Audio backend +R: Alexandre Ratchov <[email protected]> +F: audio/sndio.c
[ ... wading through my patch mail backlog ... ]
Quoted 4 lines
Thanks Alexandre for volunteering as reviewer!
Gerd, would it be OK to set you as maintainer for now until new maintainer(s) adopt audio sections? Or should this start with "S: Orphan" instead?
Yep, adding me is fine for now, although I can't promise timely responses due to being quite busy with tianocore.
take care,
Gerd
Hi Alexandre,
Quoted 24 lines · Alexandre Ratchov
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]>---
Thank you for the reviews and all the comments. Here's a second diff with all the suggested changes:
- Replace ISC license by SPDX-License-Identifier header
- Fix units (milli- vs micro-) in comment aboutSNDIO_LATENCY_US
- Drop outdated comment about the "size" argument ofsndio_get_buffer_out()
- FixAUDIO_FORMAT_U32handling (missing "break" statement)
- Set {read,write] methods to audio_generic_{read,write} (fixes craches)
- Check if backend is enabled insndio_poll_event()
- Use https://sndio.org in description
- Mark options as available after 7.0 release (instead of 6.2)
- Describe sndio-specific options (dev, latency) in qemu-options.hx
- Add myself as reviewer toMAINTAINERS
- Style fixes: no space after function names, use 4-space indent
- Don't use "returnfoo()" iffoo()returns void
- Include backend to audio_drivers_priority[]
Quoted 7 lines
Tested on OpenBSD, works as expected!
MAINTAINERS | 5 + audio/audio.c | 1 + audio/audio_template.h | 2 + audio/meson.build | 1 + audio/sndioaudio.c | 555 +++++++++++++++++++++++++++++++++++++++++
Here we can see the file added is named "sndioaudio.c", so...
Quoted 13 lines
meson.build | 9 +- meson_options.txt | 4 +- qapi/audio.json | 25 +- qemu-options.hx | 16 ++ tests/vm/freebsd | 3 + 10 files changed, 618 insertions(+), 3 deletions(-)create mode 100644
audio/sndioaudio.cMAINTAINERS +0
-0
MAINTAINERS X: audio/jackaudio.c · line 2310
Quoted 4 lines
MAINTAINERS +1
-0@@ -2307,6 +2307,7 @@ X: audio/jackaudio.c X: audio/ossaudio.c X: audio/paaudio.c X: audio/sdlaudio.c +X: audio/sndio.c
it should say "sndioaudio.c" here...
MAINTAINERS R: Thomas Huth <[email protected]> · line 2355
Quoted 10 lines
MAINTAINERS +3
-0X: audio/spiceaudio.c F: qapi/audio.json@@ -2349,6 +2350,10 @@ R: Thomas Huth <[email protected]> S: Odd Fixes F: audio/sdlaudio.c +Sndio Audio backend +R: Alexandre Ratchov <[email protected]> +F: audio/sndio.c
and here.
Quoted 4 lines
MAINTAINERS +1
-0+ Block layer core M: Kevin Wolf <[email protected]> M: Hanna Reitz <[email protected]>