From nobody Mon Feb 9 21:24:04 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 1646163672461684.7292208838428; Tue, 1 Mar 2022 11:41:12 -0800 (PST) Received: from localhost ([::1]:52080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nP8Mx-00071M-Fg for importer@patchew.org; Tue, 01 Mar 2022 14:41:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nP7wC-0005FQ-4O for qemu-devel@nongnu.org; Tue, 01 Mar 2022 14:13:32 -0500 Received: from mailout07.t-online.de ([194.25.134.83]:60072) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nP7w9-0001ox-DM for qemu-devel@nongnu.org; Tue, 01 Mar 2022 14:13:31 -0500 Received: from fwd72.dcpf.telekom.de (fwd72.aul.t-online.de [10.223.144.98]) by mailout07.t-online.de (Postfix) with SMTP id 8E89B13EB3; Tue, 1 Mar 2022 20:13:25 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd72.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1nP7vz-22DAkz0; Tue, 1 Mar 2022 20:13:20 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id EFBD020060F; Tue, 1 Mar 2022 20:13:11 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH v3 04/15] audio: inline function audio_pcm_sw_get_rpos_in() Date: Tue, 1 Mar 2022 20:13:00 +0100 Message-Id: <20220301191311.26695-4-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::1646162000-0000B7AB-CE00027A/0/0 CLEAN NORMAL X-TOI-MSGID: 95fc253c-5821-4dbd-9acb-e4d8ffd40e18 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.83; envelope-from=volker.ruemelin@t-online.de; helo=mailout07.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_H2=-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: 1646163673961100001 Simplify code by inlining function audio_pcm_sw_get_rpos_in() at the only call site and remove the duplicated audio_bug() test. Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index f28e91853f..35437986d9 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -569,37 +569,24 @@ static size_t audio_pcm_hw_conv_in(HWVoiceIn *hw, voi= d *pcm_buf, size_t samples) /* * Soft voice (capture) */ -static size_t audio_pcm_sw_get_rpos_in(SWVoiceIn *sw) -{ - HWVoiceIn *hw =3D sw->hw; - ssize_t live =3D hw->total_samples_captured - sw->total_hw_samples_acq= uired; - - if (audio_bug(__func__, live < 0 || live > hw->conv_buf->size)) { - dolog("live=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_buf-= >size); - return 0; - } - - return audio_ring_posb(hw->conv_buf->pos, live, hw->conv_buf->size); -} - static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t size) { HWVoiceIn *hw =3D sw->hw; size_t samples, live, ret =3D 0, swlim, isamp, osamp, rpos, total =3D = 0; struct st_sample *src, *dst =3D sw->buf; =20 - rpos =3D audio_pcm_sw_get_rpos_in(sw) % hw->conv_buf->size; - live =3D hw->total_samples_captured - sw->total_hw_samples_acquired; + if (!live) { + return 0; + } if (audio_bug(__func__, live > hw->conv_buf->size)) { dolog("live_in=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_b= uf->size); return 0; } =20 + rpos =3D audio_ring_posb(hw->conv_buf->pos, live, hw->conv_buf->size); + samples =3D size / sw->info.bytes_per_frame; - if (!live) { - return 0; - } =20 swlim =3D (live * sw->ratio) >> 32; swlim =3D MIN (swlim, samples); --=20 2.34.1