audio: Add sndio backend
PATCH 1/1 audio: Add sndio backend
Add a 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.).
The C code is from Alexandre Ratchov <[email protected]> and the rest of the bits are from me.
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) + +# sndio module +common-obj-$(CONFIG_AUDIO_SNDIO) += sndio.mo +sndio.mo-objs = sndioaudio.o +sndio.mo-libs := $(SNDIO_LIBS)
audio/audio.c +1 -0
@@ -1974,6 +1974,7 @@ void audio_create_pdos(Audiodev *dev)CASE (OSS , oss, Oss);CASE (PA , pa, Pa); CASE(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 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/sndioaudio.c new file +566 -0
566 lines not on this page · raw message
configure +47 -11
112 lines not on this page · raw message
qapi/audio.json +24 -1
@@ -248,6 +248,28 @@ '*out': 'AudiodevPaPerDirectionOptions', '*server': 'str' } } +## +# @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: 4.0 +## +{ 'struct': 'AudiodevSndioOptions', + 'data': { + '*in': 'AudiodevPerDirectionOptions', + '*out': 'AudiodevPerDirectionOptions', + '*dev': 'str', + '*latency': 'uint32'} } + ## # @AudiodevWavOptions: #
@@ -287,7 +309,7 @@ ## { 'enum': 'AudiodevDriver', 'data': [ 'none', 'alsa', 'coreaudio', 'dsound', 'oss', 'pa', 'sdl', - 'spice', 'wav' ] } + 'sndio', 'spice', 'wav' ] } ## # @Audiodev:
@@ -316,5 +338,6 @@ 'oss': 'AudiodevOssOptions', 'pa': 'AudiodevPaOptions', 'sdl': 'AudiodevGenericOptions', + 'sndio': 'AudiodevSndioOptions', 'spice': 'AudiodevGenericOptions', 'wav': 'AudiodevWavOptions' } }
qemu-options.hx +7 -0
@@ -566,6 +566,9 @@ DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, #ifdef CONFIG_AUDIO_SDL "-audiodev sdl,id=id[,prop[=value][,...]]\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
@@ -747,6 +750,10 @@ Creates a backend using SDL. This backend is available on most systems, but you should use your platform's native backend if possible. This backend has no backend specific properties. +@item -audiodev sndio,id=@var{id}[,@var{prop}[=@var{value}][,...]] +Creates a backend using SNDIO. This backend is available on OpenBSD and most +other Unix-like systems. This backend has no backend specific properties. + @item -audiodev spice,id=@var{id}[,@var{prop}[=@var{value}][,...]] Creates a backend that sends audio through SPICE. This backend requires @code{-spice} and automatically selected in that case, so usually you
tests/qtest/modules-test.c +3 -0
@@ -46,6 +46,9 @@ int main(int argc, char *argv[])#ifdef CONFIG_AUDIO_SDL "audio-" ,"sdl" , #endif +#ifdef CONFIG_AUDIO_SNDIO +"audio-" ,"sndio" , +#endif #ifdef CONFIG_CURSES "ui-", "curses", #endif
tests/vm/freebsd +3 -0
@@ -58,6 +58,9 @@ class FreeBSDVM(basevm.BaseVM): # libs: migration "zstd", + + # libs: sndio + "sndio", ] BUILD_SCRIPT = """
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Subject: [PATCH] audio: Add sndio backend
Message-id: [email protected]
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
421ab62 audio: Add sndio backend
=== OUTPUT BEGIN ===
ERROR: space prohibited before that close parenthesis ')' #41: FILE: audio/audio.c:1977:
+ CASE(SNDIO, sndio, );
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #59:
new file mode 100644
ERROR: g_free(NULL) is safe this check is probably not required #381: FILE: audio/sndioaudio.c:318:
+ if (self->pfds) {
+ g_free(self->pfds);
ERROR: g_free(NULL) is safe this check is probably not required #386: FILE: audio/sndioaudio.c:323:
+ if (self->pindexes) {
+ g_free(self->pindexes);
ERROR: g_free(NULL) is safe this check is probably not required #391: FILE: audio/sndioaudio.c:328:
+ if (self->buf) {
+ g_free(self->buf);
total: 4 errors, 1 warnings, 780 lines checked
Commit 421ab62c169b (audio: Add sndio backend) has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 27 lines · On Wed, Mar 04, 2020 at 07:04:07AM -0800, [email protected] wrote:
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Subject: [PATCH] audio: Add sndio backend
Message-id: [email protected]
Type: series=== TEST SCRIPT BEGIN === #!/bin/bash
git rev-parse base >/dev/null|| exit 0 git config --local diff.renamelimit 0 git config --local diff.renames True git config --local diff.algorithm histogram./scripts/checkpatch.pl--mailback base.. === TEST SCRIPT END ===From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test' 421ab62 audio: Add sndio backend
Quoted 4 lines
=== OUTPUT BEGIN ===
ERROR: space prohibited before that close parenthesis ')' #41: FILE:audio/audio.c:1977:
+CASE(SNDIO, sndio, );
False positive I'd say.
Quoted 1 line
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed updating?
Adding an entry to the MAINTAINERS file is a good idea though.
audio/sndioaudio.c line 318
Quoted 4 lines
ERROR:
g_free(NULL)is safe this check is probably not required #381: FILE:audio/sndioaudio.c:318:audio/sndioaudio.c new file +2
-0+if (self->pfds) { +g_free (self->pfds);
Reasonable too.
cheers,
Gerd
Quoted 28 lines · Gerd Hoffmann
Quoted 27 lines · On Wed, Mar 04, 2020 at 07:04:07AM -0800, [email protected] wrote:
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Subject: [PATCH] audio: Add sndio backend
Message-id: [email protected]
Type: series=== TEST SCRIPT BEGIN === #!/bin/bash
git rev-parse base >/dev/null|| exit 0 git config --local diff.renamelimit 0 git config --local diff.renames True git config --local diff.algorithm histogram./scripts/checkpatch.pl--mailback base.. === TEST SCRIPT END ===From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test' 421ab62 audio: Add sndio backend
Quoted 8 lines
Quoted 4 lines
=== OUTPUT BEGIN ===
ERROR: space prohibited before that close parenthesis ')' #41: FILE:audio/audio.c:1977:
+CASE(SNDIO, sndio, );False positive I'd say.
Quoted 1 line
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed updating?Adding an entry to the
MAINTAINERSfile is a good idea though.
Ok. Will do.
Quoted 5 lines
audio/sndioaudio.c line 318
Quoted 4 lines
ERROR:
g_free(NULL)is safe this check is probably not required #381: FILE:audio/sndioaudio.c:318:audio/sndioaudio.c new file +2
-0+if (self->pfds) { +g_free (self->pfds);Reasonable too.
Not clear to me. Leave as is or needs a change?
Quoted 7 lines
Quoted 5 lines
audio/sndioaudio.c line 318
Quoted 4 lines
ERROR:
g_free(NULL)is safe this check is probably not required #381: FILE:audio/sndioaudio.c:318:audio/sndioaudio.c new file +2
-0+if (self->pfds) { +g_free (self->pfds);Reasonable too.
Not clear to me. Leave as is or needs a change?
Just use "g_free(self->pfds)".
cheers,
Gerd
audio/Makefile.objs
Quoted 13 lines · Brad Smith
Add a 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.).
The C code is from Alexandre Ratchov <[email protected]> and the rest of the bits are from me.
Signed-off-by Alexandre Ratchov <[email protected]>Signed-off-by Brad Smith <[email protected]>audio/Makefile.objs +0
-0
Your patch lacks the usual --- separator and diffstat that 'git format-patch' (and therefore 'git send-email') uses. This makes it harder to see at a glance the approximate impact of your patch, and whether it touches a file I'm interested in.
Quoted 9 lines
+++
b/qapi/audio.jsonaudio/Makefile.objs +4
-0@@ -248,6 +248,28 @@ '*out': 'AudiodevPaPerDirectionOptions', '*server': 'str' } } +## +# @AudiodevSndioOptions: +# +# Options of the sndio audio backend.
audio/Makefile.objs line 264
Quoted 10 lines
audio/Makefile.objs +10
-0+# +# @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: 4.0
You've missed 4.0 by a long shot; the next release is 5.0.
Quoted 12 lines
audio/Makefile.objs +8
-0+## +{ 'struct': 'AudiodevSndioOptions', + 'data': { + '*in': 'AudiodevPerDirectionOptions', + '*out': 'AudiodevPerDirectionOptions', + '*dev': 'str', + '*latency': 'uint32'} } + ## # @AudiodevWavOptions: #
audio/Makefile.objs line 312
Quoted 5 lines
audio/Makefile.objs +1
-1@@ -287,7 +309,7 @@ ## { 'enum': 'AudiodevDriver', 'data': [ 'none', 'alsa', 'coreaudio', 'dsound', 'oss', 'pa', 'sdl', - 'spice', 'wav' ] } + 'sndio', 'spice', 'wav' ] }
It's also customary to document enum options, something like:
# @sndio (since 5.0)
Furthermore, since:
audio/Makefile.objs DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, · line 571
Quoted 8 lines
audio/Makefile.objs +4
-0+++ b/qemu-options.hx@@ -566,6 +566,9 @@ DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, #ifdef CONFIG_AUDIO_SDL "-audiodev sdl,id=id[,prop[=value][,...]]\n" #endif +#ifdef CONFIG_AUDIO_SNDIO + "-audiodev sndio,id=id[,prop[=value][,...]]\n" +#endif
the option is only useful based on configure-time decisions, it seems like the new enum element should be:
{ 'name': 'sndio', 'if': 'defined(CONFIG_AUDIO_SNDIO)' }
to make it introspectible whether support is compiled in to a given binary. True, there are existing enum members that should do likewise, so maybe it's worth a cleanup patch first.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org