From patchwork Fri Aug 21 15:37:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?B?Wm9sdMOhbiBLxZF2w6Fnw7M=?= X-Patchwork-Id: 509552 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DA4AE140187 for ; Sat, 22 Aug 2015 01:56:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=TnQclvrB; dkim-atps=neutral Received: from localhost ([::1]:42287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSog1-0004Rq-2B for incoming@patchwork.ozlabs.org; Fri, 21 Aug 2015 11:56:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSoOF-0002UD-S0 for qemu-devel@nongnu.org; Fri, 21 Aug 2015 11:38:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZSoOE-000260-H3 for qemu-devel@nongnu.org; Fri, 21 Aug 2015 11:37:59 -0400 Received: from mail-wi0-x22c.google.com ([2a00:1450:400c:c05::22c]:37621) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZSoOE-00025j-7s for qemu-devel@nongnu.org; Fri, 21 Aug 2015 11:37:58 -0400 Received: by widdq5 with SMTP id dq5so19216545wid.0 for ; Fri, 21 Aug 2015 08:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=qzz/VjILhhA+lO9d/KxSvKWAd+RWBilG1EySgPWkzX0=; b=TnQclvrBgvS48E1efsC1S7aM3jto76dL6ahzgM6Z2ZjcIMhCSrxCnITwBnkmWCPig6 9jr2GHS0yiq0a+nxHdbaqSEWoPSURAN4sIf5gsXkBKPC99q2AYMMTiYPqLfkbEptvMZ1 n8mAu5PIv1chNRBhcMVxPAjwc7JClKoAvXq7y7IrwQr91A9tCL8OEuMxMXMQCgWsPMdy /x2nLUw8hqmDRLIeiQWhLnPhucB/U0NV2nL4YTPGMnWguh5HUpBL9RQbPb3A92JWQNfh 5CucMkFq8sUp+drkUhbuGACUy91aFyXzGchuGxCrFiuceZjnPAsyCDy8SzmFSBP2qwIe vHaA== X-Received: by 10.194.62.211 with SMTP id a19mr16035699wjs.126.1440171477627; Fri, 21 Aug 2015 08:37:57 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (178-164-172-216.pool.digikabel.hu. [178.164.172.216]) by smtp.gmail.com with ESMTPSA id v8sm10479895wjr.15.2015.08.21.08.37.56 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Aug 2015 08:37:57 -0700 (PDT) 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, 21 Aug 2015 17:37:17 +0200 Message-Id: X-Mailer: git-send-email 2.5.0 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22c Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH v2 21/49] wavaudio: port to -audiodev config X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Kővágó, Zoltán --- 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 4d8e2b9..2004097 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -105,6 +105,14 @@ SimpleEnvMap sdl_map[] = { { /* End of list */ } }; +SimpleEnvMap wav_map[] = { + { "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; @@ -285,6 +293,8 @@ static void legacy_opt(const char *drv) handle_env_opts(opts, pa_map); } else if (strcmp(drv, "sdl") == 0) { handle_env_opts(opts, sdl_map); + } else if (strcmp(drv, "wav") == 0) { + handle_env_opts(opts, wav_map); } } diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 8b0ba91..1af6d23 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -23,6 +23,7 @@ */ #include "hw/hw.h" #include "qemu/timer.h" +#include "qapi-visit.h" #include "audio.h" #define AUDIO_CAP "wav" @@ -36,11 +37,6 @@ typedef struct WAVVoiceOut { int total_samples; } WAVVoiceOut; -typedef struct { - struct audsettings settings; - const char *wav_path; -} WAVConf; - static int wav_run_out (HWVoiceOut *hw, int live) { WAVVoiceOut *wav = (WAVVoiceOut *) hw; @@ -111,8 +107,10 @@ static int wav_init_out(HWVoiceOut *hw, struct audsettings *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 = drv_opaque; - struct audsettings wav_as = conf->settings; + Audiodev *dev = drv_opaque; + AudiodevWavOptions *wopts = dev->wav; + struct audsettings wav_as = audiodev_to_audsettings(dev->out); + const char *wav_path = wopts->has_path ? wopts->path : "qemu.wav"; stereo = wav_as.nchannels == 2; switch (wav_as.fmt) { @@ -153,10 +151,10 @@ static int wav_init_out(HWVoiceOut *hw, struct audsettings *as, le_store (hdr + 28, hw->info.freq << (bits16 + stereo), 4); le_store (hdr + 32, 1 << (bits16 + stereo), 2); - wav->f = fopen (conf->wav_path, "wb"); + wav->f = 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 = NULL; return -1; @@ -224,54 +222,17 @@ static int wav_ctl_out (HWVoiceOut *hw, int cmd, ...) return 0; } -static WAVConf glob_conf = { - .settings.freq = 44100, - .settings.nchannels = 2, - .settings.fmt = AUDIO_FORMAT_S16, - .wav_path = "qemu.wav" -}; - static void *wav_audio_init(Audiodev *dev) { - WAVConf *conf = g_malloc(sizeof(WAVConf)); - *conf = glob_conf; - return conf; + assert(dev->kind == AUDIODEV_DRIVER_WAV); + return dev; } static void wav_audio_fini (void *opaque) { ldebug ("wav_fini"); - g_free(opaque); } -static struct audio_option wav_options[] = { - { - .name = "FREQUENCY", - .tag = AUD_OPT_INT, - .valp = &glob_conf.settings.freq, - .descr = "Frequency" - }, - { - .name = "FORMAT", - .tag = AUD_OPT_FMT, - .valp = &glob_conf.settings.fmt, - .descr = "Format" - }, - { - .name = "DAC_FIXED_CHANNELS", - .tag = AUD_OPT_INT, - .valp = &glob_conf.settings.nchannels, - .descr = "Number of channels (1 - mono, 2 - stereo)" - }, - { - .name = "PATH", - .tag = AUD_OPT_STR, - .valp = &glob_conf.wav_path, - .descr = "Path to wave file" - }, - { /* End of list */ } -}; - static struct audio_pcm_ops wav_pcm_ops = { .init_out = wav_init_out, .fini_out = wav_fini_out, @@ -283,7 +244,6 @@ static struct audio_pcm_ops wav_pcm_ops = { struct audio_driver wav_audio_driver = { .name = "wav", .descr = "WAV renderer http://wikipedia.org/wiki/WAV", - .options = wav_options, .init = wav_audio_init, .fini = wav_audio_fini, .pcm_ops = &wav_pcm_ops,