From nobody Sun Nov 9 14:50:00 2025 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 1550698817614579.3158282552095; Wed, 20 Feb 2019 13:40:17 -0800 (PST) Received: from localhost ([127.0.0.1]:49240 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwZbB-0007U0-Pd for importer@patchew.org; Wed, 20 Feb 2019 16:40:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwZZ7-0006EB-IM for qemu-devel@nongnu.org; Wed, 20 Feb 2019 16:38:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwZZ5-0000p2-3j for qemu-devel@nongnu.org; Wed, 20 Feb 2019 16:38:05 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:34011) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwZZ4-0000gj-QJ for qemu-devel@nongnu.org; Wed, 20 Feb 2019 16:38:03 -0500 Received: by mail-wr1-x441.google.com with SMTP id f14so27814809wrg.1 for ; Wed, 20 Feb 2019 13:37:58 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-6fd0-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:6fd0::5]) by smtp.gmail.com with ESMTPSA id o18sm66452489wrg.40.2019.02.20.13.37.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Feb 2019 13:37:56 -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=Xw2zsB/X8aeFdPflfIiE8hLCe4+dc+rRCRpEE5v5TWg=; b=KVkvv8E8/JDIt1iKP3+lsbDmOPUcOl9O33PKYdjO8Y+leeDCucOtXIQ8vsC5mIsZnk etoLI6ZkBuDN3hhjRLbqFWC64CM6iIfpOWc26jNMxQplyWSJtVGkIZpqgpmr7SvmHEih x6XyyeR4mmKe6tnVA0nRTFP/NystpM10DCWkcW9m+vLIF+XfAxFsF+RJoaDBMNLaW1Dy 2x6YbP9U44Ct8EmM8sK+58+uKfXEV/06MzXA0B8BVv5smiu8dJV6kiClWXfOhnUWsYwQ CawP5UVXHJ5zXvmu9RmDBSfPh1Y/CplATm047S6Eji8n3l8fFujYIsNYiFpglijnObYT QoDg== 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=Xw2zsB/X8aeFdPflfIiE8hLCe4+dc+rRCRpEE5v5TWg=; b=OmwLRS8h7PRWjGxW2fGyMGpzDlehOITF26X5wqEW4tgn6m9aW3xcM+LweO/4CUYcXb GDGEBmcHV81ipczfO8zF69ku2hhWFE43B5zx4KQoW4Paw4kWIg4trId4XsieWWrRKI5s Zk23qvS331CYB2M8WhAo5jFpzHlsxqnCQAPOoZYJ/y7Hn2MML+wnk2BI4gH2E7AwcChl zZO7mc55JPRLOEfMBvfJyE+VibpBaIAOCOBV9TN1wfTGD8YMbz4n5bbPpjWIQJBLlYS6 Tnm+3HVvxnmDcRU9WtW+N6RMpZiqodpZ67V8kpbAWtWv87pCTPEoyS4orEVsJs7fA2cS ai9Q== X-Gm-Message-State: AHQUAubEH/FbiGqj1JJDQ59XX14/hH8dJ3x5pUC7BtNmj1PDEQHKy7z7 4hYaUS1bsrYqzh1MVBM2KFfhf7ukQXE= X-Google-Smtp-Source: AHgI3IYjEkjgTMrjXfuahoCY2UlaYskoBTBjOtMGYX+fWAJEDwjrwceWQ9p7b5CwAavzvR71exEjvQ== X-Received: by 2002:adf:dd86:: with SMTP id x6mr4359179wrl.250.1550698677398; Wed, 20 Feb 2019 13:37:57 -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: Wed, 20 Feb 2019 22:37:42 +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 v5 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 f730aa5bd6..7347a77922 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -287,6 +287,18 @@ static void handle_sdl(Audiodev *dev) &dev->u.sdl.out->has_buffer_len, dev->u.sdl.out); } =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) @@ -352,6 +364,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