From nobody Tue Feb 10 14:43:59 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 1646163916770238.66038084367915; Tue, 1 Mar 2022 11:45:16 -0800 (PST) Received: from localhost ([::1]:60320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nP8Qt-0004KD-Am for importer@patchew.org; Tue, 01 Mar 2022 14:45:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43412) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nP7wN-0005ga-Te for qemu-devel@nongnu.org; Tue, 01 Mar 2022 14:13:45 -0500 Received: from mailout03.t-online.de ([194.25.134.81]:53856) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nP7wM-0001sQ-54 for qemu-devel@nongnu.org; Tue, 01 Mar 2022 14:13:43 -0500 Received: from fwd75.dcpf.telekom.de (fwd75.aul.t-online.de [10.223.144.101]) by mailout03.t-online.de (Postfix) with SMTP id A9DB9D7A; Tue, 1 Mar 2022 20:13:40 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd75.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1nP7wK-0n79bF0; Tue, 1 Mar 2022 20:13:40 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 13213200627; Tue, 1 Mar 2022 20:13:12 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH v3 12/15] dsoundaudio: reduce effective playback buffer size Date: Tue, 1 Mar 2022 20:13:08 +0100 Message-Id: <20220301191311.26695-12-vr_qemu@t-online.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <3d0bd2ac-e5b9-9cf6-c98f-c047390a3ec5@t-online.de> References: <3d0bd2ac-e5b9-9cf6-c98f-c047390a3ec5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1646162020-000184BD-DDDEE319/0/0 CLEAN NORMAL X-TOI-MSGID: 77040ca6-0874-4c28-bb83-bf8fd5066c9d 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.81; envelope-from=volker.ruemelin@t-online.de; helo=mailout03.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1646163918905100001 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.34.1