From patchwork Fri Jun 12 12:33:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?B?Wm9sdMOhbiBLxZF2w6Fnw7M=?= X-Patchwork-Id: 483540 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0D88B140082 for ; Fri, 12 Jun 2015 22:36:03 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=KoPJP2dX; dkim-atps=neutral Received: from localhost ([::1]:51057 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3OBl-0003Gf-Vl for incoming@patchwork.ozlabs.org; Fri, 12 Jun 2015 08:36:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40412) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3O9A-0007QQ-Fm for qemu-devel@nongnu.org; Fri, 12 Jun 2015 08:33:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z3O97-0004Fx-5z for qemu-devel@nongnu.org; Fri, 12 Jun 2015 08:33:20 -0400 Received: from mail-wg0-x22d.google.com ([2a00:1450:400c:c00::22d]:33591) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3O96-0004Fk-SN for qemu-devel@nongnu.org; Fri, 12 Jun 2015 08:33:17 -0400 Received: by wgez8 with SMTP id z8so23897514wge.0 for ; Fri, 12 Jun 2015 05:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=E1Wk1J04plrRD/GQ0c8fTLm7M/be9rD9T2Zfmus0zKs=; b=KoPJP2dXEGR01u9xSuMIx83HiaFStBe3BJ5wQ2BTxXqYTOZWWCLwdGXAtcBvYyB9ac OaQ1HjwqoWVMj9tbBZKk+3pLa5xz8TxbWoJZQtUzAv/odb0Fj0rMLXhIOJs00tTAMXTJ Hw7qoLlNbOsoVpu7W65cQOs+Uj+zni+wOIjOd7vWhwr7coIc4+tepctLaQXfXjQNwFv1 Pu+y+TQKg8iE3kWZOPZSGSFNys86EqWYay4A+Q+IbqRVkc61q3z5vDD5SmMtA8OTfem0 uTHw9rQYzcGVhb2YcLwx5dQJKfTHc3X9HqeD80kfJQ3oj4L20y5BOerVq+IkmZtMcdXE CuDw== X-Received: by 10.194.237.34 with SMTP id uz2mr26530890wjc.155.1434112396243; Fri, 12 Jun 2015 05:33:16 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (94-21-76-230.pool.digikabel.hu. [94.21.76.230]) by mx.google.com with ESMTPSA id m2sm2569153wiy.7.2015.06.12.05.33.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jun 2015 05:33:15 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Fri, 12 Jun 2015 14:33:08 +0200 Message-Id: <5dee9d7d95eb2260edcc0de0d1090366f159b03f.1434111578.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.4.2 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::22d Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 07/12] qapi: qapi for audio backends X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 and oss backend specific option (as all other backends currently ignore it) Signed-off-by: Kővágó, Zoltán --- Changes from v2 RFC patch: * in, out are no longer optional * try-poll: moved to alsa and oss (as no other backend used them) * voices: added (env variables had this option) * dsound: removed primary buffer related fields Changes from v1 RFC patch: * fixed style issues * moved definitions into a separate file * documented undocumented options (hopefully) * removed plive option. It was useless even years ago so it can probably safely go away: https://lists.nongnu.org/archive/html/qemu-devel/2012-03/msg02427.html * removed verbose, debug options. Backends should use trace events instead. * removed *_retries options from dsound. It's a kludge. * moved buffer_usecs and buffer_count to the global config options. Some driver might ignore it (as they do not expose API to change them). * wav backend: removed frequecy, format, channels as AudiodevPerDirectionOptions already have them. Makefile | 4 +- qapi-schema.json | 3 + qapi/audio.json | 217 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 222 insertions(+), 2 deletions(-) create mode 100644 qapi/audio.json diff --git a/Makefile b/Makefile index 2d52536..982563e 100644 --- a/Makefile +++ b/Makefile @@ -257,8 +257,8 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) " GEN $@") qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ - $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \ - $(SRC_PATH)/qapi/event.json + $(SRC_PATH)/qapi/audio.json $(SRC_PATH)/qapi/block.json \ + $(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/qapi/event.json qapi-types.c qapi-types.h :\ $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) diff --git a/qapi-schema.json b/qapi-schema.json index 6e17a5c..26c470a 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -5,6 +5,9 @@ # QAPI common definitions { 'include': 'qapi/common.json' } +# QAPI audio definitions +{ 'include': 'qapi/audio.json' } + # QAPI block definitions { 'include': 'qapi/block.json' } diff --git a/qapi/audio.json b/qapi/audio.json new file mode 100644 index 0000000..157ccf6 --- /dev/null +++ b/qapi/audio.json @@ -0,0 +1,217 @@ +# -*- mode: python -*- + +## +# @AudiodevNoneOptions +# +# The none, coreaudio, sdl and spice audio backend has no options. +# +# Since: 2.4 +## +{ 'struct': 'AudiodevNoneOptions', + 'data': { } } + +## +# @AudiodevAlsaPerDirectionOptions +# +# Options of the alsa backend that are used for both playback and recording. +# +# @dev: #optional the name of the alsa device to use +# +# @try-poll: #optional attempt to use poll mode +# +# Since: 2.4 +## +{ 'struct': 'AudiodevAlsaPerDirectionOptions', + 'data': { + '*dev': 'str', + '*try-poll': 'bool' } } + +## +# @AudiodevAlsaOptions +# +# Options of the alsa audio backend. +# +# @in: #optional options of the capture stream +# +# @out: #optional options of the playback stream +# +# @threshold: #optional set the threshold (in frames) when playback starts +# +# Since: 2.4 +## +{ 'struct': 'AudiodevAlsaOptions', + 'data': { + 'in': 'AudiodevAlsaPerDirectionOptions', + 'out': 'AudiodevAlsaPerDirectionOptions', + '*threshold': 'int' } } + +## +# @AudiodevDsoundOptions +# +# Options of the dsound audio backend. +# +# @latency-millis: #optional add extra latency to playback +# +# Since: 2.4 +## +{ 'struct': 'AudiodevDsoundOptions', + 'data': { + '*latency-millis': 'int' } } + +## +# @AudiodevOssPerDirectionOptions +# +# Options of the oss backend that are used for both playback and recording. +# +# @dev: #optional path of the oss device +# +# @try-poll: #optional attempt to use poll mode +# +# Since: 2.4 +## +{ 'struct': 'AudiodevOssPerDirectionOptions', + 'data': { + '*dev': 'str', + '*try-poll': 'bool' } } + +## +# @AudiodevOssOptions +# +# Options of the oss audio backend. +# +# @in: #optional options of the capture stream +# +# @out: #optional options of the playback stream +# +# @mmap: #optional try using memory mapped access +# +# @exclusive: #optional open device in exclusive mode (vmix wont work) +# +# @dsp-policy: #optional set the timing policy of the device, -1 to use fragment +# mode (option ignored on some platforms) +# +# Since: 2.4 +## +{ 'struct': 'AudiodevOssOptions', + 'data': { + 'in': 'AudiodevOssPerDirectionOptions', + 'out': 'AudiodevOssPerDirectionOptions', + '*mmap': 'bool', + '*exclusive': 'bool', + '*dsp-policy': 'int' } } + +## +# @AudiodevPaOptions +# +# Options of the pa (PulseAudio) audio backend. +# +# @server: #optional PulseAudio server address +# +# @sink: #optional sink device name +# +# @source: #optional source device name +# +# Since: 2.4 +## +{ 'struct': 'AudiodevPaOptions', + 'data': { + '*server': 'str', + '*sink': 'str', + '*source': 'str' } } + +## +# @AudiodevWavOptions +# +# Options of the wav audio backend. +# +# @path: #optional path of the wav file to record +# +# Since: 2.4 +## +{ 'struct': 'AudiodevWavOptions', + 'data': { + '*path': 'str' } } + + +## +# @AudiodevBackendOptions +# +# A discriminated record of audio backends. +# +# Since: 2.4 +## +{ 'union': 'AudiodevBackendOptions', + 'data': { + 'none': 'AudiodevNoneOptions', + 'alsa': 'AudiodevAlsaOptions', + 'coreaudio': 'AudiodevNoneOptions', + 'dsound': 'AudiodevDsoundOptions', + 'oss': 'AudiodevOssOptions', + 'pa': 'AudiodevPaOptions', + 'sdl': 'AudiodevNoneOptions', + 'spice': 'AudiodevNoneOptions', + 'wav': 'AudiodevWavOptions' } } + +## +# @AudioFormat +# +# An enumeration of possible audio formats. +# +# Since: 2.4 +## +{ 'enum': 'AudioFormat', + 'data': [ 'u8', 's8', 'u16', 's16', 'u32', 's32' ] } + +## +# @AudiodevPerDirectionOptions +# +# General audio backend options that are used for both playback and recording. +# +# @fixed-settings: #optional use fixed settings for host DAC/ADC +# +# @frequency: #optional frequency to use when using fixed settings +# +# @channels: #optional number of channels when using fixed settings +# +# @format: #optional sample fortmat to use when using fixed settings +# +# @buffer-usecs: #optional the buffer size in microseconds +# +# @buffer-count: #optional nuber of buffers +# +# Since: 2.4 +## +{ 'struct': 'AudiodevPerDirectionOptions', + 'data': { + '*fixed-settings': 'bool', + '*frequency': 'int', + '*channels': 'int', + '*voices': 'int', + '*format': 'AudioFormat', + '*buffer-usecs': 'int', + '*buffer-count': 'int' } } + +## +# @Audiodev +# +# Captures the configuration of an audio backend. +# +# @id: identifier of the backend +# +# @in: #optional options of the capture stream +# +# @out: #optional options of the playback stream +# +# @timer-period: #optional timer period in HZ (0 - use lowest possible) +# +# @opts: audio backend specific options +# +# Since: 2.4 +## +{ 'struct': 'Audiodev', + 'data': { + '*id': 'str', + 'in': 'AudiodevPerDirectionOptions', + 'out': 'AudiodevPerDirectionOptions', + '*timer-period': 'int', + 'opts': 'AudiodevBackendOptions' } }