From nobody Fri Nov 7 04:15:01 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 1547682177107514.0067265827505; Wed, 16 Jan 2019 15:42:57 -0800 (PST) Received: from localhost ([127.0.0.1]:60586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjupk-00084P-1n for importer@patchew.org; Wed, 16 Jan 2019 18:42:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjukj-00042Q-80 for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:37:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjukh-0002pL-A1 for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:37:45 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:52847) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gjukf-0002kL-7E for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:37:41 -0500 Received: by mail-wm1-x344.google.com with SMTP id m1so3894011wml.2 for ; Wed, 16 Jan 2019 15:37:38 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-e4b0-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:e4b0::5]) by smtp.gmail.com with ESMTPSA id s66sm30760437wmf.34.2019.01.16.15.37.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 15:37: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=oD+l5pRm3zAapkGSUkdP10UgT9autl9VfiCZsWaNs7Y=; b=lTrumOnSGVG40D2/scxcUkMN4bqSZrGN/xEQP9746uUQCHMa9fE604JnAOqsVDmpYf JvIKB6Nt2n5EEl8pt+HcDX78eQYYEXNuTegtCLTps8GCEwjL4hiO74ee5Oxbws2Px892 /K0Je+O6e1uIjgrz9CJud4q7XoOrbNE02s1oexblMKRhhQCkAcrxx22EI2U+ayHfUAC1 4AMEzFptmKQ/oRqPvKneA0Gossokmk7Ng+TX1nYSP014cOumywd3p+W/otplxGl8Yj4p VeqqMHHVMvM7/lG58poKGwiQpqT5Z1VHfO8kogiI5r9Rfv8WIKMi2+kLEUO4ajiZ7eeV suDA== 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=oD+l5pRm3zAapkGSUkdP10UgT9autl9VfiCZsWaNs7Y=; b=lY1rm6Ag+BHheTMVGy4nZ58y7ISwhg/jVfPkJpPkeLQqX5iYp4c/K7voRLaNtoaggc tY9+kG2T8x0wNqUi2yuSPtfWfY8zU6LYu849EAQG9EW2FBbreV1RfPoEoGlOIU+K0TjN N1qID4QZ3ZpX/NgatGxTUnnmpc2CfkAzECPsGxVmYjUZYVReVN7C/F8frE98B6ii1FFi lnYCD1IKqnB5A1PhBKVMZ6wEJ52MonulA7sA1BRAaZ64OsP5s+9QtWFLZQaOTlkNvJ9r 5LNpPCkAcSYzxbpCf7H3NxDQ7acgxodrmEKex6UrFr5SXUJOLTSKJUwv5Et/MINxRjT3 j7Sg== X-Gm-Message-State: AJcUukcgXp6INJ0Ov/6OHbm248KRwyDj5xLfOtDj67sGosAh9gnTwK9E 4ECKJgAYRMmNtwip6tTRt+uMlEQK9c0= X-Google-Smtp-Source: ALg8bN5CGt4JmQ6c+L72DlG6euDVvwe1ljRJpux6veIMp7ecK2D1uUt07K/gls6unEPVDyvNWPnZ6Q== X-Received: by 2002:a1c:35ca:: with SMTP id c193mr9182159wma.146.1547681857050; Wed, 16 Jan 2019 15:37: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: Thu, 17 Jan 2019 00:36:46 +0100 Message-Id: <1c70f5a379f55049a1d427060ac18171b621cbfc.1547681517.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 v3 13/50] 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 | 15 ++++++++++++ audio/wavaudio.c | 58 +++++++------------------------------------- 2 files changed, 24 insertions(+), 49 deletions(-) diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index aa6c789096..cf0fc4df90 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -293,6 +293,17 @@ static void handle_sdl(Audiodev *dev) &dev->out->has_buffer_len, dev->out); } =20 +/* wav */ +static void handle_wav(Audiodev *dev) +{ + get_int("QEMU_WAV_FREQUENCY", + &dev->out->frequency, &dev->out->has_frequency); + get_fmt("QEMU_WAV_FORMAT", &dev->out->format, &dev->out->has_format); + get_int("QEMU_WAV_DAC_FIXED_CHANNELS", + &dev->out->channels, &dev->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) @@ -360,6 +371,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..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