Audio patches (was: Audio 5.1 patches)
v4 cover Audio patches (was: Audio 5.1 patches)
Hi,
Here's an updated version of my audio patches. Due to the size of the patch series, I broke it down to smaller parts, this is the first part. This series adds an -audiodev command line parameter instead of the old environment variable based config.
Changes from v3:
* fixed formatting issues reported by issues by checkpatch.pl, except in patch 2 "audio: use qapi AudioFormat instead of audfmt_e", since it's a search and replace patch
Regards,
Zoltan
Kővágó, Zoltán (14):
qapi: qapi for audio backends
audio: use qapi AudioFormat instead of audfmt_e
audio: -audiodev command line option: documentation
audio: -audiodev command line option basic implementation
alsaaudio: port to -audiodev config
coreaudio: port to -audiodev config
dsoundaudio: port to -audiodev config
noaudio: port to -audiodev config
ossaudio: port to -audiodev config
paaudio: port to -audiodev config
sdlaudio: port to -audiodev config
spiceaudio: port to -audiodev config
wavaudio: port to -audiodev config
audio: -audiodev command line option: cleanup
Makefile.objs | 6 +- qapi/audio.json | 233 +++++++++++ qapi/qapi-schema.json | 1 + audio/audio.h | 30 +- audio/audio_int.h | 33 +- audio/audio_template.h | 13 +- audio/dsound_template.h | 6 +- audio/alsaaudio.c | 383 ++++++----------- audio/audio.c | 845 ++++++++++++-------------------------- audio/audio_legacy.c | 549 +++++++++++++++++++++++++ audio/audio_win_int.c | 18 +- audio/coreaudio.c | 50 +-- audio/dsoundaudio.c | 61 +-- audio/noaudio.c | 3 +- audio/ossaudio.c | 197 ++++----- audio/paaudio.c | 121 +++--- audio/sdlaudio.c | 50 +-- audio/spiceaudio.c | 11 +- audio/wavaudio.c | 75 +--- audio/wavcapture.c | 2 +- hw/arm/omap2.c | 2 +- hw/audio/ac97.c | 2 +- hw/audio/adlib.c | 2 +- hw/audio/cs4231a.c | 6 +- hw/audio/es1370.c | 4 +- hw/audio/gus.c | 2 +- hw/audio/hda-codec.c | 18 +- hw/audio/lm4549.c | 6 +- hw/audio/milkymist-ac97.c | 2 +- hw/audio/pcspk.c | 2 +- hw/audio/sb16.c | 14 +- hw/audio/wm8750.c | 6 +- hw/display/xlnx_dp.c | 2 +- hw/input/tsc210x.c | 2 +- hw/usb/dev-audio.c | 2 +- ui/vnc.c | 26 +- vl.c | 7 +- audio/Makefile.objs | 2 +- qemu-options.hx | 222 +++++++++- 39 files changed, 1715 insertions(+), 1301 deletions(-) create mode 100644 qapi/audio.json create mode 100644 audio/audio_legacy.c
Signature · 1 line
2.20.1
PATCH v4 1/14 qapi: qapi for audio backends
This patch adds structures into qapi to replace the existing configuration structures used by audio backends currently. This qapi will be the base of the -audiodev command line parameter (that replaces the old environment variables based config).
This is not a 1:1 translation of the old options, I've tried to make them much more consistent (e.g. almost every backend had an option to specify buffer size, but the name was different for every backend, and some backends required usecs, while some other required frames, samples or bytes). Also tried to reduce the number of abbreviations used by the config keys.
Some of the more important changes:
* use in and out instead of ADC and DAC, as the former is more user friendly imho
* moved buffer settings into the global setting area (so it's the same for all backends that support it. Backends that can't change buffer size will simply ignore them). Also using usecs, as it's probably more user friendly than samples or bytes.
* try-poll is now an alsa backend specific option (as all other backends currently ignore it)
AudiodevPaPerDirectionOptions struct might look pointless right now, but later we will have new per-direction options, so it's more future-proof this way.
---
Notes:
Changes from v2:
* update copyright, version numbers
* remove #optional
* per-direction options are now optional (needed for qobject_object_visitor_new_str)
* removed unnecessary AudiodevNoOptions
* changed integers to unsigned
Makefile.objs | 6 +- qapi/audio.json | 233 ++++++++++++++++++++++++++++++++++++++++++ qapi/qapi-schema.json | 1 + 3 files changed, 237 insertions(+), 3 deletions(-) create mode 100644 qapi/audio.json
Makefile.objs +3 -3
@@ -1,6 +1,6 @@ -QAPI_MODULES = block-core block char common crypto introspect job migration -QAPI_MODULES += misc net rdma rocker run-state sockets tpm trace transaction -QAPI_MODULES += ui +QAPI_MODULES = audio block-core block char common crypto introspect job +QAPI_MODULES += migration misc net rdma rocker run-state sockets tpm trace +QAPI_MODULES += transaction ui ####################################################################### # Common libraries for tools and emulators
qapi/audio.json new file +233 -0
233 lines not on this page · raw message
qapi/qapi-schema.json +1 -0
@@ -95,3 +95,4 @@ { 'include': 'trace.json' } { 'include': 'introspect.json' } { 'include': 'misc.json' } +{ 'include': 'audio.json' }
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v4 01/14] qapi: qapi for audio backends
Quoted 65 lines · Zoltán
This patch adds structures into qapi to replace the existing configuration structures used by audio backends currently. This qapi will be the base of the -audiodev command line parameter (that replaces the old environment variables based config).
This is not a 1:1 translation of the old options, I've tried to make them much more consistent (e.g. almost every backend had an option to specify buffer size, but the name was different for every backend, and some backends required usecs, while some other required frames, samples or bytes). Also tried to reduce the number of abbreviations used by the config keys.
Some of the more important changes:
* useinandoutinstead ofADCandDAC, as the former is more user friendly imho
* moved buffer settings into the global setting area (so it's the same for all backends that support it. Backends that can't change buffer size will simply ignore them). Also using usecs, as it's probably more user friendly than samples or bytes.
* try-poll is now an alsa backend specific option (as all other backends currently ignore it)AudiodevPaPerDirectionOptions struct might look pointless right now, but later we will have new per-direction options, so it's more future-proof this way.
Signed-off-by Kővágó, Zoltán <[email protected]>---
Notes:
Changes from v2:* update copyright, version numbers
* remove #optional
* per-direction options are now optional (needed forqobject_object_visitor_new_str)
* removed unnecessary AudiodevNoOptions
* changed integers to unsignedMakefile.objs | 6 +- qapi/audio.json | 233 ++++++++++++++++++++++++++++++++++++++++++ qapi/qapi-schema.json | 1 + 3 files changed, 237 insertions(+), 3 deletions(-) create mode 100644 qapi/audio.jsonMakefile.objs +3
-3@@ -1,6 +1,6 @@ -QAPI_MODULES = block-core block char common crypto introspect job migration -QAPI_MODULES += misc net rdma rocker run-state sockets tpm trace transaction -QAPI_MODULES += ui +QAPI_MODULES = audio block-core block char common crypto introspect job +QAPI_MODULES += migration misc net rdma rocker run-state sockets tpm trace +QAPI_MODULES += transaction ui ####################################################################### # Common libraries for tools and emulatorsqapi/audio.json new file +1
-0@@ -0,0 +1,233 @@ +# -*- mode: python -*-
qapi/audio.json line 11
Quoted 10 lines
qapi/audio.json new file +10
-0+# +# Copyright (C) 2015-2019 Zoltán Kővágó <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. + +## +# @AudiodevAlsaPerDirectionOptions: +# +# Options of the alsa backend that are used for both playback and recording.
Please break your comment lines around column 70.
qapi/audio.json line 15
Quoted 4 lines
qapi/audio.json new file +4
-0+# +# @dev: the name of the alsa device to use (default 'default') +# +# @try-poll: attempt to use poll mode, falling back to non polling access on
non-polling
qapi/audio.json line 16
Quoted 1 line
qapi/audio.json new file +1
-0+# failure (default on)
default true
Quoted 36 lines
qapi/audio.json new file +36
-0+# +# Since: 4.0 +## +{ 'struct': 'AudiodevAlsaPerDirectionOptions', + 'data': { + '*dev': 'str', + '*try-poll': 'bool' } } + +## +# @AudiodevAlsaOptions: +# +# Options of the alsa audio backend. +# +# @alsa-in: options of the capture stream +# +# @alsa-out: options of the playback stream +# +# @threshold: set the threshold (in microseconds) when playback starts +# +# Since: 4.0 +## +{ 'struct': 'AudiodevAlsaOptions', + 'data': { + '*alsa-in': 'AudiodevAlsaPerDirectionOptions', + '*alsa-out': 'AudiodevAlsaPerDirectionOptions', + '*threshold': 'uint32' } } + +## +# @AudiodevDsoundOptions: +# +# Options of the dsound audio backend. +# +# @latency: add extra latency to playback in microseconds (default 10000) +# +# Since: 4.0 +##
qapi/audio.json line 62
Quoted 10 lines
qapi/audio.json new file +10
-0+{ 'struct': 'AudiodevDsoundOptions', + 'data': { + '*latency': 'uint32' } } + +## +# @AudiodevOssPerDirectionOptions: +# +# Options of the oss backend that are used for both playback and recording. +# +# @dev: file name of the oss device (default '/dev/dsp')
A device special file, unlike AudiodevAlsaPerDirectionOptions member @dev. Same name, different meaning. Doesn't bother me in this case.
qapi/audio.json line 64
Quoted 2 lines
qapi/audio.json new file +2
-0+# +# @try-poll: attempt to use poll mode, falling back to non polling access on
non-polling
qapi/audio.json line 65
Quoted 1 line
qapi/audio.json new file +1
-0+# failure (default on)
default true
Quoted 9 lines
qapi/audio.json new file +9
-0+# +# Since: 4.0 +## +{ 'struct': 'AudiodevOssPerDirectionOptions', + 'data': { + '*dev': 'str', + '*try-poll': 'bool' } } + +##
qapi/audio.json line 84
Quoted 10 lines
qapi/audio.json new file +10
-0+# @AudiodevOssOptions: +# +# Options of the oss audio backend. +# +# @oss-in: options of the capture stream +# +# @oss-out: options of the playback stream +# +# @try-mmap: try using memory mapped access, falling back to non +# memory mapped access on failure (default off)
memory-mapped, non-memory-mapped
default false
qapi/audio.json line 86
Quoted 2 lines
qapi/audio.json new file +2
-0+# +# @exclusive: open device in exclusive mode (vmix won't work) (default off)
default false
Quoted 18 lines
qapi/audio.json new file +18
-0+# +# @dsp-policy: set the timing policy of the device (between 0 and 10, where +# smaller number means smaller latency but higher CPU usage) or -1 +# to use fragment mode (option ignored on some platforms) +# (default 5) +# +# Since: 4.0 +## +{ 'struct': 'AudiodevOssOptions', + 'data': { + '*oss-in': 'AudiodevOssPerDirectionOptions', + '*oss-out': 'AudiodevOssPerDirectionOptions', + '*try-mmap': 'bool', + '*exclusive': 'bool', + '*dsp-policy': 'uint32' } } + +## +# @AudiodevPaPerDirectionOptions:
qapi/audio.json line 114
Quoted 10 lines
qapi/audio.json new file +10
-0+# +# Options of the pa backend that are used for both playback and recording. +# +# @name: name of the sink/source to use +# +# Since: 4.0 +## +{ 'struct': 'AudiodevPaPerDirectionOptions', + 'data': { + '*name': 'str' } }
Your "might look pointless" remark made me expect an empty struct. That would've been pointless indeed. Instead, you're wrapping the single option you already have in a struct, to keep open the door for more options. Makes sense.
Quoted 22 lines
qapi/audio.json new file +22
-0+ +## +# @AudiodevPaOptions: +# +# Options of the pa (PulseAudio) audio backend. +# +# @server: PulseAudio server address (default: let PulseAudio choose) +# +# @sink: name of the sink to use +# +# @source: name of the source to use +# +# Since: 4.0 +## +{ 'struct': 'AudiodevPaOptions', + 'data': { + '*server': 'str', + '*sink': 'AudiodevPaPerDirectionOptions', + '*source': 'AudiodevPaPerDirectionOptions' } } + +## +# @AudiodevWavOptions:
qapi/audio.json line 146
Quoted 10 lines
qapi/audio.json new file +10
-0+# +# Options of the wav audio backend. +# +# @path: name of the wav file to record (default 'qemu.wav') +# +# Since: 4.0 +## +{ 'struct': 'AudiodevWavOptions', + 'data': { + '*path': 'str' } }
Pattern so far:
* AudiodevFooOptions
Foo direction options other options Alsa alsa-in, alsa-out threshold Dsound latency Oss oss-in, oss-out try-map, exclusive, dsp-policy Pa sink, source server Wav path
Any particular reason for naming the direction options differently?
Quoted 21 lines
qapi/audio.json new file +21
-0+ + +## +# @AudioFormat: +# +# An enumeration of possible audio formats. +# +# Since: 4.0 +## +{ 'enum': 'AudioFormat', + 'data': [ 'u8', 's8', 'u16', 's16', 'u32', 's32' ] } + +## +# @AudiodevDriver: +# +# An enumeration of possible audio backend drivers. +# +# Since: 4.0 +## +{ 'enum': 'AudiodevDriver', + 'data': [ 'none', 'alsa', 'coreaudio', 'dsound', 'oss', 'pa', 'sdl', 'spice',
qapi/audio.json line 177
Quoted 10 lines
qapi/audio.json new file +10
-0+ 'wav' ] } + +## +# @AudiodevPerDirectionOptions: +# +# General audio backend options that are used for both playback and recording. +# +# @fixed-settings: use fixed settings for host input/output. When off, +# frequency, channels and format must not be specified +# (default on)
default true
Quoted 46 lines
qapi/audio.json new file +46
-0+# +# @frequency: frequency to use when using fixed settings (default 44100) +# +# @channels: number of channels when using fixed settings (default 2) +# +# @voices: number of voices to use (default 1) +# +# @format: sample format to use when using fixed settings (default s16) +# +# @buffer-len: the buffer size in microseconds +# +# @buffer-count: number of buffers +# +# Since: 4.0 +## +{ 'struct': 'AudiodevPerDirectionOptions', + 'data': { + '*fixed-settings': 'bool', + '*frequency': 'uint32', + '*channels': 'uint32', + '*voices': 'uint32', + '*format': 'AudioFormat', + '*buffer-len': 'uint32', + '*buffer-count': 'uint32' } } + +## +# @Audiodev: +# +# Options of an audio backend. +# +# @id: identifier of the backend +# +# @driver: the backend driver to use +# +# @in: options of the capture stream +# +# @out: options of the playback stream +# +# @timer-period: timer period (in microseconds, 0: use lowest possible) +# +# Since: 4.0 +## +{ 'union': 'Audiodev', + 'base': { + 'id': 'str', + 'driver': 'AudiodevDriver',
qapi/audio.json line 233
Quoted 10 lines
qapi/audio.json new file +10
-0+ '*in': 'AudiodevPerDirectionOptions', + '*out': 'AudiodevPerDirectionOptions', + '*timer-period': 'uint32' }, + 'discriminator': 'driver', + 'data': { + 'alsa': 'AudiodevAlsaOptions', + 'dsound': 'AudiodevDsoundOptions', + 'oss': 'AudiodevOssOptions', + 'pa': 'AudiodevPaOptions', + 'wav': 'AudiodevWavOptions' } }
'none', 'coreaudio', 'sdl' and 'spice' have no driver-specific options.
Do all the generic options apply to all drivers? Even 'none'?
Do @in and @out apply to drivers 'dsound' and 'wav'?
Per-direction options are split between generic ones in @in and @out, and driver-specific ones in @alsa-in and @alsa-out / @oss-in and @oss-out / @sink and @source.
Perhaps the following would be tidier: make the generic per-direction options AudiodevPerDirectionOptions the base of driver-specific ones AudiodevAlsaPerDirectionOptions, AudiodevOssPerDirectionOptions, AudiodevPaPerDirectionOptions, and then
{ 'struct': 'AudiodevGenericOptions',
'data': {
'*in': 'AudiodevPerDirectionOptions',
'*out': 'AudiodevPerDirectionOptions' } }
{ 'union': 'Audiodev',
'base': {
'id': 'str',
'driver': 'AudiodevDriver',
'*timer-period': 'uint32' },
'discriminator': 'driver',
'data': {
'none': 'AudiodevGenericOptions',
'alsa': 'AudiodevAlsaOptions',
'coreaudio: 'AudiodevGenericOptions',
'dsound': 'AudiodevDsoundOptions',
'oss': 'AudiodevOssOptions',
'pa': 'AudiodevPaOptions',
'sdl: 'AudiodevGenericOptions',
'spice': 'AudiodevGenericOptions',
'wav': 'AudiodevWavOptions' } }qapi/qapi-schema.json line 98
Quoted 9 lines
qapi/qapi-schema.json +1
-0@@ -95,3 +95,4 @@ { 'include': 'trace.json' } { 'include': 'introspect.json' } { 'include': 'misc.json' } +{ 'include': 'audio.json' }
Looks pretty good.
Re: [Qemu-devel] [PATCH v4 01/14] qapi: qapi for audio backends
Quoted 1 line · Markus Armbruster
"Kővágó, Zoltán" <[email protected]> writes:
[...]
Quoted 37 lines
Quoted 22 lines
qapi/audio.json new file +22
-0+ +## +# @AudiodevPaOptions: +# +# Options of the pa (PulseAudio) audio backend. +# +# @server: PulseAudio server address (default: let PulseAudio choose) +# +# @sink: name of the sink to use +# +# @source: name of the source to use +# +# Since: 4.0 +## +{ 'struct': 'AudiodevPaOptions', + 'data': { + '*server': 'str', + '*sink': 'AudiodevPaPerDirectionOptions', + '*source': 'AudiodevPaPerDirectionOptions' } } + +## +# @AudiodevWavOptions:qapi/audio.json line 146
Quoted 10 lines
qapi/audio.json new file +10
-0+# +# Options of the wav audio backend. +# +# @path: name of the wav file to record (default 'qemu.wav') +# +# Since: 4.0 +## +{ 'struct': 'AudiodevWavOptions', + 'data': { + '*path': 'str' } }Pattern so far:
* AudiodevFooOptions
Quoted 8 lines
Foo direction options other options Alsa alsa-in, alsa-out threshold Dsound latency Oss oss-in, oss-out try-map, exclusive, dsp-policy Pa sink, source server Wav pathAny particular reason for naming the direction options differently?
I probably chose that name because in PulseAudio parlance you have sources and sinks, and the current environment variable based setting of pa doesn't use ADC/DAC to refer to source/sink, but now that you mention it it probably makes sense to rename them to pa-in and pa-out, it's more uniform that way.
[...]
Quoted 34 lines
Quoted 21 lines
qapi/audio.json new file +21
-0+## +# @Audiodev: +# +# Options of an audio backend. +# +# @id: identifier of the backend +# +# @driver: the backend driver to use +# +# @in: options of the capture stream +# +# @out: options of the playback stream +# +# @timer-period: timer period (in microseconds, 0: use lowest possible) +# +# Since: 4.0 +## +{ 'union': 'Audiodev', + 'base': { + 'id': 'str', + 'driver': 'AudiodevDriver',qapi/audio.json line 233
Quoted 10 lines
qapi/audio.json new file +10
-0+ '*in': 'AudiodevPerDirectionOptions', + '*out': 'AudiodevPerDirectionOptions', + '*timer-period': 'uint32' }, + 'discriminator': 'driver', + 'data': { + 'alsa': 'AudiodevAlsaOptions', + 'dsound': 'AudiodevDsoundOptions', + 'oss': 'AudiodevOssOptions', + 'pa': 'AudiodevPaOptions', + 'wav': 'AudiodevWavOptions' } }'none', 'coreaudio', 'sdl' and 'spice' have no driver-specific options.
Quoted 1 line
Do all the generic options apply to all drivers? Even 'none'?
'fixed-settings', 'frequency', 'channels', 'voices' and 'format' are used by the mixeng thus they apply to all backends, even 'none'. (Whether it makes any sense to set them is a different story.)
'buffer-len' and 'buffer-count' was introduced as a means to give a more uniform interface to setting buffer sizes, because currently to set buffer size:
* in case of alsa: you set microseconds or frames depending on a second environment variable
* in case of coreaudio: you set it in frames
* in case of dsound, oss: you set it in milliseconds
* in case of pa, sdl: you set it in samples
* in case of spice, wav: you can't set it
I added 'buffer-len' and 'buffer-count' because they seemed like a generic option that *most* backends would support, and I didn't want to create extra backend specific options for them. But if I combine it with your inheritance-like proposal, it's probably not that bad.
Quoted 1 line
Do @in and @out apply to drivers 'dsound' and 'wav'?
@out applies to every driver. @in shouldn't apply to drivers without input support, but currently the base of mixeng is created for the input too, it'll just fail if the sound card tries to create a capture stream...
Quoted 23 lines
Per-direction options are split between generic ones in @in and @out, and driver-specific ones in @alsa-in and @alsa-out / @oss-in and @oss-out / @sink and @source.
Perhaps the following would be tidier: make the generic per-direction options AudiodevPerDirectionOptions the base of driver-specific ones AudiodevAlsaPerDirectionOptions, AudiodevOssPerDirectionOptions, AudiodevPaPerDirectionOptions, and then
{ 'struct': 'AudiodevGenericOptions', 'data': { '*in': 'AudiodevPerDirectionOptions', '*out': 'AudiodevPerDirectionOptions' } } { 'union': 'Audiodev', 'base': { 'id': 'str', 'driver': 'AudiodevDriver', '*timer-period': 'uint32' }, 'discriminator': 'driver', 'data': { 'none': 'AudiodevGenericOptions',
Quoted 8 lines
'alsa': 'AudiodevAlsaOptions',
'coreaudio: 'AudiodevGenericOptions',
'dsound': 'AudiodevDsoundOptions',
'oss': 'AudiodevOssOptions',
'pa': 'AudiodevPaOptions',
'sdl: 'AudiodevGenericOptions',
'spice': 'AudiodevGenericOptions',
'wav': 'AudiodevWavOptions' } }Neat, I'll play around with this a bit.
Quoted 12 lines
qapi/qapi-schema.json line 98
Quoted 9 lines
qapi/qapi-schema.json +1
-0@@ -95,3 +95,4 @@ { 'include': 'trace.json' } { 'include': 'introspect.json' } { 'include': 'misc.json' } +{ 'include': 'audio.json' }Looks pretty good.
Regards,
Zoltan
Re: [Qemu-devel] [PATCH v4 01/14] qapi: qapi for audio backends
In reply to Kővágó, ZoltánQuoted 27 lines · Zoltán
This patch adds structures into qapi to replace the existing configuration structures used by audio backends currently. This qapi will be the base of the -audiodev command line parameter (that replaces the old environment variables based config).
This is not a 1:1 translation of the old options, I've tried to make them much more consistent (e.g. almost every backend had an option to specify buffer size, but the name was different for every backend, and some backends required usecs, while some other required frames, samples or bytes). Also tried to reduce the number of abbreviations used by the config keys.
Some of the more important changes:
* useinandoutinstead ofADCandDAC, as the former is more user friendly imho
* moved buffer settings into the global setting area (so it's the same for all backends that support it. Backends that can't change buffer size will simply ignore them). Also using usecs, as it's probably more user friendly than samples or bytes.
* try-poll is now an alsa backend specific option (as all other backends currently ignore it)AudiodevPaPerDirectionOptions struct might look pointless right now, but later we will have new per-direction options, so it's more future-proof this way.
Signed-off-by Kővágó, Zoltán <[email protected]>
[...]
Quoted 5 lines
qapi/audio.json new file +0
-0
[...]
Quoted 6 lines
qapi/audio.json new file +6
-0+## +# @AudiodevPerDirectionOptions: +# +# General audio backend options that are used for both playback and recording. +# +# @fixed-settings: use fixed settings for host input/output. When off,
qapi/audio.json line 185
Quoted 10 lines
qapi/audio.json new file +10
-0+# frequency, channels and format must not be specified +# (default on) +# +# @frequency: frequency to use when using fixed settings (default 44100) +# +# @channels: number of channels when using fixed settings (default 2) +# +# @voices: number of voices to use (default 1) +# +# @format: sample format to use when using fixed settings (default s16)
If I specify any of @frequency, @channels, @voices, @format, then I have to have "fixed-settings": true. Since true is the default, I don't have to say it explicitly, which would be redundant and mildly annoying.
However, specifying "fixed-settings": false is *not* redundant, because it's different from specifying nothing at all, which is the same as "fixed-settings": true, "frequency": 44100, "channels": 2, "voices": 1, "format": "s16".
I think I get it.
Quoted 7 lines
qapi/audio.json new file +7
-0+# +# @buffer-len: the buffer size in microseconds +# +# @buffer-count: number of buffers +# +# Since: 4.0 +##
[...]
PATCH v4 2/14 audio: use qapi AudioFormat instead of audfmt_e
In reply to Kővágó, ZoltánI had to include an enum for audio sampling formats into qapi, but that meant duplicating the audfmt_e enum. This patch replaces audfmt_e and associated values with the qapi generated AudioFormat enum.
This patch is mostly a search-and-replace, except for switches where the qapi generated AUDIO_FORMAT_MAX caused problems.
--- audio/audio.h | 12 +---- audio/alsaaudio.c | 53 +++++++++++---------- audio/audio.c | 97 +++++++++++++++++++++------------------ audio/audio_win_int.c | 18 ++++---- audio/ossaudio.c | 30 ++++++------ audio/paaudio.c | 28 +++++------ audio/sdlaudio.c | 26 +++++------ audio/spiceaudio.c | 4 +- audio/wavaudio.c | 17 ++++--- audio/wavcapture.c | 2 +- hw/arm/omap2.c | 2 +- hw/audio/ac97.c | 2 +- hw/audio/adlib.c | 2 +- hw/audio/cs4231a.c | 6 +-- hw/audio/es1370.c | 4 +- hw/audio/gus.c | 2 +- hw/audio/hda-codec.c | 18 ++++---- hw/audio/lm4549.c | 6 +-- hw/audio/milkymist-ac97.c | 2 +- hw/audio/pcspk.c | 2 +- hw/audio/sb16.c | 14 +++--- hw/audio/wm8750.c | 6 +-- hw/display/xlnx_dp.c | 2 +- hw/input/tsc210x.c | 2 +- hw/usb/dev-audio.c | 2 +- ui/vnc.c | 26 +++++------ 26 files changed, 196 insertions(+), 189 deletions(-)
audio/audio.h +2 -10
@@ -26,18 +26,10 @@#define QEMU_AUDIO_H #include "qemu/queue.h" +#include "qapi/qapi-types-audio.h" typedef void (*audio_callback_fn ) (void *opaque,int avail); -typedef enum { -AUD_FMT_U8 , -AUD_FMT_S8 , -AUD_FMT_U16 , -AUD_FMT_S16 , -AUD_FMT_U32 , -AUD_FMT_S32 -}audfmt_e ; -#ifdef HOST_WORDS_BIGENDIAN #define AUDIO_HOST_ENDIANNESS 1#else
@@ -47,7 +39,7 @@ typedef enum {struct audsettings {int freq;int nchannels; -audfmt_e fmt; +AudioFormat fmt;int endianness; };
audio/alsaaudio.c +28 -25
149 lines not on this page · raw message
audio/audio.c +53 -44
230 lines not on this page · raw message
audio/audio_win_int.c +9 -9
@@ -24,20 +24,20 @@ int waveformat_from_audio_settings (WAVEFORMATEX *wfx, wfx->cbSize =0 ;switch (as->fmt) { -case AUD_FMT_S8 : -case AUD_FMT_U8 : +case AUDIO_FORMAT_S8 : +case AUDIO_FORMAT_U8 : wfx->wBitsPerSample =8 ;break ; -case AUD_FMT_S16 : -case AUD_FMT_U16 : +case AUDIO_FORMAT_S16 : +case AUDIO_FORMAT_U16 : wfx->wBitsPerSample =16 ; wfx->nAvgBytesPerSec <<=1 ; wfx->nBlockAlign <<=1 ;break ; -case AUD_FMT_S32 : -case AUD_FMT_U32 : +case AUDIO_FORMAT_S32 : +case AUDIO_FORMAT_U32 : wfx->wBitsPerSample =32 ; wfx->nAvgBytesPerSec <<=2 ; wfx->nBlockAlign <<=2 ;
@@ -85,15 +85,15 @@ int waveformat_to_audio_settings (WAVEFORMATEX *wfx,switch (wfx->wBitsPerSample) {case 8 : - as->fmt =AUD_FMT_U8 ; + as->fmt =AUDIO_FORMAT_U8 ;break ;case 16 : - as->fmt =AUD_FMT_S16 ; + as->fmt =AUDIO_FORMAT_S16 ;break ;case 32 : - as->fmt =AUD_FMT_S32 ; + as->fmt =AUDIO_FORMAT_S32 ;break ;default :
audio/ossaudio.c +15 -15
@@ -70,7 +70,7 @@ typedef struct OSSVoiceIn {struct oss_params {int freq; -audfmt_e fmt; +AudioFormat fmt;int nchannels;int nfrags;int fragsize;
@@ -148,16 +148,16 @@ static int oss_write (SWVoiceOut *sw, void *buf, int len)return audio_pcm_sw_write (sw, buf, len); } -static int aud_to_ossfmt (audfmt_e fmt,int endianness) +static int aud_to_ossfmt (AudioFormat fmt,int endianness) {switch (fmt) { -case AUD_FMT_S8 : +case AUDIO_FORMAT_S8 :return AFMT_S8 ; -case AUD_FMT_U8 : +case AUDIO_FORMAT_U8 :return AFMT_U8 ; -case AUD_FMT_S16 : +case AUDIO_FORMAT_S16 :if (endianness) {return AFMT_S16_BE ; }
@@ -165,7 +165,7 @@ static int aud_to_ossfmt (audfmt_e fmt, int endianness)return AFMT_S16_LE ; } -case AUD_FMT_U16 : +case AUDIO_FORMAT_U16 :if (endianness) {return AFMT_U16_BE ; }
@@ -182,37 +182,37 @@ static int aud_to_ossfmt (audfmt_e fmt, int endianness) } } -static int oss_to_audfmt (int ossfmt,audfmt_e *fmt,int *endianness) +static int oss_to_audfmt (int ossfmt,AudioFormat *fmt,int *endianness) {switch (ossfmt) {case AFMT_S8 : *endianness =0 ; - *fmt =AUD_FMT_S8 ; + *fmt =AUDIO_FORMAT_S8 ;break ;case AFMT_U8 : *endianness =0 ; - *fmt =AUD_FMT_U8 ; + *fmt =AUDIO_FORMAT_U8 ;break ;case AFMT_S16_LE : *endianness =0 ; - *fmt =AUD_FMT_S16 ; + *fmt =AUDIO_FORMAT_S16 ;break ;case AFMT_U16_LE : *endianness =0 ; - *fmt =AUD_FMT_U16 ; + *fmt =AUDIO_FORMAT_U16 ;break ;case AFMT_S16_BE : *endianness =1 ; - *fmt =AUD_FMT_S16 ; + *fmt =AUDIO_FORMAT_S16 ;break ;case AFMT_U16_BE : *endianness =1 ; - *fmt =AUD_FMT_U16 ; + *fmt =AUDIO_FORMAT_U16 ;break ;default :
@@ -500,7 +500,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsettings *as,int endianness;int err;int fd; -audfmt_e effective_fmt; +AudioFormat effective_fmt;struct audsettings obt_as;OSSConf *conf = drv_opaque;
@@ -667,7 +667,7 @@ static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)int endianness;int err;int fd; -audfmt_e effective_fmt; +AudioFormat effective_fmt;struct audsettings obt_as;OSSConf *conf = drv_opaque;
audio/paaudio.c +14 -14
@@ -385,21 +385,21 @@ static int qpa_read (SWVoiceIn *sw, void *buf, int len)return audio_pcm_sw_read (sw, buf, len); } -static pa_sample_format_t audfmt_to_pa (audfmt_e afmt,int endianness) +static pa_sample_format_t audfmt_to_pa (AudioFormat afmt,int endianness) {int format;switch (afmt) { -case AUD_FMT_S8 : -case AUD_FMT_U8 : +case AUDIO_FORMAT_S8 : +case AUDIO_FORMAT_U8 : format =PA_SAMPLE_U8 ;break ; -case AUD_FMT_S16 : -case AUD_FMT_U16 : +case AUDIO_FORMAT_S16 : +case AUDIO_FORMAT_U16 : format = endianness ?PA_SAMPLE_S16BE :PA_SAMPLE_S16LE ;break ; -case AUD_FMT_S32 : -case AUD_FMT_U32 : +case AUDIO_FORMAT_S32 : +case AUDIO_FORMAT_U32 : format = endianness ?PA_SAMPLE_S32BE :PA_SAMPLE_S32LE ;break ;default :
@@ -410,26 +410,26 @@ static pa_sample_format_t audfmt_to_pa (audfmt_e afmt, int endianness)return format; } -static audfmt_e pa_to_audfmt (pa_sample_format_t fmt,int *endianness) +static AudioFormat pa_to_audfmt (pa_sample_format_t fmt,int *endianness) {switch (fmt) {case PA_SAMPLE_U8 : -return AUD_FMT_U8 ; +return AUDIO_FORMAT_U8 ;case PA_SAMPLE_S16BE : *endianness =1 ; -return AUD_FMT_S16 ; +return AUDIO_FORMAT_S16 ;case PA_SAMPLE_S16LE : *endianness =0 ; -return AUD_FMT_S16 ; +return AUDIO_FORMAT_S16 ;case PA_SAMPLE_S32BE : *endianness =1 ; -return AUD_FMT_S32 ; +return AUDIO_FORMAT_S32 ;case PA_SAMPLE_S32LE : *endianness =0 ; -return AUD_FMT_S32 ; +return AUDIO_FORMAT_S32 ;default :dolog ("Internal logic error: Bad pa_sample_format %d\n" , fmt); -return AUD_FMT_U8 ; +return AUDIO_FORMAT_U8 ; } }
audio/sdlaudio.c +13 -13
@@ -137,19 +137,19 @@ static int sdl_unlock_and_post (SDLAudioState *s, const char *forfn)return sdl_post (s, forfn); } -static int aud_to_sdlfmt (audfmt_e fmt) +static int aud_to_sdlfmt (AudioFormat fmt) {switch (fmt) { -case AUD_FMT_S8 : +case AUDIO_FORMAT_S8 :return AUDIO_S8 ; -case AUD_FMT_U8 : +case AUDIO_FORMAT_U8 :return AUDIO_U8 ; -case AUD_FMT_S16 : +case AUDIO_FORMAT_S16 :return AUDIO_S16LSB ; -case AUD_FMT_U16 : +case AUDIO_FORMAT_U16 :return AUDIO_U16LSB ;default :
@@ -161,37 +161,37 @@ static int aud_to_sdlfmt (audfmt_e fmt) } } -static int sdl_to_audfmt (int sdlfmt,audfmt_e *fmt,int *endianness) +static int sdl_to_audfmt (int sdlfmt,AudioFormat *fmt,int *endianness) {switch (sdlfmt) {case AUDIO_S8 : *endianness =0 ; - *fmt =AUD_FMT_S8 ; + *fmt =AUDIO_FORMAT_S8 ;break ;case AUDIO_U8 : *endianness =0 ; - *fmt =AUD_FMT_U8 ; + *fmt =AUDIO_FORMAT_U8 ;break ;case AUDIO_S16LSB : *endianness =0 ; - *fmt =AUD_FMT_S16 ; + *fmt =AUDIO_FORMAT_S16 ;break ;case AUDIO_U16LSB : *endianness =0 ; - *fmt =AUD_FMT_U16 ; + *fmt =AUDIO_FORMAT_U16 ;break ;case AUDIO_S16MSB : *endianness =1 ; - *fmt =AUD_FMT_S16 ; + *fmt =AUDIO_FORMAT_S16 ;break ;case AUDIO_U16MSB : *endianness =1 ; - *fmt =AUD_FMT_U16 ; + *fmt =AUDIO_FORMAT_U16 ;break ;default :
@@ -386,7 +386,7 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as,SDL_AudioSpec req, obt;int endianness;int err; -audfmt_e effective_fmt; +AudioFormat effective_fmt;struct audsettings obt_as; req.freq = as->freq;
audio/spiceaudio.c +2 -2
@@ -130,7 +130,7 @@ static int line_out_init(HWVoiceOut *hw, struct audsettings *as, settings.freq =SPICE_INTERFACE_PLAYBACK_FREQ ;#endif settings.nchannels =SPICE_INTERFACE_PLAYBACK_CHAN ; - settings.fmt =AUD_FMT_S16 ; + settings.fmt =AUDIO_FORMAT_S16 ; settings.endianness =AUDIO_HOST_ENDIANNESS ;audio_pcm_init_info (&hw->info, &settings);
@@ -258,7 +258,7 @@ static int line_in_init(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) settings.freq =SPICE_INTERFACE_RECORD_FREQ ;#endif settings.nchannels =SPICE_INTERFACE_RECORD_CHAN ; - settings.fmt =AUD_FMT_S16 ; + settings.fmt =AUDIO_FORMAT_S16 ; settings.endianness =AUDIO_HOST_ENDIANNESS ;audio_pcm_init_info (&hw->info, &settings);
audio/wavaudio.c +10 -7
@@ -117,20 +117,23 @@ static int wav_init_out(HWVoiceOut *hw, struct audsettings *as, stereo = wav_as.nchannels ==2 ;switch (wav_as.fmt) { -case AUD_FMT_S8 : -case AUD_FMT_U8 : +case AUDIO_FORMAT_S8 : +case AUDIO_FORMAT_U8 : bits16 =0 ;break ; -case AUD_FMT_S16 : -case AUD_FMT_U16 : +case AUDIO_FORMAT_S16 : +case AUDIO_FORMAT_U16 : bits16 =1 ;break ; -case AUD_FMT_S32 : -case AUD_FMT_U32 : +case AUDIO_FORMAT_S32 : +case AUDIO_FORMAT_U32 :dolog ("WAVE files can not handle 32bit formats\n" );return -1 ; + +default : +abort (); } hdr[34 ] = bits16 ?0x10 :0x08 ;
@@ -225,7 +228,7 @@ static int wav_ctl_out (HWVoiceOut *hw, int cmd, ...)static WAVConf glob_conf = { .settings.freq =44100 , .settings.nchannels =2 , - .settings.fmt =AUD_FMT_S16 , + .settings.fmt =AUDIO_FORMAT_S16 , .wav_path ="qemu.wav" };
audio/wavcapture.c +1 -1
@@ -139,7 +139,7 @@ int wav_start_capture (CaptureState *s, const char *path, int freq, as.freq = freq; as.nchannels =1 << stereo; - as.fmt = bits16 ?AUD_FMT_S16 :AUD_FMT_U8 ; + as.fmt = bits16 ?AUDIO_FORMAT_S16 :AUDIO_FORMAT_U8 ; as.endianness =0 ; ops.notify = wav_notify;
hw/arm/omap2.c +1 -1
@@ -273,7 +273,7 @@ static void omap_eac_format_update(struct omap_eac_s *s)* does I2S specify it? */ /* All register writes are 16 bits so we we store 16-bit samples * in the buffers regardless of AGCFR[B8_16] value. */ - fmt.fmt =AUD_FMT_U16 ; + fmt.fmt =AUDIO_FORMAT_U16 ; s->codec.in_voice =AUD_open_in (&s->codec.card, s->codec.in_voice,"eac.codec.in" , s, omap_eac_in_cb, &fmt);
hw/audio/ac97.c +1 -1
@@ -365,7 +365,7 @@ static void open_voice (AC97LinkState *s, int index, int freq) as.freq = freq; as.nchannels =2 ; - as.fmt =AUD_FMT_S16 ; + as.fmt =AUDIO_FORMAT_S16 ; as.endianness =0 ;if (freq >0 ) {
hw/audio/adlib.c +1 -1
@@ -269,7 +269,7 @@ static void adlib_realizefn (DeviceState *dev, Error **errp) as.freq = s->freq; as.nchannels =SHIFT ; - as.fmt =AUD_FMT_S16 ; + as.fmt =AUDIO_FORMAT_S16 ; as.endianness =AUDIO_HOST_ENDIANNESS ;AUD_register_card ("adlib" , &s->card);
hw/audio/cs4231a.c +3 -3
@@ -288,7 +288,7 @@ static void cs_reset_voices (CSState *s, uint32_t val)switch ((val >>5 ) & ((s->dregs[MODE_And_ID] &MODE2 ) ?7 :3 )) {case 0 : - as.fmt =AUD_FMT_U8 ; + as.fmt =AUDIO_FORMAT_U8 ; s->shift = as.nchannels ==2 ;break ;
@@ -298,7 +298,7 @@ static void cs_reset_voices (CSState *s, uint32_t val)case 3 : s->tab = ALawDecompressTable; x_law: - as.fmt =AUD_FMT_S16 ; + as.fmt =AUDIO_FORMAT_S16 ; as.endianness =AUDIO_HOST_ENDIANNESS ; s->shift = as.nchannels ==2 ;break ;
@@ -307,7 +307,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) as.endianness =1 ;/* fall through */ case 2 : - as.fmt =AUD_FMT_S16 ; + as.fmt =AUDIO_FORMAT_S16 ; s->shift = as.nchannels;break ;
hw/audio/es1370.c +2 -2
@@ -414,14 +414,14 @@ static void es1370_update_voices (ES1370State *s, uint32_t ctl, uint32_t sctl) i, new_freq,1 << (new_fmt &1 ), - (new_fmt &2 ) ?AUD_FMT_S16 :AUD_FMT_U8 , + (new_fmt &2 ) ?AUDIO_FORMAT_S16 :AUDIO_FORMAT_U8 , d->shift);if (new_freq) {struct audsettings as; as.freq = new_freq; as.nchannels =1 << (new_fmt &1 ); - as.fmt = (new_fmt &2 ) ?AUD_FMT_S16 :AUD_FMT_U8 ; + as.fmt = (new_fmt &2 ) ?AUDIO_FORMAT_S16 :AUDIO_FORMAT_U8 ; as.endianness =0 ;if (i ==ADC_CHANNEL ) {
hw/audio/gus.c +1 -1
@@ -251,7 +251,7 @@ static void gus_realizefn (DeviceState *dev, Error **errp) as.freq = s->freq; as.nchannels =2 ; - as.fmt =AUD_FMT_S16 ; + as.fmt =AUDIO_FORMAT_S16 ; as.endianness =GUS_ENDIANNESS ; s->voice = AUD_open_out (
hw/audio/hda-codec.c +9 -9
@@ -99,9 +99,9 @@ static void hda_codec_parse_fmt(uint32_t format, struct audsettings *as) }switch (format &AC_FMT_BITS_MASK ) { -case AC_FMT_BITS_8 : as->fmt =AUD_FMT_S8 ;break ; -case AC_FMT_BITS_16 : as->fmt =AUD_FMT_S16 ;break ; -case AC_FMT_BITS_32 : as->fmt =AUD_FMT_S32 ;break ; +case AC_FMT_BITS_8 : as->fmt =AUDIO_FORMAT_S8 ;break ; +case AC_FMT_BITS_16 : as->fmt =AUDIO_FORMAT_S16 ;break ; +case AC_FMT_BITS_32 : as->fmt =AUDIO_FORMAT_S32 ;break ; } as->nchannels = ((format &AC_FMT_CHAN_MASK ) >>AC_FMT_CHAN_SHIFT ) +1 ;
@@ -134,12 +134,12 @@ static void hda_codec_parse_fmt(uint32_t format, struct audsettings *as)/* -------------------------------------------------------------------------- */ static const char *fmt2name[] = { - [AUD_FMT_U8 ] ="PCM-U8" , - [AUD_FMT_S8 ] ="PCM-S8" , - [AUD_FMT_U16 ] ="PCM-U16" , - [AUD_FMT_S16 ] ="PCM-S16" , - [AUD_FMT_U32 ] ="PCM-U32" , - [AUD_FMT_S32 ] ="PCM-S32" , + [AUDIO_FORMAT_U8 ] ="PCM-U8" , + [AUDIO_FORMAT_S8 ] ="PCM-S8" , + [AUDIO_FORMAT_U16 ] ="PCM-U16" , + [AUDIO_FORMAT_S16 ] ="PCM-S16" , + [AUDIO_FORMAT_U32 ] ="PCM-U32" , + [AUDIO_FORMAT_S32 ] ="PCM-S32" , };typedef struct HDAAudioState HDAAudioState ;
hw/audio/lm4549.c +3 -3
@@ -185,7 +185,7 @@ void lm4549_write(lm4549_state *s,struct audsettings as; as.freq = value; as.nchannels =2 ; - as.fmt =AUD_FMT_S16 ; + as.fmt =AUDIO_FORMAT_S16 ; as.endianness =0 ; s->voice = AUD_open_out(
@@ -255,7 +255,7 @@ static int lm4549_post_load(void *opaque, int version_id)struct audsettings as; as.freq = freq; as.nchannels =2 ; - as.fmt =AUD_FMT_S16 ; + as.fmt =AUDIO_FORMAT_S16 ; as.endianness =0 ; s->voice = AUD_open_out(
@@ -292,7 +292,7 @@ void lm4549_init(lm4549_state *s, lm4549_callback data_req_cb, void* opaque)/* Open a default voice */ as.freq =48000 ; as.nchannels =2 ; - as.fmt =AUD_FMT_S16 ; + as.fmt =AUDIO_FORMAT_S16 ; as.endianness =0 ; s->voice = AUD_open_out(
hw/audio/milkymist-ac97.c +1 -1
@@ -308,7 +308,7 @@ static void milkymist_ac97_realize(DeviceState *dev, Error **errp) as.freq =48000 ; as.nchannels =2 ; - as.fmt =AUD_FMT_S16 ; + as.fmt =AUDIO_FORMAT_S16 ; as.endianness =1 ; s->voice_in = AUD_open_in(&s->card, s->voice_in,
hw/audio/pcspk.c +1 -1
@@ -162,7 +162,7 @@ static void pcspk_initfn(Object *obj)static void pcspk_realizefn (DeviceState *dev,Error **errp) { -struct audsettings as = {PCSPK_SAMPLE_RATE ,1 ,AUD_FMT_U8 ,0 }; +struct audsettings as = {PCSPK_SAMPLE_RATE ,1 ,AUDIO_FORMAT_U8 ,0 };ISADevice *isadev =ISA_DEVICE (dev);PCSpkState *s =PC_SPEAKER (dev);
hw/audio/sb16.c +7 -7
@@ -66,7 +66,7 @@ typedef struct SB16State {int fmt_stereo;int fmt_signed;int fmt_bits; -audfmt_e fmt; +AudioFormat fmt;int dma_auto;int block_size;int fifo;
@@ -224,7 +224,7 @@ static void continue_dma8 (SB16State *s)static void dma_cmd8 (SB16State *s,int mask,int dma_len) { - s->fmt =AUD_FMT_U8 ; + s->fmt =AUDIO_FORMAT_U8 ; s->use_hdma =0 ; s->fmt_bits =8 ; s->fmt_signed =0 ;
@@ -319,18 +319,18 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8_t d0, int dma_len)if (16 == s->fmt_bits) {if (s->fmt_signed) { - s->fmt =AUD_FMT_S16 ; + s->fmt =AUDIO_FORMAT_S16 ; }else { - s->fmt =AUD_FMT_U16 ; + s->fmt =AUDIO_FORMAT_U16 ; } }else {if (s->fmt_signed) { - s->fmt =AUD_FMT_S8 ; + s->fmt =AUDIO_FORMAT_S8 ; }else { - s->fmt =AUD_FMT_U8 ; + s->fmt =AUDIO_FORMAT_U8 ; } }
@@ -852,7 +852,7 @@ static void legacy_reset (SB16State *s) as.freq = s->freq; as.nchannels =1 ; - as.fmt =AUD_FMT_U8 ; + as.fmt =AUDIO_FORMAT_U8 ; as.endianness =0 ; s->voice = AUD_open_out (
hw/audio/wm8750.c +3 -3
@@ -201,7 +201,7 @@ static void wm8750_set_format(WM8750State *s) in_fmt.endianness =0 ; in_fmt.nchannels =2 ; in_fmt.freq = s->adc_hz; - in_fmt.fmt =AUD_FMT_S16 ; + in_fmt.fmt =AUDIO_FORMAT_S16 ; s->adc_voice[0 ] =AUD_open_in (&s->card, s->adc_voice[0 ],CODEC ".input1" , s, wm8750_audio_in_cb, &in_fmt);
@@ -214,7 +214,7 @@ static void wm8750_set_format(WM8750State *s) out_fmt.endianness =0 ; out_fmt.nchannels =2 ; out_fmt.freq = s->dac_hz; - out_fmt.fmt =AUD_FMT_S16 ; + out_fmt.fmt =AUDIO_FORMAT_S16 ; s->dac_voice[0 ] =AUD_open_out (&s->card, s->dac_voice[0 ],CODEC ".speaker" , s, wm8750_audio_out_cb, &out_fmt);
@@ -681,7 +681,7 @@ uint32_t wm8750_adc_dat(void *opaque)if (s->idx_in >=sizeof (s->data_in)) {wm8750_in_load (s);if (s->idx_in >=sizeof (s->data_in)) { -return 0x80008000 ;/* silence in AUD_FMT_S16 sample format */ +return 0x80008000 ;/* silence in AUDIO_FORMAT_S16 sample format */ } }
hw/display/xlnx_dp.c +1 -1
@@ -1260,7 +1260,7 @@ static void xlnx_dp_realize(DeviceState *dev, Error **errp) as.freq =44100 ; as.nchannels =2 ; - as.fmt =AUD_FMT_S16 ; + as.fmt =AUDIO_FORMAT_S16 ; as.endianness =0 ;AUD_register_card ("xlnx_dp.audio" , &s->aud_card);
hw/input/tsc210x.c +1 -1
@@ -318,7 +318,7 @@ static void tsc2102_audio_output_update(TSC210xState *s) fmt.endianness =0 ; fmt.nchannels =2 ; fmt.freq = s->codec.tx_rate; - fmt.fmt =AUD_FMT_S16 ; + fmt.fmt =AUDIO_FORMAT_S16 ; s->dac_voice[0 ] =AUD_open_out (&s->card, s->dac_voice[0 ],"tsc2102.sink" , s, (void *) tsc210x_audio_out_cb, &fmt);
hw/usb/dev-audio.c +1 -1
@@ -650,7 +650,7 @@ static void usb_audio_realize(USBDevice *dev, Error **errp) s->out.vol[1 ] =240 ;/* 0 dB */ s->out.as.freq =USBAUDIO_SAMPLE_RATE ; s->out.as.nchannels =2 ; - s->out.as.fmt =AUD_FMT_S16 ; + s->out.as.fmt =AUDIO_FORMAT_S16 ; s->out.as.endianness =0 ;streambuf_init (&s->out.buf, s->buffer);
ui/vnc.c +13 -13
@@ -1013,16 +1013,16 @@ static void vnc_update_throttle_offset(VncState *vs)int bps;switch (vs->as.fmt) {default : -case AUD_FMT_U8 : -case AUD_FMT_S8 : +case AUDIO_FORMAT_U8 : +case AUDIO_FORMAT_S8 : bps =1 ;break ; -case AUD_FMT_U16 : -case AUD_FMT_S16 : +case AUDIO_FORMAT_U16 : +case AUDIO_FORMAT_S16 : bps =2 ;break ; -case AUD_FMT_U32 : -case AUD_FMT_S32 : +case AUDIO_FORMAT_U32 : +case AUDIO_FORMAT_S32 : bps =4 ;break ; }
@@ -2428,12 +2428,12 @@ static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)if (len ==4 )return 10 ;switch (read_u8 (data,4 )) { -case 0 : vs->as.fmt =AUD_FMT_U8 ;break ; -case 1 : vs->as.fmt =AUD_FMT_S8 ;break ; -case 2 : vs->as.fmt =AUD_FMT_U16 ;break ; -case 3 : vs->as.fmt =AUD_FMT_S16 ;break ; -case 4 : vs->as.fmt =AUD_FMT_U32 ;break ; -case 5 : vs->as.fmt =AUD_FMT_S32 ;break ; +case 0 : vs->as.fmt =AUDIO_FORMAT_U8 ;break ; +case 1 : vs->as.fmt =AUDIO_FORMAT_S8 ;break ; +case 2 : vs->as.fmt =AUDIO_FORMAT_U16 ;break ; +case 3 : vs->as.fmt =AUDIO_FORMAT_S16 ;break ; +case 4 : vs->as.fmt =AUDIO_FORMAT_U32 ;break ; +case 5 : vs->as.fmt =AUDIO_FORMAT_S32 ;break ;default :VNC_DEBUG ("Invalid audio format %d\n" ,read_u8 (data,4 ));vnc_client_error (vs);
@@ -3164,7 +3164,7 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSocket *sioc, vs->as.freq =44100 ; vs->as.nchannels =2 ; - vs->as.fmt =AUD_FMT_S16 ; + vs->as.fmt =AUDIO_FORMAT_S16 ; vs->as.endianness =0 ;qemu_mutex_init (&vs->output_mutex);
Signature · 1 line
2.20.1
Re: [Qemu-arm] [Qemu-devel] [PATCH v4 02/14] audio: use qapi AudioFormat instead of audfmt_e
Quoted 9 lines · Zoltán
I had to include an enum for audio sampling formats into qapi, but that meant duplicating the
audfmt_eenum. This patch replacesaudfmt_eand associated values with the qapi generated AudioFormat enum.This patch is mostly a search-and-replace, except for switches where the qapi generated
AUDIO_FORMAT_MAXcaused problems.Signed-off-by Kővágó, Zoltán <[email protected]>---
PATCH v4 3/14 audio: -audiodev command line option: documentation
In reply to Kővágó, ZoltánThis patch adds documentation of an -audiodev command line option, that deprecates the old QEMU_* environment variables for audio backend configuration. It's syntax is similar to existing options (-netdev, -device, etc):
-audiodev driver_name,property=value,...
Although now it's possible to specify multiple -audiodev options on command line, multiple audio backends are not supported yet.
--- qemu-options.hx | 222 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 219 insertions(+), 3 deletions(-)
qemu-options.hx +219 -3
@@ -416,14 +416,230 @@ The default is @code{en-us}. ETEXI +HXCOMM Deprecated by -audiodev DEF("audio-help", 0, QEMU_OPTION_audio_help, - "-audio-help print list of audio drivers and their options\n", + "-audio-help show -audiodev equivalent of the currently specified audio settings\n", QEMU_ARCH_ALL) STEXI @item -audio-help @findex -audio-help -Will show the audio subsystem help: list of drivers, tunable -parameters. +Will show the -audiodev equivalent of the currently specified +(deprecated) environment variables. +ETEXI + +DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, + "-audiodev [driver=]driver,id=id[,prop[=value][,...]]\n" + " specifies the audio backend to use\n" + " id= identifier of the backend\n" + " timer-period= timer period in microseconds\n" + " in|out.fixed-settings= use fixed settings for host audio\n" + " in|out.frequency= frequency to use with fixed settings\n" + " in|out.channels= number of channels to use with fixed settings\n" + " in|out.format= sample format to use with fixed settings\n" + " valid values: s8, s16, s32, u8, u16, u32\n" + " in|out.voices= number of voices to use\n" + " in|out.buffer-len= size of buffer in microseconds\n" + " in|out.buffer-count= number of buffers\n" + "-audiodev none,id=id,[,prop[=value][,...]]\n" + " dummy driver that discards all output\n" +#ifdef CONFIG_ALSA + "-audiodev alsa,id=id[,prop[=value][,...]]\n" + " alsa-in|alsa-out.dev= name of the audio device to use\n" + " alsa-in|alsa-out.try-poll= attempt to use poll mode\n" + " threshold= threshold (in microseconds) when playback starts\n" +#endif +#ifdef CONFIG_COREAUDIO + "-audiodev coreaudio,id=id[,prop[=value][,...]]\n" +#endif +#ifdef CONFIG_DSOUND + "-audiodev dsound,id=id[,prop[=value][,...]]\n" + " latency= add extra latency to playback in microseconds\n" +#endif +#ifdef CONFIG_OSS + "-audiodev oss,id=id[,prop[=value][,...]]\n" + " oss-in|oss-out.dev= path of the audio device to use\n" + " oss-in|oss-out.try-poll= attempt to use poll mode\n" + " try-mmap= try using memory mapped access\n" + " exclusive= open device in exclusive mode\n" + " dsp-policy= set timing policy (0..10), -1 to use fragment mode\n" +#endif +#ifdef CONFIG_PA + "-audiodev pa,id=id[,prop[=value][,...]]\n" + " server= PulseAudio server address\n" + " sink|source.name= sink/source device name\n" +#endif +#ifdef CONFIG_SDL + "-audiodev sdl,id=id[,prop[=value][,...]]\n" +#endif +#ifdef CONFIG_SPICE + "-audiodev spice,id=id[,prop[=value][,...]]\n" +#endif + "-audiodev wav,id=id[,prop[=value][,...]]\n" + " path= path of wav file to record\n", + QEMU_ARCH_ALL) +STEXI +@item -audiodev [driver=]@var{driver},id=@var{id}[,@var{prop}[=@var{value}][,...]] +@findex -audiodev +Adds a new audio backend @var{driver} identified by @var{id}. There are +global and driver specific properties. Some values can be set +differently for input and output, they're marked with @code{in|out.}. +You can set the input's property with @code{in.@var{prop}} and the +output's property with @code{out.@var{prop}}. For example: +@example +-audiodev alsa,id=example,in.frequency=44110,out.frequency=8000 +-audiodev alsa,id=example,out.channels=1 # leaves in.channels unspecified +@end example + +Valid global options are: + +@table @option +@item id=@var{identifier} +Identifies the audio backend. + +@item timer-period=@var{period} +Sets the timer @var{period} used by the audio subsystem in microseconds. +Default is 10000 (10 ms). + +@item in|out.fixed-settings=on|off +Use fixed settings for host audio. When off, it will change based on +how the guest opens the sound card. In this case you must not specify +@var{frequency}, @var{channels} or @var{format}. Default is on. + +@item in|out.frequency=@var{frequency} +Specify the @var{frequency} to use when using @var{fixed-settings}. +Default is 44100Hz. + +@item in|out.channels=@var{channels} +Specify the number of @var{channels} to use when using +@var{fixed-settings}. Default is 2 (stereo). + +@item in|out.format=@var{format} +Specify the sample @var{format} to use when using @var{fixed-settings}. +Valid values are: @code{s8}, @code{s16}, @code{s32}, @code{u8}, +@code{u16}, @code{u32}. Default is @code{s16}. + +@item in|out.voices=@var{voices} +Specify the number of @var{voices} to use. Default is 1. + +@item in|out.buffer=@var{usecs} +Sets the size of the buffer in microseconds. + +@item in|out.buffer-count=@var{count} +Sets the @var{count} of the buffers. + +@end table + +@item -audiodev none,id=@var{id}[,@var{prop}[=@var{value}][,...]] +Creates a dummy backend that discards all outputs. This backend has no +backend specific properties. + +@item -audiodev alsa,id=@var{id}[,@var{prop}[=@var{value}][,...]] +Creates backend using the ALSA. This backend is only available on +Linux. + +ALSA specific options are: + +@table @option +@item alsa-in|alsa-out.dev=@var{device} +Specify the ALSA @var{device} to use for input and/or output. Default +is @code{default}. + +@item alsa-in|alsa-out.try-poll=on|off +Attempt to use poll mode with the device. Default is on. + +@item threshold=@var{threshold} +Threshold (in microseconds) when playback starts. Default is 0. + +@end table + +@item -audiodev coreaudio,id=@var{id}[,@var{prop}[=@var{value}][,...]] +Creates a backend using Apple's Core Audio. This backend is only +available on Mac OS and only supports playback. This backend has no +backend specific properties. + +@item -audiodev dsound,id=@var{id}[,@var{prop}[=@var{value}][,...]] +Creates a backend using Microsoft's DirectSound. This backend is only +available on Windows and only supports playback. + +Backend specific options are: + +@table @option + +@item latency=@var{usecs} +Add extra @var{usecs} microseconds latency to playback. Default is +10000 (10 ms). + +@end table + +@item -audiodev oss,id=@var{id}[,@var{prop}[=@var{value}][,...]] +Creates a backend using OSS. This backend is available on most +Unix-like systems. + +OSS specific options are: + +@table @option + +@item oss-in|oss-out.dev=@var{device} +Specify the file name of the OSS @var{device} to use. Default is +@code{/dev/dsp}. + +@item oss-in|oss-out.try-poll=on|of +Attempt to use poll mode with the device. Default is on. + +@item try-mmap=on|off +Try using memory mapped device access. Default is off. + +@item exclusive=on|off +Open the device in exclusive mode (vmix won't work in this case). +Default is off. + +@item dsp-policy=@var{policy} +Sets the timing policy (between 0 and 10, where smaller number means +smaller latency but higher CPU usage). Use -1 to use buffer sizes +specified by @code{buffer} and @code{buffer-count}. This option is +ignored if you do not have OSS 4. Default is 5. + +@end table + +@item -audiodev pa,id=@var{id}[,@var{prop}[=@var{value}][,...]] +Creates a backend using PulseAudio. This backend is available on most +systems. + +PulseAudio specific options are: + +@table @option + +@item server=@var{server} +Sets the PulseAudio @var{server} to connect to. + +@item sink|source.name=@var{sink} +Use the specified sink/source for playback/recording. + +@end table + +@item -audiodev sdl,id=@var{id}[,@var{prop}[=@var{value}][,...]] +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 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 +can ignore this option. This backend has no backend specific +properties. + +@item -audiodev wav,id=@var{id}[,@var{prop}[=@var{value}][,...]] +Creates a backend that writes audio to a WAV file. + +Backend specific options are: + +@table @option + +@item path=@var{path} +Write recorded audio into the specified file. Default is +@code{qemu.wav}. + +@end table ETEXI DEF("soundhw", HAS_ARG, QEMU_OPTION_soundhw,
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v4 03/14] audio: -audiodev command line option: documentation
Quoted 20 lines · Zoltán
This patch adds documentation of an -audiodev command line option, that deprecates the old QEMU_* environment variables for audio backend configuration. It's syntax is similar to existing options (-netdev, -device, etc):
-audiodev driver_name,property=value,...
Although now it's possible to specify multiple -audiodev options on command line, multiple audio backends are not supported yet.
Signed-off-by Kővágó, Zoltán <[email protected]>--- qemu-options.hx | 222 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 219 insertions(+), 3 deletions(-)qemu-options.hx +0
-0
qemu-options.hx The default is @code{en-us}. · line 422
Quoted 8 lines
qemu-options.hx +2
-1@@ -416,14 +416,230 @@ The default is @code{en-us}. ETEXI +HXCOMM Deprecated by -audiodev DEF("audio-help", 0, QEMU_OPTION_audio_help, - "-audio-help print list of audio drivers and their options\n", + "-audio-help show -audiodev equivalent of the currently specified audio settings\n", QEMU_ARCH_ALL)
Note that if you want to deprecate a parameter "officially" (in the sense that it could be removed in a future release), you also have to add an entry to qemu-deprecated.texi. But that could also be done in an additional patch later, so no need to respin just because of this.
Thomas
PATCH v4 4/14 audio: -audiodev command line option basic implementation
In reply to Kővágó, ZoltánAudio drivers now get an Audiodev * as config paramters, instead of the global audio_option structs. There is some code in audio/audio_legacy.c that converts the old environment variables to audiodev options (this way backends do not have to worry about legacy options). It also contains a replacement of -audio-help, which prints out the equivalent -audiodev based config of the currently specified environment variables.
Note that backends are not updated and still rely on environment variables.
Also note that (due to moving try-poll from global to backend specific option) currently ALSA and OSS will always try poll mode, regardless of environment variables or -audiodev options.
---
Notes:
Changes from v2:
* MAJOR: use qobject_input_visitor instead of QemuOpts
* almost completely rewrote legacy options handling
* added missing license comment to audio_legacy.c0
audio/audio.h | 18 +- audio/audio_int.h | 16 +- audio/audio_template.h | 13 +- audio/alsaaudio.c | 2 +- audio/audio.c | 601 ++++++++++++++++------------------------- audio/audio_legacy.c | 295 ++++++++++++++++++++ audio/coreaudio.c | 2 +- audio/dsoundaudio.c | 2 +- audio/noaudio.c | 2 +- audio/ossaudio.c | 2 +- audio/paaudio.c | 2 +- audio/sdlaudio.c | 2 +- audio/spiceaudio.c | 2 +- audio/wavaudio.c | 2 +- vl.c | 7 +- audio/Makefile.objs | 2 +- 16 files changed, 590 insertions(+), 380 deletions(-) create mode 100644 audio/audio_legacy.c
audio/audio.h +15 -3
@@ -36,12 +36,21 @@ typedef void (*audio_callback_fn) (void *opaque, int avail);#define AUDIO_HOST_ENDIANNESS 0#endif -struct audsettings { +typedef struct audsettings {int freq;int nchannels;AudioFormat fmt;int endianness; -}; +}audsettings ; + +audsettings audiodev_to_audsettings (AudiodevPerDirectionOptions *pdo); +int audioformat_bytes_per_sample (AudioFormat fmt); +int audio_buffer_frames (AudiodevPerDirectionOptions *pdo, +audsettings *as,int def_usecs); +int audio_buffer_samples (AudiodevPerDirectionOptions *pdo, +audsettings *as,int def_usecs); +int audio_buffer_bytes (AudiodevPerDirectionOptions *pdo, +audsettings *as,int def_usecs); typedef enum { AUD_CNOTIFY_ENABLE,
@@ -81,7 +90,6 @@ typedef struct QEMUAudioTimeStamp { void AUD_vlog (const char *cap, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); void AUD_log (const char *cap, const char *fmt, ...) GCC_FMT_ATTR(2, 3); -void AUD_help (void );void AUD_register_card (const char *name,QEMUSoundCard *card);void AUD_remove_card (QEMUSoundCard *card); CaptureVoiceOut *AUD_add_capture (
@@ -163,4 +171,8 @@ void audio_sample_to_uint64(void *samples, int pos,void audio_sample_from_uint64 (void *samples,int pos,uint64_t left,uint64_t right); +void audio_parse_option (const char *opt); +void audio_init_audiodevs (void ); +void audio_legacy_help (void ); +#endif /* QEMU_AUDIO_H */
audio/audio_int.h +15 -1
@@ -146,7 +146,7 @@ struct audio_driver {const char *name;const char *descr;struct audio_option *options; -void *(*init) (void ); +void *(*init) (Audiodev *);void (*fini) (void *);struct audio_pcm_ops *pcm_ops;int can_be_default;
@@ -193,6 +193,7 @@ struct SWVoiceCap { typedef struct AudioState { struct audio_driver *drv; + Audiodev *dev; void *drv_opaque; QEMUTimer *ts;
@@ -203,10 +204,13 @@ typedef struct AudioState {int nb_hw_voices_out;int nb_hw_voices_in;int vm_running; +int64_t period_ticks; } AudioState;extern const struct mixeng_volume nominal_volume; +extern const char *audio_prio_list[]; +void audio_driver_register (audio_driver *drv);audio_driver *audio_driver_lookup (const char *name);
@@ -248,4 +252,14 @@ static inline int audio_ring_dist (int dst, int src, int len)#define AUDIO_STRINGIFY_ (n) #n#define AUDIO_STRINGIFY (n) AUDIO_STRINGIFY_(n) +typedef struct AudiodevListEntry { +Audiodev *dev; +QSIMPLEQ_ENTRY (AudiodevListEntry) next; +}AudiodevListEntry ; + +typedef QSIMPLEQ_HEAD(, AudiodevListEntry) AudiodevListHead; +AudiodevListHead audio_handle_legacy_opts (void ); + +void audio_free_audiodev_list (AudiodevListHead *head); +#endif /* QEMU_AUDIO_INT_H */
audio/audio_template.h +9 -4
@@ -302,8 +302,10 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct audsettings *as)static HW *glue (audio_pcm_hw_add_ ,TYPE ) (struct audsettings *as) {HW *hw; +AudioState *s = &glob_audio_state; +AudiodevPerDirectionOptions *pdo = s->dev->TYPE; -if (glue (conf.fixed_,TYPE ).enabled &&glue (conf.fixed_,TYPE ).greedy) { +if (pdo->fixed_settings) { hw =glue (audio_pcm_hw_add_new_,TYPE ) (as);if (hw) {return hw;
@@ -331,9 +333,11 @@ static SW *glue (audio_pcm_create_voice_pair_, TYPE) (SW *sw;HW *hw;struct audsettings hw_as; +AudioState *s = &glob_audio_state; +AudiodevPerDirectionOptions *pdo = s->dev->TYPE; -if (glue (conf.fixed_,TYPE ).enabled) { - hw_as =glue (conf.fixed_,TYPE ).settings; +if (pdo->fixed_settings) { + hw_as =audiodev_to_audsettings (pdo); }else { hw_as = *as;
@@ -398,6 +402,7 @@ SW *glue (AUD_open_, TYPE) ( ) {AudioState *s = &glob_audio_state; +AudiodevPerDirectionOptions *pdo = s->dev->TYPE;if (audio_bug (__func__, !card || !name || !callback_fn || !as)) { dolog ("card=%p name=%p callback_fn=%p as=%p\n",
@@ -422,7 +427,7 @@ SW *glue (AUD_open_, TYPE) (return sw; } -if (!glue (conf.fixed_,TYPE ).enabled && sw) { +if (!pdo->fixed_settings && sw) {glue (AUD_close_,TYPE ) (card, sw); sw =NULL ; }
audio/alsaaudio.c +1 -1
@@ -1125,7 +1125,7 @@ static ALSAConf glob_conf = { .pcm_name_in = "default", }; -static void *alsa_audio_init (void ) +static void *alsa_audio_init (Audiodev *dev) {ALSAConf *conf =g_malloc (sizeof (ALSAConf)); *conf = glob_conf;
audio/audio.c +240 -361
771 lines not on this page · raw message
audio/audio_legacy.c new file +295 -0
295 lines not on this page · raw message
audio/coreaudio.c +1 -1
@@ -685,7 +685,7 @@ static CoreaudioConf glob_conf = { .nbuffers = 4, }; -static void *coreaudio_audio_init (void ) +static void *coreaudio_audio_init (Audiodev *dev) {CoreaudioConf *conf =g_malloc (sizeof (CoreaudioConf)); *conf = glob_conf;
audio/dsoundaudio.c +1 -1
@@ -783,7 +783,7 @@ static void dsound_audio_fini (void *opaque)g_free (s); } -static void *dsound_audio_init (void ) +static void *dsound_audio_init (Audiodev *dev) {int err;HRESULT hr;
audio/noaudio.c +1 -1
@@ -136,7 +136,7 @@ static int no_ctl_in (HWVoiceIn *hw, int cmd, ...)return 0 ; } -static void *no_audio_init (void ) +static void *no_audio_init (Audiodev *dev) {return &no_audio_init; }
audio/ossaudio.c +1 -1
@@ -842,7 +842,7 @@ static OSSConf glob_conf = { .policy = 5 }; -static void *oss_audio_init (void ) +static void *oss_audio_init (Audiodev *dev) {OSSConf *conf =g_malloc (sizeof (OSSConf)); *conf = glob_conf;
audio/paaudio.c +1 -1
@@ -812,7 +812,7 @@ static PAConf glob_conf = { .samples = 4096, }; -static void *qpa_audio_init (void ) +static void *qpa_audio_init (Audiodev *dev) {if (glob_conf.server ==NULL ) {char pidfile[64 ];
audio/sdlaudio.c +1 -1
@@ -436,7 +436,7 @@ static int sdl_ctl_out (HWVoiceOut *hw, int cmd, ...)return 0 ; } -static void *sdl_audio_init (void ) +static void *sdl_audio_init (Audiodev *dev) {SDLAudioState *s = &glob_sdl;if (s->driver_created) {
audio/spiceaudio.c +1 -1
@@ -77,7 +77,7 @@ static const SpiceRecordInterface record_sif = { .base.minor_version = SPICE_INTERFACE_RECORD_MINOR, }; -static void *spice_audio_init (void ) +static void *spice_audio_init (Audiodev *dev) {if (!using_spice) {return NULL ;
audio/wavaudio.c +1 -1
@@ -232,7 +232,7 @@ static WAVConf glob_conf = { .wav_path = "qemu.wav" }; -static void *wav_audio_init (void ) +static void *wav_audio_init (Audiodev *dev) {WAVConf *conf =g_malloc (sizeof (WAVConf)); *conf = glob_conf;
vl.c +6 -1
@@ -3302,9 +3302,12 @@ int main(int argc, char **argv, char **envp)add_device_config (DEV_BT , optarg);break ;case QEMU_OPTION_audio_help: -AUD_help (); +audio_legacy_help ();exit (0 );break ; +case QEMU_OPTION_audiodev: +audio_parse_option (optarg); +break ;case QEMU_OPTION_soundhw:select_soundhw (optarg);break ;
@@ -4533,6 +4536,8 @@ int main(int argc, char **argv, char **envp)/* do monitor/qmp handling at preconfig state if requested */ main_loop (); +audio_init_audiodevs (); +/* from here on runstate is RUN_STATE_PRELAUNCH */ machine_run_board_init (current_machine);
audio/Makefile.objs +1 -1
@@ -1,4 +1,4 @@ -common-obj-y = audio.o noaudio.o wavaudio.o mixeng.o +common-obj-y = audio.o audio_legacy.o noaudio.o wavaudio.o mixeng.o common-obj-$(CONFIG_SPICE) += spiceaudio.o common-obj-$(CONFIG_AUDIO_COREAUDIO) += coreaudio.o common-obj-$(CONFIG_AUDIO_DSOUND) += dsoundaudio.o
Signature · 1 line
2.20.1
Re: [Qemu-devel] [PATCH v4 04/14] audio: -audiodev command line option basic implementation
Quoted 16 lines · Zoltán
Audio drivers now get an Audiodev * as config paramters, instead of the global
audio_optionstructs. There is some code inaudio/audio_legacy.cthat converts the old environment variables to audiodev options (this way backends do not have to worry about legacy options). It also contains a replacement of -audio-help, which prints out the equivalent -audiodev based config of the currently specified environment variables.Note that backends are not updated and still rely on environment variables.
Also note that (due to moving try-poll from global to backend specific option) currently ALSA and OSS will always try poll mode, regardless of environment variables or -audiodev options.
Signed-off-by Kővágó, Zoltán <[email protected]>---
[...]
Quoted 4 lines
audio/audio.c +0
-0
[...]
Quoted 53 lines
audio/audio.c +49
-0@@ -2129,3 +1866,145 @@ void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol) } } } + +static void audio_validate_per_direction_opts ( +AudiodevPerDirectionOptions **pdo,bool *has_pdo,Error **errp) +{ +if (!*has_pdo) { + *pdo =g_malloc0 (sizeof (AudiodevPerDirectionOptions)); + *has_pdo = true; + } + +if (!(*pdo)->has_fixed_settings) { + (*pdo)->has_fixed_settings = true; + (*pdo)->fixed_settings = true; + } +if (!(*pdo)->fixed_settings && + ((*pdo)->has_frequency || (*pdo)->has_channels || (*pdo)->has_format)) { +error_setg (errp, +"You can't use frequency, channels or format with fixed-settings=off" ); +return ; + } + +if (!(*pdo)->has_frequency) { + (*pdo)->has_frequency = true; + (*pdo)->frequency =44100 ; + } +if (!(*pdo)->has_channels) { + (*pdo)->has_channels = true; + (*pdo)->channels =2 ; + } +if (!(*pdo)->has_voices) { + (*pdo)->has_voices = true; + (*pdo)->voices =1 ; + } +if (!(*pdo)->has_format) { + (*pdo)->has_format = true; + (*pdo)->format =AUDIO_FORMAT_S16 ; + } +} + +static void audio_validate_opts (Audiodev *dev,Error **errp) +{ +Error *err =NULL ; + +audio_validate_per_direction_opts (&dev->in, &dev->has_in, &err); +if (err) { +error_propagate (errp, err); +return ; + } + +audio_validate_per_direction_opts (&dev->out, &dev->has_out, &err);
audio/audio.c void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol) · line 1927
Quoted 10 lines
audio/audio.c +10
-0+if (err) { +error_propagate (errp, err); +return ; + } + +if (!dev->has_timer_period) { + dev->has_timer_period = true; + dev->timer_period =10000 ;/* 100Hz -> 10ms */ + } +}
Drive-by question: this validates just the generic part of Audiodev gets validated, not the driver-specific part. Is there nothing to validate? Does it happen somewhere else?
Quoted 15 lines
audio/audio.c +15
-0+ +void audio_parse_option (const char *opt) +{ +AudiodevListEntry *e; +Audiodev *dev =NULL ; + +Visitor *v =qobject_input_visitor_new_str (opt,"driver" , &error_fatal); +visit_type_Audiodev (v,NULL , &dev, &error_fatal); +visit_free (v); + +audio_validate_opts (dev, &error_fatal); + + e =g_malloc0 (sizeof (AudiodevListEntry)); + e->dev = dev; +QSIMPLEQ_INSERT_TAIL (&audiodevs, e, next);
audio/audio.c void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol) · line 1952
Quoted 10 lines
audio/audio.c +10
-0+} + +void audio_init_audiodevs (void ) +{ +AudiodevListEntry *e; + + QSIMPLEQ_FOREACH(e, &audiodevs, next) { +audio_init (e->dev); + } +}
Your use of QAPI here looks good to me.
[...]
Re: [Qemu-devel] [PATCH v4 04/14] audio: -audiodev command line option basic implementation
Quoted 83 lines · Markus Armbruster
Quoted 16 lines · Zoltán
Audio drivers now get an Audiodev * as config paramters, instead of the global
audio_optionstructs. There is some code inaudio/audio_legacy.cthat converts the old environment variables to audiodev options (this way backends do not have to worry about legacy options). It also contains a replacement of -audio-help, which prints out the equivalent -audiodev based config of the currently specified environment variables.Note that backends are not updated and still rely on environment variables.
Also note that (due to moving try-poll from global to backend specific option) currently ALSA and OSS will always try poll mode, regardless of environment variables or -audiodev options.
Signed-off-by Kővágó, Zoltán <[email protected]>---
[...]
Quoted 4 lines
audio/audio.c +0
-0[...]
Quoted 59 lines
audio/audio.c +55
-0@@ -2129,3 +1866,145 @@ void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol) } } } + +static void audio_validate_per_direction_opts ( +AudiodevPerDirectionOptions **pdo,bool *has_pdo,Error **errp) +{ +if (!*has_pdo) { + *pdo =g_malloc0 (sizeof (AudiodevPerDirectionOptions)); + *has_pdo = true; + } + +if (!(*pdo)->has_fixed_settings) { + (*pdo)->has_fixed_settings = true; + (*pdo)->fixed_settings = true; + } +if (!(*pdo)->fixed_settings && + ((*pdo)->has_frequency || (*pdo)->has_channels || (*pdo)->has_format)) { +error_setg (errp, +"You can't use frequency, channels or format with fixed-settings=off" ); +return ; + } + +if (!(*pdo)->has_frequency) { + (*pdo)->has_frequency = true; + (*pdo)->frequency =44100 ; + } +if (!(*pdo)->has_channels) { + (*pdo)->has_channels = true; + (*pdo)->channels =2 ; + } +if (!(*pdo)->has_voices) { + (*pdo)->has_voices = true; + (*pdo)->voices =1 ; + } +if (!(*pdo)->has_format) { + (*pdo)->has_format = true; + (*pdo)->format =AUDIO_FORMAT_S16 ; + } +} + +static void audio_validate_opts (Audiodev *dev,Error **errp) +{ +Error *err =NULL ; + +audio_validate_per_direction_opts (&dev->in, &dev->has_in, &err); +if (err) { +error_propagate (errp, err); +return ; + } + +audio_validate_per_direction_opts (&dev->out, &dev->has_out, &err); +if (err) { +error_propagate (errp, err); +return ; + } + +if (!dev->has_timer_period) {
Quoted 8 lines
audio/audio.c void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol) · line 1927
Quoted 4 lines
audio/audio.c +4
-0+ dev->has_timer_period = true; + dev->timer_period =10000 ;/* 100Hz -> 10ms */ + } +}Drive-by question: this validates just the generic part of Audiodev gets validated, not the driver-specific part. Is there nothing to validate? Does it happen somewhere else?
Driver specific validation/initialization happens in each driver's init function (they're added in the upcoming patches).
Quoted 30 lines
Quoted 15 lines
audio/audio.c +15
-0+ +void audio_parse_option (const char *opt) +{ +AudiodevListEntry *e; +Audiodev *dev =NULL ; + +Visitor *v =qobject_input_visitor_new_str (opt,"driver" , &error_fatal); +visit_type_Audiodev (v,NULL , &dev, &error_fatal); +visit_free (v); + +audio_validate_opts (dev, &error_fatal); + + e =g_malloc0 (sizeof (AudiodevListEntry)); + e->dev = dev; +QSIMPLEQ_INSERT_TAIL (&audiodevs, e, next);audio/audio.c void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol) · line 1952
Quoted 10 lines
audio/audio.c +10
-0+} + +void audio_init_audiodevs (void ) +{ +AudiodevListEntry *e; + + QSIMPLEQ_FOREACH(e, &audiodevs, next) { +audio_init (e->dev); + } +}Your use of QAPI here looks good to me.
[...]
PATCH v4 5/14 alsaaudio: port to -audiodev config
In reply to Kővágó, Zoltán--- audio/alsaaudio.c | 344 ++++++++++++++----------------------------- audio/audio_legacy.c | 94 +++++++++++- 2 files changed, 205 insertions(+), 233 deletions(-)
audio/alsaaudio.c +112 -232
@@ -33,28 +33,9 @@#define AUDIO_CAP "alsa"#include "audio_int.h" -typedef struct ALSAConf { -int size_in_usec_in; -int size_in_usec_out; -const char *pcm_name_in; -const char *pcm_name_out; -unsigned int buffer_size_in; -unsigned int period_size_in; -unsigned int buffer_size_out; -unsigned int period_size_out; -unsigned int threshold; - -int buffer_size_in_overridden; -int period_size_in_overridden; - -int buffer_size_out_overridden; -int period_size_out_overridden; -}ALSAConf ; -struct pollhlp {snd_pcm_t *handle;struct pollfd *pfds; -ALSAConf *conf;int count;int mask; };
@@ -66,6 +47,7 @@ typedef struct ALSAVoiceOut {void *pcm_buf;snd_pcm_t *handle;struct pollhlp pollhlp; +Audiodev *dev; } ALSAVoiceOut; typedef struct ALSAVoiceIn {
@@ -73,16 +55,13 @@ typedef struct ALSAVoiceIn {snd_pcm_t *handle;void *pcm_buf;struct pollhlp pollhlp; +Audiodev *dev; } ALSAVoiceIn;struct alsa_params_req {int freq;snd_pcm_format_t fmt;int nchannels; -int size_in_usec; -int override_mask; -unsigned int buffer_size; -unsigned int period_size; };struct alsa_params_obt {
@@ -408,17 +387,19 @@ static int alsa_to_audfmt (snd_pcm_format_t alsafmt, AudioFormat *fmt,static void alsa_dump_info (struct alsa_params_req *req,struct alsa_params_obt *obt, -snd_pcm_format_t obtfmt) +snd_pcm_format_t obtfmt, +AudiodevPerDirectionOptions *pdo) { -dolog ("parameter | requested value | obtained value\n" ); -dolog ("format | %10d | %10d\n" , req->fmt, obtfmt); -dolog ("channels | %10d | %10d\n" , - req->nchannels, obt->nchannels); -dolog ("frequency | %10d | %10d\n" , req->freq, obt->freq); -dolog ("============================================\n" ); -dolog ("requested: buffer size %d period size %d\n" , - req->buffer_size, req->period_size); -dolog ("obtained: samples %ld\n" , obt->samples); +dolog ("parameter | requested value | obtained value\n" ); +dolog ("format | %10d | %10d\n" , req->fmt, obtfmt); +dolog ("channels | %10d | %10d\n" , + req->nchannels, obt->nchannels); +dolog ("frequency | %10d | %10d\n" , req->freq, obt->freq); +dolog ("============================================\n" ); +dolog ("requested: buffer len %" PRId32" buffer count %" PRId32"\n" , + pdo->has_buffer_len ? pdo->buffer_len :0 , + pdo->has_buffer_count ? pdo->buffer_count :0 ); +dolog ("obtained: samples %ld\n" , obt->samples); }static void alsa_set_threshold (snd_pcm_t *handle,snd_pcm_uframes_t threshold)
@@ -451,23 +432,25 @@ static void alsa_set_threshold (snd_pcm_t *handle, snd_pcm_uframes_t threshold) } } -static int alsa_open (int in,struct alsa_params_req *req, -struct alsa_params_obt *obt,snd_pcm_t **handlep, -ALSAConf *conf) +static int alsa_open (bool in,struct alsa_params_req *req, +struct alsa_params_obt *obt,snd_pcm_t **handlep, +Audiodev *dev) { +AudiodevPerDirectionOptions *pdo = in ? dev->in : dev->out; +AudiodevAlsaOptions *aopts = &dev->u.alsa; +AudiodevAlsaPerDirectionOptions *apdo = + in ? aopts->alsa_in : aopts->alsa_out;snd_pcm_t *handle;snd_pcm_hw_params_t *hw_params;int err; -int size_in_usec;unsigned int freq, nchannels; -const char *pcm_name = in ? conf->pcm_name_in : conf->pcm_name_out; +const char *pcm_name = apdo->has_dev ? apdo->dev :"default" ;snd_pcm_uframes_t obt_buffer_size;const char *typ = in ?"ADC" :"DAC" ;snd_pcm_format_t obtfmt; freq = req->freq; nchannels = req->nchannels; - size_in_usec = req->size_in_usec;snd_pcm_hw_params_alloca (&hw_params);
@@ -527,79 +510,49 @@ static int alsa_open (int in, struct alsa_params_req *req, goto err; } -if (req->buffer_size) { -unsigned long obt; +if (pdo->buffer_count) { +if (pdo->buffer_len) { +int64_t req = pdo->buffer_len * pdo->buffer_count; -if (size_in_usec) {int dir =0 ; -unsigned int btime = req->buffer_size; +unsigned int btime = req; - err =snd_pcm_hw_params_set_buffer_time_near ( - handle, - hw_params, - &btime, - &dir - ); - obt = btime; - } -else { -snd_pcm_uframes_t bsize = req->buffer_size; + err =snd_pcm_hw_params_set_buffer_time_near ( + handle, hw_params, &btime, &dir); - err =snd_pcm_hw_params_set_buffer_size_near ( - handle, - hw_params, - &bsize - ); - obt = bsize; - } -if (err <0 ) { -alsa_logerr2 (err, typ,"Failed to set buffer %s to %d\n" , - size_in_usec ?"time" :"size" , req->buffer_size); - goto err; - } +if (err <0 ) { +alsa_logerr2 (err, typ, +"Failed to set buffer time to %" PRId64"\n" , + req); + goto err; + } -if ((req->override_mask &2 ) && (obt - req->buffer_size)) -dolog ("Requested buffer %s %u was rejected, using %lu\n" , - size_in_usec ?"time" :"size" , req->buffer_size, obt); +if (pdo->has_buffer_count && btime != req) { +dolog ("Requested buffer time %" PRId64 +" was rejected, using %u\n" , req, btime); + } + }else { +dolog ("Can't set buffer-count without buffer-len!\n" ); + } } -if (req->period_size) { -unsigned long obt; +if (pdo->buffer_len) { +int dir =0 ; +unsigned int ptime = pdo->buffer_len; -if (size_in_usec) { -int dir =0 ; -unsigned int ptime = req->period_size; - - err =snd_pcm_hw_params_set_period_time_near ( - handle, - hw_params, - &ptime, - &dir - ); - obt = ptime; - } -else { -int dir =0 ; -snd_pcm_uframes_t psize = req->period_size; - - err =snd_pcm_hw_params_set_period_size_near ( - handle, - hw_params, - &psize, - &dir - ); - obt = psize; - } + err =snd_pcm_hw_params_set_period_time_near (handle, hw_params, &ptime, + &dir);if (err <0 ) { -alsa_logerr2 (err, typ,"Failed to set period %s to %d\n" , - size_in_usec ?"time" :"size" , req->period_size); +alsa_logerr2 (err, typ,"Failed to set period time to %" PRId32"\n" , + pdo->buffer_len); goto err; } -if (((req->override_mask &1 ) && (obt - req->period_size))) -dolog ("Requested period %s %u was rejected, using %lu\n" , - size_in_usec ?"time" :"size" , req->period_size, obt); +if (pdo->has_buffer_len && ptime != pdo->buffer_len) { +dolog ("Requested period time %" PRId32" was rejected, using %d\n" , + pdo->buffer_len, ptime); + } } err =snd_pcm_hw_params (handle, hw_params);
@@ -631,33 +584,10 @@ static int alsa_open (int in, struct alsa_params_req *req, goto err; } -if (!in && conf->threshold) { -snd_pcm_uframes_t threshold; -int bytes_per_sec; - - bytes_per_sec = freq << (nchannels ==2 ); - -switch (obt->fmt) { -case AUDIO_FORMAT_S8 : -case AUDIO_FORMAT_U8 : -break ; - -case AUDIO_FORMAT_S16 : -case AUDIO_FORMAT_U16 : - bytes_per_sec <<=1 ; -break ; - -case AUDIO_FORMAT_S32 : -case AUDIO_FORMAT_U32 : - bytes_per_sec <<=2 ; -break ; - -default : -abort (); - } - - threshold = (conf->threshold * bytes_per_sec) /1000 ; -alsa_set_threshold (handle, threshold); +if (!in && aopts->has_threshold && aopts->threshold) { +struct audsettings as = { .freq = freq }; +alsa_set_threshold (handle, +audio_buffer_frames (pdo, &as, aopts->threshold)); } obt->nchannels = nchannels;
@@ -670,11 +600,11 @@ static int alsa_open (int in, struct alsa_params_req *req, obt->nchannels != req->nchannels || obt->freq != req->freq) {dolog ("Audio parameters for %s\n" , typ); -alsa_dump_info (req, obt, obtfmt); +alsa_dump_info (req, obt, obtfmt, pdo); }#ifdef DEBUG -alsa_dump_info (req, obt, obtfmt); +alsa_dump_info (req, obt, obtfmt, pdo);#endif return 0 ;
@@ -800,19 +730,13 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsettings *as,struct alsa_params_obt obt;snd_pcm_t *handle;struct audsettings obt_as; -ALSAConf *conf = drv_opaque; +Audiodev *dev = drv_opaque; req.fmt =aud_to_alsafmt (as->fmt, as->endianness); req.freq = as->freq; req.nchannels = as->nchannels; - req.period_size = conf->period_size_out; - req.buffer_size = conf->buffer_size_out; - req.size_in_usec = conf->size_in_usec_out; - req.override_mask = - (conf->period_size_out_overridden ?1 :0 ) | - (conf->buffer_size_out_overridden ?2 :0 ); -if (alsa_open (0 , &req, &obt, &handle, conf)) { +if (alsa_open (0 , &req, &obt, &handle, dev)) {return -1 ; }
@@ -833,7 +757,7 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsettings *as, } alsa->handle = handle; - alsa->pollhlp.conf = conf; + alsa->dev = dev;return 0 ; }
@@ -873,16 +797,12 @@ static int alsa_voice_ctl (snd_pcm_t *handle, const char *typ, int ctl)static int alsa_ctl_out (HWVoiceOut *hw,int cmd, ...) {ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw; +AudiodevAlsaPerDirectionOptions *apdo = alsa->dev->u.alsa.alsa_out;switch (cmd) {case VOICE_ENABLE : { -va_list ap; -int poll_mode; - -va_start (ap, cmd); - poll_mode =va_arg (ap, int); -va_end (ap); +bool poll_mode = apdo->try_poll;ldebug ("enabling voice\n" );if (poll_mode &&alsa_poll_out (hw)) {
@@ -911,19 +831,13 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)struct alsa_params_obt obt;snd_pcm_t *handle;struct audsettings obt_as; -ALSAConf *conf = drv_opaque; +Audiodev *dev = drv_opaque; req.fmt =aud_to_alsafmt (as->fmt, as->endianness); req.freq = as->freq; req.nchannels = as->nchannels; - req.period_size = conf->period_size_in; - req.buffer_size = conf->buffer_size_in; - req.size_in_usec = conf->size_in_usec_in; - req.override_mask = - (conf->period_size_in_overridden ?1 :0 ) | - (conf->buffer_size_in_overridden ?2 :0 ); -if (alsa_open (1 , &req, &obt, &handle, conf)) { +if (alsa_open (1 , &req, &obt, &handle, dev)) {return -1 ; }
@@ -944,7 +858,7 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) } alsa->handle = handle; - alsa->pollhlp.conf = conf; + alsa->dev = dev;return 0 ; }
@@ -1086,16 +1000,12 @@ static int alsa_read (SWVoiceIn *sw, void *buf, int size)static int alsa_ctl_in (HWVoiceIn *hw,int cmd, ...) {ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw; +AudiodevAlsaPerDirectionOptions *apdo = alsa->dev->u.alsa.alsa_in;switch (cmd) {case VOICE_ENABLE : { -va_list ap; -int poll_mode; - -va_start (ap, cmd); - poll_mode =va_arg (ap, int); -va_end (ap); +bool poll_mode = apdo->try_poll;ldebug ("enabling voice\n" );if (poll_mode &&alsa_poll_in (hw)) {
@@ -1118,88 +1028,59 @@ static int alsa_ctl_in (HWVoiceIn *hw, int cmd, ...)return -1 ; } -static ALSAConf glob_conf = { - .buffer_size_out =4096 , - .period_size_out =1024 , - .pcm_name_out ="default" , - .pcm_name_in ="default" , -}; +static void alsa_init_per_direction (AudiodevAlsaPerDirectionOptions **apdo, +bool *has_apdo) +{ +if (!*has_apdo) { + *apdo =g_malloc0 (sizeof (AudiodevAlsaPerDirectionOptions)); + *has_apdo = true; + } + +if (!(*apdo)->has_try_poll) { + (*apdo)->try_poll = true; + (*apdo)->has_try_poll = true; + } +}static void *alsa_audio_init (Audiodev *dev) { -ALSAConf *conf =g_malloc (sizeof (ALSAConf)); - *conf = glob_conf; -return conf; +AudiodevAlsaOptions *aopts; +assert (dev->driver ==AUDIODEV_DRIVER_ALSA ); + + aopts = &dev->u.alsa; +alsa_init_per_direction (&aopts->alsa_in, &aopts->has_alsa_in); +alsa_init_per_direction (&aopts->alsa_out, &aopts->has_alsa_out); + +/* +* need to define them, as otherwise alsa produces no sound +* doesn't set has_* so alsa_open can identify it wasn't set by the user +*/ +if (!dev->out->has_buffer_count) { + dev->out->buffer_count =4 ; + } +if (!dev->out->has_buffer_len) { +/* 1024 frames assuming 44100Hz */ + dev->out->buffer_len =1024 *1000000 /44100 ; + } + +/* +* OptsVisitor sets unspecified optional fields to zero, but do not depend +* on it... +*/ +if (!dev->in->has_buffer_count) { + dev->in->buffer_count =0 ; + } +if (!dev->in->has_buffer_len) { + dev->in->buffer_len =0 ; + } + +return dev; }static void alsa_audio_fini (void *opaque) { -g_free (opaque); } -static struct audio_option alsa_options[] = { - { - .name ="DAC_SIZE_IN_USEC" , - .tag =AUD_OPT_BOOL , - .valp = &glob_conf.size_in_usec_out, - .descr ="DAC period/buffer size in microseconds (otherwise in frames)" - }, - { - .name ="DAC_PERIOD_SIZE" , - .tag =AUD_OPT_INT , - .valp = &glob_conf.period_size_out, - .descr ="DAC period size (0 to go with system default)" , - .overriddenp = &glob_conf.period_size_out_overridden - }, - { - .name ="DAC_BUFFER_SIZE" , - .tag =AUD_OPT_INT , - .valp = &glob_conf.buffer_size_out, - .descr ="DAC buffer size (0 to go with system default)" , - .overriddenp = &glob_conf.buffer_size_out_overridden - }, - { - .name ="ADC_SIZE_IN_USEC" , - .tag =AUD_OPT_BOOL , - .valp = &glob_conf.size_in_usec_in, - .descr = -"ADC period/buffer size in microseconds (otherwise in frames)" - }, - { - .name ="ADC_PERIOD_SIZE" , - .tag =AUD_OPT_INT , - .valp = &glob_conf.period_size_in, - .descr ="ADC period size (0 to go with system default)" , - .overriddenp = &glob_conf.period_size_in_overridden - }, - { - .name ="ADC_BUFFER_SIZE" , - .tag =AUD_OPT_INT , - .valp = &glob_conf.buffer_size_in, - .descr ="ADC buffer size (0 to go with system default)" , - .overriddenp = &glob_conf.buffer_size_in_overridden - }, - { - .name ="THRESHOLD" , - .tag =AUD_OPT_INT , - .valp = &glob_conf.threshold, - .descr ="(undocumented)" - }, - { - .name ="DAC_DEV" , - .tag =AUD_OPT_STR , - .valp = &glob_conf.pcm_name_out, - .descr ="DAC device name (for instance dmix)" - }, - { - .name ="ADC_DEV" , - .tag =AUD_OPT_STR , - .valp = &glob_conf.pcm_name_in, - .descr ="ADC device name" - }, - {/* End of list */ } -}; -static struct audio_pcm_ops alsa_pcm_ops = { .init_out = alsa_init_out, .fini_out = alsa_fini_out,
@@ -1217,7 +1098,6 @@ static struct audio_pcm_ops alsa_pcm_ops = {static struct audio_driver alsa_audio_driver = { .name ="alsa" , .descr ="ALSA http://www.alsa-project.org" , - .options = alsa_options, .init = alsa_audio_init, .fini = alsa_audio_fini, .pcm_ops = &alsa_pcm_ops,
audio/audio_legacy.c +93 -1
113 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v4 6/14 coreaudio: port to -audiodev config
In reply to Kővágó, Zoltán--- audio/audio_legacy.c | 24 ++++++++++++++++++++++ audio/coreaudio.c | 48 +++++++++----------------------------------- 2 files changed, 34 insertions(+), 38 deletions(-)
audio/audio_legacy.c +24 -0
@@ -109,6 +109,17 @@ static uint32_t frames_to_usecs(uint32_t frames,return (frames *1000000 + freq /2 ) / freq; } + +static void get_frames_to_usecs (const char *env,uint32_t *dst,bool *has_dst, +AudiodevPerDirectionOptions *pdo) +{ +const char *val =getenv (env); +if (val) { + *dst =frames_to_usecs (toui32 (val), pdo); + *has_dst = true; + } +} +/* backend specific functions */ /* ALSA */ static void handle_alsa_per_direction(
@@ -166,6 +177,15 @@ static void handle_alsa(Audiodev *dev) &aopt->threshold, &aopt->has_threshold); } +/* coreaudio */ +static void handle_coreaudio (Audiodev *dev) +{ +get_frames_to_usecs ("QEMU_COREAUDIO_BUFFER_SIZE" , &dev->out->buffer_len, + &dev->out->has_buffer_len, dev->out); +get_int ("QEMU_COREAUDIO_BUFFER_COUNT" , + &dev->out->buffer_count, &dev->out->has_buffer_count); +} +/* general */ static void handle_per_direction (AudiodevPerDirectionOptions *pdo,const char *prefix)
@@ -213,6 +233,10 @@ static AudiodevListEntry *legacy_opt(const char *drvname)handle_alsa (e->dev);break ; +case AUDIODEV_DRIVER_COREAUDIO : +handle_coreaudio (e->dev); +break ; +default :break ; }
audio/coreaudio.c +10 -38
98 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v4 7/14 dsoundaudio: port to -audiodev config
In reply to Kővágó, Zoltán--- audio/dsound_template.h | 6 ++--- audio/audio_legacy.c | 39 +++++++++++++++++++++++++++ audio/dsoundaudio.c | 59 ++++++++++++----------------------------- 3 files changed, 59 insertions(+), 45 deletions(-)
audio/dsound_template.h +3 -3
@@ -167,17 +167,18 @@ static int dsound_init_out(HWVoiceOut *hw, struct audsettings *as,dsound *s = drv_opaque;WAVEFORMATEX wfx;struct audsettings obt_as; -DSoundConf *conf = &s->conf;#ifdef DSBTYPE_IN const char *typ ="ADC" ;DSoundVoiceIn *ds = (DSoundVoiceIn *) hw;DSCBUFFERDESC bd;DSCBCAPS bc; +AudiodevPerDirectionOptions *pdo = s->dev->in;#else const char *typ ="DAC" ;DSoundVoiceOut *ds = (DSoundVoiceOut *) hw;DSBUFFERDESC bd;DSBCAPS bc; +AudiodevPerDirectionOptions *pdo = s->dev->out;#endif if (!s->FIELD2) {
@@ -193,8 +194,8 @@ static int dsound_init_out(HWVoiceOut *hw, struct audsettings *as,memset (&bd,0 ,sizeof (bd)); bd.dwSize =sizeof (bd); bd.lpwfxFormat = &wfx; + bd.dwBufferBytes =audio_buffer_bytes (pdo, as,92880 );#ifdef DSBTYPE_IN - bd.dwBufferBytes = conf->bufsize_in; hr = IDirectSoundCapture_CreateCaptureBuffer ( s->dsound_capture, &bd,
@@ -203,7 +204,6 @@ static int dsound_init_out(HWVoiceOut *hw, struct audsettings *as, );#else bd.dwFlags =DSBCAPS_STICKYFOCUS |DSBCAPS_GETCURRENTPOSITION2 ; - bd.dwBufferBytes = conf->bufsize_out; hr = IDirectSound_CreateSoundBuffer ( s->dsound, &bd,
audio/audio_legacy.c +39 -0
@@ -120,6 +120,30 @@ static void get_frames_to_usecs(const char *env, uint32_t *dst, bool *has_dst, } } +static uint32_t samples_to_usecs (uint32_t samples, +AudiodevPerDirectionOptions *pdo) +{ +uint32_t channels = pdo->has_channels ? pdo->channels :2 ; +return frames_to_usecs (samples / channels, pdo); +} + +static uint32_t bytes_to_usecs (uint32_t bytes,AudiodevPerDirectionOptions *pdo) +{ +AudioFormat fmt = pdo->has_format ? pdo->format :AUDIO_FORMAT_S16 ; +uint32_t bytes_per_sample =audioformat_bytes_per_sample (fmt); +return samples_to_usecs (bytes / bytes_per_sample, pdo); +} + +static void get_bytes_to_usecs (const char *env,uint32_t *dst,bool *has_dst, +AudiodevPerDirectionOptions *pdo) +{ +const char *val =getenv (env); +if (val) { + *dst =bytes_to_usecs (toui32 (val), pdo); + *has_dst = true; + } +} +/* backend specific functions */ /* ALSA */ static void handle_alsa_per_direction(
@@ -186,6 +210,17 @@ static void handle_coreaudio(Audiodev *dev) &dev->out->buffer_count, &dev->out->has_buffer_count); } +/* dsound */ +static void handle_dsound (Audiodev *dev) +{ +get_millis_to_usecs ("QEMU_DSOUND_LATENCY_MILLIS" , + &dev->u.dsound.latency, &dev->u.dsound.has_latency); +get_bytes_to_usecs ("QEMU_DSOUND_BUFSIZE_OUT" , &dev->out->buffer_len, + &dev->out->has_buffer_len, dev->out); +get_bytes_to_usecs ("QEMU_DSOUND_BUFSIZE_IN" , &dev->in->buffer_len, + &dev->in->has_buffer_len, dev->in); +} +/* general */ static void handle_per_direction (AudiodevPerDirectionOptions *pdo,const char *prefix)
@@ -237,6 +272,10 @@ static AudiodevListEntry *legacy_opt(const char *drvname)handle_coreaudio (e->dev);break ; +case AUDIODEV_DRIVER_DSOUND : +handle_dsound (e->dev); +break ; +default :break ; }
audio/dsoundaudio.c +17 -42
125 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v4 8/14 noaudio: port to -audiodev config
In reply to Kővágó, Zoltán--- audio/noaudio.c | 1 - 1 file changed, 1 deletion(-)
audio/noaudio.c +0 -1
@@ -163,7 +163,6 @@ static struct audio_pcm_ops no_pcm_ops = {static struct audio_driver no_audio_driver = { .name ="none" , .descr ="Timer based audio emulation" , - .options =NULL , .init = no_audio_init, .fini = no_audio_fini, .pcm_ops = &no_pcm_ops,
Signature · 1 line
2.20.1
PATCH v4 9/14 ossaudio: port to -audiodev config
In reply to Kővágó, Zoltán--- audio/audio_legacy.c | 33 +++++++++ audio/ossaudio.c | 167 +++++++++++++++---------------------------- 2 files changed, 90 insertions(+), 110 deletions(-)
audio/audio_legacy.c +33 -0
@@ -221,6 +221,35 @@ static void handle_dsound(Audiodev *dev) &dev->in->has_buffer_len, dev->in); } +/* OSS */ +static void handle_oss_per_direction ( +AudiodevPerDirectionOptions *pdo,AudiodevOssPerDirectionOptions **opdo, +bool *has_opdo,const char *try_poll_env,const char *dev_env) +{ + *opdo =g_malloc0 (sizeof (AudiodevOssPerDirectionOptions)); + *has_opdo = true; + +get_bool (try_poll_env, &(*opdo)->try_poll, &(*opdo)->has_try_poll); +get_str (dev_env, &(*opdo)->dev, &(*opdo)->has_dev); + +get_bytes_to_usecs ("QEMU_OSS_FRAGSIZE" , + &pdo->buffer_len, &pdo->has_buffer_len, pdo); +get_int ("QEMU_OSS_NFRAGS" , &pdo->buffer_count, &pdo->has_buffer_count); +} + +static void handle_oss (Audiodev *dev) +{ +AudiodevOssOptions *oopt = &dev->u.oss; +handle_oss_per_direction (dev->in, &oopt->oss_in, &oopt->has_oss_in, +"QEMU_AUDIO_ADC_TRY_POLL" ,"QEMU_OSS_ADC_DEV" ); +handle_oss_per_direction (dev->out, &oopt->oss_out, &oopt->has_oss_out, +"QEMU_AUDIO_DAC_TRY_POLL" ,"QEMU_OSS_DAC_DEV" ); + +get_bool ("QEMU_OSS_MMAP" , &oopt->try_mmap, &oopt->has_try_mmap); +get_bool ("QEMU_OSS_EXCLUSIVE" , &oopt->exclusive, &oopt->has_exclusive); +get_int ("QEMU_OSS_POLICY" , &oopt->dsp_policy, &oopt->has_dsp_policy); +} +/* general */ static void handle_per_direction (AudiodevPerDirectionOptions *pdo,const char *prefix)
@@ -276,6 +305,10 @@ static AudiodevListEntry *legacy_opt(const char *drvname)handle_dsound (e->dev);break ; +case AUDIODEV_DRIVER_OSS : +handle_oss (e->dev); +break ; +default :break ; }
audio/ossaudio.c +57 -110
310 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v4 10/14 paaudio: port to -audiodev config
In reply to Kővágó, Zoltán--- audio/audio_legacy.c | 39 +++++++++++++++++++ audio/paaudio.c | 91 +++++++++++++++++++------------------------- 2 files changed, 79 insertions(+), 51 deletions(-)
audio/audio_legacy.c +39 -0
@@ -127,6 +127,16 @@ static uint32_t samples_to_usecs(uint32_t samples,return frames_to_usecs (samples / channels, pdo); } +static void get_samples_to_usecs (const char *env,uint32_t *dst,bool *has_dst, +AudiodevPerDirectionOptions *pdo) +{ +const char *val =getenv (env); +if (val) { + *dst =samples_to_usecs (toui32 (val), pdo); + *has_dst = true; + } +} +static uint32_t bytes_to_usecs (uint32_t bytes,AudiodevPerDirectionOptions *pdo) {AudioFormat fmt = pdo->has_format ? pdo->format :AUDIO_FORMAT_S16 ;
@@ -250,6 +260,31 @@ static void handle_oss(Audiodev *dev)get_int ("QEMU_OSS_POLICY" , &oopt->dsp_policy, &oopt->has_dsp_policy); } +/* pulseaudio */ +static void handle_pa_per_direction ( +AudiodevPaPerDirectionOptions **ppdo,bool *has_ppdo,const char *env) +{ + *ppdo =g_malloc0 (sizeof (AudiodevPaPerDirectionOptions)); + *has_ppdo = true; + +get_str (env, &(*ppdo)->name, &(*ppdo)->has_name); +} + +static void handle_pa (Audiodev *dev) +{ +handle_pa_per_direction (&dev->u.pa.sink, &dev->u.pa.has_sink, +"QEMU_PA_SINK" ); +handle_pa_per_direction (&dev->u.pa.source, &dev->u.pa.has_source, +"QEMU_PA_SOURCE" ); + +get_samples_to_usecs ("QEMU_PA_SAMPLES" , &dev->in->buffer_len, + &dev->in->has_buffer_len, dev->in); +get_samples_to_usecs ("QEMU_PA_SAMPLES" , &dev->out->buffer_len, + &dev->out->has_buffer_len, dev->out); + +get_str ("QEMU_PA_SERVER" , &dev->u.pa.server, &dev->u.pa.has_server); +} +/* general */ static void handle_per_direction (AudiodevPerDirectionOptions *pdo,const char *prefix)
@@ -309,6 +344,10 @@ static AudiodevListEntry *legacy_opt(const char *drvname)handle_oss (e->dev);break ; +case AUDIODEV_DRIVER_PA : +handle_pa (e->dev); +break ; +default :break ; }
audio/paaudio.c +40 -51
202 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v4 11/14 sdlaudio: port to -audiodev config
In reply to Kővágó, Zoltán--- audio/audio_legacy.c | 12 ++++++++++++ audio/sdlaudio.c | 22 ++++------------------ 2 files changed, 16 insertions(+), 18 deletions(-)
audio/audio_legacy.c +12 -0
@@ -285,6 +285,14 @@ static void handle_pa(Audiodev *dev)get_str ("QEMU_PA_SERVER" , &dev->u.pa.server, &dev->u.pa.has_server); } +/* SDL */ +static void handle_sdl (Audiodev *dev) +{ +/* SDL is output only */ +get_samples_to_usecs ("QEMU_SDL_SAMPLES" , &dev->out->buffer_len, + &dev->out->has_buffer_len, dev->out); +} +/* general */ static void handle_per_direction (AudiodevPerDirectionOptions *pdo,const char *prefix)
@@ -348,6 +356,10 @@ static AudiodevListEntry *legacy_opt(const char *drvname)handle_pa (e->dev);break ; +case AUDIODEV_DRIVER_SDL : +handle_sdl (e->dev); +break ; +default :break ; }
audio/sdlaudio.c +4 -18
@@ -49,12 +49,6 @@ typedef struct SDLVoiceOut {int decr; } SDLVoiceOut; -static struct { -int nb_samples; -} conf = { - .nb_samples =1024 -}; - static struct SDLAudioState { int exit; #if USE_SEMAPHORE
@@ -63,6 +57,7 @@ static struct SDLAudioState {#endif int initialized;bool driver_created; +Audiodev *dev; } glob_sdl;typedef struct SDLAudioState SDLAudioState ;
@@ -392,7 +387,7 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as, req.freq = as->freq; req.format =aud_to_sdlfmt (as->fmt); req.channels = as->nchannels; - req.samples = conf.nb_samples; + req.samples =audio_buffer_samples (s->dev->out, as,11610 ); req.callback = sdl_callback; req.userdata = sdl;
@@ -467,6 +462,7 @@ static void *sdl_audio_init(Audiodev *dev)#endif s->driver_created = true; + s->dev = dev;return s; }
@@ -480,18 +476,9 @@ static void sdl_audio_fini (void *opaque)#endif SDL_QuitSubSystem (SDL_INIT_AUDIO ); s->driver_created = false; + s->dev =NULL ; } -static struct audio_option sdl_options[] = { - { - .name ="SAMPLES" , - .tag =AUD_OPT_INT , - .valp = &conf.nb_samples, - .descr ="Size of SDL buffer in samples" - }, - {/* End of list */ } -}; -static struct audio_pcm_ops sdl_pcm_ops = { .init_out = sdl_init_out, .fini_out = sdl_fini_out,
@@ -503,7 +490,6 @@ static struct audio_pcm_ops sdl_pcm_ops = {static struct audio_driver sdl_audio_driver = { .name ="sdl" , .descr ="SDL http://www.libsdl.org" , - .options = sdl_options, .init = sdl_audio_init, .fini = sdl_audio_fini, .pcm_ops = &sdl_pcm_ops,
Signature · 1 line
2.20.1
PATCH v4 12/14 spiceaudio: port to -audiodev config
In reply to Kővágó, Zoltán--- audio/spiceaudio.c | 5 ----- 1 file changed, 5 deletions(-)
audio/spiceaudio.c +0 -5
@@ -373,10 +373,6 @@ static int line_in_ctl (HWVoiceIn *hw, int cmd, ...)return 0 ; } -static struct audio_option audio_options[] = { - {/* end of list */ }, -}; -static struct audio_pcm_ops audio_callbacks = { .init_out = line_out_init, .fini_out = line_out_fini,
@@ -394,7 +390,6 @@ static struct audio_pcm_ops audio_callbacks = {static struct audio_driver spice_audio_driver = { .name ="spice" , .descr ="spice audio driver" , - .options = audio_options, .init = spice_audio_init, .fini = spice_audio_fini, .pcm_ops = &audio_callbacks,
Signature · 1 line
2.20.1
PATCH v4 13/14 wavaudio: port to -audiodev config
In reply to Kővágó, Zoltán--- audio/audio_legacy.c | 15 ++++++++++++ audio/wavaudio.c | 58 +++++++------------------------------------- 2 files changed, 24 insertions(+), 49 deletions(-)
audio/audio_legacy.c +15 -0
@@ -293,6 +293,17 @@ static void handle_sdl(Audiodev *dev) &dev->out->has_buffer_len, dev->out); } +/* wav */ +static void handle_wav (Audiodev *dev) +{ +get_int ("QEMU_WAV_FREQUENCY" , + &dev->out->frequency, &dev->out->has_frequency); +get_fmt ("QEMU_WAV_FORMAT" , &dev->out->format, &dev->out->has_format); +get_int ("QEMU_WAV_DAC_FIXED_CHANNELS" , + &dev->out->channels, &dev->out->has_channels); +get_str ("QEMU_WAV_PATH" , &dev->u.wav.path, &dev->u.wav.has_path); +} +/* general */ static void handle_per_direction (AudiodevPerDirectionOptions *pdo,const char *prefix)
@@ -360,6 +371,10 @@ static AudiodevListEntry *legacy_opt(const char *drvname)handle_sdl (e->dev);break ; +case AUDIODEV_DRIVER_WAV : +handle_wav (e->dev); +break ; +default :break ; }
audio/wavaudio.c +9 -49
105 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v4 14/14 audio: -audiodev command line option: cleanup
In reply to Kővágó, ZoltánRemove no longer needed code.
--- audio/audio_int.h | 17 ---- audio/audio.c | 201 +--------------------------------------------- 2 files changed, 4 insertions(+), 214 deletions(-)
audio/audio_int.h +0 -17
@@ -33,22 +33,6 @@struct audio_pcm_ops ; -typedef enum { -AUD_OPT_INT , -AUD_OPT_FMT , -AUD_OPT_STR , -AUD_OPT_BOOL -}audio_option_tag_e ; - -struct audio_option { -const char *name; -audio_option_tag_e tag; -void *valp; -const char *descr; -int *overriddenp; -int overridden; -}; -struct audio_callback {void *opaque;audio_callback_fn fn;
@@ -145,7 +129,6 @@ typedef struct audio_driver audio_driver;struct audio_driver {const char *name;const char *descr; -struct audio_option *options;void *(*init) (Audiodev *);void (*fini) (void *);struct audio_pcm_ops *pcm_ops;
audio/audio.c +4 -197
240 lines not on this page · raw message
Signature · 1 line
2.20.1
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: [Qemu-devel] [PATCH v4 00/14] Audio patches (was: Audio 5.1 patches)
Type: series
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
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 ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test'9505d0ef85 audio: -audiodev command line option: cleanup 2f7a6267e8 wavaudio: port to -audiodev config53f2b38246 spiceaudio: port to -audiodev config 83031a0586 sdlaudio: port to -audiodev configa4cf2daf95 paaudio: port to -audiodev configeca548aefa ossaudio: port to -audiodev config96b7a11f8e noaudio: port to -audiodev config01d330b3a7 dsoundaudio: port to -audiodev config 3738935850 coreaudio: port to -audiodev configa2c88d6cd0 alsaaudio: port to -audiodev config54e5804b4c audio: -audiodev command line option basic implementation 172a851936 audio: -audiodev command line option: documentation a418745d8a audio: use qapi AudioFormat instead of audfmt_e 820a94e64b qapi: qapi for audio backends
=== OUTPUT BEGIN ===
1/14 Checking commit 820a94e64b20 (qapi: qapi for audio backends)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #51:
new file mode 100644
total: 0 errors, 1 warnings, 246 lines checked
Patch 1/14 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/14 Checking commit a418745d8ae2 (audio: use qapi AudioFormat instead of audfmt_e)
ERROR: space prohibited between function name and open parenthesis '(' #36: FILE: audio/alsaaudio.c:297:
+static snd_pcm_format_t aud_to_alsafmt (AudioFormat fmt, int endianness)
ERROR: space prohibited between function name and open parenthesis '(' #84: FILE: audio/alsaaudio.c:347:
+static int alsa_to_audfmt (snd_pcm_format_t alsafmt, AudioFormat *fmt,
ERROR: space prohibited between function name and open parenthesis '(' #205: FILE: audio/audio.c:260:
+static const char *audio_audfmt_to_string (AudioFormat fmt)
ERROR: space prohibited between function name and open parenthesis '(' #241: FILE: audio/audio.c:289:
+static AudioFormat audio_string_to_audfmt (const char *s, AudioFormat defval,
ERROR: space prohibited between function name and open parenthesis '(' #282: FILE: audio/audio.c:324:
+static AudioFormat audio_get_conf_fmt (const char *envname,
ERROR: space prohibited between function name and open parenthesis '(' #523: FILE: audio/ossaudio.c:151:
+static int aud_to_ossfmt (AudioFormat fmt, int endianness)
ERROR: space prohibited between function name and open parenthesis '(' #553: FILE: audio/ossaudio.c:185:
+static int oss_to_audfmt (int ossfmt, AudioFormat *fmt, int *endianness)
ERROR: space prohibited between function name and open parenthesis '(' #620: FILE: audio/paaudio.c:388:
+static pa_sample_format_t audfmt_to_pa (AudioFormat afmt, int endianness)
ERROR: space prohibited between function name and open parenthesis '(' #649: FILE: audio/paaudio.c:413:
+static AudioFormat pa_to_audfmt (pa_sample_format_t fmt, int *endianness)
ERROR: space prohibited between function name and open parenthesis '(' #687: FILE: audio/sdlaudio.c:140:
+static int aud_to_sdlfmt (AudioFormat fmt)
ERROR: trailing statements should be on next line
#954: FILE: hw/audio/hda-codec.c:102:
+ case AC_FMT_BITS_8: as->fmt = AUDIO_FORMAT_S8; break;
ERROR: trailing statements should be on next line
#955: FILE: hw/audio/hda-codec.c:103:
+ case AC_FMT_BITS_16: as->fmt = AUDIO_FORMAT_S16; break;
ERROR: trailing statements should be on next line
#956: FILE: hw/audio/hda-codec.c:104:
+ case AC_FMT_BITS_32: as->fmt = AUDIO_FORMAT_S32; break;
ERROR: space prohibited after that open square bracket '[' #970: FILE: hw/audio/hda-codec.c:137:
+ [ AUDIO_FORMAT_U8 ] = "PCM-U8",
ERROR: space prohibited before that close square bracket ']' #970: FILE: hw/audio/hda-codec.c:137:
+ [ AUDIO_FORMAT_U8 ] = "PCM-U8",
ERROR: space prohibited after that open square bracket '[' #971: FILE: hw/audio/hda-codec.c:138:
+ [ AUDIO_FORMAT_S8 ] = "PCM-S8",
ERROR: space prohibited before that close square bracket ']' #971: FILE: hw/audio/hda-codec.c:138:
+ [ AUDIO_FORMAT_S8 ] = "PCM-S8",
ERROR: space prohibited after that open square bracket '[' #972: FILE: hw/audio/hda-codec.c:139:
+ [ AUDIO_FORMAT_U16 ] = "PCM-U16",
ERROR: space prohibited before that close square bracket ']' #972: FILE: hw/audio/hda-codec.c:139:
+ [ AUDIO_FORMAT_U16 ] = "PCM-U16",
ERROR: space prohibited after that open square bracket '[' #973: FILE: hw/audio/hda-codec.c:140:
+ [ AUDIO_FORMAT_S16 ] = "PCM-S16",
ERROR: space prohibited before that close square bracket ']' #973: FILE: hw/audio/hda-codec.c:140:
+ [ AUDIO_FORMAT_S16 ] = "PCM-S16",
ERROR: space prohibited after that open square bracket '[' #974: FILE: hw/audio/hda-codec.c:141:
+ [ AUDIO_FORMAT_U32 ] = "PCM-U32",
ERROR: space prohibited before that close square bracket ']' #974: FILE: hw/audio/hda-codec.c:141:
+ [ AUDIO_FORMAT_U32 ] = "PCM-U32",
ERROR: space prohibited after that open square bracket '[' #975: FILE: hw/audio/hda-codec.c:142:
+ [ AUDIO_FORMAT_S32 ] = "PCM-S32",
ERROR: space prohibited before that close square bracket ']' #975: FILE: hw/audio/hda-codec.c:142:
+ [ AUDIO_FORMAT_S32 ] = "PCM-S32",
ERROR: trailing statements should be on next line
#1197: FILE: ui/vnc.c:2431:
+ case 0: vs->as.fmt = AUDIO_FORMAT_U8; break;
ERROR: trailing statements should be on next line
#1198: FILE: ui/vnc.c:2432:
+ case 1: vs->as.fmt = AUDIO_FORMAT_S8; break;
ERROR: trailing statements should be on next line
#1199: FILE: ui/vnc.c:2433:
+ case 2: vs->as.fmt = AUDIO_FORMAT_U16; break;
ERROR: trailing statements should be on next line
#1200: FILE: ui/vnc.c:2434:
+ case 3: vs->as.fmt = AUDIO_FORMAT_S16; break;
ERROR: trailing statements should be on next line
#1201: FILE: ui/vnc.c:2435:
+ case 4: vs->as.fmt = AUDIO_FORMAT_U32; break;
ERROR: trailing statements should be on next line
#1202: FILE: ui/vnc.c:2436:
+ case 5: vs->as.fmt = AUDIO_FORMAT_S32; break;
total: 31 errors, 0 warnings, 1028 lines checked
Patch 2/14 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
3/14 Checking commit 172a8519365e (audio: -audiodev command line option: documentation) 4/14 Checking commit 54e5804b4c2a (audio: -audiodev command line option basic implementation)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #937:
new file mode 100644
total: 0 errors, 1 warnings, 1283 lines checked
Patch 4/14 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
5/14 Checking commit a2c88d6cd00e (alsaaudio: port to -audiodev config) 6/14 Checking commit 373893585072 (coreaudio: port to -audiodev config) 7/14 Checking commit 01d330b3a7f0 (dsoundaudio: port to -audiodev config) 8/14 Checking commit 96b7a11f8ee6 (noaudio: port to -audiodev config) 9/14 Checking commit eca548aefae2 (ossaudio: port to -audiodev config) 10/14 Checking commit a4cf2daf954f (paaudio: port to -audiodev config) 11/14 Checking commit 83031a0586cb (sdlaudio: port to -audiodev config) 12/14 Checking commit 53f2b3824652 (spiceaudio: port to -audiodev config) 13/14 Checking commit 2f7a6267e87e (wavaudio: port to -audiodev config) 14/14 Checking commit 9505d0ef8530 (audio: -audiodev command line option: cleanup) === 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 [http://patchew.org/].
Please send your feedback to [email protected]