From patchwork Wed Jan 16 23:36:34 2019 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: 1026283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kMEcjWkh"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43g3Ys6l62z9sBQ for ; Thu, 17 Jan 2019 10:38:41 +1100 (AEDT) Received: from localhost ([127.0.0.1]:59413 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjulb-00047F-Ql for incoming@patchwork.ozlabs.org; Wed, 16 Jan 2019 18:38:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjukj-00042P-7b for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:37:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjukf-0002nY-D2 for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:37:45 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:38058) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gjukd-0002Zc-HY for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:37:41 -0500 Received: by mail-wr1-x444.google.com with SMTP id v13so8965029wrw.5 for ; Wed, 16 Jan 2019 15:37:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FDB/hWwJr0F3fHBv+QJQDk1NqMyj+yM0hRTu3qS/kxY=; b=kMEcjWkhlqOVII+rRm5uSuwznFl6RN1kXjSESF7cVH+JeE7UpGIcCRF4w5EDZUTf4D bjOZUHDCY5UrEYKhJWHtEav0OvuKustZsLFgm0l07fwSAft69n9pEw8ggZKkKZwQpHkp JlsYlWj0n/VqBrRGu+V6nhHoajEYIMxLP6dPR0nETx8ehOZp8rhN8wKl1eLBxP0dkOIk 7Mq5reCJspn3ZENthoa4tEBNMA/R5ZdqSFzRpmNAdj2Fbp9/2xG2ja/juD66F89u6sN6 es5hwYjk/n3UCmUQcD6/jGaIce78reWl4Jsr5g/1cTyY1tHTxg7M4P/yBaYfq0UFbBpd vSfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FDB/hWwJr0F3fHBv+QJQDk1NqMyj+yM0hRTu3qS/kxY=; b=mQFwF7pFffn0KjT5cXb9GDjGX+v18xc2S/yZcx8we1mbt5xfJUDtu0l4WhooejMQwH tlweagQ3KqHV7kTzQbfM4LLBnMTdgmB6IetqmhDYF/0nUY6PHHMnVmpneEzHvPQEu/Vt r5kUCGwZVmP+Xmrxt32SPgS5XBUyXn/CIhSC5kYn9H7PjIgo/b8098Ne0L9svk//0+KG M7CF0+idjGc1BfQm6XB3X9NMLzwDmGXKBys2UqUdak+fs8M6I7X5cqjpS8WZ0Xc83UON T/lQHM0SqQERhu+jfKzskFzi8It5IKSd36BWt+gRfZnMnunEB4/ifGyAIoELQKjs19le 4rmQ== X-Gm-Message-State: AJcUukey9mNrCW/nkPzswFVCa1t8WT2YSeApH0e6364oCcDSAKcViCBW NKIbgK19kyNt2L/dGszSF1wLHzB3 X-Google-Smtp-Source: ALg8bN4yjjt7Ee7BDBl3ZoPqG+PNMd0Tc1ZG3cFf6yFcUxSUDV7ASW+3S7YkGOamx1qZlpiL16oXaw== X-Received: by 2002:adf:9361:: with SMTP id 88mr9221457wro.204.1547681845815; Wed, 16 Jan 2019 15:37:25 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-e4b0-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:e4b0::5]) by smtp.gmail.com with ESMTPSA id s66sm30760437wmf.34.2019.01.16.15.37.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 15:37:25 -0800 (PST) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?utf-8?b?S8WRdsOhZ8OzLCBab2x0w6Fu?= To: qemu-devel@nongnu.org Date: Thu, 17 Jan 2019 00:36:34 +0100 Message-Id: <0d2685bb2c3f9a7182aa99b8218f3e4bb223522d.1547681517.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PATCH v3 01/50] qapi: qapi for audio backends X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , Markus Armbruster Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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) Signed-off-by: Kővágó, Zoltán --- 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 diff --git a/Makefile.objs b/Makefile.objs index 456115992a..e830cdbafc 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -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 diff --git a/qapi/audio.json b/qapi/audio.json new file mode 100644 index 0000000000..bd6e2494bd --- /dev/null +++ b/qapi/audio.json @@ -0,0 +1,233 @@ +# -*- mode: python -*- +# +# Copyright (C) 2015-2019 Zoltán Kővágó +# +# 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. +# +# @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 +# failure (default on) +# +# 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 +## +{ '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') +# +# @try-poll: attempt to use poll mode, falling back to non polling access on +# failure (default on) +# +# Since: 4.0 +## +{ 'struct': 'AudiodevOssPerDirectionOptions', + 'data': { + '*dev': 'str', + '*try-poll': 'bool' } } + +## +# @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) +# +# @exclusive: open device in exclusive mode (vmix won't work) (default off) +# +# @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: +# +# 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' } } + +## +# @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: +# +# 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' } } + + +## +# @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', + '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) +# +# @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', + '*in': 'AudiodevPerDirectionOptions', + '*out': 'AudiodevPerDirectionOptions', + '*timer-period': 'uint32' }, + 'discriminator': 'driver', + 'data': { + 'alsa': 'AudiodevAlsaOptions', + 'dsound': 'AudiodevDsoundOptions', + 'oss': 'AudiodevOssOptions', + 'pa': 'AudiodevPaOptions', + 'wav': 'AudiodevWavOptions' } } diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index 3bbdfcee84..d5f9856be7 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -95,3 +95,4 @@ { 'include': 'trace.json' } { 'include': 'introspect.json' } { 'include': 'misc.json' } +{ 'include': 'audio.json' }