From patchwork Wed Jun 3 21:03:51 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: 480214 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 1826B140187 for ; Thu, 4 Jun 2015 07:10:09 +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=NlogCgs0; dkim-atps=neutral Received: from localhost ([::1]:38189 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0FvL-0001Mi-3A for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2015 17:10:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0FpP-0007i9-4B for qemu-devel@nongnu.org; Wed, 03 Jun 2015 17:04:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z0FpL-0005hp-U7 for qemu-devel@nongnu.org; Wed, 03 Jun 2015 17:03:59 -0400 Received: from mail-wg0-x236.google.com ([2a00:1450:400c:c00::236]:35927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0FpL-0005hU-OE for qemu-devel@nongnu.org; Wed, 03 Jun 2015 17:03:55 -0400 Received: by wgbgq6 with SMTP id gq6so19144397wgb.3 for ; Wed, 03 Jun 2015 14:03:55 -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=2vw7rI2yvya9ezi4HhGsAMGFUThv5YXkmpgZawRN0ho=; b=NlogCgs0izmrfTmRiViRb7/KQ4xtLj19pdV3aorwg8sYGfTWDl45/DJdg2FXOVwSU4 2uxeC7FxHOeiNxpQgJF7N8ZQ0Up9Mt9oU8HcVIU60khxP5H2+W6FA44Unnxv66/uAhhC WwNKpIEmABZItmbceG88R9QDG8wgWO2C0vFbQ7woh/YE6gnDk0pbJlIcngX+3EUvspvj zbsPXErQviDgWIKmwis8gLGoLbB08ohClRiH1BiZEgJeA7XOeQdMNyeSEOYuDKqVkhOW wuddegLbCIERGjLZc+Luo3YVq167wRXkclxA0IVDWxQ/uwqiSSuskAVhJ8Td0TFsug/e HHdQ== X-Received: by 10.194.248.200 with SMTP id yo8mr4393336wjc.65.1433365435084; Wed, 03 Jun 2015 14:03:55 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (94-21-43-102.pool.digikabel.hu. [94.21.43.102]) by mx.google.com with ESMTPSA id l6sm2727050wjz.4.2015.06.03.14.03.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Jun 2015 14:03:54 -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: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Wed, 3 Jun 2015 23:03:51 +0200 Message-Id: X-Mailer: git-send-email 2.4.2 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:c00::236 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH v3 08/12] wavaudio: do not use global variables 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/wavaudio.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 09083da..c586020 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -36,15 +36,10 @@ typedef struct WAVVoiceOut { int total_samples; } WAVVoiceOut; -static struct { +typedef struct { struct audsettings settings; const char *wav_path; -} conf = { - .settings.freq = 44100, - .settings.nchannels = 2, - .settings.fmt = AUD_FMT_S16, - .wav_path = "qemu.wav" -}; +} WAVConf; static int wav_run_out (HWVoiceOut *hw, int live) { @@ -116,7 +111,8 @@ 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 }; - struct audsettings wav_as = conf.settings; + WAVConf *conf = drv_opaque; + struct audsettings wav_as = conf->settings; stereo = wav_as.nchannels == 2; switch (wav_as.fmt) { @@ -154,10 +150,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 (conf->wav_path, "wb"); if (!wav->f) { dolog ("Failed to open wave file `%s'\nReason: %s\n", - conf.wav_path, strerror (errno)); + conf->wav_path, strerror (errno)); g_free (wav->pcm_buf); wav->pcm_buf = NULL; return -1; @@ -225,40 +221,49 @@ static int wav_ctl_out (HWVoiceOut *hw, int cmd, ...) return 0; } +static WAVConf glob_conf = { + .settings.freq = 44100, + .settings.nchannels = 2, + .settings.fmt = AUD_FMT_S16, + .wav_path = "qemu.wav" +}; + static void *wav_audio_init (void) { - return &conf; + WAVConf *conf = g_malloc(sizeof(WAVConf)); + *conf = glob_conf; + return conf; } static void wav_audio_fini (void *opaque) { - (void) opaque; ldebug ("wav_fini"); + g_free(opaque); } static struct audio_option wav_options[] = { { .name = "FREQUENCY", .tag = AUD_OPT_INT, - .valp = &conf.settings.freq, + .valp = &glob_conf.settings.freq, .descr = "Frequency" }, { .name = "FORMAT", .tag = AUD_OPT_FMT, - .valp = &conf.settings.fmt, + .valp = &glob_conf.settings.fmt, .descr = "Format" }, { .name = "DAC_FIXED_CHANNELS", .tag = AUD_OPT_INT, - .valp = &conf.settings.nchannels, + .valp = &glob_conf.settings.nchannels, .descr = "Number of channels (1 - mono, 2 - stereo)" }, { .name = "PATH", .tag = AUD_OPT_STR, - .valp = &conf.wav_path, + .valp = &glob_conf.wav_path, .descr = "Path to wave file" }, { /* End of list */ }