From patchwork Mon Jun 1 13:23:47 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: 479037 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 CA6D8140E62 for ; Mon, 1 Jun 2015 23:27:06 +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=NUm/Ur6y; dkim-atps=neutral Received: from localhost ([::1]:52507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzPk8-0007md-IA for incoming@patchwork.ozlabs.org; Mon, 01 Jun 2015 09:27:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzPhT-0002rb-4b for qemu-devel@nongnu.org; Mon, 01 Jun 2015 09:24:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YzPhR-0007jW-RR for qemu-devel@nongnu.org; Mon, 01 Jun 2015 09:24:19 -0400 Received: from mail-wi0-x232.google.com ([2a00:1450:400c:c05::232]:37070) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YzPhR-0007jI-LY for qemu-devel@nongnu.org; Mon, 01 Jun 2015 09:24:17 -0400 Received: by wifw1 with SMTP id w1so105069116wif.0 for ; Mon, 01 Jun 2015 06:24:17 -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=D+s+1Tlicq4jWnx1IW7mFsDmez4ZBc3LM9CVZu0syGY=; b=NUm/Ur6yDl65t3q3mmybH2THun+wTYd4T007bGN9TRKi0xBtHD4fawBpW77IRXO2YK HkE2SRM/HEdg5g3hEHFyhVPlnuuxPknrb+tJNhC4QsBv9TxPJyGQUmdUb/Wm/Nqg+FMV am+BAZbDCEwhViDLIe8Cs3xAJyiabxWdNvuLaRQqKJ4RajfmZQ8st6XScp6dPqjOetgp h8GzHlhvMP7rC5cn3uMvKbilqu5xzZWLy9JK8hyEg4blFTDoUI36n00I6Tztyx80+SDg /gc8TGWGRv82ih+DTYMHVA5I/tan3QmZh99bq6PXm8wjaZxg3I85hptJib0ixr81TLAa 5X+w== X-Received: by 10.194.103.2 with SMTP id fs2mr41556987wjb.151.1433165057152; Mon, 01 Jun 2015 06:24:17 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (212-40-90-210.pool.digikabel.hu. [212.40.90.210]) by mx.google.com with ESMTPSA id js3sm21917842wjc.5.2015.06.01.06.24.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jun 2015 06:24:16 -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: Mon, 1 Jun 2015 15:23:47 +0200 Message-Id: <15dc3ee0ba6a006893cd6915b981e595f3efa652.1433164051.git.DirtY.iCE.hu@gmail.com> 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:c05::232 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 09/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 5132aed..8acea8f 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; (void) as; (void) drv_opaque; @@ -157,10 +153,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; @@ -228,40 +224,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 */ }