xref: /openbmc/qemu/qapi/audio.json (revision cad9aa6fbdccd95e56e10cfa57c354a20a333717)
1# -*- mode: python -*-
2# vim: filetype=python
3#
4# Copyright (C) 2015-2019 Zoltán Kővágó <DirtY.iCE.hu@gmail.com>
5#
6# This work is licensed under the terms of the GNU GPL, version 2 or later.
7# See the COPYING file in the top-level directory.
8
9##
10# *****
11# Audio
12# *****
13##
14
15##
16# @AudiodevPerDirectionOptions:
17#
18# General audio backend options that are used for both playback and
19# recording.
20#
21# @mixing-engine: use QEMU's mixing engine to mix all streams inside
22#     QEMU and convert audio formats when not supported by the
23#     backend.  When set to off, fixed-settings must be also off
24#     (default on, since 4.2)
25#
26# @fixed-settings: use fixed settings for host input/output.  When
27#     off, frequency, channels and format must not be specified
28#     (default true)
29#
30# @frequency: frequency to use when using fixed settings (default
31#     44100)
32#
33# @channels: number of channels when using fixed settings (default 2)
34#
35# @voices: number of voices to use (default 1)
36#
37# @format: sample format to use when using fixed settings (default
38#     s16)
39#
40# @buffer-length: the buffer length in microseconds
41#
42# Since: 4.0
43##
44{ 'struct': 'AudiodevPerDirectionOptions',
45  'data': {
46    '*mixing-engine':  'bool',
47    '*fixed-settings': 'bool',
48    '*frequency':      'uint32',
49    '*channels':       'uint32',
50    '*voices':         'uint32',
51    '*format':         'AudioFormat',
52    '*buffer-length':  'uint32' } }
53
54##
55# @AudiodevGenericOptions:
56#
57# Generic driver-specific options.
58#
59# @in: options of the capture stream
60#
61# @out: options of the playback stream
62#
63# Since: 4.0
64##
65{ 'struct': 'AudiodevGenericOptions',
66  'data': {
67    '*in':  'AudiodevPerDirectionOptions',
68    '*out': 'AudiodevPerDirectionOptions' } }
69
70##
71# @AudiodevDBusOptions:
72#
73# Options of the D-Bus audio backend.
74#
75# @in: options of the capture stream
76#
77# @out: options of the playback stream
78#
79# @nsamples: set the number of samples per read/write calls (default to 480,
80# 10ms at 48kHz).
81#
82# Since: 10.0
83##
84{ 'struct': 'AudiodevDBusOptions',
85  'data': {
86    '*in':  'AudiodevPerDirectionOptions',
87    '*out': 'AudiodevPerDirectionOptions',
88    '*nsamples': 'uint32'} }
89
90##
91# @AudiodevAlsaPerDirectionOptions:
92#
93# Options of the ALSA backend that are used for both playback and
94# recording.
95#
96# @dev: the name of the ALSA device to use (default 'default')
97#
98# @period-length: the period length in microseconds
99#
100# @try-poll: attempt to use poll mode, falling back to non-polling
101#     access on failure (default false)
102#
103# Since: 4.0
104##
105{ 'struct': 'AudiodevAlsaPerDirectionOptions',
106  'base': 'AudiodevPerDirectionOptions',
107  'data': {
108    '*dev':           'str',
109    '*period-length': 'uint32',
110    '*try-poll':      'bool' } }
111
112##
113# @AudiodevAlsaOptions:
114#
115# Options of the ALSA audio backend.
116#
117# @in: options of the capture stream
118#
119# @out: options of the playback stream
120#
121# @threshold: set the threshold (in microseconds) when playback starts
122#
123# Since: 4.0
124##
125{ 'struct': 'AudiodevAlsaOptions',
126  'data': {
127    '*in':        'AudiodevAlsaPerDirectionOptions',
128    '*out':       'AudiodevAlsaPerDirectionOptions',
129    '*threshold': 'uint32' } }
130
131##
132# @AudiodevSndioOptions:
133#
134# Options of the sndio audio backend.
135#
136# @in: options of the capture stream
137#
138# @out: options of the playback stream
139#
140# @dev: the name of the sndio device to use (default 'default')
141#
142# @latency: play buffer size (in microseconds)
143#
144# Since: 7.2
145##
146{ 'struct': 'AudiodevSndioOptions',
147  'data': {
148    '*in':        'AudiodevPerDirectionOptions',
149    '*out':       'AudiodevPerDirectionOptions',
150    '*dev':       'str',
151    '*latency':   'uint32'} }
152
153##
154# @AudiodevCoreaudioPerDirectionOptions:
155#
156# Options of the Core Audio backend that are used for both playback
157# and recording.
158#
159# @buffer-count: number of buffers
160#
161# Since: 4.0
162##
163{ 'struct': 'AudiodevCoreaudioPerDirectionOptions',
164  'base': 'AudiodevPerDirectionOptions',
165  'data': {
166    '*buffer-count': 'uint32' } }
167
168##
169# @AudiodevCoreaudioOptions:
170#
171# Options of the coreaudio audio backend.
172#
173# @in: options of the capture stream
174#
175# @out: options of the playback stream
176#
177# Since: 4.0
178##
179{ 'struct': 'AudiodevCoreaudioOptions',
180  'data': {
181    '*in':  'AudiodevCoreaudioPerDirectionOptions',
182    '*out': 'AudiodevCoreaudioPerDirectionOptions' } }
183
184##
185# @AudiodevDsoundOptions:
186#
187# Options of the DirectSound audio backend.
188#
189# @in: options of the capture stream
190#
191# @out: options of the playback stream
192#
193# @latency: add extra latency to playback in microseconds (default
194#     10000)
195#
196# Since: 4.0
197##
198{ 'struct': 'AudiodevDsoundOptions',
199  'data': {
200    '*in':      'AudiodevPerDirectionOptions',
201    '*out':     'AudiodevPerDirectionOptions',
202    '*latency': 'uint32' } }
203
204##
205# @AudiodevJackPerDirectionOptions:
206#
207# Options of the JACK backend that are used for both playback and
208# recording.
209#
210# @server-name: select from among several possible concurrent server
211#     instances (default: environment variable $JACK_DEFAULT_SERVER if
212#     set, else "default")
213#
214# @client-name: the client name to use.  The server will modify this
215#     name to create a unique variant, if needed unless @exact-name is
216#     true (default: the guest's name)
217#
218# @connect-ports: if set, a regular expression of JACK client port
219#     name(s) to monitor for and automatically connect to
220#
221# @start-server: start a jack server process if one is not already
222#     present (default: false)
223#
224# @exact-name: use the exact name requested otherwise JACK
225#     automatically generates a unique one, if needed (default: false)
226#
227# Since: 5.1
228##
229{ 'struct': 'AudiodevJackPerDirectionOptions',
230  'base': 'AudiodevPerDirectionOptions',
231  'data': {
232    '*server-name':   'str',
233    '*client-name':   'str',
234    '*connect-ports': 'str',
235    '*start-server':  'bool',
236    '*exact-name':    'bool' } }
237
238##
239# @AudiodevJackOptions:
240#
241# Options of the JACK audio backend.
242#
243# @in: options of the capture stream
244#
245# @out: options of the playback stream
246#
247# Since: 5.1
248##
249{ 'struct': 'AudiodevJackOptions',
250  'data': {
251    '*in':  'AudiodevJackPerDirectionOptions',
252    '*out': 'AudiodevJackPerDirectionOptions' } }
253
254##
255# @AudiodevOssPerDirectionOptions:
256#
257# Options of the OSS backend that are used for both playback and
258# recording.
259#
260# @dev: file name of the OSS device (default '/dev/dsp')
261#
262# @buffer-count: number of buffers
263#
264# @try-poll: attempt to use poll mode, falling back to non-polling
265#     access on failure (default true)
266#
267# Since: 4.0
268##
269{ 'struct': 'AudiodevOssPerDirectionOptions',
270  'base': 'AudiodevPerDirectionOptions',
271  'data': {
272    '*dev':          'str',
273    '*buffer-count': 'uint32',
274    '*try-poll':     'bool' } }
275
276##
277# @AudiodevOssOptions:
278#
279# Options of the OSS audio backend.
280#
281# @in: options of the capture stream
282#
283# @out: options of the playback stream
284#
285# @try-mmap: try using memory-mapped access, falling back to
286#     non-memory-mapped access on failure (default true)
287#
288# @exclusive: open device in exclusive mode (vmix won't work) (default
289#     false)
290#
291# @dsp-policy: set the timing policy of the device (between 0 and 10,
292#     where smaller number means smaller latency but higher CPU usage)
293#     or -1 to use fragment mode (option ignored on some platforms)
294#     (default 5)
295#
296# Since: 4.0
297##
298{ 'struct': 'AudiodevOssOptions',
299  'data': {
300    '*in':         'AudiodevOssPerDirectionOptions',
301    '*out':        'AudiodevOssPerDirectionOptions',
302    '*try-mmap':   'bool',
303    '*exclusive':  'bool',
304    '*dsp-policy': 'uint32' } }
305
306##
307# @AudiodevPaPerDirectionOptions:
308#
309# Options of the Pulseaudio backend that are used for both playback
310# and recording.
311#
312# @name: name of the sink/source to use
313#
314# @stream-name: name of the PulseAudio stream created by QEMU.  Can be
315#     used to identify the stream in PulseAudio when you create
316#     multiple PulseAudio devices or run multiple QEMU instances
317#     (default: audiodev's id, since 4.2)
318#
319# @latency: latency you want PulseAudio to achieve in microseconds
320#     (default 15000)
321#
322# Since: 4.0
323##
324{ 'struct': 'AudiodevPaPerDirectionOptions',
325  'base': 'AudiodevPerDirectionOptions',
326  'data': {
327    '*name': 'str',
328    '*stream-name': 'str',
329    '*latency': 'uint32' } }
330
331##
332# @AudiodevPaOptions:
333#
334# Options of the PulseAudio audio backend.
335#
336# @in: options of the capture stream
337#
338# @out: options of the playback stream
339#
340# @server: PulseAudio server address (default: let PulseAudio choose)
341#
342# Since: 4.0
343##
344{ 'struct': 'AudiodevPaOptions',
345  'data': {
346    '*in':     'AudiodevPaPerDirectionOptions',
347    '*out':    'AudiodevPaPerDirectionOptions',
348    '*server': 'str' } }
349
350##
351# @AudiodevPipewirePerDirectionOptions:
352#
353# Options of the PipeWire backend that are used for both playback and
354# recording.
355#
356# @name: name of the sink/source to use
357#
358# @stream-name: name of the PipeWire stream created by QEMU.  Can be
359#     used to identify the stream in PipeWire when you create multiple
360#     PipeWire devices or run multiple QEMU instances (default:
361#     audiodev's id)
362#
363# @latency: latency you want PipeWire to achieve in microseconds
364#     (default 46000)
365#
366# Since: 8.1
367##
368{ 'struct': 'AudiodevPipewirePerDirectionOptions',
369  'base': 'AudiodevPerDirectionOptions',
370  'data': {
371    '*name': 'str',
372    '*stream-name': 'str',
373    '*latency': 'uint32' } }
374
375##
376# @AudiodevPipewireOptions:
377#
378# Options of the PipeWire audio backend.
379#
380# @in: options of the capture stream
381#
382# @out: options of the playback stream
383#
384# Since: 8.1
385##
386{ 'struct': 'AudiodevPipewireOptions',
387  'data': {
388    '*in':     'AudiodevPipewirePerDirectionOptions',
389    '*out':    'AudiodevPipewirePerDirectionOptions' } }
390
391##
392# @AudiodevSdlPerDirectionOptions:
393#
394# Options of the SDL audio backend that are used for both playback and
395# recording.
396#
397# @buffer-count: number of buffers (default 4)
398#
399# Since: 6.0
400##
401{ 'struct': 'AudiodevSdlPerDirectionOptions',
402  'base': 'AudiodevPerDirectionOptions',
403  'data': {
404    '*buffer-count': 'uint32' } }
405
406##
407# @AudiodevSdlOptions:
408#
409# Options of the SDL audio backend.
410#
411# @in: options of the recording stream
412#
413# @out: options of the playback stream
414#
415# Since: 6.0
416##
417{ 'struct': 'AudiodevSdlOptions',
418  'data': {
419    '*in':  'AudiodevSdlPerDirectionOptions',
420    '*out': 'AudiodevSdlPerDirectionOptions' } }
421
422##
423# @AudiodevWavOptions:
424#
425# Options of the wav audio backend.
426#
427# @in: options of the capture stream
428#
429# @out: options of the playback stream
430#
431# @path: name of the wav file to record (default 'qemu.wav')
432#
433# Since: 4.0
434##
435{ 'struct': 'AudiodevWavOptions',
436  'data': {
437    '*in':   'AudiodevPerDirectionOptions',
438    '*out':  'AudiodevPerDirectionOptions',
439    '*path': 'str' } }
440
441##
442# @AudioFormat:
443#
444# An enumeration of possible audio formats.
445#
446# @u8: unsigned 8 bit integer
447#
448# @s8: signed 8 bit integer
449#
450# @u16: unsigned 16 bit integer
451#
452# @s16: signed 16 bit integer
453#
454# @u32: unsigned 32 bit integer
455#
456# @s32: signed 32 bit integer
457#
458# @f32: single precision floating-point (since 5.0)
459#
460# Since: 4.0
461##
462{ 'enum': 'AudioFormat',
463  'data': [ 'u8', 's8', 'u16', 's16', 'u32', 's32', 'f32' ] }
464
465##
466# @AudiodevDriver:
467#
468# An enumeration of possible audio backend drivers.
469#
470# @jack: JACK audio backend (since 5.1)
471#
472# Since: 4.0
473##
474{ 'enum': 'AudiodevDriver',
475  'data': [ 'none',
476            { 'name': 'alsa', 'if': 'CONFIG_AUDIO_ALSA' },
477            { 'name': 'coreaudio', 'if': 'CONFIG_AUDIO_COREAUDIO' },
478            { 'name': 'dbus', 'if': 'CONFIG_DBUS_DISPLAY' },
479            { 'name': 'dsound', 'if': 'CONFIG_AUDIO_DSOUND' },
480            { 'name': 'jack', 'if': 'CONFIG_AUDIO_JACK' },
481            { 'name': 'oss', 'if': 'CONFIG_AUDIO_OSS' },
482            { 'name': 'pa', 'if': 'CONFIG_AUDIO_PA' },
483            { 'name': 'pipewire', 'if': 'CONFIG_AUDIO_PIPEWIRE' },
484            { 'name': 'sdl', 'if': 'CONFIG_AUDIO_SDL' },
485            { 'name': 'sndio', 'if': 'CONFIG_AUDIO_SNDIO' },
486            { 'name': 'spice', 'if': 'CONFIG_SPICE' },
487            'wav' ] }
488
489##
490# @Audiodev:
491#
492# Options of an audio backend.
493#
494# @id: identifier of the backend
495#
496# @driver: the backend driver to use
497#
498# @timer-period: timer period (in microseconds, 0: use lowest
499#     possible)
500#
501# Since: 4.0
502##
503{ 'union': 'Audiodev',
504  'base': {
505    'id':            'str',
506    'driver':        'AudiodevDriver',
507    '*timer-period': 'uint32' },
508  'discriminator': 'driver',
509  'data': {
510    'none':      'AudiodevGenericOptions',
511    'alsa':      { 'type': 'AudiodevAlsaOptions',
512                   'if': 'CONFIG_AUDIO_ALSA' },
513    'coreaudio': { 'type': 'AudiodevCoreaudioOptions',
514                   'if': 'CONFIG_AUDIO_COREAUDIO' },
515    'dbus':      { 'type': 'AudiodevDBusOptions',
516                   'if': 'CONFIG_DBUS_DISPLAY' },
517    'dsound':    { 'type': 'AudiodevDsoundOptions',
518                   'if': 'CONFIG_AUDIO_DSOUND' },
519    'jack':      { 'type': 'AudiodevJackOptions',
520                   'if': 'CONFIG_AUDIO_JACK' },
521    'oss':       { 'type': 'AudiodevOssOptions',
522                   'if': 'CONFIG_AUDIO_OSS' },
523    'pa':        { 'type': 'AudiodevPaOptions',
524                   'if': 'CONFIG_AUDIO_PA' },
525    'pipewire':  { 'type': 'AudiodevPipewireOptions',
526                   'if': 'CONFIG_AUDIO_PIPEWIRE' },
527    'sdl':       { 'type': 'AudiodevSdlOptions',
528                   'if': 'CONFIG_AUDIO_SDL' },
529    'sndio':     { 'type': 'AudiodevSndioOptions',
530                   'if': 'CONFIG_AUDIO_SNDIO' },
531    'spice':     { 'type': 'AudiodevGenericOptions',
532                   'if': 'CONFIG_SPICE' },
533    'wav':       'AudiodevWavOptions' } }
534
535##
536# @query-audiodevs:
537#
538# Return information about audiodev configuration
539#
540# Since: 8.0
541##
542{ 'command': 'query-audiodevs',
543  'returns': ['Audiodev'] }
544