From nobody Fri Nov 7 04:15:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545601040838383.00015791975613; Sun, 23 Dec 2018 13:37:20 -0800 (PST) Received: from localhost ([127.0.0.1]:60080 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbBR1-0001tb-6O for importer@patchew.org; Sun, 23 Dec 2018 16:37:19 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbAju-0007ch-A8 for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:52:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gbAjs-00028M-DX for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:52:46 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:43039) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gbAjs-00025J-5I for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:52:44 -0500 Received: by mail-wr1-x444.google.com with SMTP id r10so10087896wrs.10 for ; Sun, 23 Dec 2018 12:52:44 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-24a3-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:24a3::5]) by smtp.gmail.com with ESMTPSA id g198sm25456920wmd.23.2018.12.23.12.52.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Dec 2018 12:52:42 -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=M7msQeFIeK8RPDjcHTtd5tP//OSPSScp7Hf0dkBVVdg=; b=KzLdZA/3G3zEAZQNhrNmyApB6U2fBzvZMMigoArEB/ysisYAzfB+oq6uZrkchByEL/ LI4yauIEliqezN/rbTM5qk8+j58EIufpS02fo/OYsALgwGUMW05t0/pivML0z2YcgTh9 rS3EB4wqz7Zw9ubZmUYPiyCA+68fqR8Qlbgun8NxXBqfZ3GHruuTacVWzeDKjYYh1BcT 3UPbkxA2rz9EymFbhWJtAtMTGhCjS8JUJnn9DY1CVanwZaQIBoTU+NKtWKCLFXy8ylS8 KLY/abezlxrh9sUw/vk7FbLbHjY/vDZayqgS09EM7UNjso0wsnArWExKLSk9siIvyKe8 scSA== 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=M7msQeFIeK8RPDjcHTtd5tP//OSPSScp7Hf0dkBVVdg=; b=lcTOV3nt7c0OzIVL0AWfuSKttaB5bE07KB0IW1sPXdQINWoYGNaMj+rNO7I4lP7wUR 8i4o9x+mUHAi3GI/kFYy9FOMQcWD5JLrYqs/bYwqYUsmCBTqzNjn0kUdObICLho205mK +aDJDiWeb/E5q9VL0LG0R5pUfzOpWpgceheW9dkJ6Vhqu0NeamrHts+wD0Sb8forUcRS QxF9wNnCKMpvvNE/FsZyIlItOh0T4L6nrGULlh8jHfu8UQqYK98g6aki7an6LUBbk/xN r4uj0yHn0t9B5FmfYWNgJVzP3mxUqZzN+x6vD1i3Hrf6BRyjdPhsWSACJDFenK3jopn/ Karw== X-Gm-Message-State: AJcUukdykQHQ3JKecaahBZOlWYTBu7l4ZQJOwFb8OIwBfj0jyozlxC7I OgYuPAv0ZK+21ejqY1aQ4BbCj7rwzqM= X-Google-Smtp-Source: ALg8bN5eUVS2SDnE8Q78oIGSqaNWx++5uIc64R4nyaWsau/T5kpY7vfhV7HrlqaLpWvIJhGYkt98Ig== X-Received: by 2002:a5d:454f:: with SMTP id p15mr10183387wrr.39.1545598362913; Sun, 23 Dec 2018 12:52:42 -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: Sun, 23 Dec 2018 21:51:51 +0100 Message-Id: <801e931cea3505400b3262dc2d170e2ce6dde2fc.1545598229.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 v2 15/52] 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 | 10 ++++++++ audio/wavaudio.c | 58 +++++++------------------------------------- 2 files changed, 19 insertions(+), 49 deletions(-) diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index 6d95b761b8..71bbda04e2 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -110,6 +110,14 @@ SimpleEnvMap sdl_map[] =3D { { /* End of list */ } }; =20 +SimpleEnvMap wav_map[] =3D { + { "QEMU_WAV_FREQUENCY", "out.frequency" }, + { "QEMU_WAV_FORMAT", "out.format", ENV_TRANSFORM_FMT }, + { "QEMU_WAV_DAC_FIXED_CHANNELS", "out.channels" }, + { "QEMU_WAV_PATH", "path" }, + { /* End of list */ } +}; + static unsigned long long toull(const char *str) { unsigned long long ret; @@ -290,6 +298,8 @@ static void legacy_opt(const char *drv) handle_env_opts(opts, pa_map); } else if (strcmp(drv, "sdl") =3D=3D 0) { handle_env_opts(opts, sdl_map); + } else if (strcmp(drv, "wav") =3D=3D 0) { + handle_env_opts(opts, wav_map); } } =20 diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 9eff3555b3..214e30ccd9 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->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