From nobody Thu May 16 09:12:07 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1600622389; cv=none; d=zohomail.com; s=zohoarc; b=TUIAwV4OPKO23DLLS2w7f7cEfu4kfxDBXAcvrNEEt4WB+ElaLpHsRMuwmKp3GoqpgPPv3EFkYAQf2XD5CHyxRJQI2I98JnikaJnanQlOd3WhXK4zzWguLfvp0TmodfaoNypiy6yAwDeWwFi+0AA6cFCTkM231eH2hLNVV7ZuK6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600622389; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d/SFRzAtteMQtfcDXtvgpwJbaOEdcvpzD+BcFaJ2xpg=; b=W+gxdBLhg/QVAuBiFomEJIuRockT1A1d9T7atybWYpnFcDWKg6l+dbtmWVEbq1LFBqEhO2p8M4Qfc9ndj6MsOYjA9Yzwq1GrsYYnoqExDWRHL2efh79mWEOb4VXla9/iixhbZuVntt465+XtMBiaZXFmOV51485SJwbGzVuUbjY= ARC-Authentication-Results: i=1; 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 160062238917180.86871916453572; Sun, 20 Sep 2020 10:19:49 -0700 (PDT) Received: from localhost ([::1]:47592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kK307-0005Zt-Pu for importer@patchew.org; Sun, 20 Sep 2020 13:19:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2xz-000404-Qx for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:35 -0400 Received: from mailout11.t-online.de ([194.25.134.85]:50884) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2xy-0006FR-2G for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:35 -0400 Received: from fwd13.aul.t-online.de (fwd13.aul.t-online.de [172.20.27.62]) by mailout11.t-online.de (Postfix) with SMTP id 40457425E999; Sun, 20 Sep 2020 19:17:31 +0200 (CEST) Received: from linpower.localnet (JbTBTgZ1wh5e1YUvG8omkAi00eJ6ksRPSWkzSvHvuJpzQ7vTc-3D2ESCnrNWnBQw+q@[93.236.144.216]) by fwd13.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kK2xu-08uzLs0; Sun, 20 Sep 2020 19:17:30 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id EC356200613; Sun, 20 Sep 2020 19:17:29 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 1/9] audio: handle buf == NULL in put_buffer_out() Date: Sun, 20 Sep 2020 19:17:21 +0200 Message-Id: <20200920171729.15861-1-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> References: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: JbTBTgZ1wh5e1YUvG8omkAi00eJ6ksRPSWkzSvHvuJpzQ7vTc-3D2ESCnrNWnBQw+q X-TOI-EXPURGATEID: 150726::1600622250-00003E0D-CF49BECB/0/0 CLEAN NORMAL X-TOI-MSGID: 40b6d91d-6ee8-420f-b398-9d75a203800e 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.85; envelope-from=volker.ruemelin@t-online.de; helo=mailout11.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/20 13:17:31 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel , =?UTF-8?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" With the next patch all audio backends put_buffer_out() functions have to handle the buf =3D=3D NULL case, provided the get_buffer_out() function may return buf =3D NULL and size > 0. It turns out that all audio backends get_buffer_out() functions either can't return buf =3D NULL or return buf =3D NULL and size =3D 0 at the same time. The only exception is the spiceaudio backend where size may be uninitialized. Signed-off-by: Volker R=C3=BCmelin --- audio/spiceaudio.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index b6b5da4812..c8d81ba442 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -135,6 +135,7 @@ static void *line_out_get_buffer(HWVoiceOut *hw, size_t= *size) (out->fsize - out->fpos) * hw->info.bytes_per_frame); } else { audio_rate_start(&out->rate); + *size =3D LINE_OUT_SAMPLES << 2; } return out->frame + out->fpos; } @@ -143,12 +144,14 @@ static size_t line_out_put_buffer(HWVoiceOut *hw, voi= d *buf, size_t size) { SpiceVoiceOut *out =3D container_of(hw, SpiceVoiceOut, hw); =20 - assert(buf =3D=3D out->frame + out->fpos && out->fpos <=3D out->fsize); - out->fpos +=3D size >> 2; + if (buf) { + assert(buf =3D=3D out->frame + out->fpos && out->fpos <=3D out->fs= ize); + out->fpos +=3D size >> 2; =20 - if (out->fpos =3D=3D out->fsize) { /* buffer full */ - spice_server_playback_put_samples(&out->sin, out->frame); - out->frame =3D NULL; + if (out->fpos =3D=3D out->fsize) { /* buffer full */ + spice_server_playback_put_samples(&out->sin, out->frame); + out->frame =3D NULL; + } } =20 return size; --=20 2.26.2 From nobody Thu May 16 09:12:07 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1600622531; cv=none; d=zohomail.com; s=zohoarc; b=UYBOYzvy4eckvHEKdLUUZbimN/q9wkDvADFc35MlFD1eeCOfgJqFdUs/ByX5npiDU0BBk3C8IZiX3DoYpNzUYciie5+la4FNQJyzHXSUkNvQ3hbILZshiwW5MUjGQQq5wME2qHvkpryoRBXGRWrNjvfn/d28ee7sn6tbAlQJ6P4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600622531; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5cPmJCDLhCf6O+aH4ZidBvnZNlA60vx/F4DJrNFiJ2o=; b=j2Sh3S+j11mLhTYllrLmTmvJmHxSZljKIZq5NWhg4vW+hFnd8l8P1uB7MfLgvJYBL/qaTtXXz+kainUrdaazxAGIz+4nTihnqnaPuECMoWvA4ICi75oQK0U7Kg27RYcVB94qZ4ccHGrdWPsV4QJ7y/pr2IJL2nJjm71isVBemQ0= ARC-Authentication-Results: i=1; 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 1600622531957209.56887229420397; Sun, 20 Sep 2020 10:22:11 -0700 (PDT) Received: from localhost ([::1]:54182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kK32Q-0008O6-Eq for importer@patchew.org; Sun, 20 Sep 2020 13:22:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2y8-00041R-3o for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:45 -0400 Received: from mailout11.t-online.de ([194.25.134.85]:50978) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2y3-0006Fi-OY for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:43 -0400 Received: from fwd23.aul.t-online.de (fwd23.aul.t-online.de [172.20.26.128]) by mailout11.t-online.de (Postfix) with SMTP id 110024227A3A; Sun, 20 Sep 2020 19:17:38 +0200 (CEST) Received: from linpower.localnet (S+TPB6ZF8hyTWgWKs8RTEDB-qWhNOH3J1Hr3QLR2XNsvOS2Z0-rYyYW6LGiJ1CcQHH@[93.236.144.216]) by fwd23.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kK2xx-1mxmc40; Sun, 20 Sep 2020 19:17:33 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id EE572200618; Sun, 20 Sep 2020 19:17:29 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 2/9] audio/audio: fix video playback slowdown with spiceaudio Date: Sun, 20 Sep 2020 19:17:22 +0200 Message-Id: <20200920171729.15861-2-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> References: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: S+TPB6ZF8hyTWgWKs8RTEDB-qWhNOH3J1Hr3QLR2XNsvOS2Z0-rYyYW6LGiJ1CcQHH X-TOI-EXPURGATEID: 150726::1600622253-00017F06-698604E3/0/0 CLEAN NORMAL X-TOI-MSGID: c6469676-489e-4bdc-8004-1bcce84d763c 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.85; envelope-from=volker.ruemelin@t-online.de; helo=mailout11.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/20 13:17:31 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel , =?UTF-8?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" This patch allows the audio backends get_buffer_out() functions to drop audio data and mitigates a bug reported on the qemu-devel mailing list. https://lists.nongnu.org/archive/html/qemu-devel/2020-09/msg03832.html The new rules for the variables buf and size returned by get_buffer_out() are: size =3D=3D 0: Downstream playback buffer is full. Retry later. size > 0, buf !=3D NULL: Copy size bytes to buf for playback. size > 0, buf =3D=3D NULL: Drop size bytes. The audio playback rate with spiceaudio for the no audio case is too fast, but that's what we had before commit fb35c2cec5 "audio/dsound: fix invalid parameters error". The complete fix comes with the next patch. Reported-by: Qi Zhou Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index ce8c6dec5f..ad3f57b4c4 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1091,12 +1091,15 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, = size_t live) while (live) { size_t size, decr, proc; void *buf =3D hw->pcm_ops->get_buffer_out(hw, &size); - if (!buf || size =3D=3D 0) { + + if (size =3D=3D 0) { break; } =20 decr =3D MIN(size / hw->info.bytes_per_frame, live); - audio_pcm_hw_clip_out(hw, buf, decr); + if (buf) { + audio_pcm_hw_clip_out(hw, buf, decr); + } proc =3D hw->pcm_ops->put_buffer_out(hw, buf, decr * hw->info.bytes_per_frame= ) / hw->info.bytes_per_frame; --=20 2.26.2 From nobody Thu May 16 09:12:07 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1600622391; cv=none; d=zohomail.com; s=zohoarc; b=E6iEDZRWg+ILhIvFDWn0HoXQ7MLiOaU+8kzuQVVjCkuHV/CaEIsRjOrmjNe4MxlSXqfCgXj5SkBzbTFZeMjwqU6zz+1d1Mz79ld0AD1s3WhrXQ6nlLyYlIp6NS/gvkNSnnYzkduWcpXAfriXwnx0PlQSgYV9xZPCOLEvZlVzW40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600622391; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w0gr7x4/yMsaTREONwrl3fw1gWMmUTsA7357wxGtHX8=; b=oAG1zOM07yurb8U10HB+B34UCUKgO4LLplGBAOJEbGTMfYkmzxKVejgQXcNZVeSzPfdlyw6+pLPaZuX2OZSedEOw7lZ3GsuSyLgBW5iPbl2uQBEVo14c+kGbnlSGEBhlyo7diWTUmbvMZjrMuw0HcIo5u2qBGUkNSn/gQVmBoIU= ARC-Authentication-Results: i=1; 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 1600622391603193.88492464672913; Sun, 20 Sep 2020 10:19:51 -0700 (PDT) Received: from localhost ([::1]:47762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kK30A-0005dy-BO for importer@patchew.org; Sun, 20 Sep 2020 13:19:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2y3-00040u-Eq for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:39 -0400 Received: from mailout08.t-online.de ([194.25.134.20]:56150) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2y1-0006Fd-Nd for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:39 -0400 Received: from fwd20.aul.t-online.de (fwd20.aul.t-online.de [172.20.26.140]) by mailout08.t-online.de (Postfix) with SMTP id 07E2941E61DF; Sun, 20 Sep 2020 19:17:36 +0200 (CEST) Received: from linpower.localnet (G54emqZHYhtqxL8jXYmVtop8pYMDyAFBZ-bbdLrqWFyzWCBFxEoBEQcOotHyBf6wlm@[93.236.144.216]) by fwd20.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kK2xz-0t19hA0; Sun, 20 Sep 2020 19:17:35 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id EF210335504; Sun, 20 Sep 2020 19:17:29 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 3/9] audio/spiceaudio: always rate limit playback stream Date: Sun, 20 Sep 2020 19:17:23 +0200 Message-Id: <20200920171729.15861-3-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> References: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: G54emqZHYhtqxL8jXYmVtop8pYMDyAFBZ-bbdLrqWFyzWCBFxEoBEQcOotHyBf6wlm X-TOI-EXPURGATEID: 150726::1600622255-000053CC-410D1DA5/0/0 CLEAN NORMAL X-TOI-MSGID: c27bc480-7caa-410e-a3f0-2339759c4744 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.20; envelope-from=volker.ruemelin@t-online.de; helo=mailout08.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/20 13:17:36 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel , =?UTF-8?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" The playback rate with the spiceaudio backend is currently too fast if there's no spice client connected or the spice client can't play audio. Rate limit the audio playback stream in all cases. To calculate the rate correctly the limiter has to know the maximum buffer size. Fixes: 8c198ff065 ("spiceaudio: port to the new audio backend api") Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 3 ++- audio/spiceaudio.c | 10 ++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index ad3f57b4c4..ba52259050 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1089,7 +1089,8 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, si= ze_t live) size_t clipped =3D 0; =20 while (live) { - size_t size, decr, proc; + size_t size =3D live * hw->info.bytes_per_frame; + size_t decr, proc; void *buf =3D hw->pcm_ops->get_buffer_out(hw, &size); =20 if (size =3D=3D 0) { diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index c8d81ba442..c062742622 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -130,13 +130,11 @@ static void *line_out_get_buffer(HWVoiceOut *hw, size= _t *size) } =20 if (out->frame) { - *size =3D audio_rate_get_bytes( - &hw->info, &out->rate, - (out->fsize - out->fpos) * hw->info.bytes_per_frame); - } else { - audio_rate_start(&out->rate); - *size =3D LINE_OUT_SAMPLES << 2; + *size =3D MIN((out->fsize - out->fpos) << 2, *size); } + + *size =3D audio_rate_get_bytes(&hw->info, &out->rate, *size); + return out->frame + out->fpos; } =20 --=20 2.26.2 From nobody Thu May 16 09:12:07 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1600622612; cv=none; d=zohomail.com; s=zohoarc; b=J+YQ8WfvRuNyZ+Jkm4XzStiSGVW0blDlYPTEXAlCP00Gf69LUsV12BO64lNhJT8Mwx/wO0xOLPejmVcPxcqLBlUQ8l9F6hWAHNsbWd+s452XOvq+vCSbB4Forc/flOaZpKdaPb4Sc6s9yqEIB/Bwwaaz+a1z7Eqm2hHbz94C6iQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600622612; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PgD7BtZS/5P7OpM+B8nY09nLYzmMQg56w4dzQAXF1CE=; b=UJw2GKhPZXykFusk8RJFZaKslv3f2+32vitQw62SHjR+FVf53ABK8f4YvKv3rvA6lsBtFby1NVhzS3tgjOdK+8znfRA8Y74ihuItJijTTnJg+YabZ7w/DkgHOwq8japNT8xYXQKu2LRbFTjKb/aK+EEL9susADX+GW0Ec9S4dUk= ARC-Authentication-Results: i=1; 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 1600622612409430.87601823177226; Sun, 20 Sep 2020 10:23:32 -0700 (PDT) Received: from localhost ([::1]:57432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kK33j-0001JC-3h for importer@patchew.org; Sun, 20 Sep 2020 13:23:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2yA-00041v-23 for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:47 -0400 Received: from mailout10.t-online.de ([194.25.134.21]:34852) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2y5-0006Fv-MU for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:45 -0400 Received: from fwd11.aul.t-online.de (fwd11.aul.t-online.de [172.20.27.152]) by mailout10.t-online.de (Postfix) with SMTP id 32E8C41FA028; Sun, 20 Sep 2020 19:17:39 +0200 (CEST) Received: from linpower.localnet (bHcoO0Z1rh1GoyJ8wscsfcqD8h1sQY0m0g7Jt9tWyNtN4NA7AzN7T5g7yXaQaGhwPy@[93.236.144.216]) by fwd11.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kK2y2-2mMujg0; Sun, 20 Sep 2020 19:17:38 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id F1159335505; Sun, 20 Sep 2020 19:17:29 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 4/9] audio: align audio_generic_read with audio_pcm_hw_run_in Date: Sun, 20 Sep 2020 19:17:24 +0200 Message-Id: <20200920171729.15861-4-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> References: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: bHcoO0Z1rh1GoyJ8wscsfcqD8h1sQY0m0g7Jt9tWyNtN4NA7AzN7T5g7yXaQaGhwPy X-TOI-EXPURGATEID: 150726::1600622258-000007DF-30300D69/0/0 CLEAN NORMAL X-TOI-MSGID: 83c6d6a8-7864-42c3-99d8-9fda084f3b49 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.21; envelope-from=volker.ruemelin@t-online.de; helo=mailout10.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/20 13:17:39 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel , =?UTF-8?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" The function audio_generic_read should work exactly like audio_pcm_hw_run_in. It's a very similar function working on a different buffer. Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index ba52259050..f1f0d72389 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1495,12 +1495,23 @@ size_t audio_generic_write(HWVoiceOut *hw, void *bu= f, size_t size) =20 size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size) { - void *src =3D hw->pcm_ops->get_buffer_in(hw, &size); + size_t total =3D 0; =20 - memcpy(buf, src, size); - hw->pcm_ops->put_buffer_in(hw, src, size); + while (total < size) { + size_t src_size =3D size - total; + void *src =3D hw->pcm_ops->get_buffer_in(hw, &src_size); =20 - return size; + if (src_size =3D=3D 0) { + hw->pcm_ops->put_buffer_in(hw, src, src_size); + break; + } + + memcpy((char *)buf + total, src, src_size); + hw->pcm_ops->put_buffer_in(hw, src, src_size); + total +=3D src_size; + } + + return total; } =20 static int audio_driver_init(AudioState *s, struct audio_driver *drv, --=20 2.26.2 From nobody Thu May 16 09:12:07 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1600622408; cv=none; d=zohomail.com; s=zohoarc; b=jHVuWm0naNfJi3V7sFyzOuJ4VYifoUjq702QLOPvmzMo9z+lGmMeTgW2KxmqLmUrpLzHyqfRla6UQjGA2m/X744Xmv7lt+yzvVthaiBKzzdI2AN3kgXRAVuXWWYJVFIzwD2OX92YY2PqzQXHxmh6uhXkmaSmwTQK5C3FDSf2kp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600622408; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Soa+Q+39qCPd+VspnKlGmwVhMDUllAQEGnJTjz7jRmM=; b=ghKAn7Jeac221Dq5lCvASASJOBiefyr0e2Kcg0l68x1ixlyISPFv8735feKtM+LpAL0LA9RlpymR2o++mNDKzUQtTIHTPP0B8HzRNvXiLqvXFvsysXuZ2XutddKHU77xRAV1LcCLG+j64Pxy7zPpiICH4wQhN3M5fAFhmnkTbAo= ARC-Authentication-Results: i=1; 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 160062240849821.942776922267853; Sun, 20 Sep 2020 10:20:08 -0700 (PDT) Received: from localhost ([::1]:47990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kK30R-0005ja-4n for importer@patchew.org; Sun, 20 Sep 2020 13:20:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2yF-00042T-IC for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:57 -0400 Received: from mailout05.t-online.de ([194.25.134.82]:46070) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2yD-0006GB-28 for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:51 -0400 Received: from fwd11.aul.t-online.de (fwd11.aul.t-online.de [172.20.27.152]) by mailout05.t-online.de (Postfix) with SMTP id 412E5422766C; Sun, 20 Sep 2020 19:17:44 +0200 (CEST) Received: from linpower.localnet (r3XF58ZbQhz2tJ9f9JYa4a1q22e+raSO+9GK-nG26E+C34IPSb9Xw1IIkuYlbsXwjj@[93.236.144.216]) by fwd11.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kK2y4-2q0ftA0; Sun, 20 Sep 2020 19:17:40 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id F332A335507; Sun, 20 Sep 2020 19:17:29 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 5/9] audio: remove unnecessary calls to put_buffer_in Date: Sun, 20 Sep 2020 19:17:25 +0200 Message-Id: <20200920171729.15861-5-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> References: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: r3XF58ZbQhz2tJ9f9JYa4a1q22e+raSO+9GK-nG26E+C34IPSb9Xw1IIkuYlbsXwjj X-TOI-EXPURGATEID: 150726::1600622260-000007DF-948D9F3E/0/0 CLEAN NORMAL X-TOI-MSGID: 20318a5f-6668-46f2-9fea-077be0374dfa 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.82; envelope-from=volker.ruemelin@t-online.de; helo=mailout05.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/20 13:17:44 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel , =?UTF-8?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" This patch removes unnecessary calls to the pcm_ops function put_buffer_in(). No audio backend needs this call if the returned length of pcm_ops function get_buffer_in() is zero. For the DirectSound backend this prevents a call to dsound_unlock_in() without a preceding call to dsound_lock_in(). While Windows doesn't complain it seems wrong anyway. Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index f1f0d72389..75107a12d0 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1261,7 +1261,6 @@ static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, size= _t samples) =20 assert(size % hw->info.bytes_per_frame =3D=3D 0); if (size =3D=3D 0) { - hw->pcm_ops->put_buffer_in(hw, buf, size); break; } =20 @@ -1502,7 +1501,6 @@ size_t audio_generic_read(HWVoiceIn *hw, void *buf, s= ize_t size) void *src =3D hw->pcm_ops->get_buffer_in(hw, &src_size); =20 if (src_size =3D=3D 0) { - hw->pcm_ops->put_buffer_in(hw, src, src_size); break; } =20 --=20 2.26.2 From nobody Thu May 16 09:12:07 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1600622409; cv=none; d=zohomail.com; s=zohoarc; b=VO2KfShS28wiW4/rOum0nBFtHLS8uE03ISccFKkYP8xAUv6BAWWhUtyfN+gUZ3476ZZa7M/7sQ7zb42jYqmNy4Z0kzDG0Lw72JDrsIj3lgKv8SUKfAvbM6NtvdFG2k/jcNb2dYWmjeTuSIp6uOXqm3dSP4s1CNaXiCMjgXtvf5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600622409; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q7bIalViHwpXq9dukd1a9HyfaTh3TBXxsjqSz5Pss3I=; b=JqXwxcsISuR/72wgKhe9tr28VS+vV7fNAmKuQvHuHgrqAchmmTcVCH+CvgwhFyTXZTRtjCKeBn2KOlgr6ADXBDSJwgOiEpSnoV8ly+LGme7xH7rvu//WNK9PindieumcfBqXugUePACvb52roQXQYiMWH/XSeZ4MWQRClbOLZx4= ARC-Authentication-Results: i=1; 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 1600622409529213.1881341319928; Sun, 20 Sep 2020 10:20:09 -0700 (PDT) Received: from localhost ([::1]:47992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kK30S-0005jb-94 for importer@patchew.org; Sun, 20 Sep 2020 13:20:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2yG-00042U-7J for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:57 -0400 Received: from mailout06.t-online.de ([194.25.134.19]:43574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2yD-0006GZ-Ls for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:51 -0400 Received: from fwd27.aul.t-online.de (fwd27.aul.t-online.de [172.20.26.132]) by mailout06.t-online.de (Postfix) with SMTP id 58BC141F0588; Sun, 20 Sep 2020 19:17:47 +0200 (CEST) Received: from linpower.localnet (GuSieTZO8h624ylxxBGzLYcCBWlfKRwK+Y1HqBxfKjpXjfmdBRGNUO8FypFXY8RwrV@[93.236.144.216]) by fwd27.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kK2y7-1SNadM0; Sun, 20 Sep 2020 19:17:43 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 01503335508; Sun, 20 Sep 2020 19:17:29 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 6/9] audio: align audio_generic_write with audio_pcm_hw_run_out Date: Sun, 20 Sep 2020 19:17:26 +0200 Message-Id: <20200920171729.15861-6-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> References: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: GuSieTZO8h624ylxxBGzLYcCBWlfKRwK+Y1HqBxfKjpXjfmdBRGNUO8FypFXY8RwrV X-TOI-EXPURGATEID: 150726::1600622263-0000CED0-B7A38245/0/0 CLEAN NORMAL X-TOI-MSGID: 57f6afda-8a5b-4104-bc58-a631ae4fcd07 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.19; envelope-from=volker.ruemelin@t-online.de; helo=mailout06.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/20 13:17:47 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel , =?UTF-8?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" The function audio_generic_write should work exactly like audio_pcm_hw_run_out. It's a very similar function working on a different buffer. This patch significantly reduces the number of drop-outs with the DirectSound backend. To hear the difference start qemu with -audiodev dsound,id=3Daudio0,out.mixing-engine=3Doff and play a song in the guest with and without this patch. Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 75107a12d0..57eddb3324 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1484,12 +1484,34 @@ size_t audio_generic_put_buffer_out(HWVoiceOut *hw,= void *buf, size_t size) =20 size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size) { - size_t dst_size, copy_size; - void *dst =3D hw->pcm_ops->get_buffer_out(hw, &dst_size); - copy_size =3D MIN(size, dst_size); + size_t total =3D 0; + + while (total < size) { + size_t dst_size =3D size - total; + size_t copy_size, proc; + void *dst =3D hw->pcm_ops->get_buffer_out(hw, &dst_size); =20 - memcpy(dst, buf, copy_size); - return hw->pcm_ops->put_buffer_out(hw, dst, copy_size); + if (dst_size =3D=3D 0) { + break; + } + + copy_size =3D MIN(size - total, dst_size); + if (dst) { + memcpy(dst, (char *)buf + total, copy_size); + } + proc =3D hw->pcm_ops->put_buffer_out(hw, dst, copy_size); + total +=3D proc; + + if (proc =3D=3D 0 || proc < copy_size) { + break; + } + } + + if (hw->pcm_ops->run_buffer_out) { + hw->pcm_ops->run_buffer_out(hw); + } + + return total; } =20 size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size) --=20 2.26.2 From nobody Thu May 16 09:12:07 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1600622677; cv=none; d=zohomail.com; s=zohoarc; b=g3ZBGTji/QU3mv9XToHuA1aq5c7E2QA8C1wvwNT8p/7NN0Rigjv+oO7T+Kdx344S9v2T2J2BEfjXVnwsGwX7py4f7QtQ3dGGFkqxjUINBS5m1pP7JN9tDUIZ7Vo+dli8NRO8JzwMtES4GoeEHNhalB7PbH2nBRgqSRPrcbWgey4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600622677; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oio8TSxRWxgbIk1iq+wh4zmqnzzjOUPw3Id1374XXbk=; b=oCmJ5phkvug9qRBUSJ0CjtdwXgZ2dFQtOP9JAx4BEJNtdP2MGTgGoznauslcy0KNb+48LOW387cFCMIQSgWuY+o1znhGqlJ5R2uUuce8WxDOxCWvobmc3Z1qjG+cVLY4y5+CYCIKjaxj8Rd3lrWXupskerTe4R3Ht42K3NPWqhM= ARC-Authentication-Results: i=1; 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 1600622677157831.0766107943258; Sun, 20 Sep 2020 10:24:37 -0700 (PDT) Received: from localhost ([::1]:59828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kK34l-0002Kj-VT for importer@patchew.org; Sun, 20 Sep 2020 13:24:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2yG-00042X-Pf for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:57 -0400 Received: from mailout06.t-online.de ([194.25.134.19]:43594) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2yE-0006Gd-OD for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:52 -0400 Received: from fwd23.aul.t-online.de (fwd23.aul.t-online.de [172.20.26.128]) by mailout06.t-online.de (Postfix) with SMTP id 619E441F058C; Sun, 20 Sep 2020 19:17:49 +0200 (CEST) Received: from linpower.localnet (rC-hh8ZOohJxclY-nx5NWfzPEJZJf6vYv7VtWdsW2z8rZ8RFYOI8T6CDHX+UC5+QGD@[93.236.144.216]) by fwd23.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kK2yA-23hqEq0; Sun, 20 Sep 2020 19:17:46 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 03904335509; Sun, 20 Sep 2020 19:17:30 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 7/9] audio: run downstream playback queue unconditionally Date: Sun, 20 Sep 2020 19:17:27 +0200 Message-Id: <20200920171729.15861-7-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> References: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: rC-hh8ZOohJxclY-nx5NWfzPEJZJf6vYv7VtWdsW2z8rZ8RFYOI8T6CDHX+UC5+QGD X-TOI-EXPURGATEID: 150726::1600622266-00017F06-8537D407/0/0 CLEAN NORMAL X-TOI-MSGID: 025334c8-bcbf-4970-b261-564cb9aab7d4 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.19; envelope-from=volker.ruemelin@t-online.de; helo=mailout06.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/20 13:17:47 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel , =?UTF-8?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Run the downstream playback queue even if there are no samples in the mixing engine buffer. The downstream queue may still have queued samples. Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/audio/audio.c b/audio/audio.c index 57eddb3324..a2c4c55477 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1186,6 +1186,9 @@ static void audio_run_out (AudioState *s) } } } + if (hw->pcm_ops->run_buffer_out) { + hw->pcm_ops->run_buffer_out(hw); + } continue; } =20 --=20 2.26.2 From nobody Thu May 16 09:12:07 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1600622786; cv=none; d=zohomail.com; s=zohoarc; b=Hz9sNswqd/YslwWGH1rgtx93NLlN76Jc0+MfUmUavHVT6RDnJbsPKkE9pzEOheZNJ8+JcZQ3D7uY7qC4nfWD2Jfj4MnmXt+teZu8FlHn92naiASAdGx+hTCSh2jN+yro6VIiEVnMmkboyJkkirvdh/Y3IPFuVkAMKQWauNtiGNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600622786; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l7eSTn2GH1KrLc86jctdEzpxvJA/SLFBh3n6aIfv7p4=; b=FIDgXUmPqD87nYFG9p4cBRmfFJkweUGvskIVX3q7o+ZgRxSw2Z3ODG4ctUB3YjywITF80ALM9k6kOscB08uSpnH1g/KXObXiRHmrdXS8B0Q7oU7l41DlOi2y+JtrchhUkF23Mc7MmgGD/XERFPgaw2ewjFlHhN3uscpwz1t3b30= ARC-Authentication-Results: i=1; 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 1600622786682819.4377671948134; Sun, 20 Sep 2020 10:26:26 -0700 (PDT) Received: from localhost ([::1]:33698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kK36X-0003K1-0j for importer@patchew.org; Sun, 20 Sep 2020 13:26:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2yI-00042d-Qn for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:57 -0400 Received: from mailout10.t-online.de ([194.25.134.21]:34972) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2yF-0006Gf-Nz for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:54 -0400 Received: from fwd26.aul.t-online.de (fwd26.aul.t-online.de [172.20.26.131]) by mailout10.t-online.de (Postfix) with SMTP id 0E2BE4165931; Sun, 20 Sep 2020 19:17:50 +0200 (CEST) Received: from linpower.localnet (rfpdq-ZJohcQrlbGTEh0LqOW6-npuHtiDqYLq0Mwpb8pxPvILaI32YHrS+BynlRZhi@[93.236.144.216]) by fwd26.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kK2yC-0oazw00; Sun, 20 Sep 2020 19:17:48 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 05E7733550B; Sun, 20 Sep 2020 19:17:30 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 8/9] audio: restore mixing-engine playback buffer size Date: Sun, 20 Sep 2020 19:17:28 +0200 Message-Id: <20200920171729.15861-8-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> References: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: rfpdq-ZJohcQrlbGTEh0LqOW6-npuHtiDqYLq0Mwpb8pxPvILaI32YHrS+BynlRZhi X-TOI-EXPURGATEID: 150726::1600622268-0000FB7B-5EC4546F/0/0 CLEAN NORMAL X-TOI-MSGID: 51c93e08-6bab-4c47-a915-e2c6f1151bed 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.21; envelope-from=volker.ruemelin@t-online.de; helo=mailout10.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/20 13:17:39 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel , =?UTF-8?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Commit ff095e5231 "audio: api for mixeng code free backends" introduced another FIFO for the audio subsystem with exactly the same size as the mixing-engine FIFO. Most audio backends use this generic FIFO. The generic FIFO used together with the mixing-engine FIFO doubles the audio FIFO size, because that's just two independent FIFOs connected together in series. For audio playback this nearly doubles the playback latency. This patch restores the effective mixing-engine playback buffer size to a pre v4.2.0 size by only accepting the amount of samples for the mixing-engine queue which the downstream queue accepts. Signed-off-by: Volker R=C3=BCmelin --- audio/alsaaudio.c | 1 + audio/audio.c | 68 +++++++++++++++++++++++++++++++++------------ audio/audio_int.h | 7 ++++- audio/coreaudio.c | 3 ++ audio/dsoundaudio.c | 6 ++++ audio/jackaudio.c | 1 + audio/noaudio.c | 1 + audio/ossaudio.c | 12 ++++++++ audio/paaudio.c | 6 ++++ audio/sdlaudio.c | 3 ++ audio/spiceaudio.c | 6 ++++ audio/wavaudio.c | 1 + 12 files changed, 97 insertions(+), 18 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index a8e62542f9..80235ddf94 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -923,6 +923,7 @@ static struct audio_pcm_ops alsa_pcm_ops =3D { .init_out =3D alsa_init_out, .fini_out =3D alsa_fini_out, .write =3D alsa_write, + .buffer_get_free =3D audio_generic_buffer_get_free, .run_buffer_out =3D audio_generic_run_buffer_out, .enable_out =3D alsa_enable_out, =20 diff --git a/audio/audio.c b/audio/audio.c index a2c4c55477..b908e041dd 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -700,12 +700,18 @@ static size_t audio_pcm_hw_get_live_out (HWVoiceOut *= hw, int *nb_live) return 0; } =20 +static size_t audio_pcm_hw_get_free(HWVoiceOut *hw) +{ + return hw->pcm_ops->buffer_get_free(hw) / hw->info.bytes_per_frame; +} + /* * Soft voice (playback) */ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t size) { - size_t hwsamples, samples, isamp, osamp, wpos, live, dead, left, swlim= , blck; + size_t hwsamples, samples, isamp, osamp, wpos, live, dead, left, limit; + size_t blck; size_t ret =3D 0, pos =3D 0, total =3D 0; =20 if (!sw) { @@ -728,27 +734,28 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void= *buf, size_t size) } =20 wpos =3D (sw->hw->mix_buf->pos + live) % hwsamples; - samples =3D size / sw->info.bytes_per_frame; =20 dead =3D hwsamples - live; - swlim =3D ((int64_t) dead << 32) / sw->ratio; - swlim =3D MIN (swlim, samples); - if (swlim) { - sw->conv (sw->buf, buf, swlim); + limit =3D audio_pcm_hw_get_free(sw->hw); + samples =3D ((int64_t)MIN(dead, limit) << 32) / sw->ratio; + limit =3D size / sw->info.bytes_per_frame; + samples =3D MIN(samples, limit); + if (samples) { + sw->conv(sw->buf, buf, samples); =20 if (sw->hw->pcm_ops && !sw->hw->pcm_ops->volume_out) { - mixeng_volume (sw->buf, swlim, &sw->vol); + mixeng_volume(sw->buf, samples, &sw->vol); } } =20 - while (swlim) { + while (samples) { dead =3D hwsamples - live; left =3D hwsamples - wpos; blck =3D MIN (dead, left); if (!blck) { break; } - isamp =3D swlim; + isamp =3D samples; osamp =3D blck; st_rate_flow_mix ( sw->rate, @@ -758,7 +765,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t size) &osamp ); ret +=3D isamp; - swlim -=3D isamp; + samples -=3D isamp; pos +=3D isamp; live +=3D osamp; wpos =3D (wpos + osamp) % hwsamples; @@ -1018,6 +1025,11 @@ static size_t audio_get_avail (SWVoiceIn *sw) return (((int64_t) live << 32) / sw->ratio) * sw->info.bytes_per_frame; } =20 +static size_t audio_sw_bytes_free(SWVoiceOut *sw, size_t free) +{ + return (((int64_t)free << 32) / sw->ratio) * sw->info.bytes_per_frame; +} + static size_t audio_get_free(SWVoiceOut *sw) { size_t live, dead; @@ -1037,13 +1049,11 @@ static size_t audio_get_free(SWVoiceOut *sw) dead =3D sw->hw->mix_buf->size - live; =20 #ifdef DEBUG_OUT - dolog ("%s: get_free live %d dead %d ret %" PRId64 "\n", - SW_NAME (sw), - live, dead, (((int64_t) dead << 32) / sw->ratio) * - sw->info.bytes_per_frame); + dolog("%s: get_free live %d dead %d sw_bytes %d\n", + SW_NAME(sw), live, dead, audio_sw_bytes_free(sw, dead)); #endif =20 - return (((int64_t) dead << 32) / sw->ratio) * sw->info.bytes_per_frame; + return dead; } =20 static void audio_capture_mix_and_clear(HWVoiceOut *hw, size_t rpos, @@ -1180,7 +1190,10 @@ static void audio_run_out (AudioState *s) if (!live) { for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_ne= xt) { if (sw->active) { - free =3D audio_get_free (sw); + size_t sw_free =3D audio_get_free(sw); + size_t hw_free =3D audio_pcm_hw_get_free(hw); + + free =3D audio_sw_bytes_free(sw, MIN(sw_free, hw_free)= ); if (free > 0) { sw->callback.fn (sw->callback.opaque, free); } @@ -1230,7 +1243,10 @@ static void audio_run_out (AudioState *s) } =20 if (sw->active) { - free =3D audio_get_free (sw); + size_t sw_free =3D audio_get_free(sw); + size_t hw_free =3D audio_pcm_hw_get_free(hw); + + free =3D audio_sw_bytes_free(sw, MIN(sw_free, hw_free)); if (free > 0) { sw->callback.fn (sw->callback.opaque, free); } @@ -1437,6 +1453,15 @@ void audio_generic_put_buffer_in(HWVoiceIn *hw, void= *buf, size_t size) hw->pending_emul -=3D size; } =20 +size_t audio_generic_buffer_get_free(HWVoiceOut *hw) +{ + if (hw->buf_emul) { + return hw->size_emul - hw->pending_emul; + } else { + return hw->samples * hw->info.bytes_per_frame; + } +} + void audio_generic_run_buffer_out(HWVoiceOut *hw) { while (hw->pending_emul) { @@ -1826,6 +1851,14 @@ void AUD_remove_card (QEMUSoundCard *card) g_free (card->name); } =20 +static size_t capture_buffer_get_free(HWVoiceOut *hw) +{ + return INT_MAX; +} + +static struct audio_pcm_ops capture_pcm_ops =3D { + .buffer_get_free =3D capture_buffer_get_free, +}; =20 CaptureVoiceOut *AUD_add_capture( AudioState *s, @@ -1872,6 +1905,7 @@ CaptureVoiceOut *AUD_add_capture( =20 hw =3D &cap->hw; hw->s =3D s; + hw->pcm_ops =3D &capture_pcm_ops; QLIST_INIT (&hw->sw_head); QLIST_INIT (&cap->cb_head); =20 diff --git a/audio/audio_int.h b/audio/audio_int.h index 4775857bf2..bb9425bc60 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -154,10 +154,14 @@ struct audio_pcm_ops { void (*fini_out)(HWVoiceOut *hw); size_t (*write) (HWVoiceOut *hw, void *buf, size_t size); void (*run_buffer_out)(HWVoiceOut *hw); + /* + * Get the free output buffer size. This is an upper limit. The size + * returned by function get_buffer_out may be smaller. + */ + size_t (*buffer_get_free)(HWVoiceOut *hw); /* * get a buffer that after later can be passed to put_buffer_out; opti= onal * returns the buffer, and writes it's size to size (in bytes) - * this is unrelated to the above buffer_size_out function */ void *(*get_buffer_out)(HWVoiceOut *hw, size_t *size); /* @@ -181,6 +185,7 @@ struct audio_pcm_ops { void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size); void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size); void audio_generic_run_buffer_out(HWVoiceOut *hw); +size_t audio_generic_buffer_get_free(HWVoiceOut *hw); void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size); size_t audio_generic_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size= ); size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size); diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 4b4365660f..deff0f2419 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -409,6 +409,7 @@ static int coreaudio_unlock (coreaudioVoiceOut *core, c= onst char *fn_name) coreaudio_unlock(core, "coreaudio_" #name); \ return ret; \ } +COREAUDIO_WRAPPER_FUNC(buffer_get_free, size_t, (HWVoiceOut *hw), (hw)) COREAUDIO_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *si= ze), (hw, size)) COREAUDIO_WRAPPER_FUNC(put_buffer_out, size_t, @@ -670,6 +671,8 @@ static struct audio_pcm_ops coreaudio_pcm_ops =3D { .fini_out =3D coreaudio_fini_out, /* wrapper for audio_generic_write */ .write =3D coreaudio_write, + /* wrapper for audio_generic_buffer_get_free */ + .buffer_get_free =3D coreaudio_buffer_get_free, /* wrapper for audio_generic_get_buffer_out */ .get_buffer_out =3D coreaudio_get_buffer_out, /* wrapper for audio_generic_put_buffer_out */ diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 4cdf19ab67..a0c61fb11c 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -411,6 +411,11 @@ static void dsound_enable_out(HWVoiceOut *hw, bool ena= ble) } } =20 +static size_t dsound_buffer_get_free(HWVoiceOut *hw) +{ + return INT_MAX; +} + static void *dsound_get_buffer_out(HWVoiceOut *hw, size_t *size) { DSoundVoiceOut *ds =3D (DSoundVoiceOut *) hw; @@ -686,6 +691,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, diff --git a/audio/jackaudio.c b/audio/jackaudio.c index 72ed7c4929..07848d9991 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -628,6 +628,7 @@ static struct audio_pcm_ops jack_pcm_ops =3D { .init_out =3D qjack_init_out, .fini_out =3D qjack_fini_out, .write =3D qjack_write, + .buffer_get_free =3D audio_generic_buffer_get_free, .run_buffer_out =3D audio_generic_run_buffer_out, .enable_out =3D qjack_enable_out, =20 diff --git a/audio/noaudio.c b/audio/noaudio.c index 05798ea210..0b932056fa 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -118,6 +118,7 @@ static struct audio_pcm_ops no_pcm_ops =3D { .init_out =3D no_init_out, .fini_out =3D no_fini_out, .write =3D no_write, + .buffer_get_free =3D audio_generic_buffer_get_free, .run_buffer_out =3D audio_generic_run_buffer_out, .enable_out =3D no_enable_out, =20 diff --git a/audio/ossaudio.c b/audio/ossaudio.c index a7dcaa31ad..7c46fef68c 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -391,6 +391,17 @@ static void oss_run_buffer_out(HWVoiceOut *hw) } } =20 +static size_t oss_buffer_get_free(HWVoiceOut *hw) +{ + OSSVoiceOut *oss =3D (OSSVoiceOut *)hw; + + if (oss->mmapped) { + return oss_get_available_bytes(oss); + } else { + return audio_generic_buffer_get_free(hw); + } +} + static void *oss_get_buffer_out(HWVoiceOut *hw, size_t *size) { OSSVoiceOut *oss =3D (OSSVoiceOut *) hw; @@ -754,6 +765,7 @@ static struct audio_pcm_ops oss_pcm_ops =3D { .init_out =3D oss_init_out, .fini_out =3D oss_fini_out, .write =3D oss_write, + .buffer_get_free =3D oss_buffer_get_free, .run_buffer_out =3D oss_run_buffer_out, .get_buffer_out =3D oss_get_buffer_out, .put_buffer_out =3D oss_put_buffer_out, diff --git a/audio/paaudio.c b/audio/paaudio.c index b052084698..0cb0c83546 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -202,6 +202,11 @@ unlock_and_fail: return 0; } =20 +static size_t qpa_buffer_get_free(HWVoiceOut *hw) +{ + return INT_MAX; +} + static void *qpa_get_buffer_out(HWVoiceOut *hw, size_t *size) { PAVoiceOut *p =3D (PAVoiceOut *) hw; @@ -860,6 +865,7 @@ static struct audio_pcm_ops qpa_pcm_ops =3D { .init_out =3D qpa_init_out, .fini_out =3D qpa_fini_out, .write =3D qpa_write, + .buffer_get_free =3D qpa_buffer_get_free, .get_buffer_out =3D qpa_get_buffer_out, .put_buffer_out =3D qpa_write, /* pa handles it */ .volume_out =3D qpa_volume_out, diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 21b7a0484b..cb931d0fda 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -253,6 +253,7 @@ static void sdl_callback (void *opaque, Uint8 *buf, int= len) return ret; \ } =20 +SDL_WRAPPER_FUNC(buffer_get_free, size_t, (HWVoiceOut *hw), (hw)) SDL_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *size), (hw, size), *size =3D 0, sdl_unlock) SDL_WRAPPER_FUNC(put_buffer_out, size_t, @@ -350,6 +351,8 @@ static struct audio_pcm_ops sdl_pcm_ops =3D { .fini_out =3D sdl_fini_out, /* wrapper for audio_generic_write */ .write =3D sdl_write, + /* wrapper for audio_generic_buffer_get_free */ + .buffer_get_free =3D sdl_buffer_get_free, /* wrapper for audio_generic_get_buffer_out */ .get_buffer_out =3D sdl_get_buffer_out, /* wrapper for audio_generic_put_buffer_out */ diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index c062742622..1fb0571dcc 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -120,6 +120,11 @@ static void line_out_fini (HWVoiceOut *hw) spice_server_remove_interface (&out->sin.base); } =20 +static size_t line_out_buffer_get_free(HWVoiceOut *hw) +{ + return INT_MAX; +} + static void *line_out_get_buffer(HWVoiceOut *hw, size_t *size) { SpiceVoiceOut *out =3D container_of(hw, SpiceVoiceOut, hw); @@ -282,6 +287,7 @@ static struct audio_pcm_ops audio_callbacks =3D { .init_out =3D line_out_init, .fini_out =3D line_out_fini, .write =3D audio_generic_write, + .buffer_get_free =3D line_out_buffer_get_free, .get_buffer_out =3D line_out_get_buffer, .put_buffer_out =3D line_out_put_buffer, .enable_out =3D line_out_enable, diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 20e6853f85..ac666335c7 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -197,6 +197,7 @@ static struct audio_pcm_ops wav_pcm_ops =3D { .init_out =3D wav_init_out, .fini_out =3D wav_fini_out, .write =3D wav_write_out, + .buffer_get_free =3D audio_generic_buffer_get_free, .run_buffer_out =3D audio_generic_run_buffer_out, .enable_out =3D wav_enable_out, }; --=20 2.26.2 From nobody Thu May 16 09:12:07 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1600622533; cv=none; d=zohomail.com; s=zohoarc; b=KIGRYEzbh9yZ4ekn9RurkSqNR9XgAg9yqR7OHmFPKYcuSECQgP4BlA4L2RBv60px3+ljpkGNaFNWprhqT1Z5c7OtVrDnzPkVIKmMPKV6OAuJL8MP98SrQwS8CEiMKqSt/Ucr5e0wf8X5PJbvMv9pnm2dxV9j/Hn1jGoWImIdZKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600622533; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZYI3ZB4nBRuNoIA9NhFNpDs9l8JLYDm/Byx/xuA+is8=; b=JecDJlx2/54j+Upvc+2HSB3EXh35jRurFpd4koku6nX+heADkjhH+L7BqHpocJS2mpVraJ0/1UETi1ncPRzlGLYdBnITYszdmzo3MoOkAuCyoVh8aWIh1fcZiKL0gm3hzloGt0MPtfOpqsCWkG9lSmorpobLug71X4WmD8n2Bno= ARC-Authentication-Results: i=1; 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 1600622533133884.271572232682; Sun, 20 Sep 2020 10:22:13 -0700 (PDT) Received: from localhost ([::1]:54270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kK32R-0008QF-RG for importer@patchew.org; Sun, 20 Sep 2020 13:22:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2yN-00043K-Fy for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:18:00 -0400 Received: from mailout11.t-online.de ([194.25.134.85]:51116) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kK2yL-0006HF-SA for qemu-devel@nongnu.org; Sun, 20 Sep 2020 13:17:59 -0400 Received: from fwd40.aul.t-online.de (fwd40.aul.t-online.de [172.20.26.139]) by mailout11.t-online.de (Postfix) with SMTP id 9C2864256C51; Sun, 20 Sep 2020 19:17:56 +0200 (CEST) Received: from linpower.localnet (G-LqO6ZFQhtVJ4wGXZSDSgM57BRmZT9PIPGCSOpjRa-ikfuzLDr7U2cPpbnkf3YQ6z@[93.236.144.216]) by fwd40.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kK2yF-3uB8XQ0; Sun, 20 Sep 2020 19:17:51 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 07EFC33550C; Sun, 20 Sep 2020 19:17:30 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 9/9] audio: revert tests for pcm_ops table Date: Sun, 20 Sep 2020 19:17:29 +0200 Message-Id: <20200920171729.15861-9-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> References: <84f1c61a-8399-c75e-96c2-febfc2dd5fab@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: G-LqO6ZFQhtVJ4wGXZSDSgM57BRmZT9PIPGCSOpjRa-ikfuzLDr7U2cPpbnkf3YQ6z X-TOI-EXPURGATEID: 150726::1600622271-00001797-BE7FCD5B/0/0 CLEAN NORMAL X-TOI-MSGID: fb6186ab-3716-4ad8-81f2-02470f0e43e6 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.85; envelope-from=volker.ruemelin@t-online.de; helo=mailout11.t-online.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/20 13:17:31 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel , =?UTF-8?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" With previous commit every audio backend has a pcm_ops function table. It's no longer necessary to test if the table is available. This reverts commit cbaf25d1f5: "audio: fix wavcapture segfault" Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index b908e041dd..f63781b4db 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -649,7 +649,7 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *bu= f, size_t size) total +=3D isamp; } =20 - if (hw->pcm_ops && !hw->pcm_ops->volume_in) { + if (!hw->pcm_ops->volume_in) { mixeng_volume (sw->buf, ret, &sw->vol); } =20 @@ -743,7 +743,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t size) if (samples) { sw->conv(sw->buf, buf, samples); =20 - if (sw->hw->pcm_ops && !sw->hw->pcm_ops->volume_out) { + if (!sw->hw->pcm_ops->volume_out) { mixeng_volume(sw->buf, samples, &sw->vol); } } --=20 2.26.2