From patchwork Fri Jun 12 12:33:04 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: 483541 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 E7194140082 for ; Fri, 12 Jun 2015 22:36:04 +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=TpOyvbhM; dkim-atps=neutral Received: from localhost ([::1]:51058 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3OBn-0003Ik-4A for incoming@patchwork.ozlabs.org; Fri, 12 Jun 2015 08:36:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3O93-0007EW-BH for qemu-devel@nongnu.org; Fri, 12 Jun 2015 08:33:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z3O92-0004DU-1s for qemu-devel@nongnu.org; Fri, 12 Jun 2015 08:33:13 -0400 Received: from mail-wi0-x22b.google.com ([2a00:1450:400c:c05::22b]:36943) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3O91-0004DE-O0 for qemu-devel@nongnu.org; Fri, 12 Jun 2015 08:33:11 -0400 Received: by wifx6 with SMTP id x6so16194320wif.0 for ; Fri, 12 Jun 2015 05:33:11 -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=AiOnb9+7jBqV9UoJbO1hpcQMIe26VcAOqX9ihy6u8qY=; b=TpOyvbhM8mQUUUrPSuUOUYPYySLp2RzzmnR7zNZnwT2RQqGRs/s68t0kHybl6hJF0X lc2WXjnyUFf7QBTukaVIFBEku2h6LRVqXOrCFXO34vrkllwxtrYxxoHcZ9mnPbE6ezZY XqotfyE7/qDJhCAoHMubK1IItUBlb32SaPivMaPNsZhF0ZkMZen4kRpck9mV/zx3pKIp Ej6hJIKPWf9jo1P7lA+NUk0+Ytd+RmL0xi7Wh0eb+9uzJF3IubgTuq/99TymHlwYFwhT 6Bkb87LwcxicZbdj4Q1oeUZChsTlig5lpAL16ufDKQGASYVpxyBkljnjuqOdjbStfAba M2UA== X-Received: by 10.194.206.65 with SMTP id lm1mr26351250wjc.117.1434112391139; Fri, 12 Jun 2015 05:33:11 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (94-21-76-230.pool.digikabel.hu. [94.21.76.230]) by mx.google.com with ESMTPSA id m2sm2569153wiy.7.2015.06.12.05.33.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jun 2015 05:33:10 -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, 12 Jun 2015 14:33:04 +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:c05::22b Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 03/12] dsoundaudio: remove *_retries kludges 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 According to MSDN this may happen when the window is not in the foreground, but the default is 1 since a long time (which means no retries), so it should be ok. I've found no problems during testing it on Windows 7 and wine, so this was probably only the case with some old Windows versions. Signed-off-by: Kővágó, Zoltán --- audio/dsound_template.h | 35 +++++-------------------- audio/dsoundaudio.c | 68 ++++++++++--------------------------------------- 2 files changed, 20 insertions(+), 83 deletions(-) diff --git a/audio/dsound_template.h b/audio/dsound_template.h index 85ba858..b439f33 100644 --- a/audio/dsound_template.h +++ b/audio/dsound_template.h @@ -72,48 +72,27 @@ static int glue (dsound_lock_, TYPE) ( ) { HRESULT hr; - int i; LPVOID p1 = NULL, p2 = NULL; DWORD blen1 = 0, blen2 = 0; DWORD flag; - DSoundConf *conf = &s->conf; #ifdef DSBTYPE_IN flag = entire ? DSCBLOCK_ENTIREBUFFER : 0; #else flag = entire ? DSBLOCK_ENTIREBUFFER : 0; #endif - for (i = 0; i < conf->lock_retries; ++i) { - hr = glue (IFACE, _Lock) ( - buf, - pos, - len, - &p1, - &blen1, - &p2, - &blen2, - flag - ); + hr = glue(IFACE, _Lock)(buf, pos, len, &p1, &blen1, &p2, &blen2, flag); - if (FAILED (hr)) { + if (FAILED (hr)) { #ifndef DSBTYPE_IN - if (hr == DSERR_BUFFERLOST) { - if (glue (dsound_restore_, TYPE) (buf, s)) { - dsound_logerr (hr, "Could not lock " NAME "\n"); - goto fail; - } - continue; + if (hr == DSERR_BUFFERLOST) { + if (glue (dsound_restore_, TYPE) (buf, s)) { + dsound_logerr (hr, "Could not lock " NAME "\n"); } -#endif - dsound_logerr (hr, "Could not lock " NAME "\n"); goto fail; } - - break; - } - - if (i == conf->lock_retries) { - dolog ("%d attempts to lock " NAME " failed\n", i); +#endif + dsound_logerr (hr, "Could not lock " NAME "\n"); goto fail; } diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index c8b09e2..28b98bf 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -42,9 +42,6 @@ /* #define DEBUG_DSOUND */ typedef struct { - int lock_retries; - int restore_retries; - int getstatus_retries; int set_primary; int bufsize_in; int bufsize_out; @@ -274,26 +271,14 @@ static void print_wave_format (WAVEFORMATEX *wfx) static int dsound_restore_out (LPDIRECTSOUNDBUFFER dsb, dsound *s) { HRESULT hr; - int i; - for (i = 0; i < s->conf.restore_retries; ++i) { - hr = IDirectSoundBuffer_Restore (dsb); + hr = IDirectSoundBuffer_Restore (dsb); - switch (hr) { - case DS_OK: - return 0; - - case DSERR_BUFFERLOST: - continue; - - default: - dsound_logerr (hr, "Could not restore playback buffer\n"); - return -1; - } + if (hr != DS_OK) { + dsound_logerr (hr, "Could not restore playback buffer\n"); + return -1; } - - dolog ("%d attempts to restore playback buffer failed\n", i); - return -1; + return 0; } #include "dsound_template.h" @@ -305,22 +290,16 @@ static int dsound_get_status_out (LPDIRECTSOUNDBUFFER dsb, DWORD *statusp, dsound *s) { HRESULT hr; - int i; - for (i = 0; i < s->conf.getstatus_retries; ++i) { - hr = IDirectSoundBuffer_GetStatus (dsb, statusp); - if (FAILED (hr)) { - dsound_logerr (hr, "Could not get playback buffer status\n"); - return -1; - } + hr = IDirectSoundBuffer_GetStatus (dsb, statusp); + if (FAILED (hr)) { + dsound_logerr (hr, "Could not get playback buffer status\n"); + return -1; + } - if (*statusp & DSERR_BUFFERLOST) { - if (dsound_restore_out (dsb, s)) { - return -1; - } - continue; - } - break; + if (*statusp & DSERR_BUFFERLOST) { + dsound_restore_out(dsb, s); + return -1; } return 0; @@ -844,9 +823,6 @@ static int dsound_run_in (HWVoiceIn *hw) } static DSoundConf glob_conf = { - .lock_retries = 1, - .restore_retries = 1, - .getstatus_retries = 1, .set_primary = 0, .bufsize_in = 16384, .bufsize_out = 16384, @@ -959,24 +935,6 @@ static void *dsound_audio_init (void) static struct audio_option dsound_options[] = { { - .name = "LOCK_RETRIES", - .tag = AUD_OPT_INT, - .valp = &glob_conf.lock_retries, - .descr = "Number of times to attempt locking the buffer" - }, - { - .name = "RESTOURE_RETRIES", - .tag = AUD_OPT_INT, - .valp = &glob_conf.restore_retries, - .descr = "Number of times to attempt restoring the buffer" - }, - { - .name = "GETSTATUS_RETRIES", - .tag = AUD_OPT_INT, - .valp = &glob_conf.getstatus_retries, - .descr = "Number of times to attempt getting status of the buffer" - }, - { .name = "SET_PRIMARY", .tag = AUD_OPT_BOOL, .valp = &glob_conf.set_primary,