From nobody Tue Feb 10 02:27:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642857255197592.5911894276301; Sat, 22 Jan 2022 05:14:15 -0800 (PST) Received: from localhost ([::1]:36770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nBGDe-0001g7-9Y for importer@patchew.org; Sat, 22 Jan 2022 08:14:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBFzZ-0007sA-JX for qemu-devel@nongnu.org; Sat, 22 Jan 2022 07:59:41 -0500 Received: from mailout04.t-online.de ([194.25.134.18]:39350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBFyc-000567-KG for qemu-devel@nongnu.org; Sat, 22 Jan 2022 07:59:41 -0500 Received: from fwd88.dcpf.telekom.de (fwd88.aul.t-online.de [10.223.144.114]) by mailout04.t-online.de (Postfix) with SMTP id 7E8517E8D; Sat, 22 Jan 2022 13:58:20 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd88.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1nBFyA-3zSMjp0; Sat, 22 Jan 2022 13:58:14 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id E213120063E; Sat, 22 Jan 2022 13:57:45 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH v2 12/15] dsoundaudio: reduce effective playback buffer size Date: Sat, 22 Jan 2022 13:57:42 +0100 Message-Id: <20220122125745.5037-12-vr_qemu@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1642856294-00013579-6D42D5AE/0/0 CLEAN NORMAL X-TOI-MSGID: 85a4ea0c-8f4d-4786-822f-055004313302 Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=194.25.134.18; envelope-from=volker.ruemelin@t-online.de; helo=mailout04.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1642857257428100001 Add the buffer_get_free pcm_ops function to reduce the effective playback buffer size. All intermediate audio playback buffers become temporary buffers. Signed-off-by: Volker R=C3=BCmelin --- audio/dsoundaudio.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 3dd2c4d4a6..231f3e65b3 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -427,22 +427,18 @@ static void dsound_enable_out(HWVoiceOut *hw, bool en= able) } } =20 -static void *dsound_get_buffer_out(HWVoiceOut *hw, size_t *size) +static size_t dsound_buffer_get_free(HWVoiceOut *hw) { DSoundVoiceOut *ds =3D (DSoundVoiceOut *) hw; LPDIRECTSOUNDBUFFER dsb =3D ds->dsound_buffer; HRESULT hr; - DWORD ppos, wpos, act_size; - size_t req_size; - int err; - void *ret; + DWORD ppos, wpos; =20 hr =3D IDirectSoundBuffer_GetCurrentPosition( dsb, &ppos, ds->first_time ? &wpos : NULL); if (FAILED(hr)) { dsound_logerr(hr, "Could not get playback buffer position\n"); - *size =3D 0; - return NULL; + return 0; } =20 if (ds->first_time) { @@ -450,13 +446,20 @@ static void *dsound_get_buffer_out(HWVoiceOut *hw, si= ze_t *size) ds->first_time =3D false; } =20 - req_size =3D audio_ring_dist(ppos, hw->pos_emul, hw->size_emul); - req_size =3D MIN(req_size, hw->size_emul - hw->pos_emul); + return audio_ring_dist(ppos, hw->pos_emul, hw->size_emul); +} =20 - if (req_size =3D=3D 0) { - *size =3D 0; - return NULL; - } +static void *dsound_get_buffer_out(HWVoiceOut *hw, size_t *size) +{ + DSoundVoiceOut *ds =3D (DSoundVoiceOut *)hw; + LPDIRECTSOUNDBUFFER dsb =3D ds->dsound_buffer; + DWORD act_size; + size_t req_size; + int err; + void *ret; + + req_size =3D MIN(*size, hw->size_emul - hw->pos_emul); + assert(req_size > 0); =20 err =3D dsound_lock_out(dsb, &hw->info, hw->pos_emul, req_size, &ret, = NULL, &act_size, NULL, false, ds->s); @@ -699,6 +702,7 @@ static struct audio_pcm_ops dsound_pcm_ops =3D { .init_out =3D dsound_init_out, .fini_out =3D dsound_fini_out, .write =3D audio_generic_write, + .buffer_get_free =3D dsound_buffer_get_free, .get_buffer_out =3D dsound_get_buffer_out, .put_buffer_out =3D dsound_put_buffer_out, .enable_out =3D dsound_enable_out, --=20 2.31.1