From nobody Mon May 6 19:52:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552084610484880.2703329646621; Fri, 8 Mar 2019 14:36:50 -0800 (PST) Received: from localhost ([127.0.0.1]:50787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O6Y-0000XX-VF for importer@patchew.org; Fri, 08 Mar 2019 17:36:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O4V-0007ap-96 for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2O4T-0002ZU-Nk for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:31 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:47025) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2O4T-0002Yx-Bz for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:29 -0500 Received: by mail-wr1-x442.google.com with SMTP id i16so22933026wrs.13 for ; Fri, 08 Mar 2019 14:34:29 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6af5-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6af5::5]) by smtp.gmail.com with ESMTPSA id v2sm15269144wme.29.2019.03.08.14.34.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:34: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=gYOpp5DfDsEuhzy/2nQog/TDIuKvpxZ3kbRTztGAmN0=; b=ZJuXoGVMcnWmO+y77YVdvuwgU3QKKpNN4SzDoOBGPWQDve8wrqi3P51dFUHkCKB58o /+8NZeX+suyGcvyiixjHEX2IPedUNe2z0s7tDd84ExOZ2y99zdQL/TkwHiqaQjaoxZKq W20rH4cq+No/YwgHNmod9aanASSraeoVxVeTqucgRTqxu6s+7Y0V3kWI700G93rMFn50 1FaMmnT5SQi3R8cThJtGm8x+adVYh7nJ/aUIQd19880PAe/1Qw6Q5fSR6uSEl//c5cxD 4WjQOYAvNJ4rNMY6qFuqP9Jq+1tMTrvQ0tTzNcgh1UpmziYZjcGdPoI8Sd/4kv/2vlLf /+Ng== 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=gYOpp5DfDsEuhzy/2nQog/TDIuKvpxZ3kbRTztGAmN0=; b=GsU1per3t+D9SLcu1t9BMV9GV0SusXXHKlBqdTzH3zxZit1od7sm15nRUyYp54UvRu cXjT/CqPq9hniTzadUy/Iq6s2KE9OVQWcB6CjdFCZHiyuISAMMCBTI/C76dVzy1UtfdU qcdOUxeMiYCMTE6ekUkli/UGIKL8t15DLTAzwoH5QRlu3gZrg23z+8qI7WXTTDWDArKF SsKijrX/z271T1S1eZ4hTXr7kAjBC9oQUtuaD6upyo+xhFtiyUkUPd6cu/9YHsG7sKBI qPyKfKvi6RYBO+gtpe6tNu485i1oUW8Spujx5ZQF7IC9+56nV14k6SQBUvMUGS61PcpH koNQ== X-Gm-Message-State: APjAAAUKMvuxC493q5Mg8gQ2YzFhlArwGUILorqRmEvE7d0HNf5eWWHz xqZ2bI63CWS8rsFUKeBp7itf3E4K X-Google-Smtp-Source: APXvYqxgfgI/pwx2wksXpJJhf20FnXT7INJRx25Axzr6+q1AFLsL08tHpUXPJ0iLIUoVvRX3dTY9XQ== X-Received: by 2002:adf:ce90:: with SMTP id r16mr12430916wrn.64.1552084467891; Fri, 08 Mar 2019 14:34:27 -0800 (PST) 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, 8 Mar 2019 23:34:12 +0100 Message-Id: <5461b514dbf3e0bc31b0abb6498a9b3a008c271e.1552083282.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v6 01/14] 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: Michael Roth , Gerd Hoffmann , Markus Armbruster Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Reviewed-by: Markus Armbruster --- Notes: Changes from v5: =20 * documentation fixes * renamed buffer-len to buffer-length and period-len to period-length =20 Changes from v4: =20 * documentation fixes * renamed pa's source/sink to pa-in/pa-out * per-direction options changed per Markus Armbruster's comments =20 Changes from v2: =20 * update copyright, version numbers * remove #optional * per-direction options are now optional (needed for qobject_object_vis= itor_new_str) * removed unnecessary AudiodevNoOptions * changed integers to unsigned qapi/audio.json | 304 ++++++++++++++++++++++++++++++++++++++++++ qapi/qapi-schema.json | 1 + qapi/Makefile.objs | 6 +- 3 files changed, 308 insertions(+), 3 deletions(-) create mode 100644 qapi/audio.json diff --git a/qapi/audio.json b/qapi/audio.json new file mode 100644 index 0000000000..97aee37288 --- /dev/null +++ b/qapi/audio.json @@ -0,0 +1,304 @@ +# -*- mode: python -*- +# +# Copyright (C) 2015-2019 Zolt=C3=A1n K=C5=91v=C3=A1g=C3=B3 +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. + +## +# @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 true) +# +# @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-length: the buffer length in microseconds +# +# Since: 4.0 +## +{ 'struct': 'AudiodevPerDirectionOptions', + 'data': { + '*fixed-settings': 'bool', + '*frequency': 'uint32', + '*channels': 'uint32', + '*voices': 'uint32', + '*format': 'AudioFormat', + '*buffer-length': 'uint32' } } + +## +# @AudiodevGenericOptions: +# +# Generic driver-specific options. +# +# @in: options of the capture stream +# +# @out: options of the playback stream +# +# Since: 4.0 +## +{ 'struct': 'AudiodevGenericOptions', + 'data': { + '*in': 'AudiodevPerDirectionOptions', + '*out': 'AudiodevPerDirectionOptions' } } + +## +# @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') +# +# @period-length: the period length in microseconds +# +# @try-poll: attempt to use poll mode, falling back to non-polling +# access on failure (default true) +# +# Since: 4.0 +## +{ 'struct': 'AudiodevAlsaPerDirectionOptions', + 'base': 'AudiodevPerDirectionOptions', + 'data': { + '*dev': 'str', + '*period-length': 'uint32', + '*try-poll': 'bool' } } + +## +# @AudiodevAlsaOptions: +# +# Options of the ALSA audio backend. +# +# @in: options of the capture stream +# +# @out: options of the playback stream +# +# @threshold: set the threshold (in microseconds) when playback starts +# +# Since: 4.0 +## +{ 'struct': 'AudiodevAlsaOptions', + 'data': { + '*in': 'AudiodevAlsaPerDirectionOptions', + '*out': 'AudiodevAlsaPerDirectionOptions', + '*threshold': 'uint32' } } + +## +# @AudiodevCoreaudioPerDirectionOptions: +# +# Options of the Core Audio backend that are used for both playback and +# recording. +# +# @buffer-count: number of buffers +# +# Since: 4.0 +## +{ 'struct': 'AudiodevCoreaudioPerDirectionOptions', + 'base': 'AudiodevPerDirectionOptions', + 'data': { + '*buffer-count': 'uint32' } } + +## +# @AudiodevCoreaudioOptions: +# +# Options of the coreaudio audio backend. +# +# @in: options of the capture stream +# +# @out: options of the playback stream +# +# Since: 4.0 +## +{ 'struct': 'AudiodevCoreaudioOptions', + 'data': { + '*in': 'AudiodevCoreaudioPerDirectionOptions', + '*out': 'AudiodevCoreaudioPerDirectionOptions' } } + +## +# @AudiodevDsoundOptions: +# +# Options of the DirectSound audio backend. +# +# @in: options of the capture stream +# +# @out: options of the playback stream +# +# @latency: add extra latency to playback in microseconds +# (default 10000) +# +# Since: 4.0 +## +{ 'struct': 'AudiodevDsoundOptions', + 'data': { + '*in': 'AudiodevPerDirectionOptions', + '*out': 'AudiodevPerDirectionOptions', + '*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') +# +# @buffer-count: number of buffers +# +# @try-poll: attempt to use poll mode, falling back to non-polling +# access on failure (default true) +# +# Since: 4.0 +## +{ 'struct': 'AudiodevOssPerDirectionOptions', + 'base': 'AudiodevPerDirectionOptions', + 'data': { + '*dev': 'str', + '*buffer-count': 'uint32', + '*try-poll': 'bool' } } + +## +# @AudiodevOssOptions: +# +# Options of the OSS audio backend. +# +# @in: options of the capture stream +# +# @out: options of the playback stream +# +# @try-mmap: try using memory-mapped access, falling back to +# non-memory-mapped access on failure (default true) +# +# @exclusive: open device in exclusive mode (vmix won't work) +# (default false) +# +# @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': { + '*in': 'AudiodevOssPerDirectionOptions', + '*out': 'AudiodevOssPerDirectionOptions', + '*try-mmap': 'bool', + '*exclusive': 'bool', + '*dsp-policy': 'uint32' } } + +## +# @AudiodevPaPerDirectionOptions: +# +# Options of the Pulseaudio backend that are used for both playback and +# recording. +# +# @name: name of the sink/source to use +# +# Since: 4.0 +## +{ 'struct': 'AudiodevPaPerDirectionOptions', + 'base': 'AudiodevPerDirectionOptions', + 'data': { + '*name': 'str' } } + +## +# @AudiodevPaOptions: +# +# Options of the PulseAudio audio backend. +# +# @in: options of the capture stream +# +# @out: options of the playback stream +# +# @server: PulseAudio server address (default: let PulseAudio choose) +# +# Since: 4.0 +## +{ 'struct': 'AudiodevPaOptions', + 'data': { + '*in': 'AudiodevPaPerDirectionOptions', + '*out': 'AudiodevPaPerDirectionOptions', + '*server': 'str' } } + +## +# @AudiodevWavOptions: +# +# Options of the wav audio backend. +# +# @in: options of the capture stream +# +# @out: options of the playback stream +# +# @path: name of the wav file to record (default 'qemu.wav') +# +# Since: 4.0 +## +{ 'struct': 'AudiodevWavOptions', + 'data': { + '*in': 'AudiodevPerDirectionOptions', + '*out': 'AudiodevPerDirectionOptions', + '*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' ] } + +## +# @Audiodev: +# +# Options of an audio backend. +# +# @id: identifier of the backend +# +# @driver: the backend driver to use +# +# @timer-period: timer period (in microseconds, 0: use lowest possible) +# +# Since: 4.0 +## +{ 'union': 'Audiodev', + 'base': { + 'id': 'str', + 'driver': 'AudiodevDriver', + '*timer-period': 'uint32' }, + 'discriminator': 'driver', + 'data': { + 'none': 'AudiodevGenericOptions', + 'alsa': 'AudiodevAlsaOptions', + 'coreaudio': 'AudiodevCoreaudioOptions', + 'dsound': 'AudiodevDsoundOptions', + 'oss': 'AudiodevOssOptions', + 'pa': 'AudiodevPaOptions', + 'sdl': 'AudiodevGenericOptions', + 'spice': 'AudiodevGenericOptions', + 'wav': 'AudiodevWavOptions' } } diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index a34899c626..4bd1223637 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -99,3 +99,4 @@ { 'include': 'introspect.json' } { 'include': 'misc.json' } { 'include': 'target.json' } +{ 'include': 'audio.json' } diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs index 77acca0209..729e5185c5 100644 --- a/qapi/Makefile.objs +++ b/qapi/Makefile.objs @@ -5,9 +5,9 @@ util-obj-y +=3D opts-visitor.o qapi-clone-visitor.o util-obj-y +=3D qmp-event.o util-obj-y +=3D qapi-util.o =20 -QAPI_COMMON_MODULES =3D authz block-core block char common crypto introspe= ct -QAPI_COMMON_MODULES +=3D job migration misc net rdma rocker run-state -QAPI_COMMON_MODULES +=3D sockets tpm trace transaction ui +QAPI_COMMON_MODULES =3D audio authz block-core block char common crypto +QAPI_COMMON_MODULES +=3D introspect job migration misc net rdma rocker +QAPI_COMMON_MODULES +=3D run-state sockets tpm trace transaction ui QAPI_TARGET_MODULES =3D target QAPI_MODULES =3D $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES) =20 --=20 2.20.1 From nobody Mon May 6 19:52:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552084787179394.56259998225016; Fri, 8 Mar 2019 14:39:47 -0800 (PST) Received: from localhost ([127.0.0.1]:50816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O9X-00036m-Sa for importer@patchew.org; Fri, 08 Mar 2019 17:39:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O4Y-0007cp-L5 for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2O4V-0002aT-Ig for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:34 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:39365) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2O4V-0002Zz-6h; Fri, 08 Mar 2019 17:34:31 -0500 Received: by mail-wm1-x342.google.com with SMTP id z84so13683406wmg.4; Fri, 08 Mar 2019 14:34:31 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6af5-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6af5::5]) by smtp.gmail.com with ESMTPSA id v2sm15269144wme.29.2019.03.08.14.34.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:34:28 -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=Hvlphl/zwUzHITek935+1OYpx2LA56IB8mO/sERYlgk=; b=t5cUPTmBk82ez5plv6LXATVZt9eQzRObf6qiThTz/CgZ/6hrPcrF+YgE+GOiCawOfA FrQ3zBRRKJRSTnGinJX0+DQuHW8fuRwtrfW9FCkoZvLK1lQRxB7hODxK4mx1wmMsBPho mteUoxHlUwYfWcFCskHFrfAeQATCq8MDRqtpyJBsaH27nn6jFItETj7JOE5QomtYpXW7 WAET3+L5nja4znf33ritQoyfQnyshJ9SMCb1ODMEHn2/T5yf+pZXlHty27bkqOfM4NP3 GYuyx4rXPCO00J2Oq1wzkbyy0r5xrzOtsGgh+amHjt/gsFvu025GlAdE3ph/KEi9OcH4 WMTQ== 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=Hvlphl/zwUzHITek935+1OYpx2LA56IB8mO/sERYlgk=; b=N6sW1UQ0XCpQkmD4PbAKOqpVgxgcwcTBhTN/EUBzs1u7p3jdJnEeBK05aelJAfeK55 iEd3X9l7mIJ+RRxdGwG996wPFNb+jb1G5+ezgFy7NddLjrJnojICAqCeJ4DRhV4G8zU3 VrM5WKmcUjS+zOA0we4hgycEdZclzeB7qzqm57QgyDqrogLC0RvHUJNDcb0HiilPN6Cu PO2kLYmrE+zxLrQDW2CeD//J0qb9sDIyUAyajZOGhrY7mUh41/AIWFBhWSH9MJXfp7dC QH2jTwiGOMvI9b4fG3HEIcBGOxJaVSMb6omx1yV5mSdu+A1sktmguU55bDpLmMrNZk4I CplQ== X-Gm-Message-State: APjAAAVmDzzFGcVugHJFUqkSZvmP5vQes3Kfbz4ZOScp2e8drM2m7bPu hoGb++6wEoCRI7kiRpIaSqKLY2DhwgM= X-Google-Smtp-Source: APXvYqz5VXQV0UwUGYMCCyGvNn/uJwChhMipdV1k7p1NoY/vRicMXEov3MiHJmnRQACOYjF2knSzYw== X-Received: by 2002:a1c:dc85:: with SMTP id t127mr10085317wmg.136.1552084469377; Fri, 08 Mar 2019 14:34:29 -0800 (PST) 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, 8 Mar 2019 23:34:13 +0100 Message-Id: <01251b2758a1679c66842120b77c0fb46d7d0eaf.1552083282.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH v6 02/14] audio: use qapi AudioFormat instead of audfmt_e 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: Peter Maydell , Thomas Huth , Alistair Francis , Michael Walle , "open list:ARM" , Gerd Hoffmann , "Edgar E. Iglesias" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) I 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. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Reviewed-by: Thomas Huth --- 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(-) diff --git a/audio/audio.h b/audio/audio.h index f4339a185e..02f29a3b3e 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -26,18 +26,10 @@ #define QEMU_AUDIO_H =20 #include "qemu/queue.h" +#include "qapi/qapi-types-audio.h" =20 typedef void (*audio_callback_fn) (void *opaque, int avail); =20 -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; }; =20 diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 635be73bf4..5bd034267f 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -87,7 +87,7 @@ struct alsa_params_req { =20 struct alsa_params_obt { int freq; - audfmt_e fmt; + AudioFormat fmt; int endianness; int nchannels; snd_pcm_uframes_t samples; @@ -294,16 +294,16 @@ static int alsa_write (SWVoiceOut *sw, void *buf, int= len) return audio_pcm_sw_write (sw, buf, len); } =20 -static snd_pcm_format_t aud_to_alsafmt (audfmt_e fmt, int endianness) +static snd_pcm_format_t aud_to_alsafmt (AudioFormat fmt, int endianness) { switch (fmt) { - case AUD_FMT_S8: + case AUDIO_FORMAT_S8: return SND_PCM_FORMAT_S8; =20 - case AUD_FMT_U8: + case AUDIO_FORMAT_U8: return SND_PCM_FORMAT_U8; =20 - case AUD_FMT_S16: + case AUDIO_FORMAT_S16: if (endianness) { return SND_PCM_FORMAT_S16_BE; } @@ -311,7 +311,7 @@ static snd_pcm_format_t aud_to_alsafmt (audfmt_e fmt, i= nt endianness) return SND_PCM_FORMAT_S16_LE; } =20 - case AUD_FMT_U16: + case AUDIO_FORMAT_U16: if (endianness) { return SND_PCM_FORMAT_U16_BE; } @@ -319,7 +319,7 @@ static snd_pcm_format_t aud_to_alsafmt (audfmt_e fmt, i= nt endianness) return SND_PCM_FORMAT_U16_LE; } =20 - case AUD_FMT_S32: + case AUDIO_FORMAT_S32: if (endianness) { return SND_PCM_FORMAT_S32_BE; } @@ -327,7 +327,7 @@ static snd_pcm_format_t aud_to_alsafmt (audfmt_e fmt, i= nt endianness) return SND_PCM_FORMAT_S32_LE; } =20 - case AUD_FMT_U32: + case AUDIO_FORMAT_U32: if (endianness) { return SND_PCM_FORMAT_U32_BE; } @@ -344,58 +344,58 @@ static snd_pcm_format_t aud_to_alsafmt (audfmt_e fmt,= int endianness) } } =20 -static int alsa_to_audfmt (snd_pcm_format_t alsafmt, audfmt_e *fmt, +static int alsa_to_audfmt (snd_pcm_format_t alsafmt, AudioFormat *fmt, int *endianness) { switch (alsafmt) { case SND_PCM_FORMAT_S8: *endianness =3D 0; - *fmt =3D AUD_FMT_S8; + *fmt =3D AUDIO_FORMAT_S8; break; =20 case SND_PCM_FORMAT_U8: *endianness =3D 0; - *fmt =3D AUD_FMT_U8; + *fmt =3D AUDIO_FORMAT_U8; break; =20 case SND_PCM_FORMAT_S16_LE: *endianness =3D 0; - *fmt =3D AUD_FMT_S16; + *fmt =3D AUDIO_FORMAT_S16; break; =20 case SND_PCM_FORMAT_U16_LE: *endianness =3D 0; - *fmt =3D AUD_FMT_U16; + *fmt =3D AUDIO_FORMAT_U16; break; =20 case SND_PCM_FORMAT_S16_BE: *endianness =3D 1; - *fmt =3D AUD_FMT_S16; + *fmt =3D AUDIO_FORMAT_S16; break; =20 case SND_PCM_FORMAT_U16_BE: *endianness =3D 1; - *fmt =3D AUD_FMT_U16; + *fmt =3D AUDIO_FORMAT_U16; break; =20 case SND_PCM_FORMAT_S32_LE: *endianness =3D 0; - *fmt =3D AUD_FMT_S32; + *fmt =3D AUDIO_FORMAT_S32; break; =20 case SND_PCM_FORMAT_U32_LE: *endianness =3D 0; - *fmt =3D AUD_FMT_U32; + *fmt =3D AUDIO_FORMAT_U32; break; =20 case SND_PCM_FORMAT_S32_BE: *endianness =3D 1; - *fmt =3D AUD_FMT_S32; + *fmt =3D AUDIO_FORMAT_S32; break; =20 case SND_PCM_FORMAT_U32_BE: *endianness =3D 1; - *fmt =3D AUD_FMT_U32; + *fmt =3D AUDIO_FORMAT_U32; break; =20 default: @@ -638,19 +638,22 @@ static int alsa_open (int in, struct alsa_params_req = *req, bytes_per_sec =3D freq << (nchannels =3D=3D 2); =20 switch (obt->fmt) { - case AUD_FMT_S8: - case AUD_FMT_U8: + case AUDIO_FORMAT_S8: + case AUDIO_FORMAT_U8: break; =20 - case AUD_FMT_S16: - case AUD_FMT_U16: + case AUDIO_FORMAT_S16: + case AUDIO_FORMAT_U16: bytes_per_sec <<=3D 1; break; =20 - case AUD_FMT_S32: - case AUD_FMT_U32: + case AUDIO_FORMAT_S32: + case AUDIO_FORMAT_U32: bytes_per_sec <<=3D 2; break; + + default: + abort(); } =20 threshold =3D (conf->threshold * bytes_per_sec) / 1000; diff --git a/audio/audio.c b/audio/audio.c index 909c817103..77216e5010 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -113,7 +113,7 @@ static struct { .settings =3D { .freq =3D 44100, .nchannels =3D 2, - .fmt =3D AUD_FMT_S16, + .fmt =3D AUDIO_FORMAT_S16, .endianness =3D AUDIO_HOST_ENDIANNESS, } }, @@ -125,7 +125,7 @@ static struct { .settings =3D { .freq =3D 44100, .nchannels =3D 2, - .fmt =3D AUD_FMT_S16, + .fmt =3D AUDIO_FORMAT_S16, .endianness =3D AUDIO_HOST_ENDIANNESS, } }, @@ -257,58 +257,61 @@ static char *audio_alloc_prefix (const char *s) return r; } =20 -static const char *audio_audfmt_to_string (audfmt_e fmt) +static const char *audio_audfmt_to_string (AudioFormat fmt) { switch (fmt) { - case AUD_FMT_U8: + case AUDIO_FORMAT_U8: return "U8"; =20 - case AUD_FMT_U16: + case AUDIO_FORMAT_U16: return "U16"; =20 - case AUD_FMT_S8: + case AUDIO_FORMAT_S8: return "S8"; =20 - case AUD_FMT_S16: + case AUDIO_FORMAT_S16: return "S16"; =20 - case AUD_FMT_U32: + case AUDIO_FORMAT_U32: return "U32"; =20 - case AUD_FMT_S32: + case AUDIO_FORMAT_S32: return "S32"; + + default: + abort(); } =20 dolog ("Bogus audfmt %d returning S16\n", fmt); return "S16"; } =20 -static audfmt_e audio_string_to_audfmt (const char *s, audfmt_e defval, +static AudioFormat audio_string_to_audfmt (const char *s, AudioFormat defv= al, int *defaultp) { if (!strcasecmp (s, "u8")) { *defaultp =3D 0; - return AUD_FMT_U8; + return AUDIO_FORMAT_U8; } else if (!strcasecmp (s, "u16")) { *defaultp =3D 0; - return AUD_FMT_U16; + return AUDIO_FORMAT_U16; } else if (!strcasecmp (s, "u32")) { *defaultp =3D 0; - return AUD_FMT_U32; + return AUDIO_FORMAT_U32; } else if (!strcasecmp (s, "s8")) { *defaultp =3D 0; - return AUD_FMT_S8; + return AUDIO_FORMAT_S8; } else if (!strcasecmp (s, "s16")) { *defaultp =3D 0; - return AUD_FMT_S16; + return AUDIO_FORMAT_S16; } else if (!strcasecmp (s, "s32")) { *defaultp =3D 0; - return AUD_FMT_S32; + return AUDIO_FORMAT_S32; } else { dolog ("Bogus audio format `%s' using %s\n", @@ -318,8 +321,8 @@ static audfmt_e audio_string_to_audfmt (const char *s, = audfmt_e defval, } } =20 -static audfmt_e audio_get_conf_fmt (const char *envname, - audfmt_e defval, +static AudioFormat audio_get_conf_fmt (const char *envname, + AudioFormat defval, int *defaultp) { const char *var =3D getenv (envname); @@ -421,7 +424,7 @@ static void audio_print_options (const char *prefix, =20 case AUD_OPT_FMT: { - audfmt_e *fmtp =3D opt->valp; + AudioFormat *fmtp =3D opt->valp; printf ( "format, %s =3D %s, (one of: U8 S8 U16 S16 U32 S32)\n", state, @@ -492,7 +495,7 @@ static void audio_process_options (const char *prefix, =20 case AUD_OPT_FMT: { - audfmt_e *fmtp =3D opt->valp; + AudioFormat *fmtp =3D opt->valp; *fmtp =3D audio_get_conf_fmt (optname, *fmtp, &def); } break; @@ -524,22 +527,22 @@ static void audio_print_settings (struct audsettings = *as) dolog ("frequency=3D%d nchannels=3D%d fmt=3D", as->freq, as->nchannels= ); =20 switch (as->fmt) { - case AUD_FMT_S8: + case AUDIO_FORMAT_S8: AUD_log (NULL, "S8"); break; - case AUD_FMT_U8: + case AUDIO_FORMAT_U8: AUD_log (NULL, "U8"); break; - case AUD_FMT_S16: + case AUDIO_FORMAT_S16: AUD_log (NULL, "S16"); break; - case AUD_FMT_U16: + case AUDIO_FORMAT_U16: AUD_log (NULL, "U16"); break; - case AUD_FMT_S32: + case AUDIO_FORMAT_S32: AUD_log (NULL, "S32"); break; - case AUD_FMT_U32: + case AUDIO_FORMAT_U32: AUD_log (NULL, "U32"); break; default: @@ -570,12 +573,12 @@ static int audio_validate_settings (struct audsetting= s *as) invalid |=3D as->endianness !=3D 0 && as->endianness !=3D 1; =20 switch (as->fmt) { - case AUD_FMT_S8: - case AUD_FMT_U8: - case AUD_FMT_S16: - case AUD_FMT_U16: - case AUD_FMT_S32: - case AUD_FMT_U32: + case AUDIO_FORMAT_S8: + case AUDIO_FORMAT_U8: + case AUDIO_FORMAT_S16: + case AUDIO_FORMAT_U16: + case AUDIO_FORMAT_S32: + case AUDIO_FORMAT_U32: break; default: invalid =3D 1; @@ -591,25 +594,28 @@ static int audio_pcm_info_eq (struct audio_pcm_info *= info, struct audsettings *a int bits =3D 8, sign =3D 0; =20 switch (as->fmt) { - case AUD_FMT_S8: + case AUDIO_FORMAT_S8: sign =3D 1; /* fall through */ - case AUD_FMT_U8: + case AUDIO_FORMAT_U8: break; =20 - case AUD_FMT_S16: + case AUDIO_FORMAT_S16: sign =3D 1; /* fall through */ - case AUD_FMT_U16: + case AUDIO_FORMAT_U16: bits =3D 16; break; =20 - case AUD_FMT_S32: + case AUDIO_FORMAT_S32: sign =3D 1; /* fall through */ - case AUD_FMT_U32: + case AUDIO_FORMAT_U32: bits =3D 32; break; + + default: + abort(); } return info->freq =3D=3D as->freq && info->nchannels =3D=3D as->nchannels @@ -623,24 +629,27 @@ void audio_pcm_init_info (struct audio_pcm_info *info= , struct audsettings *as) int bits =3D 8, sign =3D 0, shift =3D 0; =20 switch (as->fmt) { - case AUD_FMT_S8: + case AUDIO_FORMAT_S8: sign =3D 1; - case AUD_FMT_U8: + case AUDIO_FORMAT_U8: break; =20 - case AUD_FMT_S16: + case AUDIO_FORMAT_S16: sign =3D 1; - case AUD_FMT_U16: + case AUDIO_FORMAT_U16: bits =3D 16; shift =3D 1; break; =20 - case AUD_FMT_S32: + case AUDIO_FORMAT_S32: sign =3D 1; - case AUD_FMT_U32: + case AUDIO_FORMAT_U32: bits =3D 32; shift =3D 2; break; + + default: + abort(); } =20 info->freq =3D as->freq; diff --git a/audio/audio_win_int.c b/audio/audio_win_int.c index 6900008d0c..b938fd667b 100644 --- a/audio/audio_win_int.c +++ b/audio/audio_win_int.c @@ -24,20 +24,20 @@ int waveformat_from_audio_settings (WAVEFORMATEX *wfx, wfx->cbSize =3D 0; =20 switch (as->fmt) { - case AUD_FMT_S8: - case AUD_FMT_U8: + case AUDIO_FORMAT_S8: + case AUDIO_FORMAT_U8: wfx->wBitsPerSample =3D 8; break; =20 - case AUD_FMT_S16: - case AUD_FMT_U16: + case AUDIO_FORMAT_S16: + case AUDIO_FORMAT_U16: wfx->wBitsPerSample =3D 16; wfx->nAvgBytesPerSec <<=3D 1; wfx->nBlockAlign <<=3D 1; break; =20 - case AUD_FMT_S32: - case AUD_FMT_U32: + case AUDIO_FORMAT_S32: + case AUDIO_FORMAT_U32: wfx->wBitsPerSample =3D 32; wfx->nAvgBytesPerSec <<=3D 2; wfx->nBlockAlign <<=3D 2; @@ -85,15 +85,15 @@ int waveformat_to_audio_settings (WAVEFORMATEX *wfx, =20 switch (wfx->wBitsPerSample) { case 8: - as->fmt =3D AUD_FMT_U8; + as->fmt =3D AUDIO_FORMAT_U8; break; =20 case 16: - as->fmt =3D AUD_FMT_S16; + as->fmt =3D AUDIO_FORMAT_S16; break; =20 case 32: - as->fmt =3D AUD_FMT_S32; + as->fmt =3D AUDIO_FORMAT_S32; break; =20 default: diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 6c69622b4c..355e8fbda5 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -70,7 +70,7 @@ typedef struct OSSVoiceIn { =20 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); } =20 -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; =20 - case AUD_FMT_U8: + case AUDIO_FORMAT_U8: return AFMT_U8; =20 - 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; } =20 - 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 endiannes= s) } } =20 -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 =3D 0; - *fmt =3D AUD_FMT_S8; + *fmt =3D AUDIO_FORMAT_S8; break; =20 case AFMT_U8: *endianness =3D 0; - *fmt =3D AUD_FMT_U8; + *fmt =3D AUDIO_FORMAT_U8; break; =20 case AFMT_S16_LE: *endianness =3D 0; - *fmt =3D AUD_FMT_S16; + *fmt =3D AUDIO_FORMAT_S16; break; =20 case AFMT_U16_LE: *endianness =3D 0; - *fmt =3D AUD_FMT_U16; + *fmt =3D AUDIO_FORMAT_U16; break; =20 case AFMT_S16_BE: *endianness =3D 1; - *fmt =3D AUD_FMT_S16; + *fmt =3D AUDIO_FORMAT_S16; break; =20 case AFMT_U16_BE: *endianness =3D 1; - *fmt =3D AUD_FMT_U16; + *fmt =3D AUDIO_FORMAT_U16; break; =20 default: @@ -500,7 +500,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, int endianness; int err; int fd; - audfmt_e effective_fmt; + AudioFormat effective_fmt; struct audsettings obt_as; OSSConf *conf =3D drv_opaque; =20 @@ -667,7 +667,7 @@ static int oss_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) int endianness; int err; int fd; - audfmt_e effective_fmt; + AudioFormat effective_fmt; struct audsettings obt_as; OSSConf *conf =3D drv_opaque; =20 diff --git a/audio/paaudio.c b/audio/paaudio.c index 6153b908da..8246f260a8 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -385,21 +385,21 @@ static int qpa_read (SWVoiceIn *sw, void *buf, int le= n) return audio_pcm_sw_read (sw, buf, len); } =20 -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; =20 switch (afmt) { - case AUD_FMT_S8: - case AUD_FMT_U8: + case AUDIO_FORMAT_S8: + case AUDIO_FORMAT_U8: format =3D PA_SAMPLE_U8; break; - case AUD_FMT_S16: - case AUD_FMT_U16: + case AUDIO_FORMAT_S16: + case AUDIO_FORMAT_U16: format =3D 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 =3D 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; } =20 -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 =3D 1; - return AUD_FMT_S16; + return AUDIO_FORMAT_S16; case PA_SAMPLE_S16LE: *endianness =3D 0; - return AUD_FMT_S16; + return AUDIO_FORMAT_S16; case PA_SAMPLE_S32BE: *endianness =3D 1; - return AUD_FMT_S32; + return AUDIO_FORMAT_S32; case PA_SAMPLE_S32LE: *endianness =3D 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; } } =20 diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index f7ee70b153..4cd4cbaf00 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -68,19 +68,19 @@ static void GCC_FMT_ATTR (1, 2) sdl_logerr (const char = *fmt, ...) AUD_log (AUDIO_CAP, "Reason: %s\n", SDL_GetError ()); } =20 -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; =20 - case AUD_FMT_U8: + case AUDIO_FORMAT_U8: return AUDIO_U8; =20 - case AUD_FMT_S16: + case AUDIO_FORMAT_S16: return AUDIO_S16LSB; =20 - case AUD_FMT_U16: + case AUDIO_FORMAT_U16: return AUDIO_U16LSB; =20 default: @@ -92,37 +92,37 @@ static int aud_to_sdlfmt (audfmt_e fmt) } } =20 -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 =3D 0; - *fmt =3D AUD_FMT_S8; + *fmt =3D AUDIO_FORMAT_S8; break; =20 case AUDIO_U8: *endianness =3D 0; - *fmt =3D AUD_FMT_U8; + *fmt =3D AUDIO_FORMAT_U8; break; =20 case AUDIO_S16LSB: *endianness =3D 0; - *fmt =3D AUD_FMT_S16; + *fmt =3D AUDIO_FORMAT_S16; break; =20 case AUDIO_U16LSB: *endianness =3D 0; - *fmt =3D AUD_FMT_U16; + *fmt =3D AUDIO_FORMAT_U16; break; =20 case AUDIO_S16MSB: *endianness =3D 1; - *fmt =3D AUD_FMT_S16; + *fmt =3D AUDIO_FORMAT_S16; break; =20 case AUDIO_U16MSB: *endianness =3D 1; - *fmt =3D AUD_FMT_U16; + *fmt =3D AUDIO_FORMAT_U16; break; =20 default: @@ -265,7 +265,7 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, SDL_AudioSpec req, obt; int endianness; int err; - audfmt_e effective_fmt; + AudioFormat effective_fmt; struct audsettings obt_as; =20 req.freq =3D as->freq; diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 6ad0eafbc6..3aeb0cb357 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -130,7 +130,7 @@ static int line_out_init(HWVoiceOut *hw, struct audsett= ings *as, settings.freq =3D SPICE_INTERFACE_PLAYBACK_FREQ; #endif settings.nchannels =3D SPICE_INTERFACE_PLAYBACK_CHAN; - settings.fmt =3D AUD_FMT_S16; + settings.fmt =3D AUDIO_FORMAT_S16; settings.endianness =3D AUDIO_HOST_ENDIANNESS; =20 audio_pcm_init_info (&hw->info, &settings); @@ -258,7 +258,7 @@ static int line_in_init(HWVoiceIn *hw, struct audsettin= gs *as, void *drv_opaque) settings.freq =3D SPICE_INTERFACE_RECORD_FREQ; #endif settings.nchannels =3D SPICE_INTERFACE_RECORD_CHAN; - settings.fmt =3D AUD_FMT_S16; + settings.fmt =3D AUDIO_FORMAT_S16; settings.endianness =3D AUDIO_HOST_ENDIANNESS; =20 audio_pcm_init_info (&hw->info, &settings); diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 40adfa30c3..35a614785e 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -117,20 +117,23 @@ static int wav_init_out(HWVoiceOut *hw, struct audset= tings *as, =20 stereo =3D wav_as.nchannels =3D=3D 2; switch (wav_as.fmt) { - case AUD_FMT_S8: - case AUD_FMT_U8: + case AUDIO_FORMAT_S8: + case AUDIO_FORMAT_U8: bits16 =3D 0; break; =20 - case AUD_FMT_S16: - case AUD_FMT_U16: + case AUDIO_FORMAT_S16: + case AUDIO_FORMAT_U16: bits16 =3D 1; break; =20 - 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(); } =20 hdr[34] =3D bits16 ? 0x10 : 0x08; @@ -225,7 +228,7 @@ static int wav_ctl_out (HWVoiceOut *hw, int cmd, ...) static WAVConf glob_conf =3D { .settings.freq =3D 44100, .settings.nchannels =3D 2, - .settings.fmt =3D AUD_FMT_S16, + .settings.fmt =3D AUDIO_FORMAT_S16, .wav_path =3D "qemu.wav" }; =20 diff --git a/audio/wavcapture.c b/audio/wavcapture.c index cd24570aa7..74320dfecc 100644 --- a/audio/wavcapture.c +++ b/audio/wavcapture.c @@ -136,7 +136,7 @@ int wav_start_capture (CaptureState *s, const char *pat= h, int freq, =20 as.freq =3D freq; as.nchannels =3D 1 << stereo; - as.fmt =3D bits16 ? AUD_FMT_S16 : AUD_FMT_U8; + as.fmt =3D bits16 ? AUDIO_FORMAT_S16 : AUDIO_FORMAT_U8; as.endianness =3D 0; =20 ops.notify =3D wav_notify; diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c index 94dffb2f57..446223906e 100644 --- a/hw/arm/omap2.c +++ b/hw/arm/omap2.c @@ -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 =3D AUD_FMT_U16; + fmt.fmt =3D AUDIO_FORMAT_U16; =20 s->codec.in_voice =3D AUD_open_in(&s->codec.card, s->codec.in_voice, "eac.codec.in", s, omap_eac_in_cb, &fmt); diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index d799533aa9..2265622d44 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -365,7 +365,7 @@ static void open_voice (AC97LinkState *s, int index, in= t freq) =20 as.freq =3D freq; as.nchannels =3D 2; - as.fmt =3D AUD_FMT_S16; + as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D 0; =20 if (freq > 0) { diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index 97b876c7e0..0957780a3d 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -269,7 +269,7 @@ static void adlib_realizefn (DeviceState *dev, Error **= errp) =20 as.freq =3D s->freq; as.nchannels =3D SHIFT; - as.fmt =3D AUD_FMT_S16; + as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D AUDIO_HOST_ENDIANNESS; =20 AUD_register_card ("adlib", &s->card); diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c index 9089dcb47e..62da75eefe 100644 --- a/hw/audio/cs4231a.c +++ b/hw/audio/cs4231a.c @@ -288,7 +288,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) =20 switch ((val >> 5) & ((s->dregs[MODE_And_ID] & MODE2) ? 7 : 3)) { case 0: - as.fmt =3D AUD_FMT_U8; + as.fmt =3D AUDIO_FORMAT_U8; s->shift =3D as.nchannels =3D=3D 2; break; =20 @@ -298,7 +298,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) case 3: s->tab =3D ALawDecompressTable; x_law: - as.fmt =3D AUD_FMT_S16; + as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D AUDIO_HOST_ENDIANNESS; s->shift =3D as.nchannels =3D=3D 2; break; @@ -307,7 +307,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) as.endianness =3D 1; /* fall through */ case 2: - as.fmt =3D AUD_FMT_S16; + as.fmt =3D AUDIO_FORMAT_S16; s->shift =3D as.nchannels; break; =20 diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 97789a0771..a5314d66fd 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -414,14 +414,14 @@ static void es1370_update_voices (ES1370State *s, uin= t32_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; =20 as.freq =3D new_freq; as.nchannels =3D 1 << (new_fmt & 1); - as.fmt =3D (new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8; + as.fmt =3D (new_fmt & 2) ? AUDIO_FORMAT_S16 : AUDIO_FORMAT= _U8; as.endianness =3D 0; =20 if (i =3D=3D ADC_CHANNEL) { diff --git a/hw/audio/gus.c b/hw/audio/gus.c index 8e0b27e0f2..b3e2a7fdd5 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -251,7 +251,7 @@ static void gus_realizefn (DeviceState *dev, Error **er= rp) =20 as.freq =3D s->freq; as.nchannels =3D 2; - as.fmt =3D AUD_FMT_S16; + as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D GUS_ENDIANNESS; =20 s->voice =3D AUD_open_out ( diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index 617a1c1016..c25bfa38b1 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -99,9 +99,9 @@ static void hda_codec_parse_fmt(uint32_t format, struct a= udsettings *as) } =20 switch (format & AC_FMT_BITS_MASK) { - case AC_FMT_BITS_8: as->fmt =3D AUD_FMT_S8; break; - case AC_FMT_BITS_16: as->fmt =3D AUD_FMT_S16; break; - case AC_FMT_BITS_32: as->fmt =3D AUD_FMT_S32; break; + case AC_FMT_BITS_8: as->fmt =3D AUDIO_FORMAT_S8; break; + case AC_FMT_BITS_16: as->fmt =3D AUDIO_FORMAT_S16; break; + case AC_FMT_BITS_32: as->fmt =3D AUDIO_FORMAT_S32; break; } =20 as->nchannels =3D ((format & AC_FMT_CHAN_MASK) >> AC_FMT_CHAN_SHIFT) += 1; @@ -134,12 +134,12 @@ static void hda_codec_parse_fmt(uint32_t format, stru= ct audsettings *as) /* -----------------------------------------------------------------------= --- */ =20 static const char *fmt2name[] =3D { - [ AUD_FMT_U8 ] =3D "PCM-U8", - [ AUD_FMT_S8 ] =3D "PCM-S8", - [ AUD_FMT_U16 ] =3D "PCM-U16", - [ AUD_FMT_S16 ] =3D "PCM-S16", - [ AUD_FMT_U32 ] =3D "PCM-U32", - [ AUD_FMT_S32 ] =3D "PCM-S32", + [ AUDIO_FORMAT_U8 ] =3D "PCM-U8", + [ AUDIO_FORMAT_S8 ] =3D "PCM-S8", + [ AUDIO_FORMAT_U16 ] =3D "PCM-U16", + [ AUDIO_FORMAT_S16 ] =3D "PCM-S16", + [ AUDIO_FORMAT_U32 ] =3D "PCM-U32", + [ AUDIO_FORMAT_S32 ] =3D "PCM-S32", }; =20 typedef struct HDAAudioState HDAAudioState; diff --git a/hw/audio/lm4549.c b/hw/audio/lm4549.c index a46f2301af..af8b22b541 100644 --- a/hw/audio/lm4549.c +++ b/hw/audio/lm4549.c @@ -185,7 +185,7 @@ void lm4549_write(lm4549_state *s, struct audsettings as; as.freq =3D value; as.nchannels =3D 2; - as.fmt =3D AUD_FMT_S16; + as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D 0; =20 s->voice =3D AUD_open_out( @@ -255,7 +255,7 @@ static int lm4549_post_load(void *opaque, int version_i= d) struct audsettings as; as.freq =3D freq; as.nchannels =3D 2; - as.fmt =3D AUD_FMT_S16; + as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D 0; =20 s->voice =3D 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 =3D 48000; as.nchannels =3D 2; - as.fmt =3D AUD_FMT_S16; + as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D 0; =20 s->voice =3D AUD_open_out( diff --git a/hw/audio/milkymist-ac97.c b/hw/audio/milkymist-ac97.c index bc8db71ae0..90cce1e6ed 100644 --- a/hw/audio/milkymist-ac97.c +++ b/hw/audio/milkymist-ac97.c @@ -308,7 +308,7 @@ static void milkymist_ac97_realize(DeviceState *dev, Er= ror **errp) =20 as.freq =3D 48000; as.nchannels =3D 2; - as.fmt =3D AUD_FMT_S16; + as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D 1; =20 s->voice_in =3D AUD_open_in(&s->card, s->voice_in, diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index b80a62ce90..fdbb4b6e99 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -162,7 +162,7 @@ static void pcspk_initfn(Object *obj) =20 static void pcspk_realizefn(DeviceState *dev, Error **errp) { - struct audsettings as =3D {PCSPK_SAMPLE_RATE, 1, AUD_FMT_U8, 0}; + struct audsettings as =3D {PCSPK_SAMPLE_RATE, 1, AUDIO_FORMAT_U8, 0}; ISADevice *isadev =3D ISA_DEVICE(dev); PCSpkState *s =3D PC_SPEAKER(dev); =20 diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index c5b9bf79e8..65ea0cd938 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -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) =20 static void dma_cmd8 (SB16State *s, int mask, int dma_len) { - s->fmt =3D AUD_FMT_U8; + s->fmt =3D AUDIO_FORMAT_U8; s->use_hdma =3D 0; s->fmt_bits =3D 8; s->fmt_signed =3D 0; @@ -319,18 +319,18 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8= _t d0, int dma_len) =20 if (16 =3D=3D s->fmt_bits) { if (s->fmt_signed) { - s->fmt =3D AUD_FMT_S16; + s->fmt =3D AUDIO_FORMAT_S16; } else { - s->fmt =3D AUD_FMT_U16; + s->fmt =3D AUDIO_FORMAT_U16; } } else { if (s->fmt_signed) { - s->fmt =3D AUD_FMT_S8; + s->fmt =3D AUDIO_FORMAT_S8; } else { - s->fmt =3D AUD_FMT_U8; + s->fmt =3D AUDIO_FORMAT_U8; } } =20 @@ -852,7 +852,7 @@ static void legacy_reset (SB16State *s) =20 as.freq =3D s->freq; as.nchannels =3D 1; - as.fmt =3D AUD_FMT_U8; + as.fmt =3D AUDIO_FORMAT_U8; as.endianness =3D 0; =20 s->voice =3D AUD_open_out ( diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c index 169b006ade..ca0ad73caf 100644 --- a/hw/audio/wm8750.c +++ b/hw/audio/wm8750.c @@ -201,7 +201,7 @@ static void wm8750_set_format(WM8750State *s) in_fmt.endianness =3D 0; in_fmt.nchannels =3D 2; in_fmt.freq =3D s->adc_hz; - in_fmt.fmt =3D AUD_FMT_S16; + in_fmt.fmt =3D AUDIO_FORMAT_S16; =20 s->adc_voice[0] =3D 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 =3D 0; out_fmt.nchannels =3D 2; out_fmt.freq =3D s->dac_hz; - out_fmt.fmt =3D AUD_FMT_S16; + out_fmt.fmt =3D AUDIO_FORMAT_S16; =20 s->dac_voice[0] =3D 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 >=3D sizeof(s->data_in)) { wm8750_in_load(s); if (s->idx_in >=3D sizeof(s->data_in)) { - return 0x80008000; /* silence in AUD_FMT_S16 sample format */ + return 0x80008000; /* silence in AUDIO_FORMAT_S16 sample forma= t */ } } =20 diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c index cc0f9bc9cc..11b09bd18c 100644 --- a/hw/display/xlnx_dp.c +++ b/hw/display/xlnx_dp.c @@ -1260,7 +1260,7 @@ static void xlnx_dp_realize(DeviceState *dev, Error *= *errp) =20 as.freq =3D 44100; as.nchannels =3D 2; - as.fmt =3D AUD_FMT_S16; + as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D 0; =20 AUD_register_card("xlnx_dp.audio", &s->aud_card); diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c index 2eb3cb9518..41731619bb 100644 --- a/hw/input/tsc210x.c +++ b/hw/input/tsc210x.c @@ -318,7 +318,7 @@ static void tsc2102_audio_output_update(TSC210xState *s) fmt.endianness =3D 0; fmt.nchannels =3D 2; fmt.freq =3D s->codec.tx_rate; - fmt.fmt =3D AUD_FMT_S16; + fmt.fmt =3D AUDIO_FORMAT_S16; =20 s->dac_voice[0] =3D AUD_open_out(&s->card, s->dac_voice[0], "tsc2102.sink", s, (void *) tsc210x_audio_out_cb, &fmt= ); diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c index 28ac7c5165..c46d5eeb79 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -650,7 +650,7 @@ static void usb_audio_realize(USBDevice *dev, Error **e= rrp) s->out.vol[1] =3D 240; /* 0 dB */ s->out.as.freq =3D USBAUDIO_SAMPLE_RATE; s->out.as.nchannels =3D 2; - s->out.as.fmt =3D AUD_FMT_S16; + s->out.as.fmt =3D AUDIO_FORMAT_S16; s->out.as.endianness =3D 0; streambuf_init(&s->out.buf, s->buffer); =20 diff --git a/ui/vnc.c b/ui/vnc.c index da4a21d4ce..b724e998ba 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -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 =3D 1; break; - case AUD_FMT_U16: - case AUD_FMT_S16: + case AUDIO_FORMAT_U16: + case AUDIO_FORMAT_S16: bps =3D 2; break; - case AUD_FMT_U32: - case AUD_FMT_S32: + case AUDIO_FORMAT_U32: + case AUDIO_FORMAT_S32: bps =3D 4; break; } @@ -2369,12 +2369,12 @@ static int protocol_client_msg(VncState *vs, uint8_= t *data, size_t len) if (len =3D=3D 4) return 10; switch (read_u8(data, 4)) { - case 0: vs->as.fmt =3D AUD_FMT_U8; break; - case 1: vs->as.fmt =3D AUD_FMT_S8; break; - case 2: vs->as.fmt =3D AUD_FMT_U16; break; - case 3: vs->as.fmt =3D AUD_FMT_S16; break; - case 4: vs->as.fmt =3D AUD_FMT_U32; break; - case 5: vs->as.fmt =3D AUD_FMT_S32; break; + case 0: vs->as.fmt =3D AUDIO_FORMAT_U8; break; + case 1: vs->as.fmt =3D AUDIO_FORMAT_S8; break; + case 2: vs->as.fmt =3D AUDIO_FORMAT_U16; break; + case 3: vs->as.fmt =3D AUDIO_FORMAT_S16; break; + case 4: vs->as.fmt =3D AUDIO_FORMAT_U32; break; + case 5: vs->as.fmt =3D AUDIO_FORMAT_S32; break; default: VNC_DEBUG("Invalid audio format %d\n", read_u8(data, 4= )); vnc_client_error(vs); @@ -3105,7 +3105,7 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSoc= ket *sioc, =20 vs->as.freq =3D 44100; vs->as.nchannels =3D 2; - vs->as.fmt =3D AUD_FMT_S16; + vs->as.fmt =3D AUDIO_FORMAT_S16; vs->as.endianness =3D 0; =20 qemu_mutex_init(&vs->output_mutex); --=20 2.20.1 From nobody Mon May 6 19:52:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552084492803595.8938075215732; Fri, 8 Mar 2019 14:34:52 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A5B330B9329; Fri, 8 Mar 2019 22:34:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 878E360143; Fri, 8 Mar 2019 22:34:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A356641F3D; Fri, 8 Mar 2019 22:34:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x28MYckP026126 for ; Fri, 8 Mar 2019 17:34:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4D72C60F86; Fri, 8 Mar 2019 22:34:38 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A23260BE7; Fri, 8 Mar 2019 22:34:34 +0000 (UTC) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 656CFC058CA8; Fri, 8 Mar 2019 22:34:32 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id c13so9858783wmb.0; Fri, 08 Mar 2019 14:34:32 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6af5-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6af5::5]) by smtp.gmail.com with ESMTPSA id v2sm15269144wme.29.2019.03.08.14.34.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:34:29 -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=nW2sQvZ4fj2xcBHMyMkjEcq6w4k16hS6AmY7GC+F2F0=; b=FVPs+Iyzyu4RVcFmO5Utl0YpkTwBeF/YpvuzwoPkTpKABNVdkTNZ+w5093vc/kMmnf xm2OT5up0VZQ5YhVN85tzN7ARQG6avXAAvhfSaWrBz7cgdQNNbb01NW2k7h5XHmoXdcE HI1xkKFwo9Xi7jFiVCRkRx9YNWF8AuBry6kROxM/PrdUe1bjUdU1ySxe6/mqHa+OOup2 lfkzLumNt88UAaMd5kZ2Zwnn1V5ZwI1vj5ldUIoatuQKFea4SPuP0s4S6X49Ipo71m5J BY+sQ7Az+qLhuL52Gw7ZINZNPNVi0K0JFpb7p58roUk7+hxHUfzqfd8pcyk37zqX7Bb6 udeg== 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=nW2sQvZ4fj2xcBHMyMkjEcq6w4k16hS6AmY7GC+F2F0=; b=P7mr+JKOPYZBCRb7t3EjRcg6FmDALrIOgrQJtsKc6zGMWoKHl/PJhoaQWVk1p6lQzq eqALoUziuYuDaafk+5m7WUinVg6POUaGbyiBHCDtmaYFu4HCvSm0L1Myqyz7alYxSpXp bp8X1Zjl6rzwL0V5SCeXHF3IO5UEb64PhM/6FtebLI2CqW60Z3ag9LZT7FrSjJi2Z8HV a669CICeDHmgyjj67QgVbxHPGbKB717+PfsspDsiZ0W4FWs1eMlNX2KVUFidcRdeHU+6 1nD7HVoGNfZoUfqErlAM/3/Zgd/NxwXT9NBik43BuTT1B0c8cbdaiQ226ionJallEfY3 UwhA== X-Gm-Message-State: APjAAAVFwIoWy57CqhEvYNKoCWXlVvqH2t+q7rJLr2EuqmRJFI2dcFJW YX+szgvboEvn7PZbBPLGjnV00m2R9cU= X-Google-Smtp-Source: APXvYqx35Npb8CYDoFRf7F+Uh7pHcHD9iS0I9yf2b6Dn754vox93oru9N+WjfHkqXSZro5E1koXNdg== X-Received: by 2002:a1c:a941:: with SMTP id s62mr10595528wme.16.1552084470829; Fri, 08 Mar 2019 14:34:30 -0800 (PST) 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, 8 Mar 2019 23:34:14 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 08 Mar 2019 22:34:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 08 Mar 2019 22:34:32 +0000 (UTC) for IP:'209.85.128.67' DOMAIN:'mail-wm1-f67.google.com' HELO:'mail-wm1-f67.google.com' FROM:'dirty.ice.hu@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.111 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.128.67 mail-wm1-f67.google.com 209.85.128.67 mail-wm1-f67.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: "reviewer:Incompatible changes" , Gerd Hoffmann Subject: [libvirt] [PATCH v6 03/14] audio: -audiodev command line option: documentation X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 08 Mar 2019 22:34:51 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) 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=3Dvalue,... Although now it's possible to specify multiple -audiodev options on command line, multiple audio backends are not supported yet. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- Notes: Changes from v4: =20 * deprecated QEMU_AUDIO_ env vars * updated to reflect qapi changes * added info to qemu-deprecated.texi qemu-deprecated.texi | 7 ++ qemu-options.hx | 236 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 240 insertions(+), 3 deletions(-) diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index 45c57952da..5c07ad4acb 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -60,6 +60,13 @@ Support for invalid topologies will be removed, the user= must ensure topologies described with -smp include all possible cpus, i.e. @math{@var{sockets} * @var{cores} * @var{threads} =3D @var{maxcpus}}. =20 +@subsection QEMU_AUDIO_ environment variables and -audio-help (since 4.0) + +The ``-audiodev'' argument is now the preferred way to specify audio +backend settings instead of environment variables. To ease migration to +the new format, the ``-audiodev-help'' option can be used to convert +the current values of the environment variables to ``-audiodev'' options. + @section QEMU Machine Protocol (QMP) commands =20 @subsection block-dirty-bitmap-add "autoload" parameter (since 2.12.0) diff --git a/qemu-options.hx b/qemu-options.hx index 1cf9aac1fe..52ea13e6a2 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -416,14 +416,244 @@ The default is @code{en-us}. ETEXI =20 =20 +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=3D]driver,id=3Did[,prop[=3Dvalue][,...]]\n" + " specifies the audio backend to use\n" + " id=3D identifier of the backend\n" + " timer-period=3D timer period in microseconds\n" + " in|out.fixed-settings=3D use fixed settings for host = audio\n" + " in|out.frequency=3D frequency to use with fixed setti= ngs\n" + " in|out.channels=3D number of channels to use with fix= ed settings\n" + " in|out.format=3D sample format to use with fixed sett= ings\n" + " valid values: s8, s16, s32, u8, u16, u32\n" + " in|out.voices=3D number of voices to use\n" + " in|out.buffer-len=3D length of buffer in microseconds= \n" + "-audiodev none,id=3Did,[,prop[=3Dvalue][,...]]\n" + " dummy driver that discards all output\n" +#ifdef CONFIG_AUDIO_ALSA + "-audiodev alsa,id=3Did[,prop[=3Dvalue][,...]]\n" + " in|out.dev=3D name of the audio device to use\n" + " in|out.period-len=3D length of period in microseconds= \n" + " in|out.try-poll=3D attempt to use poll mode\n" + " threshold=3D threshold (in microseconds) when playbac= k starts\n" +#endif +#ifdef CONFIG_AUDIO_COREAUDIO + "-audiodev coreaudio,id=3Did[,prop[=3Dvalue][,...]]\n" + " in|out.buffer-count=3D number of buffers\n" +#endif +#ifdef CONFIG_AUDIO_DSOUND + "-audiodev dsound,id=3Did[,prop[=3Dvalue][,...]]\n" + " latency=3D add extra latency to playback in microseco= nds\n" +#endif +#ifdef CONFIG_AUDIO_OSS + "-audiodev oss,id=3Did[,prop[=3Dvalue][,...]]\n" + " in|out.dev=3D path of the audio device to use\n" + " in|out.buffer-count=3D number of buffers\n" + " in|out.try-poll=3D attempt to use poll mode\n" + " try-mmap=3D try using memory mapped access\n" + " exclusive=3D open device in exclusive mode\n" + " dsp-policy=3D set timing policy (0..10), -1 to use fr= agment mode\n" +#endif +#ifdef CONFIG_AUDIO_PA + "-audiodev pa,id=3Did[,prop[=3Dvalue][,...]]\n" + " server=3D PulseAudio server address\n" + " in|out.name=3D source/sink device name\n" +#endif +#ifdef CONFIG_AUDIO_SDL + "-audiodev sdl,id=3Did[,prop[=3Dvalue][,...]]\n" +#endif +#ifdef CONFIG_SPICE + "-audiodev spice,id=3Did[,prop[=3Dvalue][,...]]\n" +#endif + "-audiodev wav,id=3Did[,prop[=3Dvalue][,...]]\n" + " path=3D path of wav file to record\n", + QEMU_ARCH_ALL) +STEXI +@item -audiodev [driver=3D]@var{driver},id=3D@var{id}[,@var{prop}[=3D@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=3Dexample,in.frequency=3D44110,out.frequency=3D8000 +-audiodev alsa,id=3Dexample,out.channels=3D1 # leaves in.channels unspecif= ied +@end example + +Valid global options are: + +@table @option +@item id=3D@var{identifier} +Identifies the audio backend. + +@item timer-period=3D@var{period} +Sets the timer @var{period} used by the audio subsystem in microseconds. +Default is 10000 (10 ms). + +@item in|out.fixed-settings=3Don|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=3D@var{frequency} +Specify the @var{frequency} to use when using @var{fixed-settings}. +Default is 44100Hz. + +@item in|out.channels=3D@var{channels} +Specify the number of @var{channels} to use when using +@var{fixed-settings}. Default is 2 (stereo). + +@item in|out.format=3D@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=3D@var{voices} +Specify the number of @var{voices} to use. Default is 1. + +@item in|out.buffer=3D@var{usecs} +Sets the size of the buffer in microseconds. + +@end table + +@item -audiodev none,id=3D@var{id}[,@var{prop}[=3D@var{value}][,...]] +Creates a dummy backend that discards all outputs. This backend has no +backend specific properties. + +@item -audiodev alsa,id=3D@var{id}[,@var{prop}[=3D@var{value}][,...]] +Creates backend using the ALSA. This backend is only available on +Linux. + +ALSA specific options are: + +@table @option + +@item in|out.dev=3D@var{device} +Specify the ALSA @var{device} to use for input and/or output. Default +is @code{default}. + +@item in|out.period-len=3D@var{usecs} +Sets the period length in microseconds. + +@item in|out.try-poll=3Don|off +Attempt to use poll mode with the device. Default is on. + +@item threshold=3D@var{threshold} +Threshold (in microseconds) when playback starts. Default is 0. + +@end table + +@item -audiodev coreaudio,id=3D@var{id}[,@var{prop}[=3D@var{value}][,...]] +Creates a backend using Apple's Core Audio. This backend is only +available on Mac OS and only supports playback. + +Core Audio specific options are: + +@table @option + +@item in|out.buffer-count=3D@var{count} +Sets the @var{count} of the buffers. + +@end table + +@item -audiodev dsound,id=3D@var{id}[,@var{prop}[=3D@var{value}][,...]] +Creates a backend using Microsoft's DirectSound. This backend is only +available on Windows and only supports playback. + +DirectSound specific options are: + +@table @option + +@item latency=3D@var{usecs} +Add extra @var{usecs} microseconds latency to playback. Default is +10000 (10 ms). + +@end table + +@item -audiodev oss,id=3D@var{id}[,@var{prop}[=3D@var{value}][,...]] +Creates a backend using OSS. This backend is available on most +Unix-like systems. + +OSS specific options are: + +@table @option + +@item in|out.dev=3D@var{device} +Specify the file name of the OSS @var{device} to use. Default is +@code{/dev/dsp}. + +@item in|out.buffer-count=3D@var{count} +Sets the @var{count} of the buffers. + +@item in|out.try-poll=3Don|of +Attempt to use poll mode with the device. Default is on. + +@item try-mmap=3Don|off +Try using memory mapped device access. Default is off. + +@item exclusive=3Don|off +Open the device in exclusive mode (vmix won't work in this case). +Default is off. + +@item dsp-policy=3D@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=3D@var{id}[,@var{prop}[=3D@var{value}][,...]] +Creates a backend using PulseAudio. This backend is available on most +systems. + +PulseAudio specific options are: + +@table @option + +@item server=3D@var{server} +Sets the PulseAudio @var{server} to connect to. + +@item in|out.name=3D@var{sink} +Use the specified source/sink for recording/playback. + +@end table + +@item -audiodev sdl,id=3D@var{id}[,@var{prop}[=3D@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=3D@var{id}[,@var{prop}[=3D@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=3D@var{id}[,@var{prop}[=3D@var{value}][,...]] +Creates a backend that writes audio to a WAV file. + +Backend specific options are: + +@table @option + +@item path=3D@var{path} +Write recorded audio into the specified file. Default is +@code{qemu.wav}. + +@end table ETEXI =20 DEF("soundhw", HAS_ARG, QEMU_OPTION_soundhw, --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 19:52:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155208496883179.7224632665592; Fri, 8 Mar 2019 14:42:48 -0800 (PST) Received: from localhost ([127.0.0.1]:50876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2OCN-0005mo-IN for importer@patchew.org; Fri, 08 Mar 2019 17:42:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O4d-0007hH-Qk for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2O4Y-0002c5-HX for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:39 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:33427) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2O4X-0002bg-V6 for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:34 -0500 Received: by mail-wr1-x441.google.com with SMTP id i12so22952059wrw.0 for ; Fri, 08 Mar 2019 14:34:33 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6af5-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6af5::5]) by smtp.gmail.com with ESMTPSA id v2sm15269144wme.29.2019.03.08.14.34.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:34:31 -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=llwPC71ujk+UI5rlnw4Gm9wpJDJEHVqnO+kRsfXgrsw=; b=LIs+Vm3Kb+EsBJhfgzcqLJbC7gWgYo2gdWp2k9WfLgh3q7cwhA0b8rxYzCxYhOsgrS WTytPF9MO7h18jbTEVwOHdfY6uXyhGRq2vIajDyLIgmT0NPobzc68QQvsJehgp5/mCkC 3V9h3oE5YBTi7ZNaS8aNVsiRmbn+swLe/PFz4PeQh/NcISfmDcQ6LcDxeH8YU6CfBpTA W8VSJqPMvNVabius3xuH0jnaka7IpkNQPfqgX2I635ZC2Fj494hrArxYK61Q3xAjSYlI dymMJOgDxI02D957RqrlMX/kNzRQbYwsPWUqPV8CXTGw1Pq6Gymn0qmO0rGxtcx4xZhZ Wjjw== 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=llwPC71ujk+UI5rlnw4Gm9wpJDJEHVqnO+kRsfXgrsw=; b=d0iEFRmQFDxdWhjb49irc4573Ry7kHcy0KTisvDXRftQV9R+m1AgnEvQmdHOhmPNTI CW/P5ZOQwlW0OzhvtlCSL+7xsnvPuyLXStDTo7wDyeGQ1WtR2j/oGt0qElIxoDRjda8o sFvcIffmW7qYac6kpqYqpOXSxnxJH0nbM1Z7V3lihq+0pcYvsLxDzHAelU0VtxXFemAK g01M3PvQLzbc8V3F7MefFtOWh3h3Eja6YZu/1p9dGqpQJrCeyWqSbi73MMYVwJobTIsr k29NPV+mHMt3cl+j8yRqeikBej3pf3toztkDrAgQNIz+86GYK20hi5yqhJR2oWDa/xvz /isw== X-Gm-Message-State: APjAAAVpKzshS4fAMC2qEVLdWqSTN2z7fdnOuUtNWPMLloVutAakyx3U XMT79T0JyjnO+vQqQBJb/mEMhu1b2FM= X-Google-Smtp-Source: APXvYqz6kTAk4CUqDkDuhEbqaZli6IYU2OyC7nA19udglOdG9K4qTIT0uw3tk1Fe9T4gu1z6IJXIjQ== X-Received: by 2002:a5d:690d:: with SMTP id t13mr12211748wru.135.1552084472001; Fri, 08 Mar 2019 14:34:32 -0800 (PST) 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, 8 Mar 2019 23:34:15 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH v6 04/14] audio: -audiodev command line option basic implementation 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: Paolo Bonzini , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Audio 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. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio.h | 18 +- audio/audio_int.h | 20 +- audio/audio_template.h | 42 ++- audio/alsaaudio.c | 2 +- audio/audio.c | 630 ++++++++++++++++++----------------------- audio/audio_legacy.c | 293 +++++++++++++++++++ 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, 650 insertions(+), 380 deletions(-) create mode 100644 audio/audio_legacy.c diff --git a/audio/audio.h b/audio/audio.h index 02f29a3b3e..64b0f761bc 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -36,12 +36,21 @@ typedef void (*audio_callback_fn) (void *opaque, int av= ail); #define AUDIO_HOST_ENDIANNESS 0 #endif =20 -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); =20 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); =20 -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); =20 +void audio_parse_option(const char *opt); +void audio_init_audiodevs(void); +void audio_legacy_help(void); + #endif /* QEMU_AUDIO_H */ diff --git a/audio/audio_int.h b/audio/audio_int.h index 6c451b995c..7bf5dfc0b5 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -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 { =20 typedef struct AudioState { struct audio_driver *drv; + Audiodev *dev; void *drv_opaque; =20 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; =20 extern const struct mixeng_volume nominal_volume; =20 +extern const char *audio_prio_list[]; + void audio_driver_register(audio_driver *drv); audio_driver *audio_driver_lookup(const char *name); =20 @@ -248,4 +252,18 @@ static inline int audio_ring_dist (int dst, int src, i= nt len) #define AUDIO_STRINGIFY_(n) #n #define AUDIO_STRINGIFY(n) AUDIO_STRINGIFY_(n) =20 +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); + +void audio_create_pdos(Audiodev *dev); +AudiodevPerDirectionOptions *audio_get_pdo_in(Audiodev *dev); +AudiodevPerDirectionOptions *audio_get_pdo_out(Audiodev *dev); + #endif /* QEMU_AUDIO_INT_H */ diff --git a/audio/audio_template.h b/audio/audio_template.h index 7de227d2d1..1232bb54db 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -299,11 +299,42 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct= audsettings *as) return NULL; } =20 +AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)(Audiodev *dev) +{ + switch (dev->driver) { + case AUDIODEV_DRIVER_NONE: + return dev->u.none.TYPE; + case AUDIODEV_DRIVER_ALSA: + return qapi_AudiodevAlsaPerDirectionOptions_base(dev->u.alsa.TYPE); + case AUDIODEV_DRIVER_COREAUDIO: + return qapi_AudiodevCoreaudioPerDirectionOptions_base( + dev->u.coreaudio.TYPE); + case AUDIODEV_DRIVER_DSOUND: + return dev->u.dsound.TYPE; + case AUDIODEV_DRIVER_OSS: + return qapi_AudiodevOssPerDirectionOptions_base(dev->u.oss.TYPE); + case AUDIODEV_DRIVER_PA: + return qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.TYPE); + case AUDIODEV_DRIVER_SDL: + return dev->u.sdl.TYPE; + case AUDIODEV_DRIVER_SPICE: + return dev->u.spice.TYPE; + case AUDIODEV_DRIVER_WAV: + return dev->u.wav.TYPE; + + case AUDIODEV_DRIVER__MAX: + break; + } + abort(); +} + static HW *glue (audio_pcm_hw_add_, TYPE) (struct audsettings *as) { HW *hw; + AudioState *s =3D &glob_audio_state; + AudiodevPerDirectionOptions *pdo =3D glue(audio_get_pdo_, TYPE)(s->dev= ); =20 - if (glue (conf.fixed_, TYPE).enabled && glue (conf.fixed_, TYPE).greed= y) { + if (pdo->fixed_settings) { hw =3D glue (audio_pcm_hw_add_new_, TYPE) (as); if (hw) { return hw; @@ -331,9 +362,11 @@ static SW *glue (audio_pcm_create_voice_pair_, TYPE) ( SW *sw; HW *hw; struct audsettings hw_as; + AudioState *s =3D &glob_audio_state; + AudiodevPerDirectionOptions *pdo =3D glue(audio_get_pdo_, TYPE)(s->dev= ); =20 - if (glue (conf.fixed_, TYPE).enabled) { - hw_as =3D glue (conf.fixed_, TYPE).settings; + if (pdo->fixed_settings) { + hw_as =3D audiodev_to_audsettings(pdo); } else { hw_as =3D *as; @@ -398,6 +431,7 @@ SW *glue (AUD_open_, TYPE) ( ) { AudioState *s =3D &glob_audio_state; + AudiodevPerDirectionOptions *pdo =3D glue(audio_get_pdo_, TYPE)(s->dev= ); =20 if (audio_bug(__func__, !card || !name || !callback_fn || !as)) { dolog ("card=3D%p name=3D%p callback_fn=3D%p as=3D%p\n", @@ -422,7 +456,7 @@ SW *glue (AUD_open_, TYPE) ( return sw; } =20 - if (!glue (conf.fixed_, TYPE).enabled && sw) { + if (!pdo->fixed_settings && sw) { glue (AUD_close_, TYPE) (card, sw); sw =3D NULL; } diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 5bd034267f..8302f3e882 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -1125,7 +1125,7 @@ static ALSAConf glob_conf =3D { .pcm_name_in =3D "default", }; =20 -static void *alsa_audio_init (void) +static void *alsa_audio_init(Audiodev *dev) { ALSAConf *conf =3D g_malloc(sizeof(ALSAConf)); *conf =3D glob_conf; diff --git a/audio/audio.c b/audio/audio.c index 77216e5010..79ed360666 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -26,6 +26,9 @@ #include "audio.h" #include "monitor/monitor.h" #include "qemu/timer.h" +#include "qapi/error.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi/qapi-visit-audio.h" #include "sysemu/sysemu.h" #include "qemu/cutils.h" #include "sysemu/replay.h" @@ -46,14 +49,16 @@ The 1st one is the one used by default, that is the reason that we generate the list. */ -static const char *audio_prio_list[] =3D { +const char *audio_prio_list[] =3D { "spice", CONFIG_AUDIO_DRIVERS "none", "wav", + NULL }; =20 static QLIST_HEAD(, audio_driver) audio_drivers; +static AudiodevListHead audiodevs =3D QSIMPLEQ_HEAD_INITIALIZER(audiodevs); =20 void audio_driver_register(audio_driver *drv) { @@ -80,61 +85,6 @@ audio_driver *audio_driver_lookup(const char *name) return NULL; } =20 -static void audio_module_load_all(void) -{ - int i; - - for (i =3D 0; i < ARRAY_SIZE(audio_prio_list); i++) { - audio_driver_lookup(audio_prio_list[i]); - } -} - -struct fixed_settings { - int enabled; - int nb_voices; - int greedy; - struct audsettings settings; -}; - -static struct { - struct fixed_settings fixed_out; - struct fixed_settings fixed_in; - union { - int hertz; - int64_t ticks; - } period; - int try_poll_in; - int try_poll_out; -} conf =3D { - .fixed_out =3D { /* DAC fixed settings */ - .enabled =3D 1, - .nb_voices =3D 1, - .greedy =3D 1, - .settings =3D { - .freq =3D 44100, - .nchannels =3D 2, - .fmt =3D AUDIO_FORMAT_S16, - .endianness =3D AUDIO_HOST_ENDIANNESS, - } - }, - - .fixed_in =3D { /* ADC fixed settings */ - .enabled =3D 1, - .nb_voices =3D 1, - .greedy =3D 1, - .settings =3D { - .freq =3D 44100, - .nchannels =3D 2, - .fmt =3D AUDIO_FORMAT_S16, - .endianness =3D AUDIO_HOST_ENDIANNESS, - } - }, - - .period =3D { .hertz =3D 100 }, - .try_poll_in =3D 1, - .try_poll_out =3D 1, -}; - static AudioState glob_audio_state; =20 const struct mixeng_volume nominal_volume =3D { @@ -151,9 +101,6 @@ const struct mixeng_volume nominal_volume =3D { #ifdef AUDIO_IS_FLAWLESS_AND_NO_CHECKS_ARE_REQURIED #error No its not #else -static void audio_print_options (const char *prefix, - struct audio_option *opt); - int audio_bug (const char *funcname, int cond) { if (cond) { @@ -161,16 +108,9 @@ int audio_bug (const char *funcname, int cond) =20 AUD_log (NULL, "A bug was just triggered in %s\n", funcname); if (!shown) { - struct audio_driver *d; - shown =3D 1; AUD_log (NULL, "Save all your work and restart without audio\n= "); - AUD_log (NULL, "Please send bug report to av1474@comtv.ru\n"); AUD_log (NULL, "I am sorry\n"); - d =3D glob_audio_state.drv; - if (d) { - audio_print_options (d->name, d->options); - } } AUD_log (NULL, "Context:\n"); =20 @@ -232,31 +172,6 @@ void *audio_calloc (const char *funcname, int nmemb, s= ize_t size) return g_malloc0 (len); } =20 -static char *audio_alloc_prefix (const char *s) -{ - const char qemu_prefix[] =3D "QEMU_"; - size_t len, i; - char *r, *u; - - if (!s) { - return NULL; - } - - len =3D strlen (s); - r =3D g_malloc (len + sizeof (qemu_prefix)); - - u =3D r + sizeof (qemu_prefix) - 1; - - pstrcpy (r, len + sizeof (qemu_prefix), qemu_prefix); - pstrcat (r, len + sizeof (qemu_prefix), s); - - for (i =3D 0; i < len; ++i) { - u[i] =3D qemu_toupper(u[i]); - } - - return r; -} - static const char *audio_audfmt_to_string (AudioFormat fmt) { switch (fmt) { @@ -382,78 +297,6 @@ void AUD_log (const char *cap, const char *fmt, ...) va_end (ap); } =20 -static void audio_print_options (const char *prefix, - struct audio_option *opt) -{ - char *uprefix; - - if (!prefix) { - dolog ("No prefix specified\n"); - return; - } - - if (!opt) { - dolog ("No options\n"); - return; - } - - uprefix =3D audio_alloc_prefix (prefix); - - for (; opt->name; opt++) { - const char *state =3D "default"; - printf (" %s_%s: ", uprefix, opt->name); - - if (opt->overriddenp && *opt->overriddenp) { - state =3D "current"; - } - - switch (opt->tag) { - case AUD_OPT_BOOL: - { - int *intp =3D opt->valp; - printf ("boolean, %s =3D %d\n", state, *intp ? 1 : 0); - } - break; - - case AUD_OPT_INT: - { - int *intp =3D opt->valp; - printf ("integer, %s =3D %d\n", state, *intp); - } - break; - - case AUD_OPT_FMT: - { - AudioFormat *fmtp =3D opt->valp; - printf ( - "format, %s =3D %s, (one of: U8 S8 U16 S16 U32 S32)\n", - state, - audio_audfmt_to_string (*fmtp) - ); - } - break; - - case AUD_OPT_STR: - { - const char **strp =3D opt->valp; - printf ("string, %s =3D %s\n", - state, - *strp ? *strp : "(not set)"); - } - break; - - default: - printf ("???\n"); - dolog ("Bad value tag for option %s_%s %d\n", - uprefix, opt->name, opt->tag); - break; - } - printf (" %s\n", opt->descr); - } - - g_free (uprefix); -} - static void audio_process_options (const char *prefix, struct audio_option *opt) { @@ -1141,11 +984,11 @@ static void audio_reset_timer (AudioState *s) { if (audio_is_timer_needed ()) { timer_mod_anticipate_ns(s->ts, - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + conf.period.ticks); + qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + s->period_ticks); if (!audio_timer_running) { audio_timer_running =3D true; audio_timer_last =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - trace_audio_timer_start(conf.period.ticks / SCALE_MS); + trace_audio_timer_start(s->period_ticks / SCALE_MS); } } else { timer_del(s->ts); @@ -1159,16 +1002,17 @@ static void audio_reset_timer (AudioState *s) static void audio_timer (void *opaque) { int64_t now, diff; + AudioState *s =3D opaque; =20 now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); diff =3D now - audio_timer_last; - if (diff > conf.period.ticks * 3 / 2) { + if (diff > s->period_ticks * 3 / 2) { trace_audio_timer_delayed(diff / SCALE_MS); } audio_timer_last =3D now; =20 - audio_run ("timer"); - audio_reset_timer (opaque); + audio_run("timer"); + audio_reset_timer(s); } =20 /* @@ -1228,7 +1072,7 @@ void AUD_set_active_out (SWVoiceOut *sw, int on) if (!hw->enabled) { hw->enabled =3D 1; if (s->vm_running) { - hw->pcm_ops->ctl_out (hw, VOICE_ENABLE, conf.try_poll_= out); + hw->pcm_ops->ctl_out(hw, VOICE_ENABLE, true); audio_reset_timer (s); } } @@ -1273,7 +1117,7 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) if (!hw->enabled) { hw->enabled =3D 1; if (s->vm_running) { - hw->pcm_ops->ctl_in (hw, VOICE_ENABLE, conf.try_poll_i= n); + hw->pcm_ops->ctl_in(hw, VOICE_ENABLE, true); audio_reset_timer (s); } } @@ -1594,169 +1438,13 @@ void audio_run (const char *msg) #endif } =20 -static struct audio_option audio_options[] =3D { - /* DAC */ - { - .name =3D "DAC_FIXED_SETTINGS", - .tag =3D AUD_OPT_BOOL, - .valp =3D &conf.fixed_out.enabled, - .descr =3D "Use fixed settings for host DAC" - }, - { - .name =3D "DAC_FIXED_FREQ", - .tag =3D AUD_OPT_INT, - .valp =3D &conf.fixed_out.settings.freq, - .descr =3D "Frequency for fixed host DAC" - }, - { - .name =3D "DAC_FIXED_FMT", - .tag =3D AUD_OPT_FMT, - .valp =3D &conf.fixed_out.settings.fmt, - .descr =3D "Format for fixed host DAC" - }, - { - .name =3D "DAC_FIXED_CHANNELS", - .tag =3D AUD_OPT_INT, - .valp =3D &conf.fixed_out.settings.nchannels, - .descr =3D "Number of channels for fixed DAC (1 - mono, 2 - stereo= )" - }, - { - .name =3D "DAC_VOICES", - .tag =3D AUD_OPT_INT, - .valp =3D &conf.fixed_out.nb_voices, - .descr =3D "Number of voices for DAC" - }, - { - .name =3D "DAC_TRY_POLL", - .tag =3D AUD_OPT_BOOL, - .valp =3D &conf.try_poll_out, - .descr =3D "Attempt using poll mode for DAC" - }, - /* ADC */ - { - .name =3D "ADC_FIXED_SETTINGS", - .tag =3D AUD_OPT_BOOL, - .valp =3D &conf.fixed_in.enabled, - .descr =3D "Use fixed settings for host ADC" - }, - { - .name =3D "ADC_FIXED_FREQ", - .tag =3D AUD_OPT_INT, - .valp =3D &conf.fixed_in.settings.freq, - .descr =3D "Frequency for fixed host ADC" - }, - { - .name =3D "ADC_FIXED_FMT", - .tag =3D AUD_OPT_FMT, - .valp =3D &conf.fixed_in.settings.fmt, - .descr =3D "Format for fixed host ADC" - }, - { - .name =3D "ADC_FIXED_CHANNELS", - .tag =3D AUD_OPT_INT, - .valp =3D &conf.fixed_in.settings.nchannels, - .descr =3D "Number of channels for fixed ADC (1 - mono, 2 - stereo= )" - }, - { - .name =3D "ADC_VOICES", - .tag =3D AUD_OPT_INT, - .valp =3D &conf.fixed_in.nb_voices, - .descr =3D "Number of voices for ADC" - }, - { - .name =3D "ADC_TRY_POLL", - .tag =3D AUD_OPT_BOOL, - .valp =3D &conf.try_poll_in, - .descr =3D "Attempt using poll mode for ADC" - }, - /* Misc */ - { - .name =3D "TIMER_PERIOD", - .tag =3D AUD_OPT_INT, - .valp =3D &conf.period.hertz, - .descr =3D "Timer period in HZ (0 - use lowest possible)" - }, - { /* End of list */ } -}; - -static void audio_pp_nb_voices (const char *typ, int nb) -{ - switch (nb) { - case 0: - printf ("Does not support %s\n", typ); - break; - case 1: - printf ("One %s voice\n", typ); - break; - case INT_MAX: - printf ("Theoretically supports many %s voices\n", typ); - break; - default: - printf ("Theoretically supports up to %d %s voices\n", nb, typ); - break; - } - -} - -void AUD_help (void) -{ - struct audio_driver *d; - - /* make sure we print the help text for modular drivers too */ - audio_module_load_all(); - - audio_process_options ("AUDIO", audio_options); - QLIST_FOREACH(d, &audio_drivers, next) { - if (d->options) { - audio_process_options (d->name, d->options); - } - } - - printf ("Audio options:\n"); - audio_print_options ("AUDIO", audio_options); - printf ("\n"); - - printf ("Available drivers:\n"); - - QLIST_FOREACH(d, &audio_drivers, next) { - - printf ("Name: %s\n", d->name); - printf ("Description: %s\n", d->descr); - - audio_pp_nb_voices ("playback", d->max_voices_out); - audio_pp_nb_voices ("capture", d->max_voices_in); - - if (d->options) { - printf ("Options:\n"); - audio_print_options (d->name, d->options); - } - else { - printf ("No options\n"); - } - printf ("\n"); - } - - printf ( - "Options are settable through environment variables.\n" - "Example:\n" -#ifdef _WIN32 - " set QEMU_AUDIO_DRV=3Dwav\n" - " set QEMU_WAV_PATH=3Dc:\\tune.wav\n" -#else - " export QEMU_AUDIO_DRV=3Dwav\n" - " export QEMU_WAV_PATH=3D$HOME/tune.wav\n" - "(for csh replace export with setenv in the above)\n" -#endif - " qemu ...\n\n" - ); -} - -static int audio_driver_init(AudioState *s, struct audio_driver *drv, bool= msg) +static int audio_driver_init(AudioState *s, struct audio_driver *drv, + bool msg, Audiodev *dev) { if (drv->options) { audio_process_options (drv->name, drv->options); } - s->drv_opaque =3D drv->init (); + s->drv_opaque =3D drv->init(dev); =20 if (s->drv_opaque) { audio_init_nb_voices_out (drv); @@ -1782,11 +1470,11 @@ static void audio_vm_change_state_handler (void *op= aque, int running, =20 s->vm_running =3D running; while ((hwo =3D audio_pcm_hw_find_any_enabled_out (hwo))) { - hwo->pcm_ops->ctl_out (hwo, op, conf.try_poll_out); + hwo->pcm_ops->ctl_out(hwo, op, true); } =20 while ((hwi =3D audio_pcm_hw_find_any_enabled_in (hwi))) { - hwi->pcm_ops->ctl_in (hwi, op, conf.try_poll_in); + hwi->pcm_ops->ctl_in(hwi, op, true); } audio_reset_timer (s); } @@ -1836,6 +1524,11 @@ void audio_cleanup(void) s->drv->fini (s->drv_opaque); s->drv =3D NULL; } + + if (s->dev) { + qapi_free_Audiodev(s->dev); + s->dev =3D NULL; + } } =20 static const VMStateDescription vmstate_audio =3D { @@ -1847,19 +1540,58 @@ static const VMStateDescription vmstate_audio =3D { } }; =20 -static void audio_init (void) +static void audio_validate_opts(Audiodev *dev, Error **errp); + +static AudiodevListEntry *audiodev_find( + AudiodevListHead *head, const char *drvname) +{ + AudiodevListEntry *e; + QSIMPLEQ_FOREACH(e, head, next) { + if (strcmp(AudiodevDriver_str(e->dev->driver), drvname) =3D=3D 0) { + return e; + } + } + + return NULL; +} + +static int audio_init(Audiodev *dev) { size_t i; int done =3D 0; - const char *drvname; + const char *drvname =3D NULL; VMChangeStateEntry *e; AudioState *s =3D &glob_audio_state; struct audio_driver *driver; + /* silence gcc warning about uninitialized variable */ + AudiodevListHead head =3D QSIMPLEQ_HEAD_INITIALIZER(head); =20 if (s->drv) { - return; + if (dev) { + dolog("Cannot create more than one audio backend, sorry\n"); + qapi_free_Audiodev(dev); + } + return -1; } =20 + if (dev) { + /* -audiodev option */ + drvname =3D AudiodevDriver_str(dev->driver); + } else { + /* legacy implicit initialization */ + head =3D audio_handle_legacy_opts(); + /* + * In case of legacy initialization, all Audiodevs in the list wil= l have + * the same configuration (except the driver), so it does't matter= which + * one we chose. We need an Audiodev to set up AudioState before = we can + * init a driver. Also note that dev at this point is still in the + * list. + */ + dev =3D QSIMPLEQ_FIRST(&head)->dev; + audio_validate_opts(dev, &error_abort); + } + s->dev =3D dev; + QLIST_INIT (&s->hw_head_out); QLIST_INIT (&s->hw_head_in); QLIST_INIT (&s->cap_head); @@ -1867,10 +1599,8 @@ static void audio_init (void) =20 s->ts =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s); =20 - audio_process_options ("AUDIO", audio_options); - - s->nb_hw_voices_out =3D conf.fixed_out.nb_voices; - s->nb_hw_voices_in =3D conf.fixed_in.nb_voices; + s->nb_hw_voices_out =3D audio_get_pdo_out(dev)->voices; + s->nb_hw_voices_in =3D audio_get_pdo_in(dev)->voices; =20 if (s->nb_hw_voices_out <=3D 0) { dolog ("Bogus number of playback voices %d, setting to 1\n", @@ -1884,46 +1614,42 @@ static void audio_init (void) s->nb_hw_voices_in =3D 0; } =20 - { - int def; - drvname =3D audio_get_conf_str ("QEMU_AUDIO_DRV", NULL, &def); - } - if (drvname) { driver =3D audio_driver_lookup(drvname); if (driver) { - done =3D !audio_driver_init(s, driver, true); + done =3D !audio_driver_init(s, driver, true, dev); } else { dolog ("Unknown audio driver `%s'\n", drvname); - dolog ("Run with -audio-help to list available drivers\n"); } - } - - if (!done) { - for (i =3D 0; !done && i < ARRAY_SIZE(audio_prio_list); i++) { + } else { + for (i =3D 0; audio_prio_list[i]; i++) { + AudiodevListEntry *e =3D audiodev_find(&head, audio_prio_list[= i]); driver =3D audio_driver_lookup(audio_prio_list[i]); - if (driver && driver->can_be_default) { - done =3D !audio_driver_init(s, driver, false); + + if (e && driver) { + s->dev =3D dev =3D e->dev; + audio_validate_opts(dev, &error_abort); + done =3D !audio_driver_init(s, driver, false, dev); + if (done) { + e->dev =3D NULL; + break; + } } } } + audio_free_audiodev_list(&head); =20 if (!done) { driver =3D audio_driver_lookup("none"); - done =3D !audio_driver_init(s, driver, false); + done =3D !audio_driver_init(s, driver, false, dev); assert(done); dolog("warning: Using timer based audio emulation\n"); } =20 - if (conf.period.hertz <=3D 0) { - if (conf.period.hertz < 0) { - dolog ("warning: Timer period is negative - %d " - "treating as zero\n", - conf.period.hertz); - } - conf.period.ticks =3D 1; + if (dev->timer_period <=3D 0) { + s->period_ticks =3D 1; } else { - conf.period.ticks =3D NANOSECONDS_PER_SECOND / conf.period.hertz; + s->period_ticks =3D NANOSECONDS_PER_SECOND / dev->timer_period; } =20 e =3D qemu_add_vm_change_state_handler (audio_vm_change_state_handler,= s); @@ -1934,11 +1660,22 @@ static void audio_init (void) =20 QLIST_INIT (&s->card_head); vmstate_register (NULL, 0, &vmstate_audio, s); + return 0; +} + +void audio_free_audiodev_list(AudiodevListHead *head) +{ + AudiodevListEntry *e; + while ((e =3D QSIMPLEQ_FIRST(head))) { + QSIMPLEQ_REMOVE_HEAD(head, next); + qapi_free_Audiodev(e->dev); + g_free(e); + } } =20 void AUD_register_card (const char *name, QEMUSoundCard *card) { - audio_init (); + audio_init(NULL); card->name =3D g_strdup (name); memset (&card->entries, 0, sizeof (card->entries)); QLIST_INSERT_HEAD (&glob_audio_state.card_head, card, entries); @@ -2078,3 +1815,174 @@ void AUD_set_volume_in (SWVoiceIn *sw, int mute, ui= nt8_t lvol, uint8_t rvol) } } } + +void audio_create_pdos(Audiodev *dev) +{ + switch (dev->driver) { +#define CASE(DRIVER, driver, pdo_name) \ + case AUDIODEV_DRIVER_##DRIVER: \ + if (!dev->u.driver.has_in) { \ + dev->u.driver.in =3D g_malloc0( \ + sizeof(Audiodev##pdo_name##PerDirectionOptions)); \ + dev->u.driver.has_in =3D true; \ + } \ + if (!dev->u.driver.has_out) { \ + dev->u.driver.out =3D g_malloc0( \ + sizeof(AudiodevAlsaPerDirectionOptions)); \ + dev->u.driver.has_out =3D true; \ + } \ + break + + CASE(NONE, none, ); + CASE(ALSA, alsa, Alsa); + CASE(COREAUDIO, coreaudio, Coreaudio); + CASE(DSOUND, dsound, ); + CASE(OSS, oss, Oss); + CASE(PA, pa, Pa); + CASE(SDL, sdl, ); + CASE(SPICE, spice, ); + CASE(WAV, wav, ); + + case AUDIODEV_DRIVER__MAX: + abort(); + }; +} + +static void audio_validate_per_direction_opts( + AudiodevPerDirectionOptions *pdo, Error **errp) +{ + if (!pdo->has_fixed_settings) { + pdo->has_fixed_settings =3D true; + pdo->fixed_settings =3D 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=3Doff"); + return; + } + + if (!pdo->has_frequency) { + pdo->has_frequency =3D true; + pdo->frequency =3D 44100; + } + if (!pdo->has_channels) { + pdo->has_channels =3D true; + pdo->channels =3D 2; + } + if (!pdo->has_voices) { + pdo->has_voices =3D true; + pdo->voices =3D 1; + } + if (!pdo->has_format) { + pdo->has_format =3D true; + pdo->format =3D AUDIO_FORMAT_S16; + } +} + +static void audio_validate_opts(Audiodev *dev, Error **errp) +{ + Error *err =3D NULL; + + audio_create_pdos(dev); + + audio_validate_per_direction_opts(audio_get_pdo_in(dev), &err); + if (err) { + error_propagate(errp, err); + return; + } + + audio_validate_per_direction_opts(audio_get_pdo_out(dev), &err); + if (err) { + error_propagate(errp, err); + return; + } + + if (!dev->has_timer_period) { + dev->has_timer_period =3D true; + dev->timer_period =3D 10000; /* 100Hz -> 10ms */ + } +} + +void audio_parse_option(const char *opt) +{ + AudiodevListEntry *e; + Audiodev *dev =3D NULL; + + Visitor *v =3D qobject_input_visitor_new_str(opt, "driver", &error_fat= al); + visit_type_Audiodev(v, NULL, &dev, &error_fatal); + visit_free(v); + + audio_validate_opts(dev, &error_fatal); + + e =3D g_malloc0(sizeof(AudiodevListEntry)); + e->dev =3D dev; + QSIMPLEQ_INSERT_TAIL(&audiodevs, e, next); +} + +void audio_init_audiodevs(void) +{ + AudiodevListEntry *e; + + QSIMPLEQ_FOREACH(e, &audiodevs, next) { + audio_init(e->dev); + } +} + +audsettings audiodev_to_audsettings(AudiodevPerDirectionOptions *pdo) +{ + return (audsettings) { + .freq =3D pdo->frequency, + .nchannels =3D pdo->channels, + .fmt =3D pdo->format, + .endianness =3D AUDIO_HOST_ENDIANNESS, + }; +} + +int audioformat_bytes_per_sample(AudioFormat fmt) +{ + switch (fmt) { + case AUDIO_FORMAT_U8: + case AUDIO_FORMAT_S8: + return 1; + + case AUDIO_FORMAT_U16: + case AUDIO_FORMAT_S16: + return 2; + + case AUDIO_FORMAT_U32: + case AUDIO_FORMAT_S32: + return 4; + + case AUDIO_FORMAT__MAX: + ; + } + abort(); +} + + +/* frames =3D freq * usec / 1e6 */ +int audio_buffer_frames(AudiodevPerDirectionOptions *pdo, + audsettings *as, int def_usecs) +{ + uint64_t usecs =3D pdo->has_buffer_length ? pdo->buffer_length : def_u= secs; + return (as->freq * usecs + 500000) / 1000000; +} + +/* samples =3D channels * frames =3D channels * freq * usec / 1e6 */ +int audio_buffer_samples(AudiodevPerDirectionOptions *pdo, + audsettings *as, int def_usecs) +{ + return as->nchannels * audio_buffer_frames(pdo, as, def_usecs); +} + +/* + * bytes =3D bytes_per_sample * samples =3D + * bytes_per_sample * channels * freq * usec / 1e6 + */ +int audio_buffer_bytes(AudiodevPerDirectionOptions *pdo, + audsettings *as, int def_usecs) +{ + return audio_buffer_samples(pdo, as, def_usecs) * + audioformat_bytes_per_sample(as->fmt); +} diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c new file mode 100644 index 0000000000..ad3b781add --- /dev/null +++ b/audio/audio_legacy.c @@ -0,0 +1,293 @@ +/* + * QEMU Audio subsystem: legacy configuration handling + * + * Copyright (c) 2015-2019 Zolt=C3=A1n K=C5=91v=C3=A1g=C3=B3 + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ +#include "qemu/osdep.h" +#include "audio.h" +#include "audio_int.h" +#include "qemu-common.h" +#include "qemu/cutils.h" +#include "qapi/error.h" +#include "qapi/qapi-visit-audio.h" +#include "qapi/visitor-impl.h" + +#define AUDIO_CAP "audio-legacy" +#include "audio_int.h" + +static uint32_t toui32(const char *str) +{ + unsigned long long ret; + if (parse_uint_full(str, &ret, 10) || ret > UINT32_MAX) { + dolog("Invalid integer value `%s'\n", str); + exit(1); + } + return ret; +} + +/* helper functions to convert env variables */ +static void get_bool(const char *env, bool *dst, bool *has_dst) +{ + const char *val =3D getenv(env); + if (val) { + *dst =3D toui32(val) !=3D 0; + *has_dst =3D true; + } +} + +static void get_int(const char *env, uint32_t *dst, bool *has_dst) +{ + const char *val =3D getenv(env); + if (val) { + *dst =3D toui32(val); + *has_dst =3D true; + } +} + +static void get_fmt(const char *env, AudioFormat *dst, bool *has_dst) +{ + const char *val =3D getenv(env); + if (val) { + size_t i; + for (i =3D 0; AudioFormat_lookup.size; ++i) { + if (strcasecmp(val, AudioFormat_lookup.array[i]) =3D=3D 0) { + *dst =3D i; + *has_dst =3D true; + return; + } + } + + dolog("Invalid audio format `%s'\n", val); + exit(1); + } +} + +/* backend specific functions */ +/* todo */ + +/* general */ +static void handle_per_direction( + AudiodevPerDirectionOptions *pdo, const char *prefix) +{ + char buf[64]; + size_t len =3D strlen(prefix); + + memcpy(buf, prefix, len); + strcpy(buf + len, "FIXED_SETTINGS"); + get_bool(buf, &pdo->fixed_settings, &pdo->has_fixed_settings); + + strcpy(buf + len, "FIXED_FREQ"); + get_int(buf, &pdo->frequency, &pdo->has_frequency); + + strcpy(buf + len, "FIXED_FMT"); + get_fmt(buf, &pdo->format, &pdo->has_format); + + strcpy(buf + len, "FIXED_CHANNELS"); + get_int(buf, &pdo->channels, &pdo->has_channels); + + strcpy(buf + len, "VOICES"); + get_int(buf, &pdo->voices, &pdo->has_voices); +} + +static AudiodevListEntry *legacy_opt(const char *drvname) +{ + AudiodevListEntry *e =3D g_malloc0(sizeof(AudiodevListEntry)); + e->dev =3D g_malloc0(sizeof(Audiodev)); + e->dev->id =3D g_strdup(drvname); + e->dev->driver =3D qapi_enum_parse( + &AudiodevDriver_lookup, drvname, -1, &error_abort); + + audio_create_pdos(e->dev); + + handle_per_direction(audio_get_pdo_in(e->dev), "QEMU_AUDIO_ADC_"); + handle_per_direction(audio_get_pdo_out(e->dev), "QEMU_AUDIO_DAC_"); + + get_int("QEMU_AUDIO_TIMER_PERIOD", + &e->dev->timer_period, &e->dev->has_timer_period); + + return e; +} + +AudiodevListHead audio_handle_legacy_opts(void) +{ + const char *drvname =3D getenv("QEMU_AUDIO_DRV"); + AudiodevListHead head =3D QSIMPLEQ_HEAD_INITIALIZER(head); + + if (drvname) { + AudiodevListEntry *e; + audio_driver *driver =3D audio_driver_lookup(drvname); + if (!driver) { + dolog("Unknown audio driver `%s'\n", drvname); + exit(1); + } + e =3D legacy_opt(drvname); + QSIMPLEQ_INSERT_TAIL(&head, e, next); + } else { + for (int i =3D 0; audio_prio_list[i]; i++) { + audio_driver *driver =3D audio_driver_lookup(audio_prio_list[i= ]); + if (driver && driver->can_be_default) { + AudiodevListEntry *e =3D legacy_opt(driver->name); + QSIMPLEQ_INSERT_TAIL(&head, e, next); + } + } + if (QSIMPLEQ_EMPTY(&head)) { + dolog("Internal error: no default audio driver available\n"); + exit(1); + } + } + + return head; +} + +/* visitor to print -audiodev option */ +typedef struct { + Visitor visitor; + + bool comma; + GList *path; +} LegacyPrintVisitor; + +static void lv_start_struct(Visitor *v, const char *name, void **obj, + size_t size, Error **errp) +{ + LegacyPrintVisitor *lv =3D (LegacyPrintVisitor *) v; + lv->path =3D g_list_append(lv->path, g_strdup(name)); +} + +static void lv_end_struct(Visitor *v, void **obj) +{ + LegacyPrintVisitor *lv =3D (LegacyPrintVisitor *) v; + lv->path =3D g_list_delete_link(lv->path, g_list_last(lv->path)); +} + +static void lv_print_key(Visitor *v, const char *name) +{ + GList *e; + LegacyPrintVisitor *lv =3D (LegacyPrintVisitor *) v; + if (lv->comma) { + putchar(','); + } else { + lv->comma =3D true; + } + + for (e =3D lv->path; e; e =3D e->next) { + if (e->data) { + printf("%s.", (const char *) e->data); + } + } + + printf("%s=3D", name); +} + +static void lv_type_int64(Visitor *v, const char *name, int64_t *obj, + Error **errp) +{ + lv_print_key(v, name); + printf("%" PRIi64, *obj); +} + +static void lv_type_uint64(Visitor *v, const char *name, uint64_t *obj, + Error **errp) +{ + lv_print_key(v, name); + printf("%" PRIu64, *obj); +} + +static void lv_type_bool(Visitor *v, const char *name, bool *obj, Error **= errp) +{ + lv_print_key(v, name); + printf("%s", *obj ? "on" : "off"); +} + +static void lv_type_str(Visitor *v, const char *name, char **obj, Error **= errp) +{ + const char *str =3D *obj; + lv_print_key(v, name); + + while (*str) { + if (*str =3D=3D ',') { + putchar(','); + } + putchar(*str++); + } +} + +static void lv_complete(Visitor *v, void *opaque) +{ + LegacyPrintVisitor *lv =3D (LegacyPrintVisitor *) v; + assert(lv->path =3D=3D NULL); +} + +static void lv_free(Visitor *v) +{ + LegacyPrintVisitor *lv =3D (LegacyPrintVisitor *) v; + + g_list_free_full(lv->path, g_free); + g_free(lv); +} + +static Visitor *legacy_visitor_new(void) +{ + LegacyPrintVisitor *lv =3D g_malloc0(sizeof(LegacyPrintVisitor)); + + lv->visitor.start_struct =3D lv_start_struct; + lv->visitor.end_struct =3D lv_end_struct; + /* lists not supported */ + lv->visitor.type_int64 =3D lv_type_int64; + lv->visitor.type_uint64 =3D lv_type_uint64; + lv->visitor.type_bool =3D lv_type_bool; + lv->visitor.type_str =3D lv_type_str; + + lv->visitor.type =3D VISITOR_OUTPUT; + lv->visitor.complete =3D lv_complete; + lv->visitor.free =3D lv_free; + + return &lv->visitor; +} + +void audio_legacy_help(void) +{ + AudiodevListHead head; + AudiodevListEntry *e; + + printf("Environment variable based configuration deprecated.\n"); + printf("Please use the new -audiodev option.\n"); + + head =3D audio_handle_legacy_opts(); + printf("\nEquivalent -audiodev to your current environment variables:\= n"); + if (!getenv("QEMU_AUDIO_DRV")) { + printf("(Since you didn't specify QEMU_AUDIO_DRV, I'll list all " + "possibilities)\n"); + } + + QSIMPLEQ_FOREACH(e, &head, next) { + Visitor *v; + Audiodev *dev =3D e->dev; + printf("-audiodev "); + + v =3D legacy_visitor_new(); + visit_type_Audiodev(v, NULL, &dev, &error_abort); + visit_free(v); + + printf("\n"); + } + audio_free_audiodev_list(&head); +} diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 638c60b300..7d4225dbee 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -685,7 +685,7 @@ static CoreaudioConf glob_conf =3D { .nbuffers =3D 4, }; =20 -static void *coreaudio_audio_init (void) +static void *coreaudio_audio_init(Audiodev *dev) { CoreaudioConf *conf =3D g_malloc(sizeof(CoreaudioConf)); *conf =3D glob_conf; diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 3ed73a30d1..02fe777cba 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -783,7 +783,7 @@ static void dsound_audio_fini (void *opaque) g_free(s); } =20 -static void *dsound_audio_init (void) +static void *dsound_audio_init(Audiodev *dev) { int err; HRESULT hr; diff --git a/audio/noaudio.c b/audio/noaudio.c index 1bfebeca7d..79690af1ea 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -136,7 +136,7 @@ static int no_ctl_in (HWVoiceIn *hw, int cmd, ...) return 0; } =20 -static void *no_audio_init (void) +static void *no_audio_init(Audiodev *dev) { return &no_audio_init; } diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 355e8fbda5..e0cadbef29 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -842,7 +842,7 @@ static OSSConf glob_conf =3D { .policy =3D 5 }; =20 -static void *oss_audio_init (void) +static void *oss_audio_init(Audiodev *dev) { OSSConf *conf =3D g_malloc(sizeof(OSSConf)); *conf =3D glob_conf; diff --git a/audio/paaudio.c b/audio/paaudio.c index 8246f260a8..d649c58e3d 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -812,7 +812,7 @@ static PAConf glob_conf =3D { .samples =3D 4096, }; =20 -static void *qpa_audio_init (void) +static void *qpa_audio_init(Audiodev *dev) { if (glob_conf.server =3D=3D NULL) { char pidfile[64]; diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 4cd4cbaf00..b9ae506a56 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -315,7 +315,7 @@ static int sdl_ctl_out (HWVoiceOut *hw, int cmd, ...) return 0; } =20 -static void *sdl_audio_init (void) +static void *sdl_audio_init(Audiodev *dev) { SDLAudioState *s =3D &glob_sdl; if (s->driver_created) { diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 3aeb0cb357..affc3df17f 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -77,7 +77,7 @@ static const SpiceRecordInterface record_sif =3D { .base.minor_version =3D SPICE_INTERFACE_RECORD_MINOR, }; =20 -static void *spice_audio_init (void) +static void *spice_audio_init(Audiodev *dev) { if (!using_spice) { return NULL; diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 35a614785e..9eff3555b3 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -232,7 +232,7 @@ static WAVConf glob_conf =3D { .wav_path =3D "qemu.wav" }; =20 -static void *wav_audio_init (void) +static void *wav_audio_init(Audiodev *dev) { WAVConf *conf =3D g_malloc(sizeof(WAVConf)); *conf =3D glob_conf; diff --git a/vl.c b/vl.c index 4a350de5cd..db04aea7f8 100644 --- a/vl.c +++ b/vl.c @@ -3253,9 +3253,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; @@ -4447,6 +4450,8 @@ int main(int argc, char **argv, char **envp) /* do monitor/qmp handling at preconfig state if requested */ main_loop(); =20 + audio_init_audiodevs(); + /* from here on runstate is RUN_STATE_PRELAUNCH */ machine_run_board_init(current_machine); =20 diff --git a/audio/Makefile.objs b/audio/Makefile.objs index db4fa7f18f..dca87f6347 100644 --- a/audio/Makefile.objs +++ b/audio/Makefile.objs @@ -1,4 +1,4 @@ -common-obj-y =3D audio.o noaudio.o wavaudio.o mixeng.o +common-obj-y =3D audio.o audio_legacy.o noaudio.o wavaudio.o mixeng.o common-obj-$(CONFIG_SPICE) +=3D spiceaudio.o common-obj-$(CONFIG_AUDIO_COREAUDIO) +=3D coreaudio.o common-obj-$(CONFIG_AUDIO_DSOUND) +=3D dsoundaudio.o --=20 2.20.1 From nobody Mon May 6 19:52:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552084944789500.73065365580305; Fri, 8 Mar 2019 14:42:24 -0800 (PST) Received: from localhost ([127.0.0.1]:50874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2OC1-0005SD-9s for importer@patchew.org; Fri, 08 Mar 2019 17:42:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O4a-0007fL-Sq for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2O4Y-0002cA-Hd for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:36 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:46384) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2O4Y-0002bi-2s for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:34 -0500 Received: by mail-wr1-x42e.google.com with SMTP id i16so22933198wrs.13 for ; Fri, 08 Mar 2019 14:34:33 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6af5-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6af5::5]) by smtp.gmail.com with ESMTPSA id v2sm15269144wme.29.2019.03.08.14.34.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:34:32 -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=gaHdir15EirF/hlhMFUsUdiPTNAOm/UWRLXIYmmdsks=; b=aHfYb7ZjFaJ6HZ7cY7v4gDCU1TBvS6HicOmZHZQe1XaUTdMbtupH7+/GCq/jiGwg1F aI5YYiFLaiPSjKTMz6VH3O7rVaz7t3auWlfNMuEwIGznwIixvBIzaCI2MY/VIYUAOUkX ZB4A8IB3/64zjqWtcSbgff2I0jR5mhJEh08xJ9Cp6PXtJJT5PWoB60J7HHajYYzNufOE uJnMLDrwqslhcCyGo3Z3qhzQZnf2u+CyLFPKv0NaqL68rp8tHD/QtcHfGOOdSBo1G3wr mHnUNDSqXGyy0frl1u0qoD0e/jJmj2Qhq/Gk7sspSCP6gavN+9vNhgLgvufrLr7wxWhP 0Z/A== 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=gaHdir15EirF/hlhMFUsUdiPTNAOm/UWRLXIYmmdsks=; b=OQvQoH9MdHCgbIRf/8SlJEode0sYyKBsRTNJOX/Qv4zgqSZNzeiNRvOEzWiqg+d1bi eiFxNjloOPvXzUzifoTDheTdokxbNClUxyzfCsJmzNQcRTQ3bTj3VYPQX+Z4g1XGw0kw nyshzuoiJ+RQ0qiP/cXxPlYankLuPmkn0wjsprxwtYFH4wz227CXBCEk9jDZOCF0PLyS /y1cHlx7UNS6/mdyWfguPmlI/ulYkuiYoXFOGw3Hi5MDSgWCSwGtnEaffpF811ivgRnX 1VJKtHxK1SPWnFDth2xazusNBJCbtvL5psjr5ObhBgwS7izDSUBA+rI8elFFYWQkd1d/ 7Dig== X-Gm-Message-State: APjAAAWsFkwgfd4v5vXsiInAA0SYigw+wuV8sK02Gplqje/TpMvsWndU 7iVmMwovrC8NgMPwMOBo0i6rJYclmQM= X-Google-Smtp-Source: APXvYqzDDh7ybd4NjEhzozdZ3CSOnGx344L1a8FycrVTpMCXLWDo4hqxg03aTfP7t1aWgQ7H+UBPuA== X-Received: by 2002:adf:e64c:: with SMTP id b12mr3449357wrn.112.1552084472713; Fri, 08 Mar 2019 14:34:32 -0800 (PST) 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, 8 Mar 2019 23:34:16 +0100 Message-Id: <663d2c918a11ef44d4042e56c796d6dbf40be70c.1552083282.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e Subject: [Qemu-devel] [PATCH v6 05/14] alsaaudio: port to -audiodev config 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/alsaaudio.c | 329 +++++++++++++------------------------------ audio/audio_legacy.c | 84 ++++++++++- 2 files changed, 181 insertions(+), 232 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 8302f3e882..49e6884309 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -33,28 +33,9 @@ #define AUDIO_CAP "alsa" #include "audio_int.h" =20 -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; =20 typedef struct ALSAVoiceIn { @@ -73,16 +55,13 @@ typedef struct ALSAVoiceIn { snd_pcm_t *handle; void *pcm_buf; struct pollhlp pollhlp; + Audiodev *dev; } ALSAVoiceIn; =20 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; }; =20 struct alsa_params_obt { @@ -408,17 +387,18 @@ static int alsa_to_audfmt (snd_pcm_format_t alsafmt, = AudioFormat *fmt, =20 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, + AudiodevAlsaPerDirectionOptions *apdo) { - 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 ("=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\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("=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n"); + dolog("requested: buffer len %" PRId32 " period len %" PRId32 "\n", + apdo->buffer_length, apdo->period_length); + dolog("obtained: samples %ld\n", obt->samples); } =20 static void alsa_set_threshold (snd_pcm_t *handle, snd_pcm_uframes_t thres= hold) @@ -451,23 +431,23 @@ static void alsa_set_threshold (snd_pcm_t *handle, sn= d_pcm_uframes_t threshold) } } =20 -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) { + AudiodevAlsaOptions *aopts =3D &dev->u.alsa; + AudiodevAlsaPerDirectionOptions *apdo =3D in ? aopts->in : aopts->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 =3D in ? conf->pcm_name_in : conf->pcm_name_out; + const char *pcm_name =3D apdo->has_dev ? apdo->dev : "default"; snd_pcm_uframes_t obt_buffer_size; const char *typ =3D in ? "ADC" : "DAC"; snd_pcm_format_t obtfmt; =20 freq =3D req->freq; nchannels =3D req->nchannels; - size_in_usec =3D req->size_in_usec; =20 snd_pcm_hw_params_alloca (&hw_params); =20 @@ -527,79 +507,42 @@ static int alsa_open (int in, struct alsa_params_req = *req, goto err; } =20 - if (req->buffer_size) { - unsigned long obt; + if (apdo->buffer_length) { + int dir =3D 0; + unsigned int btime =3D apdo->buffer_length; =20 - if (size_in_usec) { - int dir =3D 0; - unsigned int btime =3D req->buffer_size; + err =3D snd_pcm_hw_params_set_buffer_time_near( + handle, hw_params, &btime, &dir); =20 - err =3D snd_pcm_hw_params_set_buffer_time_near ( - handle, - hw_params, - &btime, - &dir - ); - obt =3D btime; - } - else { - snd_pcm_uframes_t bsize =3D req->buffer_size; - - err =3D snd_pcm_hw_params_set_buffer_size_near ( - handle, - hw_params, - &bsize - ); - obt =3D bsize; - } if (err < 0) { - alsa_logerr2 (err, typ, "Failed to set buffer %s to %d\n", - size_in_usec ? "time" : "size", req->buffer_size= ); + alsa_logerr2(err, typ, "Failed to set buffer time to %" PRId32= "\n", + apdo->buffer_length); goto err; } =20 - 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 (apdo->has_buffer_length && btime !=3D apdo->buffer_length) { + dolog("Requested buffer time %" PRId32 + " was rejected, using %u\n", apdo->buffer_length, btime); + } } =20 - if (req->period_size) { - unsigned long obt; + if (apdo->period_length) { + int dir =3D 0; + unsigned int ptime =3D apdo->period_length; =20 - if (size_in_usec) { - int dir =3D 0; - unsigned int ptime =3D req->period_size; - - err =3D snd_pcm_hw_params_set_period_time_near ( - handle, - hw_params, - &ptime, - &dir - ); - obt =3D ptime; - } - else { - int dir =3D 0; - snd_pcm_uframes_t psize =3D req->period_size; - - err =3D snd_pcm_hw_params_set_period_size_near ( - handle, - hw_params, - &psize, - &dir - ); - obt =3D psize; - } + err =3D snd_pcm_hw_params_set_period_time_near(handle, hw_params, = &ptime, + &dir); =20 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", + apdo->period_length); goto err; } =20 - 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 (apdo->has_period_length && ptime !=3D apdo->period_length) { + dolog("Requested period time %" PRId32 " was rejected, using %= d\n", + apdo->period_length, ptime); + } } =20 err =3D snd_pcm_hw_params (handle, hw_params); @@ -631,33 +574,12 @@ static int alsa_open (int in, struct alsa_params_req = *req, goto err; } =20 - if (!in && conf->threshold) { - snd_pcm_uframes_t threshold; - int bytes_per_sec; - - bytes_per_sec =3D freq << (nchannels =3D=3D 2); - - switch (obt->fmt) { - case AUDIO_FORMAT_S8: - case AUDIO_FORMAT_U8: - break; - - case AUDIO_FORMAT_S16: - case AUDIO_FORMAT_U16: - bytes_per_sec <<=3D 1; - break; - - case AUDIO_FORMAT_S32: - case AUDIO_FORMAT_U32: - bytes_per_sec <<=3D 2; - break; - - default: - abort(); - } - - threshold =3D (conf->threshold * bytes_per_sec) / 1000; - alsa_set_threshold (handle, threshold); + if (!in && aopts->has_threshold && aopts->threshold) { + struct audsettings as =3D { .freq =3D freq }; + alsa_set_threshold( + handle, + audio_buffer_frames(qapi_AudiodevAlsaPerDirectionOptions_base(= apdo), + &as, aopts->threshold)); } =20 obt->nchannels =3D nchannels; @@ -670,11 +592,11 @@ static int alsa_open (int in, struct alsa_params_req = *req, obt->nchannels !=3D req->nchannels || obt->freq !=3D req->freq) { dolog ("Audio parameters for %s\n", typ); - alsa_dump_info (req, obt, obtfmt); + alsa_dump_info(req, obt, obtfmt, apdo); } =20 #ifdef DEBUG - alsa_dump_info (req, obt, obtfmt); + alsa_dump_info(req, obt, obtfmt, pdo); #endif return 0; =20 @@ -800,19 +722,13 @@ static int alsa_init_out(HWVoiceOut *hw, struct audse= ttings *as, struct alsa_params_obt obt; snd_pcm_t *handle; struct audsettings obt_as; - ALSAConf *conf =3D drv_opaque; + Audiodev *dev =3D drv_opaque; =20 req.fmt =3D aud_to_alsafmt (as->fmt, as->endianness); req.freq =3D as->freq; req.nchannels =3D as->nchannels; - req.period_size =3D conf->period_size_out; - req.buffer_size =3D conf->buffer_size_out; - req.size_in_usec =3D conf->size_in_usec_out; - req.override_mask =3D - (conf->period_size_out_overridden ? 1 : 0) | - (conf->buffer_size_out_overridden ? 2 : 0); =20 - if (alsa_open (0, &req, &obt, &handle, conf)) { + if (alsa_open(0, &req, &obt, &handle, dev)) { return -1; } =20 @@ -833,7 +749,7 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsett= ings *as, } =20 alsa->handle =3D handle; - alsa->pollhlp.conf =3D conf; + alsa->dev =3D dev; return 0; } =20 @@ -873,16 +789,12 @@ static int alsa_voice_ctl (snd_pcm_t *handle, const c= har *typ, int ctl) static int alsa_ctl_out (HWVoiceOut *hw, int cmd, ...) { ALSAVoiceOut *alsa =3D (ALSAVoiceOut *) hw; + AudiodevAlsaPerDirectionOptions *apdo =3D alsa->dev->u.alsa.out; =20 switch (cmd) { case VOICE_ENABLE: { - va_list ap; - int poll_mode; - - va_start (ap, cmd); - poll_mode =3D va_arg (ap, int); - va_end (ap); + bool poll_mode =3D apdo->try_poll; =20 ldebug ("enabling voice\n"); if (poll_mode && alsa_poll_out (hw)) { @@ -911,19 +823,13 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsett= ings *as, void *drv_opaque) struct alsa_params_obt obt; snd_pcm_t *handle; struct audsettings obt_as; - ALSAConf *conf =3D drv_opaque; + Audiodev *dev =3D drv_opaque; =20 req.fmt =3D aud_to_alsafmt (as->fmt, as->endianness); req.freq =3D as->freq; req.nchannels =3D as->nchannels; - req.period_size =3D conf->period_size_in; - req.buffer_size =3D conf->buffer_size_in; - req.size_in_usec =3D conf->size_in_usec_in; - req.override_mask =3D - (conf->period_size_in_overridden ? 1 : 0) | - (conf->buffer_size_in_overridden ? 2 : 0); =20 - if (alsa_open (1, &req, &obt, &handle, conf)) { + if (alsa_open(1, &req, &obt, &handle, dev)) { return -1; } =20 @@ -944,7 +850,7 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettin= gs *as, void *drv_opaque) } =20 alsa->handle =3D handle; - alsa->pollhlp.conf =3D conf; + alsa->dev =3D dev; return 0; } =20 @@ -1086,16 +992,12 @@ static int alsa_read (SWVoiceIn *sw, void *buf, int = size) static int alsa_ctl_in (HWVoiceIn *hw, int cmd, ...) { ALSAVoiceIn *alsa =3D (ALSAVoiceIn *) hw; + AudiodevAlsaPerDirectionOptions *apdo =3D alsa->dev->u.alsa.in; =20 switch (cmd) { case VOICE_ENABLE: { - va_list ap; - int poll_mode; - - va_start (ap, cmd); - poll_mode =3D va_arg (ap, int); - va_end (ap); + bool poll_mode =3D apdo->try_poll; =20 ldebug ("enabling voice\n"); if (poll_mode && alsa_poll_in (hw)) { @@ -1118,88 +1020,54 @@ static int alsa_ctl_in (HWVoiceIn *hw, int cmd, ...) return -1; } =20 -static ALSAConf glob_conf =3D { - .buffer_size_out =3D 4096, - .period_size_out =3D 1024, - .pcm_name_out =3D "default", - .pcm_name_in =3D "default", -}; +static void alsa_init_per_direction(AudiodevAlsaPerDirectionOptions *apdo) +{ + if (!apdo->has_try_poll) { + apdo->try_poll =3D true; + apdo->has_try_poll =3D true; + } +} =20 static void *alsa_audio_init(Audiodev *dev) { - ALSAConf *conf =3D g_malloc(sizeof(ALSAConf)); - *conf =3D glob_conf; - return conf; + AudiodevAlsaOptions *aopts; + assert(dev->driver =3D=3D AUDIODEV_DRIVER_ALSA); + + aopts =3D &dev->u.alsa; + alsa_init_per_direction(aopts->in); + alsa_init_per_direction(aopts->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 us= er + */ + if (!dev->u.alsa.out->has_period_length) { + /* 1024 frames assuming 44100Hz */ + dev->u.alsa.out->period_length =3D 1024 * 1000000 / 44100; + } + if (!dev->u.alsa.out->has_buffer_length) { + /* 4096 frames assuming 44100Hz */ + dev->u.alsa.out->buffer_length =3D 4096ll * 1000000 / 44100; + } + + /* + * OptsVisitor sets unspecified optional fields to zero, but do not de= pend + * on it... + */ + if (!dev->u.alsa.in->has_period_length) { + dev->u.alsa.in->period_length =3D 0; + } + if (!dev->u.alsa.in->has_buffer_length) { + dev->u.alsa.in->buffer_length =3D 0; + } + + return dev; } =20 static void alsa_audio_fini (void *opaque) { - g_free(opaque); } =20 -static struct audio_option alsa_options[] =3D { - { - .name =3D "DAC_SIZE_IN_USEC", - .tag =3D AUD_OPT_BOOL, - .valp =3D &glob_conf.size_in_usec_out, - .descr =3D "DAC period/buffer size in microseconds (otherwis= e in frames)" - }, - { - .name =3D "DAC_PERIOD_SIZE", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.period_size_out, - .descr =3D "DAC period size (0 to go with system default)", - .overriddenp =3D &glob_conf.period_size_out_overridden - }, - { - .name =3D "DAC_BUFFER_SIZE", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.buffer_size_out, - .descr =3D "DAC buffer size (0 to go with system default)", - .overriddenp =3D &glob_conf.buffer_size_out_overridden - }, - { - .name =3D "ADC_SIZE_IN_USEC", - .tag =3D AUD_OPT_BOOL, - .valp =3D &glob_conf.size_in_usec_in, - .descr =3D - "ADC period/buffer size in microseconds (otherwise in frames)" - }, - { - .name =3D "ADC_PERIOD_SIZE", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.period_size_in, - .descr =3D "ADC period size (0 to go with system default)", - .overriddenp =3D &glob_conf.period_size_in_overridden - }, - { - .name =3D "ADC_BUFFER_SIZE", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.buffer_size_in, - .descr =3D "ADC buffer size (0 to go with system default)", - .overriddenp =3D &glob_conf.buffer_size_in_overridden - }, - { - .name =3D "THRESHOLD", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.threshold, - .descr =3D "(undocumented)" - }, - { - .name =3D "DAC_DEV", - .tag =3D AUD_OPT_STR, - .valp =3D &glob_conf.pcm_name_out, - .descr =3D "DAC device name (for instance dmix)" - }, - { - .name =3D "ADC_DEV", - .tag =3D AUD_OPT_STR, - .valp =3D &glob_conf.pcm_name_in, - .descr =3D "ADC device name" - }, - { /* End of list */ } -}; - static struct audio_pcm_ops alsa_pcm_ops =3D { .init_out =3D alsa_init_out, .fini_out =3D alsa_fini_out, @@ -1217,7 +1085,6 @@ static struct audio_pcm_ops alsa_pcm_ops =3D { static struct audio_driver alsa_audio_driver =3D { .name =3D "alsa", .descr =3D "ALSA http://www.alsa-project.org", - .options =3D alsa_options, .init =3D alsa_audio_init, .fini =3D alsa_audio_fini, .pcm_ops =3D &alsa_pcm_ops, diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index ad3b781add..f58c8b6aee 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -62,6 +62,18 @@ static void get_int(const char *env, uint32_t *dst, bool= *has_dst) } } =20 +static void get_str(const char *env, char **dst, bool *has_dst) +{ + const char *val =3D getenv(env); + if (val) { + if (*has_dst) { + g_free(*dst); + } + *dst =3D g_strdup(val); + *has_dst =3D true; + } +} + static void get_fmt(const char *env, AudioFormat *dst, bool *has_dst) { const char *val =3D getenv(env); @@ -80,8 +92,69 @@ static void get_fmt(const char *env, AudioFormat *dst, b= ool *has_dst) } } =20 + +static void get_millis_to_usecs(const char *env, uint32_t *dst, bool *has_= dst) +{ + const char *val =3D getenv(env); + if (val) { + *dst =3D toui32(val) * 1000; + *has_dst =3D true; + } +} + +static uint32_t frames_to_usecs(uint32_t frames, + AudiodevPerDirectionOptions *pdo) +{ + uint32_t freq =3D pdo->has_frequency ? pdo->frequency : 44100; + return (frames * 1000000 + freq / 2) / freq; +} + /* backend specific functions */ -/* todo */ +/* ALSA */ +static void handle_alsa_per_direction( + AudiodevAlsaPerDirectionOptions *apdo, const char *prefix) +{ + char buf[64]; + size_t len =3D strlen(prefix); + bool size_in_usecs =3D false; + bool dummy; + + memcpy(buf, prefix, len); + strcpy(buf + len, "TRY_POLL"); + get_bool(buf, &apdo->try_poll, &apdo->has_try_poll); + + strcpy(buf + len, "DEV"); + get_str(buf, &apdo->dev, &apdo->has_dev); + + strcpy(buf + len, "SIZE_IN_USEC"); + get_bool(buf, &size_in_usecs, &dummy); + + strcpy(buf + len, "PERIOD_SIZE"); + get_int(buf, &apdo->period_length, &apdo->has_period_length); + if (apdo->has_period_length && !size_in_usecs) { + apdo->period_length =3D frames_to_usecs( + apdo->period_length, + qapi_AudiodevAlsaPerDirectionOptions_base(apdo)); + } + + strcpy(buf + len, "BUFFER_SIZE"); + get_int(buf, &apdo->buffer_length, &apdo->has_buffer_length); + if (apdo->has_buffer_length && !size_in_usecs) { + apdo->buffer_length =3D frames_to_usecs( + apdo->buffer_length, + qapi_AudiodevAlsaPerDirectionOptions_base(apdo)); + } +} + +static void handle_alsa(Audiodev *dev) +{ + AudiodevAlsaOptions *aopt =3D &dev->u.alsa; + handle_alsa_per_direction(aopt->in, "QEMU_ALSA_ADC_"); + handle_alsa_per_direction(aopt->out, "QEMU_ALSA_DAC_"); + + get_millis_to_usecs("QEMU_ALSA_THRESHOLD", + &aopt->threshold, &aopt->has_threshold); +} =20 /* general */ static void handle_per_direction( @@ -123,6 +196,15 @@ static AudiodevListEntry *legacy_opt(const char *drvna= me) get_int("QEMU_AUDIO_TIMER_PERIOD", &e->dev->timer_period, &e->dev->has_timer_period); =20 + switch (e->dev->driver) { + case AUDIODEV_DRIVER_ALSA: + handle_alsa(e->dev); + break; + + default: + break; + } + return e; } =20 --=20 2.20.1 From nobody Mon May 6 19:52:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15520847819164.181846085271445; Fri, 8 Mar 2019 14:39:41 -0800 (PST) Received: from localhost ([127.0.0.1]:50812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O9O-0002us-Ol for importer@patchew.org; Fri, 08 Mar 2019 17:39:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38623) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O4a-0007fK-SZ for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2O4Z-0002cf-6U for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:36 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:33442) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2O4Y-0002bz-UT for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:35 -0500 Received: by mail-wm1-x333.google.com with SMTP id c13so9858830wmb.0 for ; Fri, 08 Mar 2019 14:34:34 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6af5-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6af5::5]) by smtp.gmail.com with ESMTPSA id v2sm15269144wme.29.2019.03.08.14.34.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:34:33 -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=HfT1Bgu3ouHsEn6l184HjHFtxbgdO6RCgXDiiibth5k=; b=bheKu8yBr9zq2Hq3YVEtQXrcDWWXP6bqlcjQBCc248UT8yDjaHdQV8XBbIuAkVp/VD l/uG34BO6/iq+erV1e1czgSupj+W/eBOd2LCJ9G8aq0DkJO6FY5/EvKKzdM6ghSsYPEo ewuOrHAzSUlVCJk+ySy4lNqXXaaTNSg4MR5IhVfG7ACx3pLZ4hinsKSZUdHjj7eYJ7/o VTjuxArmvG76ol68/AmJ5Mbuxzna2dOhcyOF0YQqAHllS/1rb0BWAvKGZPERexiCC8JF PiPbJIE4zJhue8VIriUePfF+OEaSBAmuw6IrWISbZuA9s7DxAId1c5fryxwoV/FecDvS 5ZIg== 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=HfT1Bgu3ouHsEn6l184HjHFtxbgdO6RCgXDiiibth5k=; b=bpD0ULIxJkXolOQULvtr3akaVECDCm1g6gd9OiLO9R+qjxmsKR/9zVUlsim1GCglgw Hx1l9V9SYHBsRZVjVPvgDFP827HgbnGHwycNKrPkfyc4428nK0wK8762CrKCpvpUTx2m FYGn8nm6A59tml4hU5CgX1W/99lcoceQ0y9oDDWTD7P4AaefBO4XvFcZeYWOWbx+khsK x7KSQWAjrEdO473Pi0HWheidtKP9Hg/sqSM/h6GcJNT/dhJCSRgpo/BFkHuo4+AGM/TL xi48OWgEFXrNnubE5OTJmpfiVAa16fTvyWZnmsMDVPESkWZ/I1Y3nrL9V53Svkj9oAoA /xeQ== X-Gm-Message-State: APjAAAX21AKzFy7u3dYpKlYwzItPQqt2GCOg+AV7LjDJpOxNibny45tA zOiIIhAdxg9VqX3b0gTEmGMIkbrkVb4= X-Google-Smtp-Source: APXvYqyHe3aIX14+AC8lj5Bm1Z6z23RoR7ntZTbGSkjkqNncIcdzKCpiWssqv1lxsalPB4UlGAKjlA== X-Received: by 2002:a1c:2407:: with SMTP id k7mr10357768wmk.137.1552084473586; Fri, 08 Mar 2019 14:34:33 -0800 (PST) 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, 8 Mar 2019 23:34:17 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 Subject: [Qemu-devel] [PATCH v6 06/14] coreaudio: port to -audiodev config 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio_legacy.c | 28 +++++++++++++++++++++++++ audio/coreaudio.c | 49 ++++++++++---------------------------------- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index f58c8b6aee..5f557a2de9 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -109,6 +109,17 @@ static uint32_t frames_to_usecs(uint32_t frames, return (frames * 1000000 + freq / 2) / freq; } =20 + +static void get_frames_to_usecs(const char *env, uint32_t *dst, bool *has_= dst, + AudiodevPerDirectionOptions *pdo) +{ + const char *val =3D getenv(env); + if (val) { + *dst =3D frames_to_usecs(toui32(val), pdo); + *has_dst =3D true; + } +} + /* backend specific functions */ /* ALSA */ static void handle_alsa_per_direction( @@ -156,6 +167,19 @@ static void handle_alsa(Audiodev *dev) &aopt->threshold, &aopt->has_threshold); } =20 +/* coreaudio */ +static void handle_coreaudio(Audiodev *dev) +{ + get_frames_to_usecs( + "QEMU_COREAUDIO_BUFFER_SIZE", + &dev->u.coreaudio.out->buffer_length, + &dev->u.coreaudio.out->has_buffer_length, + qapi_AudiodevCoreaudioPerDirectionOptions_base(dev->u.coreaudio.ou= t)); + get_int("QEMU_COREAUDIO_BUFFER_COUNT", + &dev->u.coreaudio.out->buffer_count, + &dev->u.coreaudio.out->has_buffer_count); +} + /* general */ static void handle_per_direction( AudiodevPerDirectionOptions *pdo, const char *prefix) @@ -201,6 +225,10 @@ static AudiodevListEntry *legacy_opt(const char *drvna= me) handle_alsa(e->dev); break; =20 + case AUDIODEV_DRIVER_COREAUDIO: + handle_coreaudio(e->dev); + break; + default: break; } diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 7d4225dbee..1ee43b7d5f 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -36,11 +36,6 @@ #define MAC_OS_X_VERSION_10_6 1060 #endif =20 -typedef struct { - int buffer_frames; - int nbuffers; -} CoreaudioConf; - typedef struct coreaudioVoiceOut { HWVoiceOut hw; pthread_mutex_t mutex; @@ -507,7 +502,9 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct au= dsettings *as, int err; const char *typ =3D "playback"; AudioValueRange frameRange; - CoreaudioConf *conf =3D drv_opaque; + Audiodev *dev =3D drv_opaque; + AudiodevCoreaudioPerDirectionOptions *cpdo =3D dev->u.coreaudio.out; + int frames; =20 /* create mutex */ err =3D pthread_mutex_init(&core->mutex, NULL); @@ -538,16 +535,17 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct = audsettings *as, return -1; } =20 - if (frameRange.mMinimum > conf->buffer_frames) { + frames =3D audio_buffer_frames( + qapi_AudiodevCoreaudioPerDirectionOptions_base(cpdo), as, 11610); + if (frameRange.mMinimum > frames) { core->audioDevicePropertyBufferFrameSize =3D (UInt32) frameRange.m= Minimum; dolog ("warning: Upsizing Buffer Frames to %f\n", frameRange.mMini= mum); - } - else if (frameRange.mMaximum < conf->buffer_frames) { + } else if (frameRange.mMaximum < frames) { core->audioDevicePropertyBufferFrameSize =3D (UInt32) frameRange.m= Maximum; dolog ("warning: Downsizing Buffer Frames to %f\n", frameRange.mMa= ximum); } else { - core->audioDevicePropertyBufferFrameSize =3D conf->buffer_frames; + core->audioDevicePropertyBufferFrameSize =3D frames; } =20 /* set Buffer Frame Size */ @@ -568,7 +566,8 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct au= dsettings *as, "Could not get device buffer frame size\n"); return -1; } - hw->samples =3D conf->nbuffers * core->audioDevicePropertyBufferFrameS= ize; + hw->samples =3D (cpdo->has_buffer_count ? cpdo->buffer_count : 4) * + core->audioDevicePropertyBufferFrameSize; =20 /* get StreamFormat */ status =3D coreaudio_get_streamformat(core->outputDeviceID, @@ -680,40 +679,15 @@ static int coreaudio_ctl_out (HWVoiceOut *hw, int cmd= , ...) return 0; } =20 -static CoreaudioConf glob_conf =3D { - .buffer_frames =3D 512, - .nbuffers =3D 4, -}; - static void *coreaudio_audio_init(Audiodev *dev) { - CoreaudioConf *conf =3D g_malloc(sizeof(CoreaudioConf)); - *conf =3D glob_conf; - - return conf; + return dev; } =20 static void coreaudio_audio_fini (void *opaque) { - g_free(opaque); } =20 -static struct audio_option coreaudio_options[] =3D { - { - .name =3D "BUFFER_SIZE", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.buffer_frames, - .descr =3D "Size of the buffer in frames" - }, - { - .name =3D "BUFFER_COUNT", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.nbuffers, - .descr =3D "Number of buffers" - }, - { /* End of list */ } -}; - static struct audio_pcm_ops coreaudio_pcm_ops =3D { .init_out =3D coreaudio_init_out, .fini_out =3D coreaudio_fini_out, @@ -725,7 +699,6 @@ static struct audio_pcm_ops coreaudio_pcm_ops =3D { static struct audio_driver coreaudio_audio_driver =3D { .name =3D "coreaudio", .descr =3D "CoreAudio http://developer.apple.com/audio/coreau= dio.html", - .options =3D coreaudio_options, .init =3D coreaudio_audio_init, .fini =3D coreaudio_audio_fini, .pcm_ops =3D &coreaudio_pcm_ops, --=20 2.20.1 From nobody Mon May 6 19:52:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552084612089802.6273713009908; Fri, 8 Mar 2019 14:36:52 -0800 (PST) Received: from localhost ([127.0.0.1]:50792 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O6h-0000fP-Eq for importer@patchew.org; Fri, 08 Mar 2019 17:36:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O4b-0007gT-Ui for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2O4a-0002d3-1a for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:37 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:42059) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2O4Z-0002cZ-NG for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:35 -0500 Received: by mail-wr1-x444.google.com with SMTP id r5so22945253wrg.9 for ; Fri, 08 Mar 2019 14:34:35 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6af5-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6af5::5]) by smtp.gmail.com with ESMTPSA id v2sm15269144wme.29.2019.03.08.14.34.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:34:33 -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=upAIWK4HpknTDa6MGpUiQ4bcMsJrKVDOA6/LZSFF8vM=; b=Ko/plJj1PsjsDXGKOyId+O26b6qavP7MkLS3M3opQzwMQ2blZM0EIRyvUYSnVuvHPq YnbdewjaxI6Lekig5SK2SXvCNogLdhF4iGvi2XbXiFW/R09O8hCs7tm0qrU6Wxm0/KlU ngbYrCn3XE+X0Rfp0SYeBo9AfOUmoOvI7cuEiedDHklEmamKW7kamjrmkq23kdaIPjG0 SNWlLo5OhD5G9rIZ8u8IpSHaMeCbykk6w37sMYkQ0WprJLI18iXvTUNeHun2aIOwnZQF MAxje41SpCp4PFVRkvFmd3YwFfGVL/L7AZNS+V6C4D6fW7mJTKCDDD+0ojI1/svdNeID cpGA== 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=upAIWK4HpknTDa6MGpUiQ4bcMsJrKVDOA6/LZSFF8vM=; b=CjYsGsrNGVoq6Vk+uXkwN5pYsvwvUaVVFCRi1VU0qfzzg4DcQdRG/igij+uhYLs4lI Ax2FK2JbKh8UQqkza6g7clwQhZ9xPCRwq1Q9+ZiJuy61IGD7CA+rwVc6lPDM5gCtNMci cWw6qxopbPUltFWBctZs7HoIQ5yFaDBurfIwwJo+yAMK27QJrehYBuWhWbGgGFa3DSuV p4IxakzKf9CiHk5li4C9EdP210ttf/J2Eh/p4Muf+i//pnxKNZxYIBUQrL/saIaXhfbo pB8zye7eCdrWWKlbtNEQMle1QHmLlWs7zBQblg1cVsly7f3vLdf7uSNmvagYr+EKtniN 4rEg== X-Gm-Message-State: APjAAAWYexpn5pRrXtStKPLzQKk+d7o7K9vN/Hl/tviHb2PAwEEYo29O S/pr8Zr/bSaZejJmAK/jSwiH7yND9KI= X-Google-Smtp-Source: APXvYqzkwCXpW434LT6HZzlFOAG/ioCGEDs3OlhedhtjUVALtWvHh+zUVOHR46Ppe8uq5zRMyFQA9Q== X-Received: by 2002:adf:f08b:: with SMTP id n11mr13096868wro.182.1552084474434; Fri, 08 Mar 2019 14:34:34 -0800 (PST) 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, 8 Mar 2019 23:34:18 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v6 07/14] dsoundaudio: port to -audiodev config 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/dsound_template.h | 6 ++--- audio/audio_legacy.c | 43 ++++++++++++++++++++++++++++++ audio/dsoundaudio.c | 59 ++++++++++++----------------------------- 3 files changed, 63 insertions(+), 45 deletions(-) diff --git a/audio/dsound_template.h b/audio/dsound_template.h index b439f33f58..8ece870c9e 100644 --- a/audio/dsound_template.h +++ b/audio/dsound_template.h @@ -167,17 +167,18 @@ static int dsound_init_out(HWVoiceOut *hw, struct aud= settings *as, dsound *s =3D drv_opaque; WAVEFORMATEX wfx; struct audsettings obt_as; - DSoundConf *conf =3D &s->conf; #ifdef DSBTYPE_IN const char *typ =3D "ADC"; DSoundVoiceIn *ds =3D (DSoundVoiceIn *) hw; DSCBUFFERDESC bd; DSCBCAPS bc; + AudiodevPerDirectionOptions *pdo =3D s->dev->u.dsound.in; #else const char *typ =3D "DAC"; DSoundVoiceOut *ds =3D (DSoundVoiceOut *) hw; DSBUFFERDESC bd; DSBCAPS bc; + AudiodevPerDirectionOptions *pdo =3D s->dev->u.dsound.out; #endif =20 if (!s->FIELD2) { @@ -193,8 +194,8 @@ static int dsound_init_out(HWVoiceOut *hw, struct audse= ttings *as, memset (&bd, 0, sizeof (bd)); bd.dwSize =3D sizeof (bd); bd.lpwfxFormat =3D &wfx; + bd.dwBufferBytes =3D audio_buffer_bytes(pdo, as, 92880); #ifdef DSBTYPE_IN - bd.dwBufferBytes =3D conf->bufsize_in; hr =3D IDirectSoundCapture_CreateCaptureBuffer ( s->dsound_capture, &bd, @@ -203,7 +204,6 @@ static int dsound_init_out(HWVoiceOut *hw, struct audse= ttings *as, ); #else bd.dwFlags =3D DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2; - bd.dwBufferBytes =3D conf->bufsize_out; hr =3D IDirectSound_CreateSoundBuffer ( s->dsound, &bd, diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index 5f557a2de9..bf326bd360 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -120,6 +120,30 @@ static void get_frames_to_usecs(const char *env, uint3= 2_t *dst, bool *has_dst, } } =20 +static uint32_t samples_to_usecs(uint32_t samples, + AudiodevPerDirectionOptions *pdo) +{ + uint32_t channels =3D 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 =3D pdo->has_format ? pdo->format : AUDIO_FORMAT_S16; + uint32_t bytes_per_sample =3D 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_d= st, + AudiodevPerDirectionOptions *pdo) +{ + const char *val =3D getenv(env); + if (val) { + *dst =3D bytes_to_usecs(toui32(val), pdo); + *has_dst =3D true; + } +} + /* backend specific functions */ /* ALSA */ static void handle_alsa_per_direction( @@ -180,6 +204,21 @@ static void handle_coreaudio(Audiodev *dev) &dev->u.coreaudio.out->has_buffer_count); } =20 +/* 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->u.dsound.out->buffer_length, + &dev->u.dsound.out->has_buffer_length, + dev->u.dsound.out); + get_bytes_to_usecs("QEMU_DSOUND_BUFSIZE_IN", + &dev->u.dsound.in->buffer_length, + &dev->u.dsound.in->has_buffer_length, + dev->u.dsound.in); +} + /* general */ static void handle_per_direction( AudiodevPerDirectionOptions *pdo, const char *prefix) @@ -229,6 +268,10 @@ static AudiodevListEntry *legacy_opt(const char *drvna= me) handle_coreaudio(e->dev); break; =20 + case AUDIODEV_DRIVER_DSOUND: + handle_dsound(e->dev); + break; + default: break; } diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 02fe777cba..a7d04b5033 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -32,6 +32,7 @@ =20 #define AUDIO_CAP "dsound" #include "audio_int.h" +#include "qemu/host-utils.h" =20 #include #include @@ -42,17 +43,11 @@ =20 /* #define DEBUG_DSOUND */ =20 -typedef struct { - int bufsize_in; - int bufsize_out; - int latency_millis; -} DSoundConf; - typedef struct { LPDIRECTSOUND dsound; LPDIRECTSOUNDCAPTURE dsound_capture; struct audsettings settings; - DSoundConf conf; + Audiodev *dev; } dsound; =20 typedef struct { @@ -248,9 +243,9 @@ static void GCC_FMT_ATTR (3, 4) dsound_logerr2 ( dsound_log_hresult (hr); } =20 -static DWORD millis_to_bytes (struct audio_pcm_info *info, DWORD millis) +static uint64_t usecs_to_bytes(struct audio_pcm_info *info, uint32_t usecs) { - return (millis * info->bytes_per_second) / 1000; + return muldiv64(usecs, info->bytes_per_second, 1000000); } =20 #ifdef DEBUG_DSOUND @@ -478,7 +473,7 @@ static int dsound_run_out (HWVoiceOut *hw, int live) LPVOID p1, p2; int bufsize; dsound *s =3D ds->s; - DSoundConf *conf =3D &s->conf; + AudiodevDsoundOptions *dso =3D &s->dev->u.dsound; =20 if (!dsb) { dolog ("Attempt to run empty with playback buffer\n"); @@ -501,14 +496,14 @@ static int dsound_run_out (HWVoiceOut *hw, int live) len =3D live << hwshift; =20 if (ds->first_time) { - if (conf->latency_millis) { + if (dso->latency) { DWORD cur_blat; =20 cur_blat =3D audio_ring_dist (wpos, ppos, bufsize); ds->first_time =3D 0; old_pos =3D wpos; old_pos +=3D - millis_to_bytes (&hw->info, conf->latency_millis) - cur_bl= at; + usecs_to_bytes(&hw->info, dso->latency) - cur_blat; old_pos %=3D bufsize; old_pos &=3D ~hw->info.align; } @@ -747,12 +742,6 @@ static int dsound_run_in (HWVoiceIn *hw) return decr; } =20 -static DSoundConf glob_conf =3D { - .bufsize_in =3D 16384, - .bufsize_out =3D 16384, - .latency_millis =3D 10 -}; - static void dsound_audio_fini (void *opaque) { HRESULT hr; @@ -788,8 +777,17 @@ static void *dsound_audio_init(Audiodev *dev) int err; HRESULT hr; dsound *s =3D g_malloc0(sizeof(dsound)); + AudiodevDsoundOptions *dso; + + assert(dev->driver =3D=3D AUDIODEV_DRIVER_DSOUND); + s->dev =3D dev; + dso =3D &dev->u.dsound; + + if (!dso->has_latency) { + dso->has_latency =3D true; + dso->latency =3D 10000; /* 10 ms */ + } =20 - s->conf =3D glob_conf; hr =3D CoInitialize (NULL); if (FAILED (hr)) { dsound_logerr (hr, "Could not initialize COM\n"); @@ -854,28 +852,6 @@ static void *dsound_audio_init(Audiodev *dev) return s; } =20 -static struct audio_option dsound_options[] =3D { - { - .name =3D "LATENCY_MILLIS", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.latency_millis, - .descr =3D "(undocumented)" - }, - { - .name =3D "BUFSIZE_OUT", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.bufsize_out, - .descr =3D "(undocumented)" - }, - { - .name =3D "BUFSIZE_IN", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.bufsize_in, - .descr =3D "(undocumented)" - }, - { /* End of list */ } -}; - static struct audio_pcm_ops dsound_pcm_ops =3D { .init_out =3D dsound_init_out, .fini_out =3D dsound_fini_out, @@ -893,7 +869,6 @@ static struct audio_pcm_ops dsound_pcm_ops =3D { static struct audio_driver dsound_audio_driver =3D { .name =3D "dsound", .descr =3D "DirectSound http://wikipedia.org/wiki/DirectSound= ", - .options =3D dsound_options, .init =3D dsound_audio_init, .fini =3D dsound_audio_fini, .pcm_ops =3D &dsound_pcm_ops, --=20 2.20.1 From nobody Mon May 6 19:52:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552084827029780.30416941364; Fri, 8 Mar 2019 14:40:27 -0800 (PST) Received: from localhost ([127.0.0.1]:50818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2OAB-0003nX-GQ for importer@patchew.org; Fri, 08 Mar 2019 17:40:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38647) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O4b-0007gY-VV for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2O4b-0002de-21 for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:37 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:42057) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2O4a-0002cw-Rd for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:36 -0500 Received: by mail-wr1-x441.google.com with SMTP id r5so22945289wrg.9 for ; Fri, 08 Mar 2019 14:34:36 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6af5-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6af5::5]) by smtp.gmail.com with ESMTPSA id v2sm15269144wme.29.2019.03.08.14.34.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:34:34 -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=5xK9dVHrb98gQfhXePE10y7ks65rcNRmc5Tmv6NvGfs=; b=EXk5EZCyNPho4IVGkn5hWr0+cbazv/X/iBcEKzwiS1ekInW5cKxmMWlTHQPD+AbG0y FB3padGxqS3JM/afwbQka3QrvlQqN15Nm37+ypFeHqfmVqFwMVPkt5ThoOzCggAijWF1 6Ual4rzTe0G9EQ/gXaBSNHMkO/4T6Wtr/5GDGFeJs6oGrMdavvbvy+2/BJtMRmRlLmCa g8FS4Mw0A2GWDI5XMGeUaDp6EHpEg/bJAD92BElLEYCXoKdNwXHw6hWyBFNYtirtfHGl +eePCnxPLiMEVpgge8QeC2CA++WHN7ImX5m9AinHqMaBPpNDSXrmLvMp8bq1rnXf2LCa ut0A== 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=5xK9dVHrb98gQfhXePE10y7ks65rcNRmc5Tmv6NvGfs=; b=YxLeBbNKRxlpm7uDRTH46Q2zHTmdR0yNvmcKneHDGyUJD78CWOy1eUBSAZb2aDkf7B wO0YM1RGqwWcqC0kp/5Nzud4U9d5Gom+pIKeumbRsQg46egZSFz0xNpT46fy2Jb7tWp3 KXm74jlC8Mgm7Cg05Zrz5IA12hdgQWWOk3E87tmLzDp4nIz6LGNSfvgRxZbnDMOmULXo GbmHWkOd5gUJGPRFuLJRJ9kac3vxgNFYiJFKbpeubdMki3uaeOaX7+f6z4KETZpQTRTV KjYBHV67/MoXpGCReHRKE3U0+ZV+oL3s09TjX+38kUOmoqa5nvcG0Zb7THE5IJFfgdlu 6yqg== X-Gm-Message-State: APjAAAW7Eb4uNvuagqBgp/lgPXD1MXaDtIfArKvjTvG6FOfvJSSj0vvD 1ukPFUiFw00FWmoRye7zQZiPd80LmwE= X-Google-Smtp-Source: APXvYqyGLpm5i875PrMp9tmCp9ZgIItU5c3sbN6A4aA5hduIvvNGHg4S4g/X5Xd6tkHmZZVm+4r4Qw== X-Received: by 2002:a5d:4a05:: with SMTP id m5mr13195630wrq.46.1552084475229; Fri, 08 Mar 2019 14:34:35 -0800 (PST) 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, 8 Mar 2019 23:34:19 +0100 Message-Id: <0c35b1956ed1105244309a774c038816c040108c.1552083282.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH v6 08/14] noaudio: port to -audiodev config 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/noaudio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/audio/noaudio.c b/audio/noaudio.c index 79690af1ea..ccc611fc84 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -163,7 +163,6 @@ static struct audio_pcm_ops no_pcm_ops =3D { static struct audio_driver no_audio_driver =3D { .name =3D "none", .descr =3D "Timer based audio emulation", - .options =3D NULL, .init =3D no_audio_init, .fini =3D no_audio_fini, .pcm_ops =3D &no_pcm_ops, --=20 2.20.1 From nobody Mon May 6 19:52:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155208478381010.02458834925767; Fri, 8 Mar 2019 14:39:43 -0800 (PST) Received: from localhost ([127.0.0.1]:50814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O9U-000345-Mm for importer@patchew.org; Fri, 08 Mar 2019 17:39:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O4f-0007j6-Ne for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2O4d-0002fO-S9 for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:41 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:33277) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2O4b-0002dR-Tv for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:39 -0500 Received: by mail-wr1-x434.google.com with SMTP id i12so22952151wrw.0 for ; Fri, 08 Mar 2019 14:34:37 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6af5-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6af5::5]) by smtp.gmail.com with ESMTPSA id v2sm15269144wme.29.2019.03.08.14.34.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:34:35 -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=wL9qTYgqg+FdujEdXe048mK5nC93eTfwsf6oTUFI/Jg=; b=nzEVm4osDj4KlVRYZ1nzgyk2TMjXHbI26UY0yX2EcyrsJIFioeDCbT4bXnXwwfxN2D im5bvjzOpnvsFk8ntjXTSAvLEmLfOSq2kPMe6dCJRJ8ZM14+Z3fHUZwW0MhtFwbd6BjP ZgQHz3+L+oeO6cN7PUsdbU35IvR190eyK9C7l8MQy2MKWdiFiGUKojmb9prwttECjqGo gyq1zI+ZoAD7xlEKvIbVVdeyK2Lr/1K8SHPOGC4/Ta0Jt5upBBF2uI25qSopey8Pzjqn 4V+XPunepfYP5fc9wElZoPywkYDAoLsDeR8uwBPtYFvhXrFXk8F1L8lPP/x5NZFWH4Cw CbNQ== 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=wL9qTYgqg+FdujEdXe048mK5nC93eTfwsf6oTUFI/Jg=; b=JJ3cJMHFRI+ByaxUOIlSqlvKc4M99TvXRrOdnPyFxB0ySJH62WPp/CC+ZxkSHjEMky K5mh5v5RmHmnjBdOiY2VAyq09Qy/kUG9vdfM1slxWx5V+7uqoJQUzIsUQ/NKaU+C8OID 6+/ngFxPlQCK0ebKh6NJLgKxjD8VXoF1DjGa7EO+sMhz3KDuMeTnZoFaSU/X6GD+penZ MP06JWQal64SDV/eSdy7Lt4khN9CKeRBeDjaodXMv0wrHrwbfb0g8UcUkiLBC96tc13x r/2IKj0iRzV2qLyRgr2B2kGwj1cy24vRfqYW5Zx6gaRwj6HXNvj7rgdW1qgJuJJnZWvl DeXA== X-Gm-Message-State: APjAAAVhX+S7ajEDAvsctKgq+eWWgx9+MIFnKoyweb2KfqpyIcXfSmuL pndddEaQoRBr4SuJDGhuWTmywI37Nms= X-Google-Smtp-Source: APXvYqyP5pbHn8tiyPmuJ20Q/ppTpdvC7x7neDygl6fSR0EHnd75BB9caQnRFrmzPF73gCzRPF1mpw== X-Received: by 2002:adf:f011:: with SMTP id j17mr12806092wro.166.1552084476019; Fri, 08 Mar 2019 14:34:36 -0800 (PST) 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, 8 Mar 2019 23:34:20 +0100 Message-Id: <31c899f2f78e40fbc01f563ee4829c98debb68db.1552083282.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::434 Subject: [Qemu-devel] [PATCH v6 09/14] ossaudio: port to -audiodev config 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio_legacy.c | 32 +++++++++ audio/ossaudio.c | 161 ++++++++++++++----------------------------- 2 files changed, 83 insertions(+), 110 deletions(-) diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index bf326bd360..94f95bbc73 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -219,6 +219,34 @@ static void handle_dsound(Audiodev *dev) dev->u.dsound.in); } =20 +/* OSS */ +static void handle_oss_per_direction( + AudiodevOssPerDirectionOptions *opdo, const char *try_poll_env, + const char *dev_env) +{ + 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", + &opdo->buffer_length, &opdo->has_buffer_length, + qapi_AudiodevOssPerDirectionOptions_base(opdo)); + get_int("QEMU_OSS_NFRAGS", &opdo->buffer_count, + &opdo->has_buffer_count); +} + +static void handle_oss(Audiodev *dev) +{ + AudiodevOssOptions *oopt =3D &dev->u.oss; + handle_oss_per_direction(oopt->in, "QEMU_AUDIO_ADC_TRY_POLL", + "QEMU_OSS_ADC_DEV"); + handle_oss_per_direction(oopt->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) @@ -272,6 +300,10 @@ static AudiodevListEntry *legacy_opt(const char *drvna= me) handle_dsound(e->dev); break; =20 + case AUDIODEV_DRIVER_OSS: + handle_oss(e->dev); + break; + default: break; } diff --git a/audio/ossaudio.c b/audio/ossaudio.c index e0cadbef29..fc28981a39 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -37,16 +37,6 @@ #define USE_DSP_POLICY #endif =20 -typedef struct OSSConf { - int try_mmap; - int nfrags; - int fragsize; - const char *devpath_out; - const char *devpath_in; - int exclusive; - int policy; -} OSSConf; - typedef struct OSSVoiceOut { HWVoiceOut hw; void *pcm_buf; @@ -56,7 +46,7 @@ typedef struct OSSVoiceOut { int fragsize; int mmapped; int pending; - OSSConf *conf; + Audiodev *dev; } OSSVoiceOut; =20 typedef struct OSSVoiceIn { @@ -65,12 +55,12 @@ typedef struct OSSVoiceIn { int fd; int nfrags; int fragsize; - OSSConf *conf; + Audiodev *dev; } OSSVoiceIn; =20 struct oss_params { int freq; - AudioFormat fmt; + int fmt; int nchannels; int nfrags; int fragsize; @@ -262,19 +252,25 @@ static int oss_get_version (int fd, int *version, con= st char *typ) } #endif =20 -static int oss_open (int in, struct oss_params *req, - struct oss_params *obt, int *pfd, OSSConf* conf) +static int oss_open(int in, struct oss_params *req, audsettings *as, + struct oss_params *obt, int *pfd, Audiodev *dev) { + AudiodevOssOptions *oopts =3D &dev->u.oss; + AudiodevOssPerDirectionOptions *opdo =3D in ? oopts->in : oopts->out; int fd; - int oflags =3D conf->exclusive ? O_EXCL : 0; + int oflags =3D (oopts->has_exclusive && oopts->exclusive) ? O_EXCL : 0; audio_buf_info abinfo; int fmt, freq, nchannels; int setfragment =3D 1; - const char *dspname =3D in ? conf->devpath_in : conf->devpath_out; + const char *dspname =3D opdo->has_dev ? opdo->dev : "/dev/dsp"; const char *typ =3D in ? "ADC" : "DAC"; +#ifdef USE_DSP_POLICY + int policy =3D oopts->has_dsp_policy ? oopts->dsp_policy : 5; +#endif =20 /* Kludge needed to have working mmap on Linux */ - oflags |=3D conf->try_mmap ? O_RDWR : (in ? O_RDONLY : O_WRONLY); + oflags |=3D (oopts->has_try_mmap && oopts->try_mmap) ? + O_RDWR : (in ? O_RDONLY : O_WRONLY); =20 fd =3D open (dspname, oflags | O_NONBLOCK); if (-1 =3D=3D fd) { @@ -285,6 +281,9 @@ static int oss_open (int in, struct oss_params *req, freq =3D req->freq; nchannels =3D req->nchannels; fmt =3D req->fmt; + req->nfrags =3D opdo->has_buffer_count ? opdo->buffer_count : 4; + req->fragsize =3D audio_buffer_bytes( + qapi_AudiodevOssPerDirectionOptions_base(opdo), as, 23220); =20 if (ioctl (fd, SNDCTL_DSP_SAMPLESIZE, &fmt)) { oss_logerr2 (errno, typ, "Failed to set sample size %d\n", req->fm= t); @@ -308,18 +307,18 @@ static int oss_open (int in, struct oss_params *req, } =20 #ifdef USE_DSP_POLICY - if (conf->policy >=3D 0) { + if (policy >=3D 0) { int version; =20 if (!oss_get_version (fd, &version, typ)) { trace_oss_version(version); =20 if (version >=3D 0x040000) { - int policy =3D conf->policy; - if (ioctl (fd, SNDCTL_DSP_POLICY, &policy)) { + int policy2 =3D policy; + if (ioctl(fd, SNDCTL_DSP_POLICY, &policy2)) { oss_logerr2 (errno, typ, "Failed to set timing policy to %d\n", - conf->policy); + policy); goto err; } setfragment =3D 0; @@ -502,17 +501,16 @@ static int oss_init_out(HWVoiceOut *hw, struct audset= tings *as, int fd; AudioFormat effective_fmt; struct audsettings obt_as; - OSSConf *conf =3D drv_opaque; + Audiodev *dev =3D drv_opaque; + AudiodevOssOptions *oopts =3D &dev->u.oss; =20 oss->fd =3D -1; =20 req.fmt =3D aud_to_ossfmt (as->fmt, as->endianness); req.freq =3D as->freq; req.nchannels =3D as->nchannels; - req.fragsize =3D conf->fragsize; - req.nfrags =3D conf->nfrags; =20 - if (oss_open (0, &req, &obt, &fd, conf)) { + if (oss_open(0, &req, as, &obt, &fd, dev)) { return -1; } =20 @@ -539,7 +537,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, hw->samples =3D (obt.nfrags * obt.fragsize) >> hw->info.shift; =20 oss->mmapped =3D 0; - if (conf->try_mmap) { + if (oopts->has_try_mmap && oopts->try_mmap) { oss->pcm_buf =3D mmap ( NULL, hw->samples << hw->info.shift, @@ -597,7 +595,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, } =20 oss->fd =3D fd; - oss->conf =3D conf; + oss->dev =3D dev; return 0; } =20 @@ -605,16 +603,12 @@ static int oss_ctl_out (HWVoiceOut *hw, int cmd, ...) { int trig; OSSVoiceOut *oss =3D (OSSVoiceOut *) hw; + AudiodevOssPerDirectionOptions *opdo =3D oss->dev->u.oss.out; =20 switch (cmd) { case VOICE_ENABLE: { - va_list ap; - int poll_mode; - - va_start (ap, cmd); - poll_mode =3D va_arg (ap, int); - va_end (ap); + bool poll_mode =3D opdo->try_poll; =20 ldebug ("enabling voice\n"); if (poll_mode) { @@ -669,16 +663,14 @@ static int oss_init_in(HWVoiceIn *hw, struct audsetti= ngs *as, void *drv_opaque) int fd; AudioFormat effective_fmt; struct audsettings obt_as; - OSSConf *conf =3D drv_opaque; + Audiodev *dev =3D drv_opaque; =20 oss->fd =3D -1; =20 req.fmt =3D aud_to_ossfmt (as->fmt, as->endianness); req.freq =3D as->freq; req.nchannels =3D as->nchannels; - req.fragsize =3D conf->fragsize; - req.nfrags =3D conf->nfrags; - if (oss_open (1, &req, &obt, &fd, conf)) { + if (oss_open(1, &req, as, &obt, &fd, dev)) { return -1; } =20 @@ -712,7 +704,7 @@ static int oss_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) } =20 oss->fd =3D fd; - oss->conf =3D conf; + oss->dev =3D dev; return 0; } =20 @@ -803,16 +795,12 @@ static int oss_read (SWVoiceIn *sw, void *buf, int si= ze) static int oss_ctl_in (HWVoiceIn *hw, int cmd, ...) { OSSVoiceIn *oss =3D (OSSVoiceIn *) hw; + AudiodevOssPerDirectionOptions *opdo =3D oss->dev->u.oss.out; =20 switch (cmd) { case VOICE_ENABLE: { - va_list ap; - int poll_mode; - - va_start (ap, cmd); - poll_mode =3D va_arg (ap, int); - va_end (ap); + bool poll_mode =3D opdo->try_poll; =20 if (poll_mode) { oss_poll_in (hw); @@ -832,82 +820,36 @@ static int oss_ctl_in (HWVoiceIn *hw, int cmd, ...) return 0; } =20 -static OSSConf glob_conf =3D { - .try_mmap =3D 0, - .nfrags =3D 4, - .fragsize =3D 4096, - .devpath_out =3D "/dev/dsp", - .devpath_in =3D "/dev/dsp", - .exclusive =3D 0, - .policy =3D 5 -}; +static void oss_init_per_direction(AudiodevOssPerDirectionOptions *opdo) +{ + if (!opdo->has_try_poll) { + opdo->try_poll =3D true; + opdo->has_try_poll =3D true; + } +} =20 static void *oss_audio_init(Audiodev *dev) { - OSSConf *conf =3D g_malloc(sizeof(OSSConf)); - *conf =3D glob_conf; + AudiodevOssOptions *oopts; + assert(dev->driver =3D=3D AUDIODEV_DRIVER_OSS); =20 - if (access(conf->devpath_in, R_OK | W_OK) < 0 || - access(conf->devpath_out, R_OK | W_OK) < 0) { - g_free(conf); + oopts =3D &dev->u.oss; + oss_init_per_direction(oopts->in); + oss_init_per_direction(oopts->out); + + if (access(oopts->in->has_dev ? oopts->in->dev : "/dev/dsp", + R_OK | W_OK) < 0 || + access(oopts->out->has_dev ? oopts->out->dev : "/dev/dsp", + R_OK | W_OK) < 0) { return NULL; } - return conf; + return dev; } =20 static void oss_audio_fini (void *opaque) { - g_free(opaque); } =20 -static struct audio_option oss_options[] =3D { - { - .name =3D "FRAGSIZE", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.fragsize, - .descr =3D "Fragment size in bytes" - }, - { - .name =3D "NFRAGS", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.nfrags, - .descr =3D "Number of fragments" - }, - { - .name =3D "MMAP", - .tag =3D AUD_OPT_BOOL, - .valp =3D &glob_conf.try_mmap, - .descr =3D "Try using memory mapped access" - }, - { - .name =3D "DAC_DEV", - .tag =3D AUD_OPT_STR, - .valp =3D &glob_conf.devpath_out, - .descr =3D "Path to DAC device" - }, - { - .name =3D "ADC_DEV", - .tag =3D AUD_OPT_STR, - .valp =3D &glob_conf.devpath_in, - .descr =3D "Path to ADC device" - }, - { - .name =3D "EXCLUSIVE", - .tag =3D AUD_OPT_BOOL, - .valp =3D &glob_conf.exclusive, - .descr =3D "Open device in exclusive mode (vmix won't work)" - }, -#ifdef USE_DSP_POLICY - { - .name =3D "POLICY", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.policy, - .descr =3D "Set the timing policy of the device, -1 to use fragmen= t mode", - }, -#endif - { /* End of list */ } -}; - static struct audio_pcm_ops oss_pcm_ops =3D { .init_out =3D oss_init_out, .fini_out =3D oss_fini_out, @@ -925,7 +867,6 @@ static struct audio_pcm_ops oss_pcm_ops =3D { static struct audio_driver oss_audio_driver =3D { .name =3D "oss", .descr =3D "OSS http://www.opensound.com", - .options =3D oss_options, .init =3D oss_audio_init, .fini =3D oss_audio_fini, .pcm_ops =3D &oss_pcm_ops, --=20 2.20.1 From nobody Mon May 6 19:52:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552084964149878.5725129142979; Fri, 8 Mar 2019 14:42:44 -0800 (PST) Received: from localhost ([127.0.0.1]:50878 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2OCL-0005oQ-MP for importer@patchew.org; Fri, 08 Mar 2019 17:42:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O4k-0007p0-I6 for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2O4h-0002hG-KO for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:45 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:43740) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2O4d-0002dx-PO for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:41 -0500 Received: by mail-wr1-x42e.google.com with SMTP id d17so22954997wre.10 for ; Fri, 08 Mar 2019 14:34:38 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6af5-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6af5::5]) by smtp.gmail.com with ESMTPSA id v2sm15269144wme.29.2019.03.08.14.34.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:34:36 -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=mW8o2Rq41gYXbKgsxduviwlZXpzRXTaOF/sHELm/hlo=; b=Uf+QtYhcm/rp7zJFDYQWJ627Fqc/Uk2OJ4XMeitgyEk2NqJQEHk9y40vAVXHVlMxHY WTacjKZhECqnQmScreXztQVh4/GRf30BGm+z1AVuq9Tu8wAuovOThnW7EoK9Ydj8/VyG IM7vm8Uu143Hydzsg3qHmaQapcaxYwWKM8KE1HuztGl7vEPfKzSg8CQGPP1lpgPYjDlD iIHocrGZ16uE/080wQUsiIYbAlctXIqFeBxQtMIj65e85o6yw6IoNO45VyIX5shkI4Q5 rd3Kw5fehM6LG8PdDcEURMod3rxr+o/oqz9bk2WZ+eP6L6e5X2nnvXZ4rWTPyEvFD9am 65Zw== 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=mW8o2Rq41gYXbKgsxduviwlZXpzRXTaOF/sHELm/hlo=; b=SJprypTkiKlFQzznr+nmA7GytsL+2GrhcAtJcZ4BCiNAMYVikdHOvkAot/spShRG8E TDtpbmes+IYm/Xe/C24qRR4lYS/HwSlKGXGQ5mtZkhYwLYp/vaUEbciiFvpUwle80DC2 HJnYYWvp+PFJ7iPixlCFTLpIKmU7TmkRWS5wC1njYvegSKZfxS8Bh1ebKT39uVzoo/eR tao/ra4XEct5KHtzRfuS4167kpCdBMkgiJTGT5erQwHVbixKYHLLYvLT6chtFMIFgCHR Vzn8CDYmixSh6OVR8nmLaB6ng0Tt2ucZTKD5Ci8QgSl6UBwryyby9u485x2X4qcwri6c bMEQ== X-Gm-Message-State: APjAAAU67JGMkMZdk3fvk49jZ/T5XlgdTolZFed9Bjsex1ffUh+8QLoZ H5VQhciSgCfj/NmRhuKK8LotF9CskLo= X-Google-Smtp-Source: APXvYqxHb0TxIcvn6rKaskMuYy8YvdTtJO9NMSizPzGNwGXg3hoWEDO1sM449s2AODP8EqIGoE4Wkw== X-Received: by 2002:a05:6000:124a:: with SMTP id j10mr12197703wrx.26.1552084476869; Fri, 08 Mar 2019 14:34:36 -0800 (PST) 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, 8 Mar 2019 23:34:21 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e Subject: [Qemu-devel] [PATCH v6 10/14] paaudio: port to -audiodev config 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio_legacy.c | 38 +++++++++++++++++++++ audio/paaudio.c | 81 ++++++++++++++++---------------------------- 2 files changed, 67 insertions(+), 52 deletions(-) diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index 94f95bbc73..8d7f1475b5 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -127,6 +127,16 @@ static uint32_t samples_to_usecs(uint32_t samples, return frames_to_usecs(samples / channels, pdo); } =20 +static void get_samples_to_usecs(const char *env, uint32_t *dst, bool *has= _dst, + AudiodevPerDirectionOptions *pdo) +{ + const char *val =3D getenv(env); + if (val) { + *dst =3D samples_to_usecs(toui32(val), pdo); + *has_dst =3D true; + } +} + static uint32_t bytes_to_usecs(uint32_t bytes, AudiodevPerDirectionOptions= *pdo) { AudioFormat fmt =3D pdo->has_format ? pdo->format : AUDIO_FORMAT_S16; @@ -247,6 +257,30 @@ static void handle_oss(Audiodev *dev) get_int("QEMU_OSS_POLICY", &oopt->dsp_policy, &oopt->has_dsp_policy); } =20 +/* pulseaudio */ +static void handle_pa_per_direction( + AudiodevPaPerDirectionOptions *ppdo, const char *env) +{ + get_str(env, &ppdo->name, &ppdo->has_name); +} + +static void handle_pa(Audiodev *dev) +{ + handle_pa_per_direction(dev->u.pa.in, "QEMU_PA_SOURCE"); + handle_pa_per_direction(dev->u.pa.out, "QEMU_PA_SINK"); + + get_samples_to_usecs( + "QEMU_PA_SAMPLES", &dev->u.pa.in->buffer_length, + &dev->u.pa.in->has_buffer_length, + qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.in)); + get_samples_to_usecs( + "QEMU_PA_SAMPLES", &dev->u.pa.out->buffer_length, + &dev->u.pa.out->has_buffer_length, + qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.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) @@ -304,6 +338,10 @@ static AudiodevListEntry *legacy_opt(const char *drvna= me) handle_oss(e->dev); break; =20 + case AUDIODEV_DRIVER_PA: + handle_pa(e->dev); + break; + default: break; } diff --git a/audio/paaudio.c b/audio/paaudio.c index d649c58e3d..5d410ed73f 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -2,6 +2,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "audio.h" +#include "qapi/opts-visitor.h" =20 #include =20 @@ -10,14 +11,7 @@ #include "audio_pt_int.h" =20 typedef struct { - int samples; - char *server; - char *sink; - char *source; -} PAConf; - -typedef struct { - PAConf conf; + Audiodev *dev; pa_threaded_mainloop *mainloop; pa_context *context; } paaudio; @@ -32,6 +26,7 @@ typedef struct { void *pcm_buf; struct audio_pt pt; paaudio *g; + int samples; } PAVoiceOut; =20 typedef struct { @@ -46,6 +41,7 @@ typedef struct { const void *read_data; size_t read_index, read_length; paaudio *g; + int samples; } PAVoiceIn; =20 static void qpa_audio_fini(void *opaque); @@ -227,7 +223,7 @@ static void *qpa_thread_out (void *arg) } } =20 - decr =3D to_mix =3D audio_MIN(pa->live, pa->g->conf.samples >> 5); + decr =3D to_mix =3D audio_MIN(pa->live, pa->samples >> 5); rpos =3D pa->rpos; =20 if (audio_pt_unlock(&pa->pt, __func__)) { @@ -319,7 +315,7 @@ static void *qpa_thread_in (void *arg) } } =20 - incr =3D to_grab =3D audio_MIN(pa->dead, pa->g->conf.samples >> 5); + incr =3D to_grab =3D audio_MIN(pa->dead, pa->samples >> 5); wpos =3D pa->wpos; =20 if (audio_pt_unlock(&pa->pt, __func__)) { @@ -546,6 +542,8 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, struct audsettings obt_as =3D *as; PAVoiceOut *pa =3D (PAVoiceOut *) hw; paaudio *g =3D pa->g =3D drv_opaque; + AudiodevPaOptions *popts =3D &g->dev->u.pa; + AudiodevPaPerDirectionOptions *ppdo =3D popts->out; =20 ss.format =3D audfmt_to_pa (as->fmt, as->endianness); ss.channels =3D as->nchannels; @@ -566,7 +564,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, g, "qemu", PA_STREAM_PLAYBACK, - g->conf.sink, + ppdo->has_name ? ppdo->name : NULL, &ss, NULL, /* channel map */ &ba, /* buffering attributes */ @@ -578,7 +576,8 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, } =20 audio_pcm_init_info (&hw->info, &obt_as); - hw->samples =3D g->conf.samples; + hw->samples =3D pa->samples =3D audio_buffer_samples( + qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, 46440); pa->pcm_buf =3D audio_calloc(__func__, hw->samples, 1 << hw->info.shif= t); pa->rpos =3D hw->rpos; if (!pa->pcm_buf) { @@ -612,6 +611,8 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) struct audsettings obt_as =3D *as; PAVoiceIn *pa =3D (PAVoiceIn *) hw; paaudio *g =3D pa->g =3D drv_opaque; + AudiodevPaOptions *popts =3D &g->dev->u.pa; + AudiodevPaPerDirectionOptions *ppdo =3D popts->in; =20 ss.format =3D audfmt_to_pa (as->fmt, as->endianness); ss.channels =3D as->nchannels; @@ -623,7 +624,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) g, "qemu", PA_STREAM_RECORD, - g->conf.source, + ppdo->has_name ? ppdo->name : NULL, &ss, NULL, /* channel map */ NULL, /* buffering attributes */ @@ -635,7 +636,8 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) } =20 audio_pcm_init_info (&hw->info, &obt_as); - hw->samples =3D g->conf.samples; + hw->samples =3D pa->samples =3D audio_buffer_samples( + qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, 46440); pa->pcm_buf =3D audio_calloc(__func__, hw->samples, 1 << hw->info.shif= t); pa->wpos =3D hw->wpos; if (!pa->pcm_buf) { @@ -808,13 +810,13 @@ static int qpa_ctl_in (HWVoiceIn *hw, int cmd, ...) } =20 /* common */ -static PAConf glob_conf =3D { - .samples =3D 4096, -}; - static void *qpa_audio_init(Audiodev *dev) { - if (glob_conf.server =3D=3D NULL) { + paaudio *g; + AudiodevPaOptions *popts =3D &dev->u.pa; + const char *server; + + if (!popts->has_server) { char pidfile[64]; char *runtime; struct stat st; @@ -829,8 +831,12 @@ static void *qpa_audio_init(Audiodev *dev) } } =20 - paaudio *g =3D g_malloc(sizeof(paaudio)); - g->conf =3D glob_conf; + assert(dev->driver =3D=3D AUDIODEV_DRIVER_PA); + + g =3D g_malloc(sizeof(paaudio)); + server =3D popts->has_server ? popts->server : NULL; + + g->dev =3D dev; g->mainloop =3D NULL; g->context =3D NULL; =20 @@ -840,14 +846,14 @@ static void *qpa_audio_init(Audiodev *dev) } =20 g->context =3D pa_context_new (pa_threaded_mainloop_get_api (g->mainlo= op), - g->conf.server); + server); if (!g->context) { goto fail; } =20 pa_context_set_state_callback (g->context, context_state_cb, g); =20 - if (pa_context_connect (g->context, g->conf.server, 0, NULL) < 0) { + if (pa_context_connect(g->context, server, 0, NULL) < 0) { qpa_logerr (pa_context_errno (g->context), "pa_context_connect() failed\n"); goto fail; @@ -910,34 +916,6 @@ static void qpa_audio_fini (void *opaque) g_free(g); } =20 -struct audio_option qpa_options[] =3D { - { - .name =3D "SAMPLES", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.samples, - .descr =3D "buffer size in samples" - }, - { - .name =3D "SERVER", - .tag =3D AUD_OPT_STR, - .valp =3D &glob_conf.server, - .descr =3D "server address" - }, - { - .name =3D "SINK", - .tag =3D AUD_OPT_STR, - .valp =3D &glob_conf.sink, - .descr =3D "sink device name" - }, - { - .name =3D "SOURCE", - .tag =3D AUD_OPT_STR, - .valp =3D &glob_conf.source, - .descr =3D "source device name" - }, - { /* End of list */ } -}; - static struct audio_pcm_ops qpa_pcm_ops =3D { .init_out =3D qpa_init_out, .fini_out =3D qpa_fini_out, @@ -955,7 +933,6 @@ static struct audio_pcm_ops qpa_pcm_ops =3D { static struct audio_driver pa_audio_driver =3D { .name =3D "pa", .descr =3D "http://www.pulseaudio.org/", - .options =3D qpa_options, .init =3D qpa_audio_init, .fini =3D qpa_audio_fini, .pcm_ops =3D &qpa_pcm_ops, --=20 2.20.1 From nobody Mon May 6 19:52:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552085091605520.1122934303194; Fri, 8 Mar 2019 14:44:51 -0800 (PST) Received: from localhost ([127.0.0.1]:50901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2OEU-0007yB-Kl for importer@patchew.org; Fri, 08 Mar 2019 17:44:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O4h-0007lV-L5 for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2O4f-0002gB-O6 for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:43 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:38359) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2O4d-0002eb-Qq for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:40 -0500 Received: by mail-wr1-x444.google.com with SMTP id g12so22947698wrm.5 for ; Fri, 08 Mar 2019 14:34:38 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6af5-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6af5::5]) by smtp.gmail.com with ESMTPSA id v2sm15269144wme.29.2019.03.08.14.34.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:34:37 -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=m3RSlMV5oUljuFlOQoyWqtjNmJ2slIs3aaMjFOehxJ4=; b=teFF2G8auRzeOpuHyCGOdX12EyxjGMEXCttS3+gsLkcUcR8i3M+RSzr/WC1P5h1zgv 2rIRxPPgNJ4dfjLgmxescvZxZrcM3JVENyinIvvc+KQtkvdPAn8XMr1i8jQrNBndIbef RIda9qsPrAghArLnsbyeNylOpER2YQtzc1MlwP6EHoqD1wWrf1VC+ZOYj9rEuZNP2voW WY59kbKauW/B568Sod1sh9pASkJE8C8mBFFXm7YrmjOhoGOUtD0KnDWZKhp0U+5ChZiS LvCm8NpYW1uvAOWMWXPW3ndFvj4TZSeDvKsT6YNk0JutaJA3avPQbUVFrBenKsdRB9Yg kXVg== 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=m3RSlMV5oUljuFlOQoyWqtjNmJ2slIs3aaMjFOehxJ4=; b=PDE7YmNdhrSQXJX4E3HQa78bA9qMw5ndbVWg+TyYIMVO9HChJ74i30jXrprsPVyJZa 2m8S9+EbmNWpJPW1gRxkAh1AA4cjfz3RntW2RoCX29x6fdYyKIj3KyKYcN7kdbal1dD7 hZ0aXcN+Avsp+YwPJgC24mAYKFYvo/TJZ46QvkEWUT2yHUFNK2294wcRQ21oUFHqSgD/ wectHldpb0GOTIBMTvOYFGynkBAvzbNYCV+25HEueVupCdtumMtz33WupNLB+XSHG4bt X3i94m7cF+FbvgEgw/OAsJ9lG0br7d/mLSHy9aL0lgWFaycM6nK4TfVo26k3rBAbjs9i PsdQ== X-Gm-Message-State: APjAAAUC6rQYZ4YPFrm6bZNPZh2uqhXdF9Jq+P0dFwyEob83XG7CFOUf vdssrq0CslZNqb2ZJRLgGLr9/7njZb4= X-Google-Smtp-Source: APXvYqzt71Wy+Rgtir1ggSyKmLEkZbkYbwnLmBwHTdBck6TDfk7JXewS+CyO/ppIji6GxMIeqi2qGQ== X-Received: by 2002:a5d:4090:: with SMTP id o16mr12219733wrp.208.1552084477851; Fri, 08 Mar 2019 14:34:37 -0800 (PST) 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, 8 Mar 2019 23:34:22 +0100 Message-Id: <1dc596cba39378df862582a0b952e497a16c6c31.1552083282.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 v6 11/14] sdlaudio: port to -audiodev config 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio_legacy.c | 12 ++++++++++++ audio/sdlaudio.c | 22 ++++------------------ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index 8d7f1475b5..478cf76d5f 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -281,6 +281,14 @@ static void handle_pa(Audiodev *dev) get_str("QEMU_PA_SERVER", &dev->u.pa.server, &dev->u.pa.has_server); } =20 +/* SDL */ +static void handle_sdl(Audiodev *dev) +{ + /* SDL is output only */ + get_samples_to_usecs("QEMU_SDL_SAMPLES", &dev->u.sdl.out->buffer_lengt= h, + &dev->u.sdl.out->has_buffer_length, dev->u.sdl.ou= t); +} + /* general */ static void handle_per_direction( AudiodevPerDirectionOptions *pdo, const char *prefix) @@ -342,6 +350,10 @@ static AudiodevListEntry *legacy_opt(const char *drvna= me) handle_pa(e->dev); break; =20 + case AUDIODEV_DRIVER_SDL: + handle_sdl(e->dev); + break; + default: break; } diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index b9ae506a56..ff9248ba68 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -44,16 +44,11 @@ typedef struct SDLVoiceOut { int decr; } SDLVoiceOut; =20 -static struct { - int nb_samples; -} conf =3D { - .nb_samples =3D 1024 -}; - static struct SDLAudioState { int exit; int initialized; bool driver_created; + Audiodev *dev; } glob_sdl; typedef struct SDLAudioState SDLAudioState; =20 @@ -271,7 +266,7 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, req.freq =3D as->freq; req.format =3D aud_to_sdlfmt (as->fmt); req.channels =3D as->nchannels; - req.samples =3D conf.nb_samples; + req.samples =3D audio_buffer_samples(s->dev->u.sdl.out, as, 11610); req.callback =3D sdl_callback; req.userdata =3D sdl; =20 @@ -329,6 +324,7 @@ static void *sdl_audio_init(Audiodev *dev) } =20 s->driver_created =3D true; + s->dev =3D dev; return s; } =20 @@ -338,18 +334,9 @@ static void sdl_audio_fini (void *opaque) sdl_close (s); SDL_QuitSubSystem (SDL_INIT_AUDIO); s->driver_created =3D false; + s->dev =3D NULL; } =20 -static struct audio_option sdl_options[] =3D { - { - .name =3D "SAMPLES", - .tag =3D AUD_OPT_INT, - .valp =3D &conf.nb_samples, - .descr =3D "Size of SDL buffer in samples" - }, - { /* End of list */ } -}; - static struct audio_pcm_ops sdl_pcm_ops =3D { .init_out =3D sdl_init_out, .fini_out =3D sdl_fini_out, @@ -361,7 +348,6 @@ static struct audio_pcm_ops sdl_pcm_ops =3D { static struct audio_driver sdl_audio_driver =3D { .name =3D "sdl", .descr =3D "SDL http://www.libsdl.org", - .options =3D sdl_options, .init =3D sdl_audio_init, .fini =3D sdl_audio_fini, .pcm_ops =3D &sdl_pcm_ops, --=20 2.20.1 From nobody Mon May 6 19:52:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552085108286749.9193510414689; Fri, 8 Mar 2019 14:45:08 -0800 (PST) Received: from localhost ([127.0.0.1]:50917 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2OEj-0008CD-9F for importer@patchew.org; Fri, 08 Mar 2019 17:45:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O4l-0007rh-D0 for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2O4j-0002hx-H9 for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:46 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:36550) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2O4f-0002f4-Lu for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:43 -0500 Received: by mail-wr1-x443.google.com with SMTP id o17so22975255wrw.3 for ; Fri, 08 Mar 2019 14:34:39 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6af5-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6af5::5]) by smtp.gmail.com with ESMTPSA id v2sm15269144wme.29.2019.03.08.14.34.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:34:38 -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=gFlI6J52EuSN1uBwYtC2z1Nd0p5GKE1yjn2uKwH4Jm0=; b=tap+59zBCHJzrZnPxlQNOe0ZQOwtezhYBoqmpy9oa7PTrcmrlDF6P2sM1h7x1Svo5Z rtvcV82ogyw63IxWdZ/uslUBoUCAryPmG4jzYyvK1Nql4WQpZPWdCJ8sotgEAPYcRqyG FHQjtg5pqF9XwasTE4avW326aPbJDbLm2Cxlw08LJoyHnxYhoj/mlHtNQbRO5ZeBDmvd xVpXvQAbhYvVMBX3wdBQxQ26SZWwpnyUO6biNoAZyeN+ggttBcg75NzPZL1DN6GJSXjE axuLRfIZ5qkKPWP+AoT5wNuvO1DyGoCngvtnJ0HOgkgFzwJtdt4UKBOdumio0Q3qVrdQ Bd0Q== 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=gFlI6J52EuSN1uBwYtC2z1Nd0p5GKE1yjn2uKwH4Jm0=; b=ctPe2XkN2PnH+E/7zJpsXfF55Rfz/6ob5GZn9ctNTG89U59BCyp9PXgjV/2Hlt58YQ QXt3Pyo2JzYtENiUzAdEPjbaRqKbKd4mlhETQJCN1sWbwwyOX3lzD21JeepZB/UDibLi lWtUdfUXY85mbP6dgeHPPPbXMlS1J9EjhrLwMTWG//VlYPQs3H7eYJK+goB5x8tlX14t N6dlHM0n4bFIxrEWKpjQOD4CCxE7I6V767Sf7zoJQHeacdrPKzsSCxxQG8J10QjcvlGj SAuTMq6uX+Icab1dCmTVdIHdHEdX8cBcX6HNGAsTfvL5FCQaMdAUiTziQ7eycekf5W9/ dQxA== X-Gm-Message-State: APjAAAVbXGqwW/LGCvGzILxNh04eO0Ybz+kmWSCa7UBghS7cfiBz4K9y nc4MR/JQp6ywiAwkrBtoG4xRMkuslVs= X-Google-Smtp-Source: APXvYqxotsvz4l8xSAtRAdL+9ce7NNHBaGR6tPs6SjwyIZhLKuvF3U+5XFVKJIvU+FGYM4NSOIjNNA== X-Received: by 2002:adf:f805:: with SMTP id s5mr12560293wrp.234.1552084478627; Fri, 08 Mar 2019 14:34:38 -0800 (PST) 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, 8 Mar 2019 23:34:23 +0100 Message-Id: <040d1241f29104ecfeecb26b0a14f0d042484fc5.1552083282.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PATCH v6 12/14] spiceaudio: port to -audiodev config 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/spiceaudio.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index affc3df17f..4f7873af5a 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -373,10 +373,6 @@ static int line_in_ctl (HWVoiceIn *hw, int cmd, ...) return 0; } =20 -static struct audio_option audio_options[] =3D { - { /* end of list */ }, -}; - static struct audio_pcm_ops audio_callbacks =3D { .init_out =3D line_out_init, .fini_out =3D line_out_fini, @@ -394,7 +390,6 @@ static struct audio_pcm_ops audio_callbacks =3D { static struct audio_driver spice_audio_driver =3D { .name =3D "spice", .descr =3D "spice audio driver", - .options =3D audio_options, .init =3D spice_audio_init, .fini =3D spice_audio_fini, .pcm_ops =3D &audio_callbacks, --=20 2.20.1 From nobody Mon May 6 19:52:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552084995119199.98066589664813; Fri, 8 Mar 2019 14:43:15 -0800 (PST) Received: from localhost ([127.0.0.1]:50880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2OCt-0006Gy-1r for importer@patchew.org; Fri, 08 Mar 2019 17:43:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O4n-0007tk-Bv for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2O4l-0002kH-Cx for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:49 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:40452) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2O4j-0002fU-0s for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:45 -0500 Received: by mail-wm1-x344.google.com with SMTP id g20so13550299wmh.5 for ; Fri, 08 Mar 2019 14:34:40 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6af5-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6af5::5]) by smtp.gmail.com with ESMTPSA id v2sm15269144wme.29.2019.03.08.14.34.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:34:38 -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=T/f3yy5NiF0gGZ1FUW51aSoR7kMwsD4w88l5wdMBSws=; b=oO/0j8C+o1TxlNY/T6JYgYcvVom6UOhe0MAF3hHrJU2BW/toi/yrefCVgyMJ8/OIo4 zcKkuFQLTT2NCJdhXyzvSoS7RTXbSkqt6KWmY4MUvfCpeOdDpCm4sqj0B+K8t5AbhbUM bXlENBpqT2vHA5SYFfDcvg3T450ixZuL8ijbmDnyXRx46yWCCxqihTWWbyLcB+QUnsXr zkETxUg7uylvxI5dI4sHVsrKF9/uVQH2vu0fGz/JrK0H1ZhXFvzuE7SWU+5naDQPm84M 7m5Z/uyt6QEWD8YFK5OTIM8bZmacaN9XCCYihJxCWuGiERKgRFa3ojQHZAiEVZ1B2OZ0 exVg== 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=T/f3yy5NiF0gGZ1FUW51aSoR7kMwsD4w88l5wdMBSws=; b=QflTUVNj+DYUTV/x9/IuZNE3YUF1yFedXe1tpxmLKjA3o9Op5eptJ4EbmwJC0o1YMp 0l6V+S/bQdoz2deCqA9Io3LbciLxLfwZHttc3RnVFZft7mqWu3m2bZ7mRsWvgkld3Qi2 un2j4r5+jjjg0JnhwmD5Off2O3TLidG95TwE2ORDVjuVn1XzDoqvgBJle5dEUqos6mNf 4K7WHAnP2hDb1shi1swcZ+/Tp04Etv3VrPGodwDMMulcSbLhQdkIm3LQdRnwlF9yXD0C SuD6zMECffyBQR6wAEQSHMeUjTcRcW86lElwdHSPDAwnFe/ZLhqxuQmPR89atsn/OOVW o55Q== X-Gm-Message-State: APjAAAWjMBSCd5dYHKuPnMyIW/pJip6La9Q9GHS08SnxYPRBkygJCBgn MF8Vg39gMUsuuHvnAW1D/wGVRy1BDVg= X-Google-Smtp-Source: APXvYqwCFqEGYYFuVSBpU6NyQjtgke43YxkI2iH7m2YNtIZvXSTG6KbtyrVOOELHpGV1FWSFKCxD/A== X-Received: by 2002:a7b:c7da:: with SMTP id z26mr10661290wmk.151.1552084479352; Fri, 08 Mar 2019 14:34:39 -0800 (PST) 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, 8 Mar 2019 23:34:24 +0100 Message-Id: <28c2bf374c447c20937a192695c7b9f5367dea7e.1552083282.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PATCH v6 13/14] wavaudio: port to -audiodev config 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio_legacy.c | 16 ++++++++++++ audio/wavaudio.c | 58 +++++++------------------------------------- 2 files changed, 25 insertions(+), 49 deletions(-) diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index 478cf76d5f..6d140119d9 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -289,6 +289,18 @@ static void handle_sdl(Audiodev *dev) &dev->u.sdl.out->has_buffer_length, dev->u.sdl.ou= t); } =20 +/* wav */ +static void handle_wav(Audiodev *dev) +{ + get_int("QEMU_WAV_FREQUENCY", + &dev->u.wav.out->frequency, &dev->u.wav.out->has_frequency); + get_fmt("QEMU_WAV_FORMAT", &dev->u.wav.out->format, + &dev->u.wav.out->has_format); + get_int("QEMU_WAV_DAC_FIXED_CHANNELS", + &dev->u.wav.out->channels, &dev->u.wav.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) @@ -354,6 +366,10 @@ static AudiodevListEntry *legacy_opt(const char *drvna= me) handle_sdl(e->dev); break; =20 + case AUDIODEV_DRIVER_WAV: + handle_wav(e->dev); + break; + default: break; } diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 9eff3555b3..8d30f57296 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -24,6 +24,7 @@ #include "qemu/osdep.h" #include "qemu/host-utils.h" #include "qemu/timer.h" +#include "qapi/opts-visitor.h" #include "audio.h" =20 #define AUDIO_CAP "wav" @@ -37,11 +38,6 @@ typedef struct WAVVoiceOut { int total_samples; } WAVVoiceOut; =20 -typedef struct { - struct audsettings settings; - const char *wav_path; -} WAVConf; - static int wav_run_out (HWVoiceOut *hw, int live) { WAVVoiceOut *wav =3D (WAVVoiceOut *) hw; @@ -112,8 +108,10 @@ static int wav_init_out(HWVoiceOut *hw, struct audsett= ings *as, 0x02, 0x00, 0x44, 0xac, 0x00, 0x00, 0x10, 0xb1, 0x02, 0x00, 0x04, 0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x00 }; - WAVConf *conf =3D drv_opaque; - struct audsettings wav_as =3D conf->settings; + Audiodev *dev =3D drv_opaque; + AudiodevWavOptions *wopts =3D &dev->u.wav; + struct audsettings wav_as =3D audiodev_to_audsettings(dev->u.wav.out); + const char *wav_path =3D wopts->has_path ? wopts->path : "qemu.wav"; =20 stereo =3D wav_as.nchannels =3D=3D 2; switch (wav_as.fmt) { @@ -154,10 +152,10 @@ static int wav_init_out(HWVoiceOut *hw, struct audset= tings *as, le_store (hdr + 28, hw->info.freq << (bits16 + stereo), 4); le_store (hdr + 32, 1 << (bits16 + stereo), 2); =20 - wav->f =3D fopen (conf->wav_path, "wb"); + wav->f =3D fopen(wav_path, "wb"); if (!wav->f) { dolog ("Failed to open wave file `%s'\nReason: %s\n", - conf->wav_path, strerror (errno)); + wav_path, strerror(errno)); g_free (wav->pcm_buf); wav->pcm_buf =3D NULL; return -1; @@ -225,54 +223,17 @@ static int wav_ctl_out (HWVoiceOut *hw, int cmd, ...) return 0; } =20 -static WAVConf glob_conf =3D { - .settings.freq =3D 44100, - .settings.nchannels =3D 2, - .settings.fmt =3D AUDIO_FORMAT_S16, - .wav_path =3D "qemu.wav" -}; - static void *wav_audio_init(Audiodev *dev) { - WAVConf *conf =3D g_malloc(sizeof(WAVConf)); - *conf =3D glob_conf; - return conf; + assert(dev->driver =3D=3D AUDIODEV_DRIVER_WAV); + return dev; } =20 static void wav_audio_fini (void *opaque) { ldebug ("wav_fini"); - g_free(opaque); } =20 -static struct audio_option wav_options[] =3D { - { - .name =3D "FREQUENCY", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.settings.freq, - .descr =3D "Frequency" - }, - { - .name =3D "FORMAT", - .tag =3D AUD_OPT_FMT, - .valp =3D &glob_conf.settings.fmt, - .descr =3D "Format" - }, - { - .name =3D "DAC_FIXED_CHANNELS", - .tag =3D AUD_OPT_INT, - .valp =3D &glob_conf.settings.nchannels, - .descr =3D "Number of channels (1 - mono, 2 - stereo)" - }, - { - .name =3D "PATH", - .tag =3D AUD_OPT_STR, - .valp =3D &glob_conf.wav_path, - .descr =3D "Path to wave file" - }, - { /* End of list */ } -}; - static struct audio_pcm_ops wav_pcm_ops =3D { .init_out =3D wav_init_out, .fini_out =3D wav_fini_out, @@ -284,7 +245,6 @@ static struct audio_pcm_ops wav_pcm_ops =3D { static struct audio_driver wav_audio_driver =3D { .name =3D "wav", .descr =3D "WAV renderer http://wikipedia.org/wiki/WAV", - .options =3D wav_options, .init =3D wav_audio_init, .fini =3D wav_audio_fini, .pcm_ops =3D &wav_pcm_ops, --=20 2.20.1 From nobody Mon May 6 19:52:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552085198380742.073503825076; Fri, 8 Mar 2019 14:46:38 -0800 (PST) Received: from localhost ([127.0.0.1]:50965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2OGA-0000qE-D9 for importer@patchew.org; Fri, 08 Mar 2019 17:46:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2O4n-0007tj-Bj for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2O4k-0002j3-Hv for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:49 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:33226) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2O4h-0002fn-IW for qemu-devel@nongnu.org; Fri, 08 Mar 2019 17:34:45 -0500 Received: by mail-wm1-x343.google.com with SMTP id c13so9858973wmb.0 for ; Fri, 08 Mar 2019 14:34:41 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6af5-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6af5::5]) by smtp.gmail.com with ESMTPSA id v2sm15269144wme.29.2019.03.08.14.34.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 14:34:39 -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=wxIu56HmMTAmUDUnm4qtPAz0v2l8dKOwcPabL+bUGBk=; b=IPhhrSnvCTU459IwlSiCPeQsaiA9ODGAlYE5eJjkycM9T53TtBsNwaxtv2ZdObgAyZ mdDzuxWSP/s1wZZY8U6ZiKB0Di3UIp6rsXLFI3YUTccD1vBtn30Yf7iE7/BmE7wE+4wS aqXwHupju2jj03KaIG61puuhbyTubr/yl3ANyTHIyV+EmOPWvolTrUxx6pgNyOtH1LjZ vxKjf6WJoyuv3S0nwV61k6aWKvexSoxA+L6onX3ck1dPBrow6SziaAmuhmyMlSu+W2MA +Cwm/Ub3FU5xxokG2Ookxzga9i0+JQUhGk9YJ70e1Krzb4Z86QnWVy7NLEBhA8l5Q9DI MknA== 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=wxIu56HmMTAmUDUnm4qtPAz0v2l8dKOwcPabL+bUGBk=; b=SGKWKgnFwfqePOWmlfBsMLPIP0g8HW0Pqhu9wQoaVbBYn5lXYcBx2S6OIxoi15DITW SiBTDghY8v9F6Ky5cxQ4drN9rB14wBr4FmqUGQtrfZzrHDTEQAmL1raiizgdxge0jPFX 3L5j97MP51Nkq0EEfpnK5iS5G/gtmItOnto9KllO3Ky3arQRAvZTz0/6MnH1qnEtDdE/ vX/vQnyV8/lDPVZGsNpUsn3aZ0un509CR3S23UmZjp6HGMbjXuLk/KF3+M7GpBPdXUe7 LNJSqCcPMfJJs5yDRyY98NkEQ97u5gKFBQWBOF1HfR4cxohtEkvZKuBCXmB0IAcenlbq 1qmA== X-Gm-Message-State: APjAAAWYc7JLAWisT5JayhPzZmyh9vya10nwYaqi7jPgPG7ixWpf9BWe eidotKNGtE/mVuhcchrCikWR2dScfJM= X-Google-Smtp-Source: APXvYqzFGZZ7CvmoCio77UNeLukQaZzYR3KoSjHfT2MCgMVXVbq/CQpC8Ol5Uqe+kebElsjI245vLw== X-Received: by 2002:a1c:2dc9:: with SMTP id t192mr10149300wmt.119.1552084480148; Fri, 08 Mar 2019 14:34:40 -0800 (PST) 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, 8 Mar 2019 23:34:25 +0100 Message-Id: <82c176a5222a56e4fde45d2b423ada797caddd5d.1552083282.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH v6 14/14] audio: -audiodev command line option: cleanup 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 Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Remove no longer needed code. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio_int.h | 17 ----- audio/audio.c | 186 +--------------------------------------------- 2 files changed, 4 insertions(+), 199 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 7bf5dfc0b5..3f14842709 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -33,22 +33,6 @@ =20 struct audio_pcm_ops; =20 -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; diff --git a/audio/audio.c b/audio/audio.c index 79ed360666..5fd9a58a80 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -172,113 +172,6 @@ void *audio_calloc (const char *funcname, int nmemb, = size_t size) return g_malloc0 (len); } =20 -static const char *audio_audfmt_to_string (AudioFormat fmt) -{ - switch (fmt) { - case AUDIO_FORMAT_U8: - return "U8"; - - case AUDIO_FORMAT_U16: - return "U16"; - - case AUDIO_FORMAT_S8: - return "S8"; - - case AUDIO_FORMAT_S16: - return "S16"; - - case AUDIO_FORMAT_U32: - return "U32"; - - case AUDIO_FORMAT_S32: - return "S32"; - - default: - abort(); - } - - dolog ("Bogus audfmt %d returning S16\n", fmt); - return "S16"; -} - -static AudioFormat audio_string_to_audfmt (const char *s, AudioFormat defv= al, - int *defaultp) -{ - if (!strcasecmp (s, "u8")) { - *defaultp =3D 0; - return AUDIO_FORMAT_U8; - } - else if (!strcasecmp (s, "u16")) { - *defaultp =3D 0; - return AUDIO_FORMAT_U16; - } - else if (!strcasecmp (s, "u32")) { - *defaultp =3D 0; - return AUDIO_FORMAT_U32; - } - else if (!strcasecmp (s, "s8")) { - *defaultp =3D 0; - return AUDIO_FORMAT_S8; - } - else if (!strcasecmp (s, "s16")) { - *defaultp =3D 0; - return AUDIO_FORMAT_S16; - } - else if (!strcasecmp (s, "s32")) { - *defaultp =3D 0; - return AUDIO_FORMAT_S32; - } - else { - dolog ("Bogus audio format `%s' using %s\n", - s, audio_audfmt_to_string (defval)); - *defaultp =3D 1; - return defval; - } -} - -static AudioFormat audio_get_conf_fmt (const char *envname, - AudioFormat defval, - int *defaultp) -{ - const char *var =3D getenv (envname); - if (!var) { - *defaultp =3D 1; - return defval; - } - return audio_string_to_audfmt (var, defval, defaultp); -} - -static int audio_get_conf_int (const char *key, int defval, int *defaultp) -{ - int val; - char *strval; - - strval =3D getenv (key); - if (strval && !qemu_strtoi(strval, NULL, 10, &val)) { - *defaultp =3D 0; - return val; - } - else { - *defaultp =3D 1; - return defval; - } -} - -static const char *audio_get_conf_str (const char *key, - const char *defval, - int *defaultp) -{ - const char *val =3D getenv (key); - if (!val) { - *defaultp =3D 1; - return defval; - } - else { - *defaultp =3D 0; - return val; - } -} - void AUD_vlog (const char *cap, const char *fmt, va_list ap) { if (cap) { @@ -297,74 +190,6 @@ void AUD_log (const char *cap, const char *fmt, ...) va_end (ap); } =20 -static void audio_process_options (const char *prefix, - struct audio_option *opt) -{ - gchar *prefix_upper; - - if (audio_bug(__func__, !prefix)) { - dolog ("prefix =3D NULL\n"); - return; - } - - if (audio_bug(__func__, !opt)) { - dolog ("opt =3D NULL\n"); - return; - } - - prefix_upper =3D g_utf8_strup(prefix, -1); - - for (; opt->name; opt++) { - char *optname; - int def; - - if (!opt->valp) { - dolog ("Option value pointer for `%s' is not set\n", - opt->name); - continue; - } - - optname =3D g_strdup_printf("QEMU_%s_%s", prefix_upper, opt->name); - - def =3D 1; - switch (opt->tag) { - case AUD_OPT_BOOL: - case AUD_OPT_INT: - { - int *intp =3D opt->valp; - *intp =3D audio_get_conf_int (optname, *intp, &def); - } - break; - - case AUD_OPT_FMT: - { - AudioFormat *fmtp =3D opt->valp; - *fmtp =3D audio_get_conf_fmt (optname, *fmtp, &def); - } - break; - - case AUD_OPT_STR: - { - const char **strp =3D opt->valp; - *strp =3D audio_get_conf_str (optname, *strp, &def); - } - break; - - default: - dolog ("Bad value tag for option `%s' - %d\n", - optname, opt->tag); - break; - } - - if (!opt->overriddenp) { - opt->overriddenp =3D &opt->overridden; - } - *opt->overriddenp =3D !def; - g_free (optname); - } - g_free(prefix_upper); -} - static void audio_print_settings (struct audsettings *as) { dolog ("frequency=3D%d nchannels=3D%d fmt=3D", as->freq, as->nchannels= ); @@ -1072,7 +897,7 @@ void AUD_set_active_out (SWVoiceOut *sw, int on) if (!hw->enabled) { hw->enabled =3D 1; if (s->vm_running) { - hw->pcm_ops->ctl_out(hw, VOICE_ENABLE, true); + hw->pcm_ops->ctl_out(hw, VOICE_ENABLE); audio_reset_timer (s); } } @@ -1117,7 +942,7 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) if (!hw->enabled) { hw->enabled =3D 1; if (s->vm_running) { - hw->pcm_ops->ctl_in(hw, VOICE_ENABLE, true); + hw->pcm_ops->ctl_in(hw, VOICE_ENABLE); audio_reset_timer (s); } } @@ -1441,9 +1266,6 @@ void audio_run (const char *msg) static int audio_driver_init(AudioState *s, struct audio_driver *drv, bool msg, Audiodev *dev) { - if (drv->options) { - audio_process_options (drv->name, drv->options); - } s->drv_opaque =3D drv->init(dev); =20 if (s->drv_opaque) { @@ -1470,11 +1292,11 @@ static void audio_vm_change_state_handler (void *op= aque, int running, =20 s->vm_running =3D running; while ((hwo =3D audio_pcm_hw_find_any_enabled_out (hwo))) { - hwo->pcm_ops->ctl_out(hwo, op, true); + hwo->pcm_ops->ctl_out(hwo, op); } =20 while ((hwi =3D audio_pcm_hw_find_any_enabled_in (hwi))) { - hwi->pcm_ops->ctl_in(hwi, op, true); + hwi->pcm_ops->ctl_in(hwi, op); } audio_reset_timer (s); } --=20 2.20.1