From nobody Sat Nov 15 17:50:03 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748179705; cv=none; d=zohomail.com; s=zohoarc; b=FhfnAvsbGfJ4uP0Ot2l6xdFVDMkmAwkmB6jXM2gbUcQ6xpj5NVI29gIHJKgRHBzMWtGLCze3urr/W7s5r+CqAbYow0H41xrK7Myj4FpZdvA4yuzFj5wUd3rQW1rJQf8Vonp7V2wxVMS2jIDdYVXKslXMkIjCKIKLEyOL/XNm2MY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748179705; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AMGaSW13wOdC4VmIpjDX+VnZ2CkLsJw6JxNfUQcYMkg=; b=RBaDadAghTY+O870tKsGCNJaMy5tDTv1QXTxV9glzZxOcJBEAuXINeOai5yACU5wVrjjGUbJE0Qnilxoy54SdgBGflkmK/XYLChVHXpO4qy4hajZuQ1ntR/IfRNT71BvZeO54dbSfC1wwYL8q36JJjw0zHi+nl9C+R1F6bEWGHM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748179705098557.2802157802427; Sun, 25 May 2025 06:28:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uJBO0-0007T2-O7; Sun, 25 May 2025 09:27:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBNz-0007Sm-9k for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBNx-0003K0-GY for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:31 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-251-hWs1IlVJMda1mwgVLylVrw-1; Sun, 25 May 2025 09:27:25 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CC5CE195608A; Sun, 25 May 2025 13:27:23 +0000 (UTC) Received: from localhost (unknown [10.45.242.5]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D3DB11800361; Sun, 25 May 2025 13:27:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748179648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AMGaSW13wOdC4VmIpjDX+VnZ2CkLsJw6JxNfUQcYMkg=; b=ACw2nuph5n0g4Ldgzs1mR+scL1CruXp9uH3EUgAsXScxk1jQq+GrOgjoBWXVzKnE8vWn5e xwThmMnyH6M02/Uu8FUedxqByvOaan+4N5AYR+vQWcNDg67t+XLcM9mhioh/BTQV2QpaG8 65/DMHGZg1mt6az9+VyalgUKesKxHK0= X-MC-Unique: hWs1IlVJMda1mwgVLylVrw-1 X-Mimecast-MFC-AGG-ID: hWs1IlVJMda1mwgVLylVrw_1748179644 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Volker=20R=C3=BCmelin?= , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PULL 1/9] tests/functional: use 'none' audio driver for q800 tests Date: Sun, 25 May 2025 15:27:08 +0200 Message-ID: <20250525132717.527392-2-marcandre.lureau@redhat.com> In-Reply-To: <20250525132717.527392-1-marcandre.lureau@redhat.com> References: <20250525132717.527392-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -59 X-Spam_score: -6.0 X-Spam_bar: ------ X-Spam_report: (-6.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1748179707131116600 From: Volker R=C3=BCmelin Since commit ac13a6b3fd ("audio: add Apple Sound Chip (ASC) emulation") the Quadra 800 machine has an audio device. It is not guaranteed that the default audio driver of the audio subsystem will work correctly on all host systems. Therefore, the 'none' audio driver should be used in all q800 tests. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2812 Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20250515054429.7385-1-vr_qemu@t-online.de> --- tests/functional/test_m68k_q800.py | 3 ++- tests/functional/test_m68k_replay.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/functional/test_m68k_q800.py b/tests/functional/test_m68= k_q800.py index 400b7aeb5d..b3e655346c 100755 --- a/tests/functional/test_m68k_q800.py +++ b/tests/functional/test_m68k_q800.py @@ -25,7 +25,8 @@ def test_m68k_q800(self): kernel_command_line =3D (self.KERNEL_COMMON_COMMAND_LINE + 'console=3DttyS0 vga=3Doff') self.vm.add_args('-kernel', kernel_path, - '-append', kernel_command_line) + '-append', kernel_command_line, + '-audio', 'none') self.vm.launch() console_pattern =3D 'Kernel command line: %s' % kernel_command_line self.wait_for_console_pattern(console_pattern) diff --git a/tests/functional/test_m68k_replay.py b/tests/functional/test_m= 68k_replay.py index 18c1db539c..213d6ae07e 100755 --- a/tests/functional/test_m68k_replay.py +++ b/tests/functional/test_m68k_replay.py @@ -24,7 +24,8 @@ def test_q800(self): kernel_command_line =3D (self.KERNEL_COMMON_COMMAND_LINE + 'console=3DttyS0 vga=3Doff') console_pattern =3D 'No filesystem could mount root' - self.run_rr(kernel_path, kernel_command_line, console_pattern) + self.run_rr(kernel_path, kernel_command_line, console_pattern, + args=3D('-audio', 'none')) =20 ASSET_MCF5208 =3D Asset( 'https://qemu-advcal.gitlab.io/qac-best-of-multiarch/download/day07= .tar.xz', --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748179705; cv=none; d=zohomail.com; s=zohoarc; b=IPwTfMA4iSJMGYYT25Sp/xa9ZGrOyGGfZVoas8+4n4W3Z2I1gOnTd8bhmDk/vhzqO4DqoNtGjqf+KpwhrJuqq8cNp5PTfcFfgZdh8KBrE46vLWUpvChnwe4zHDKziK2ypPskU0JDVLfFFCokXypqaNnu6QRros1KQhuf0aR4xK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748179705; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lnusP8ELZOXFE2ANHFuk76diHHj8M43cSa1crKA301c=; b=K0kfg+ankNRLH+LJxUeLsvv4asmzrn7lNgo4vLr+OlbBBNpK2Hii2XrmYlgdcL/YjGr6F5mEyn/KnPuhtGsMpn9mAypW6pykP4buBTu6Ch3tGa9yEN3Edc9I8SUOdccxWDYpO/ECBsBpvn02fncl4/+mHYQNW2ZKqszop1KgnTE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748179705104631.2346311671513; Sun, 25 May 2025 06:28:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uJBO2-0007To-84; Sun, 25 May 2025 09:27:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBO0-0007T9-KG for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBNz-0003K5-1u for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:32 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-477-U35HYQl7MmeClTk-y0xPjw-1; Sun, 25 May 2025 09:27:28 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 01E3C19560AA; Sun, 25 May 2025 13:27:27 +0000 (UTC) Received: from localhost (unknown [10.45.242.5]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A856930001A1; Sun, 25 May 2025 13:27:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748179649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lnusP8ELZOXFE2ANHFuk76diHHj8M43cSa1crKA301c=; b=giFFAodf/Q+I065TonaNRzavbrCnZO+XmF424TDnJ9tMl3DYlWQ8SgwjsgJOcniyxwx7rZ WIegIaOv1X9Ek4xRpICU7fCJlCOGj7Vj8tiJogdZiJLjTeGzQwJyQd9/ep7xw/T6GgyeAf Jeb37j2Gn7rIIJSFF+1TN3lyELxWKI8= X-MC-Unique: U35HYQl7MmeClTk-y0xPjw-1 X-Mimecast-MFC-AGG-ID: U35HYQl7MmeClTk-y0xPjw_1748179647 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 2/9] audio: fix SIGSEGV in AUD_get_buffer_size_out() Date: Sun, 25 May 2025 15:27:09 +0200 Message-ID: <20250525132717.527392-3-marcandre.lureau@redhat.com> In-Reply-To: <20250525132717.527392-1-marcandre.lureau@redhat.com> References: <20250525132717.527392-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -59 X-Spam_score: -6.0 X-Spam_bar: ------ X-Spam_report: (-6.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1748179707099116600 From: Volker R=C3=BCmelin As far as the emulated audio devices are concerned the pointer returned by AUD_open_out() is an opaque handle. This includes the NULL pointer. In this case, AUD_get_buffer_size_out() should return a sensible buffer size instead of triggering a segmentation fault. All other public AUD_*_out() and audio_*_out() functions handle this case. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20250515054429.7385-2-vr_qemu@t-online.de> --- audio/audio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/audio/audio.c b/audio/audio.c index 41ee11aaad..70ef22b1a4 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -905,6 +905,10 @@ size_t AUD_read(SWVoiceIn *sw, void *buf, size_t size) =20 int AUD_get_buffer_size_out(SWVoiceOut *sw) { + if (!sw) { + return 0; + } + return sw->hw->samples * sw->hw->info.bytes_per_frame; } =20 --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748179731; cv=none; d=zohomail.com; s=zohoarc; b=CX8EGLAkc2e0Q5/NCE81/ub3J2fLXDhfnooVDCtsquFNDV0mwXvKeL+9iDLhCmNGeplGzmr1bQofNYzWyP+zs/LbH9hXPUU9tUqyHqO4TFXdUqYRNa3zLmrQNrhAtaRZxxV6MdQjNL4zs2x4WPKDtPemXnvu/h3POaoKu2hCkk8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748179731; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BqlUAxT+hdSLz403cEf2Dsl53ycpIlMX0426Ocr9F4U=; b=hzOw+j5cRHhzazGv83xFRb0eSqLPrrKDM+uL0K9Zh7qznfDeriGQfj2gj5hW4g4OlYndFj4kcboNfrmD706LHgQIEycUHMuAF1RGLW2KeMBJhhBanu//jzXQ8phAckRFxQx5097U3M+RHCR5zpRMyJFSmZesUxE/CEuZugOXp+8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748179731409336.38201212793365; Sun, 25 May 2025 06:28:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uJBO5-0007UV-0i; Sun, 25 May 2025 09:27:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBO3-0007Tx-7Y for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBO1-0003KL-Ku for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:34 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-505-lO1IB8owPni4NJ4xU90g0g-1; Sun, 25 May 2025 09:27:31 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 684301956080; Sun, 25 May 2025 13:27:30 +0000 (UTC) Received: from localhost (unknown [10.45.242.5]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 262DF1956095; Sun, 25 May 2025 13:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748179652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BqlUAxT+hdSLz403cEf2Dsl53ycpIlMX0426Ocr9F4U=; b=ijw1ljmtPT+Jf5GbMJKsahxcCxIovbvHyjAGfyCeEGjHBHCMLI6eb5NuFqGfb7cShZJk0c mQma9fCr1tD3ssJokmZPqYWgw7rZXz/56kZsG0golo55idGHtmSwfBRsMBQWyJJKZ1YkSl U0b9CS67uRUuZvuob4To98xjaPZ6C4Q= X-MC-Unique: lO1IB8owPni4NJ4xU90g0g-1 X-Mimecast-MFC-AGG-ID: lO1IB8owPni4NJ4xU90g0g_1748179650 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 3/9] audio: fix size calculation in AUD_get_buffer_size_out() Date: Sun, 25 May 2025 15:27:10 +0200 Message-ID: <20250525132717.527392-4-marcandre.lureau@redhat.com> In-Reply-To: <20250525132717.527392-1-marcandre.lureau@redhat.com> References: <20250525132717.527392-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -59 X-Spam_score: -6.0 X-Spam_bar: ------ X-Spam_report: (-6.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1748179733330116600 From: Volker R=C3=BCmelin The buffer size calculated by AUD_get_buffer_size_out() is often incorrect. sw->hw->samples * sw->hw->info.bytes_per_frame is the size of the mixing engine buffer in audio frames multiplied by the size of one frame of the audio backend. Due to resampling or format conversion, the size of the frontend buffer can differ significantly. Return the correct buffer size when the mixing engine is used. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20250515054429.7385-3-vr_qemu@t-online.de> --- audio/audio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/audio/audio.c b/audio/audio.c index 70ef22b1a4..3f5baf0cc6 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -909,6 +909,10 @@ int AUD_get_buffer_size_out(SWVoiceOut *sw) return 0; } =20 + if (audio_get_pdo_out(sw->s->dev)->mixing_engine) { + return sw->resample_buf.size * sw->info.bytes_per_frame; + } + return sw->hw->samples * sw->hw->info.bytes_per_frame; } =20 --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748179705; cv=none; d=zohomail.com; s=zohoarc; b=TW63FXyZhiNfQVpRkUHu8JNPz/dQdgWU7fL78Xxow4eKDShy2eToLRL8h8FGogR2mZmNV40HEH5nlTRUkmz1H/zNWSp21+YemS/+DX1PX4iu44ajterYrFB+P8jCI7apEvxM/fQJI0QYEzKC/RI3YiF82xSKjN3oxIazVVY0SpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748179705; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BDhB1i4A6BjVBlpPJhMtwYfTcIqCx6p1i4XfmTXC0wc=; b=GFYDPdCDGEA1JSThdUBlYBDJBYoKcV84zh5TV8Q1yq599J3qdO/yEL29ZygnibHI0MVmrox8rpzTVw5e8vfB2o7cJ1+8c/qwEFEMhQxMXXF2OpATCUhLt0q7ZX1Dw6o7j70BShzAeD1F+VEKCJMEQe7Jp7OEKQTzZdxQQdKJCqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17481797051291003.3577205619405; Sun, 25 May 2025 06:28:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uJBOB-0007WG-V9; Sun, 25 May 2025 09:27:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBO9-0007VZ-Mv for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBO8-0003Kh-0P for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:41 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-279-0ZnTovqQOmmIY01fCM5e_g-1; Sun, 25 May 2025 09:27:34 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BA8D418004AD; Sun, 25 May 2025 13:27:33 +0000 (UTC) Received: from localhost (unknown [10.45.242.5]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E0F3319560AB; Sun, 25 May 2025 13:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748179658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BDhB1i4A6BjVBlpPJhMtwYfTcIqCx6p1i4XfmTXC0wc=; b=OGD5LwZKvZNReGOq+CYlM3x8v7XupZn80wBpGLEyw4da7jCyyQahWyD9Wg+J1orEAEsO7M O+/BwRADSLLaMHsA5q7tsNEtQ2hUfqbjVknb0c6X9g4zeErDklInR5j4Nal0MnUCsrikfp TfB+h11clMl4bfwWocvkYNWN3oTwdfg= X-MC-Unique: 0ZnTovqQOmmIY01fCM5e_g-1 X-Mimecast-MFC-AGG-ID: 0ZnTovqQOmmIY01fCM5e_g_1748179653 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Volker=20R=C3=BCmelin?= , Laurent Vivier , Gerd Hoffmann Subject: [PULL 4/9] hw/audio/asc: fix SIGSEGV in asc_realize() Date: Sun, 25 May 2025 15:27:11 +0200 Message-ID: <20250525132717.527392-5-marcandre.lureau@redhat.com> In-Reply-To: <20250525132717.527392-1-marcandre.lureau@redhat.com> References: <20250525132717.527392-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -59 X-Spam_score: -6.0 X-Spam_bar: ------ X-Spam_report: (-6.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1748179707110116600 From: Volker R=C3=BCmelin AUD_open_out() may fail and return NULL. This may then lead to a segmentation fault in memset() below. The memset() behaviour is undefined if the pointer to the destination object is a null pointer. Add the missing error handling code. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Mark Cave-Ayland Message-Id: <20250515054429.7385-4-vr_qemu@t-online.de> --- hw/audio/asc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/audio/asc.c b/hw/audio/asc.c index 18382ccf6a..6721c0d9fb 100644 --- a/hw/audio/asc.c +++ b/hw/audio/asc.c @@ -12,6 +12,7 @@ =20 #include "qemu/osdep.h" #include "qemu/timer.h" +#include "qapi/error.h" #include "hw/sysbus.h" #include "hw/irq.h" #include "audio/audio.h" @@ -653,6 +654,12 @@ static void asc_realize(DeviceState *dev, Error **errp) =20 s->voice =3D AUD_open_out(&s->card, s->voice, "asc.out", s, asc_out_cb, &as); + if (!s->voice) { + AUD_remove_card(&s->card); + error_setg(errp, "Initializing audio stream failed"); + return; + } + s->shift =3D 1; s->samples =3D AUD_get_buffer_size_out(s->voice) >> s->shift; s->mixbuf =3D g_malloc0(s->samples << s->shift); --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748179746; cv=none; d=zohomail.com; s=zohoarc; b=cc8E9i8k1hEqJ/99Eo7sX5IjWnGwj3sVPBRaO/nSBc113e0A3uemXw2oxD8O3Attwh4m0/NlyRhJ5M+6ynsUGIuOH1hUccZxX0wAN0LRkrdC+PM6vf8orw4jS4PIf7UGmgorN5Tw40REEyRM9qh9gKfUMZwimhy+UGmpBZGPkMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748179746; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4zBlc/trBlZVvlSclE+TjFVwrWRwhdoV0H1DLERA2U0=; b=YKOcIjHQR7G65xzgqn0CwSTRZAaUWUbloliWXlwlnccQo3gppjrWgfI/uKZOFCMv2HuYjYL1vtKL2iSw1trApSfhICgnowDUn9yPP9nNc0oECYjWn1brBIGRYKkuwO413V6V8kf8TOLfuJ9W3ksaOK1ctiAvsAIwQsDICCfcbXk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748179746591396.8215328581814; Sun, 25 May 2025 06:29:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uJBOA-0007Vt-Rx; Sun, 25 May 2025 09:27:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBO9-0007VY-MP for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBO8-0003Kj-08 for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:41 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-287-0x-jPlCWO8K_cTYlWVGtxQ-1; Sun, 25 May 2025 09:27:37 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 559C61800447; Sun, 25 May 2025 13:27:36 +0000 (UTC) Received: from localhost (unknown [10.45.242.5]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A7A5D1956095; Sun, 25 May 2025 13:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748179659; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4zBlc/trBlZVvlSclE+TjFVwrWRwhdoV0H1DLERA2U0=; b=cUt1pMZzeHGj6E11OndJUNZFKEl3chFdGTrVfbiC0mLIUbaJH23+IbEptwklk8bhI9q0TG u+XZjr4TmmEj9heBfamCnwTC7zAZmXL8CiBUbPvcONlI0tlvjeqVWsiqBJi5c466l+QC8J 9YMwa6cyapZwjz5HFwMW0aLsZlYiS5A= X-MC-Unique: 0x-jPlCWO8K_cTYlWVGtxQ-1 X-Mimecast-MFC-AGG-ID: 0x-jPlCWO8K_cTYlWVGtxQ_1748179656 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Volker=20R=C3=BCmelin?= , Laurent Vivier , Gerd Hoffmann Subject: [PULL 5/9] hw/audio/asc: replace g_malloc0() with g_malloc() Date: Sun, 25 May 2025 15:27:12 +0200 Message-ID: <20250525132717.527392-6-marcandre.lureau@redhat.com> In-Reply-To: <20250525132717.527392-1-marcandre.lureau@redhat.com> References: <20250525132717.527392-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -59 X-Spam_score: -6.0 X-Spam_bar: ------ X-Spam_report: (-6.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1748179747489116600 From: Volker R=C3=BCmelin There is no need to allocate initialized memory with g_malloc0() if it's directly followed by a memset() function call. g_malloc() is sufficient. Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Mark Cave-Ayland Signed-off-by: Volker R=C3=BCmelin Message-Id: <20250515054429.7385-5-vr_qemu@t-online.de> --- hw/audio/asc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/audio/asc.c b/hw/audio/asc.c index 6721c0d9fb..edd42d6d91 100644 --- a/hw/audio/asc.c +++ b/hw/audio/asc.c @@ -664,7 +664,7 @@ static void asc_realize(DeviceState *dev, Error **errp) s->samples =3D AUD_get_buffer_size_out(s->voice) >> s->shift; s->mixbuf =3D g_malloc0(s->samples << s->shift); =20 - s->silentbuf =3D g_malloc0(s->samples << s->shift); + s->silentbuf =3D g_malloc(s->samples << s->shift); memset(s->silentbuf, 0x80, s->samples << s->shift); =20 /* Add easc registers if required */ --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748179711; cv=none; d=zohomail.com; s=zohoarc; b=iywADAhqAdWeOfr8dkh5U6MhDBO0WZzkVCsWDU4cq+pJyFJordN4mw+SETH/vVu/CJXUIQnzKzD/WKLbeul9rY/zVPOrEJGIKQBcEurTXbjvGgVVvV5qxrJu26JQxp8IhBFI/U3UtYvJrM6pUv08dklXyeNpikSDVNFTG3R6ygk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748179711; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FLku0fleFOmUk4q9nyUVYXtVJGIVygN4ILzV4cARliE=; b=ayxt6Tztf5ACtRpbyU2cyWgugSGxlqNluNzIi+8J0UEzxK4NdmctgsibhWA+ad1G+ZCeVXhbMpCPQS2Id55O3IEdy35QLOY5+sCSF+ojgZPZBuThxZh3cvyYw62qAPtzv8Bf/aduxUx0c+pgGHfPT1kC+C4jki/isldh/VyUCSw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17481797111401013.6717304452543; Sun, 25 May 2025 06:28:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uJBOG-0007YG-QU; Sun, 25 May 2025 09:27:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBOE-0007XO-TN for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBOD-0003Lw-75 for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:46 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-oLvzES_uPX-V1savboGTeQ-1; Sun, 25 May 2025 09:27:40 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F3E5219560AA; Sun, 25 May 2025 13:27:39 +0000 (UTC) Received: from localhost (unknown [10.45.242.5]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A0081180045B; Sun, 25 May 2025 13:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748179664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FLku0fleFOmUk4q9nyUVYXtVJGIVygN4ILzV4cARliE=; b=YZF/lpa0Y3iV+wexO3dN/7VurlVjTcdRxHveDm3N3YLSpjueUDv8LWzb6dgO3RBC5KZuxN 0xA8QGn7+kLWXyszkcbCmx5u1HglOaEMNL04FSpqTzaLLtakxrBeeuRUR3fj4I+aLaW2dg jd1n69M0VQ6CwYf6t29+p7ZarakSIP4= X-MC-Unique: oLvzES_uPX-V1savboGTeQ-1 X-Mimecast-MFC-AGG-ID: oLvzES_uPX-V1savboGTeQ_1748179660 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 6/9] audio/mixeng: remove unnecessary pointer type casts Date: Sun, 25 May 2025 15:27:13 +0200 Message-ID: <20250525132717.527392-7-marcandre.lureau@redhat.com> In-Reply-To: <20250525132717.527392-1-marcandre.lureau@redhat.com> References: <20250525132717.527392-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -59 X-Spam_score: -6.0 X-Spam_bar: ------ X-Spam_report: (-6.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1748179713118116600 From: Volker R=C3=BCmelin A simple assignment automatically converts a void pointer type to any other pointer type. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20250515054429.7385-6-vr_qemu@t-online.de> --- audio/mixeng.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/audio/mixeng.c b/audio/mixeng.c index 69f6549224..13e1ff9b08 100644 --- a/audio/mixeng.c +++ b/audio/mixeng.c @@ -286,7 +286,7 @@ static const float float_scale_reciprocal =3D 1.f / ((i= nt64_t)INT32_MAX + 1); static void conv_natural_float_to_mono(struct st_sample *dst, const void *= src, int samples) { - float *in =3D (float *)src; + const float *in =3D src; =20 while (samples--) { dst->r =3D dst->l =3D CONV_NATURAL_FLOAT(*in++); @@ -297,7 +297,7 @@ static void conv_natural_float_to_mono(struct st_sample= *dst, const void *src, static void conv_natural_float_to_stereo(struct st_sample *dst, const void= *src, int samples) { - float *in =3D (float *)src; + const float *in =3D src; =20 while (samples--) { dst->l =3D CONV_NATURAL_FLOAT(*in++); @@ -314,7 +314,7 @@ t_sample *mixeng_conv_float[2] =3D { static void clip_natural_float_from_mono(void *dst, const struct st_sample= *src, int samples) { - float *out =3D (float *)dst; + float *out =3D dst; =20 while (samples--) { *out++ =3D CLIP_NATURAL_FLOAT(src->l + src->r); @@ -325,7 +325,7 @@ static void clip_natural_float_from_mono(void *dst, con= st struct st_sample *src, static void clip_natural_float_from_stereo( void *dst, const struct st_sample *src, int samples) { - float *out =3D (float *)dst; + float *out =3D dst; =20 while (samples--) { *out++ =3D CLIP_NATURAL_FLOAT(src->l); --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748179775; cv=none; d=zohomail.com; s=zohoarc; b=DvEksetlcb3BRh/HHrRSMpGe9/LyLPjiMykecnNkvgHnLWNJzRcPwJUAH2DhqC+xpukh0oN1jozDHcdRy0tPf+qubWTOrZZ8qKJXBA6ApQv7q8geQMUDe+Nsywsin4wmFWEFZPqtwJOMsFG+BpOfl4UAlYxbf3LHfnCPmu27Zzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748179775; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FBIR8jEV7umWJBJj66t3fKCqalHrQZeavnN66Mv4MRY=; b=nc8fsMuxcDZh2kQMl6YnjYSk4g/h2313tF6PoOYEZA8eqOQHSCxM6Jz5HWXGA2beeX5epzh+f89hhBzR39DK5qjSJxQS4OU0f8MkcTM8w7V0I+nkT+mnKHwfXAnZ6BG6IrIyg9Ol66MMcHAIrMka3pnq+prm2Sfy2H0VhLRpNUk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174817977565251.36455724653035; Sun, 25 May 2025 06:29:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uJBOL-0007Z9-BW; Sun, 25 May 2025 09:27:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBOI-0007YJ-Co for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBOG-0003MB-6C for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:49 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-P90y0w1rOeebLNo7yUszsA-1; Sun, 25 May 2025 09:27:44 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 47545195608A; Sun, 25 May 2025 13:27:43 +0000 (UTC) Received: from localhost (unknown [10.45.242.5]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 36BF3195608D; Sun, 25 May 2025 13:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748179667; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FBIR8jEV7umWJBJj66t3fKCqalHrQZeavnN66Mv4MRY=; b=cUISZEMfb0hJk5tAuYh1SdiOvzfa78+r7mfnuIn7TWZpEBBMpTs3rTgcdVziwW2rNyAMXB Odf/Z8RomkdJstrRA39vA+q2OJsF3QjV5N5wjmsMTKGDLHWqAU/6ODO2Nskuw3Vc7OmcM+ MFd1L7RqfUZHzbmxN4VUpkH/tE6Xs5U= X-MC-Unique: P90y0w1rOeebLNo7yUszsA-1 X-Mimecast-MFC-AGG-ID: P90y0w1rOeebLNo7yUszsA_1748179663 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 7/9] audio: add float sample endianness converters Date: Sun, 25 May 2025 15:27:14 +0200 Message-ID: <20250525132717.527392-8-marcandre.lureau@redhat.com> In-Reply-To: <20250525132717.527392-1-marcandre.lureau@redhat.com> References: <20250525132717.527392-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -59 X-Spam_score: -6.0 X-Spam_bar: ------ X-Spam_report: (-6.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1748179778005116600 From: Volker R=C3=BCmelin Commit ed2a4a7941 ("audio: proper support for float samples in mixeng") added support for float audio samples. As there were no audio frontend devices with float support at that time, the code was limited to native endian float samples. When nobody was paying attention, an audio device that supports floating point samples crept in with commit eb9ad377bb ("virtio-sound: handle control messages and streams"). Add code for the audio subsystem to convert float samples to the correct endianness. The type punning code was taken from the PipeWire project. Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20250515054429.7385-7-vr_qemu@t-online.de> --- audio/audio_template.h | 12 ++++--- audio/mixeng.h | 6 ++-- audio/audio.c | 3 +- audio/mixeng.c | 75 ++++++++++++++++++++++++++++++++++++++---- 4 files changed, 82 insertions(+), 14 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index 7ccfec0116..c29d79c443 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -174,9 +174,11 @@ static int glue (audio_pcm_sw_init_, TYPE) ( =20 if (sw->info.is_float) { #ifdef DAC - sw->conv =3D mixeng_conv_float[sw->info.nchannels =3D=3D 2]; + sw->conv =3D mixeng_conv_float[sw->info.nchannels =3D=3D 2] + [sw->info.swap_endianness]; #else - sw->clip =3D mixeng_clip_float[sw->info.nchannels =3D=3D 2]; + sw->clip =3D mixeng_clip_float[sw->info.nchannels =3D=3D 2] + [sw->info.swap_endianness]; #endif } else { #ifdef DAC @@ -303,9 +305,11 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioStat= e *s, =20 if (hw->info.is_float) { #ifdef DAC - hw->clip =3D mixeng_clip_float[hw->info.nchannels =3D=3D 2]; + hw->clip =3D mixeng_clip_float[hw->info.nchannels =3D=3D 2] + [hw->info.swap_endianness]; #else - hw->conv =3D mixeng_conv_float[hw->info.nchannels =3D=3D 2]; + hw->conv =3D mixeng_conv_float[hw->info.nchannels =3D=3D 2] + [hw->info.swap_endianness]; #endif } else { #ifdef DAC diff --git a/audio/mixeng.h b/audio/mixeng.h index a5f56d2c26..ead93ac2f7 100644 --- a/audio/mixeng.h +++ b/audio/mixeng.h @@ -42,9 +42,9 @@ typedef void (f_sample) (void *dst, const struct st_sampl= e *src, int samples); extern t_sample *mixeng_conv[2][2][2][3]; extern f_sample *mixeng_clip[2][2][2][3]; =20 -/* indices: [stereo] */ -extern t_sample *mixeng_conv_float[2]; -extern f_sample *mixeng_clip_float[2]; +/* indices: [stereo][swap endianness] */ +extern t_sample *mixeng_conv_float[2][2]; +extern f_sample *mixeng_clip_float[2][2]; =20 void *st_rate_start (int inrate, int outrate); void st_rate_flow(void *opaque, st_sample *ibuf, st_sample *obuf, diff --git a/audio/audio.c b/audio/audio.c index 3f5baf0cc6..b58ad74433 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1892,7 +1892,8 @@ CaptureVoiceOut *AUD_add_capture( cap->buf =3D g_malloc0_n(hw->mix_buf.size, hw->info.bytes_per_fram= e); =20 if (hw->info.is_float) { - hw->clip =3D mixeng_clip_float[hw->info.nchannels =3D=3D 2]; + hw->clip =3D mixeng_clip_float[hw->info.nchannels =3D=3D 2] + [hw->info.swap_endianness]; } else { hw->clip =3D mixeng_clip [hw->info.nchannels =3D=3D 2] diff --git a/audio/mixeng.c b/audio/mixeng.c index 13e1ff9b08..703ee5448f 100644 --- a/audio/mixeng.c +++ b/audio/mixeng.c @@ -283,6 +283,11 @@ static const float float_scale_reciprocal =3D 1.f / ((= int64_t)INT32_MAX + 1); #endif #endif =20 +#define F32_TO_F32S(v) \ + bswap32((union { uint32_t i; float f; }){ .f =3D (v) }.i) +#define F32S_TO_F32(v) \ + ((union { uint32_t i; float f; }){ .i =3D bswap32(v) }.f) + static void conv_natural_float_to_mono(struct st_sample *dst, const void *= src, int samples) { @@ -294,6 +299,17 @@ static void conv_natural_float_to_mono(struct st_sampl= e *dst, const void *src, } } =20 +static void conv_swap_float_to_mono(struct st_sample *dst, const void *src, + int samples) +{ + const uint32_t *in_f32s =3D src; + + while (samples--) { + dst->r =3D dst->l =3D CONV_NATURAL_FLOAT(F32S_TO_F32(*in_f32s++)); + dst++; + } +} + static void conv_natural_float_to_stereo(struct st_sample *dst, const void= *src, int samples) { @@ -306,9 +322,27 @@ static void conv_natural_float_to_stereo(struct st_sam= ple *dst, const void *src, } } =20 -t_sample *mixeng_conv_float[2] =3D { - conv_natural_float_to_mono, - conv_natural_float_to_stereo, +static void conv_swap_float_to_stereo(struct st_sample *dst, const void *s= rc, + int samples) +{ + const uint32_t *in_f32s =3D src; + + while (samples--) { + dst->l =3D CONV_NATURAL_FLOAT(F32S_TO_F32(*in_f32s++)); + dst->r =3D CONV_NATURAL_FLOAT(F32S_TO_F32(*in_f32s++)); + dst++; + } +} + +t_sample *mixeng_conv_float[2][2] =3D { + { + conv_natural_float_to_mono, + conv_swap_float_to_mono, + }, + { + conv_natural_float_to_stereo, + conv_swap_float_to_stereo, + } }; =20 static void clip_natural_float_from_mono(void *dst, const struct st_sample= *src, @@ -322,6 +356,17 @@ static void clip_natural_float_from_mono(void *dst, co= nst struct st_sample *src, } } =20 +static void clip_swap_float_from_mono(void *dst, const struct st_sample *s= rc, + int samples) +{ + uint32_t *out_f32s =3D dst; + + while (samples--) { + *out_f32s++ =3D F32_TO_F32S(CLIP_NATURAL_FLOAT(src->l + src->r)); + src++; + } +} + static void clip_natural_float_from_stereo( void *dst, const struct st_sample *src, int samples) { @@ -334,9 +379,27 @@ static void clip_natural_float_from_stereo( } } =20 -f_sample *mixeng_clip_float[2] =3D { - clip_natural_float_from_mono, - clip_natural_float_from_stereo, +static void clip_swap_float_from_stereo( + void *dst, const struct st_sample *src, int samples) +{ + uint32_t *out_f32s =3D dst; + + while (samples--) { + *out_f32s++ =3D F32_TO_F32S(CLIP_NATURAL_FLOAT(src->l)); + *out_f32s++ =3D F32_TO_F32S(CLIP_NATURAL_FLOAT(src->r)); + src++; + } +} + +f_sample *mixeng_clip_float[2][2] =3D { + { + clip_natural_float_from_mono, + clip_swap_float_from_mono, + }, + { + clip_natural_float_from_stereo, + clip_swap_float_from_stereo, + } }; =20 void audio_sample_to_uint64(const void *samples, int pos, --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748179767; cv=none; d=zohomail.com; s=zohoarc; b=Oje8xQ3im+hRs7bC+8qTm+RXHfRw44l4GcWTy3GaTRi2Ut44mJLqltlTGryOB1/geocdli+StiVPaDigjKk48s3TNnNWaJszNL0pwGUgmvm592wOxG6N+M5jq3DfaWK+SzEOWcH08oft8nxNl+inORTdWxOnPuwaDcEN1/cBO/E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748179767; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uGQQjmsFQDOZCLUWla4tbc9wwaNUFpGpLEggjyCxOWY=; b=N+Exm8Uwn7TKpbN/9KUiBa+wzJWMoRfrEZZF7zJPGhBLpYdX+m+da7wSZJ2BZjd0Zw3W6hM5CCp2al5qAZ/2Xui7BJmEcP+qPR+4WWd1Wph58DTv+hJjZ5LvKuybiQEr/Cs7YCTg13PFVkcdDKNDrgPfkiL79ofClOw90fP4U4k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748179767733601.4508474739096; Sun, 25 May 2025 06:29:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uJBOP-0007bj-Gy; Sun, 25 May 2025 09:27:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBON-0007ZY-2U for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBOL-0003MN-1y for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:54 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-168-cOcm32kANVOAQcg5ACGA_A-1; Sun, 25 May 2025 09:27:48 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 131E61800446; Sun, 25 May 2025 13:27:47 +0000 (UTC) Received: from localhost (unknown [10.45.242.5]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 763B719560AF; Sun, 25 May 2025 13:27:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748179672; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uGQQjmsFQDOZCLUWla4tbc9wwaNUFpGpLEggjyCxOWY=; b=gzODGqx79j/u2HMGuBccj8acf6D8l9dfmPEaUziCZnwPRRnn+kIVo1Sq2I3I7e6SlCZZVb rxijbGj/knjue0fEfBTtS0QVIFF8pSof6ollUytoWIjQsBf6J8AM2XIqsTv3wJLAtEp5W6 b29cIAQ+JaQGbj08YDZhTezPCdVaXGA= X-MC-Unique: cOcm32kANVOAQcg5ACGA_A-1 X-Mimecast-MFC-AGG-ID: cOcm32kANVOAQcg5ACGA_A_1748179667 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, BALATON Zoltan , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Christian Schoenebeck , Eric Blake , Markus Armbruster Subject: [PULL 8/9] alsaaudio: Set try-poll to false by default Date: Sun, 25 May 2025 15:27:15 +0200 Message-ID: <20250525132717.527392-9-marcandre.lureau@redhat.com> In-Reply-To: <20250525132717.527392-1-marcandre.lureau@redhat.com> References: <20250525132717.527392-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -59 X-Spam_score: -6.0 X-Spam_bar: ------ X-Spam_report: (-6.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1748179770065116600 From: BALATON Zoltan Quoting Volker R=C3=BCmelin: "try-poll=3Don tells the ALSA backend to try to use an event loop instead of the audio timer. This works most of the time. But the poll event handler in the ALSA backend has a bug. For example, if the guest can't provide enough audio frames in time, the ALSA buffer is only partly full and the event handler will be called again and again on every iteration of the main loop. This increases the processor load and the guest has less processor time to provide new audio frames in time. I have two examples where a guest can't recover from this situation and the guest seems to hang." One reproducer I've found is booting MorphOS demo iso on qemu-system-ppc -machine pegasos2 -audio alsa which should play a startup sound but instead it freezes. Even when it does not hang it plays choppy sound. Volker suggested using command line to set try-poll=3Doff saying: "The try-poll=3Doff arguments are typically necessary, because the alsa backend has a design issue with try-poll=3Don. If the guest can't provide enough audio frames, it's really unhelpful to ask for new audio frames on every main loop iteration until the guest can provide enough audio frames. Timer based playback doesn't have that problem." But users cannot easily find this option and having a non-working default is really unhelpful so to make life easier just set it to false by default which works until the issue with the alsa backend can be fixed. Signed-off-by: BALATON Zoltan Acked-by: Marc-Andr=C3=A9 Lureau [ Marc-Andr=C3=A9 - Updated QAPI and CLI doc ] Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20250316002046.D066A4E6004@zero.eik.bme.hu> --- qapi/audio.json | 2 +- audio/alsaaudio.c | 2 +- qemu-options.hx | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qapi/audio.json b/qapi/audio.json index dd5a58d13e..49633cf317 100644 --- a/qapi/audio.json +++ b/qapi/audio.json @@ -96,7 +96,7 @@ # @period-length: the period length in microseconds # # @try-poll: attempt to use poll mode, falling back to non-polling -# access on failure (default true) +# access on failure (default false) # # Since: 4.0 ## diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index cacae1ea59..9b6c01c0ef 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -899,7 +899,7 @@ static void alsa_enable_in(HWVoiceIn *hw, bool enable) static void alsa_init_per_direction(AudiodevAlsaPerDirectionOptions *apdo) { if (!apdo->has_try_poll) { - apdo->try_poll =3D true; + apdo->try_poll =3D false; apdo->has_try_poll =3D true; } } diff --git a/qemu-options.hx b/qemu-options.hx index aab53bcfe8..7eb8e02b4b 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -965,7 +965,7 @@ SRST Sets the period length in microseconds. =20 ``in|out.try-poll=3Don|off`` - Attempt to use poll mode with the device. Default is on. + Attempt to use poll mode with the device. Default is off. =20 ``threshold=3Dthreshold`` Threshold (in microseconds) when playback starts. Default is 0. @@ -1002,7 +1002,7 @@ SRST ``in|out.buffer-count=3Dcount`` Sets the count of the buffers. =20 - ``in|out.try-poll=3Don|of`` + ``in|out.try-poll=3Don|off`` Attempt to use poll mode with the device. Default is on. =20 ``try-mmap=3Don|off`` --=20 2.49.0 From nobody Sat Nov 15 17:50:03 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748179721; cv=none; d=zohomail.com; s=zohoarc; b=f9M/swCcJ4k3kHvrB6LgU+YB3rsA+MdSRu17nY7XKfuzqPGjls4XuTp9rVTAAIs6+uG2KvMIPW/fgZHWV3U99xX96666kVM+yFSqdUyIy5fmHcZPIRoLjG+ZnmVVf0cG3fsakkpB6PGaw2ZxhvVDMRYz+ULtvAM1JbSmIRBiZgs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748179721; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dFvrH2+9GANTq3N03obPSF9VQnhO5Ah93xhdKnav2dY=; b=g28cFa0Xf5lCzpR4PLqCcsp4QokeE9kBILYVyVAJ/jkkTnEwh2HdV4F6f2SHplswtmzaqnVRZH01R7w0PRoLbSSsQQrKhchAAJ0tT0diNqPHeubbYvhSE6J1rHGjKm9as1K17o0bHsD5Avx7zRWo7kpSUDmTo1PEaKsC/SRB7gI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1748179721986336.1899357514817; Sun, 25 May 2025 06:28:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uJBOS-0007ca-St; Sun, 25 May 2025 09:28:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBON-0007Zt-L1 for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uJBOL-0003MU-TB for qemu-devel@nongnu.org; Sun, 25 May 2025 09:27:55 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-39-sIypGuJJN22k1EBZFpOKUQ-1; Sun, 25 May 2025 09:27:51 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BB806180045C; Sun, 25 May 2025 13:27:50 +0000 (UTC) Received: from localhost (unknown [10.45.242.5]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4A9CB1956095; Sun, 25 May 2025 13:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748179673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dFvrH2+9GANTq3N03obPSF9VQnhO5Ah93xhdKnav2dY=; b=GMu9ntdFQxfpceQfjR875R+vdnk6Yi22wya85WP5nUd8mil6nzBfuTkPie116FFWE3yEDd KTm4XKa8b1SngprxXg/Zgt7/YXYuB3i1MSXdUEb3OuAws2ursgD2lLRBSE+hJJ8qD0NBnA LGzJbYQZVcI+qipa1YC00HOcbotpw84= X-MC-Unique: sIypGuJJN22k1EBZFpOKUQ-1 X-Mimecast-MFC-AGG-ID: sIypGuJJN22k1EBZFpOKUQ_1748179670 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Akihiko Odaki , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 9/9] audio: Reset rate control when adding bytes Date: Sun, 25 May 2025 15:27:16 +0200 Message-ID: <20250525132717.527392-10-marcandre.lureau@redhat.com> In-Reply-To: <20250525132717.527392-1-marcandre.lureau@redhat.com> References: <20250525132717.527392-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -59 X-Spam_score: -6.0 X-Spam_bar: ------ X-Spam_report: (-6.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.904, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1748179723162116600 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki Commit 90320051ea99 ("spiceaudio: add a pcm_ops buffer_get_free function") caused to emit messages saying "Resetting rate control" frequently when the guest generates no frames. audio_rate_peek_bytes() resets the rate control when frames < 0 || frames > 65536 where frames is the rate-limited number of frames. Resetting when frames < 0 is sensible as the number simply doesn't make sense. There is a problem when frames > 65536. It implies the guest stopped generating frames for a while so it makes sense to reset the rate control when the guest resumed generating frames. However, the commit mentioned earlier broke this assumption by letting spiceaudio call audio_rate_peek_bytes() whether the guest is generating frames or not. Reset the rate control in audio_rate_add_bytes(), which is called only when actually adding frames, according to the previous call to audio_rate_peek_bytes() to avoid frequent rate control resets even when the guest generates no frame. Signed-off-by: Akihiko Odaki Message-Id: <20250317-rate-v1-1-da9df062747c@daynix.com> --- audio/audio_int.h | 1 + audio/audio.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 2d079d00a2..f78ca05f92 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -255,6 +255,7 @@ const char *audio_application_name(void); typedef struct RateCtl { int64_t start_ticks; int64_t bytes_sent; + int64_t peeked_frames; } RateCtl; =20 void audio_rate_start(RateCtl *rate); diff --git a/audio/audio.c b/audio/audio.c index b58ad74433..89f091bc88 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -2283,17 +2283,19 @@ size_t audio_rate_peek_bytes(RateCtl *rate, struct = audio_pcm_info *info) ticks =3D now - rate->start_ticks; bytes =3D muldiv64(ticks, info->bytes_per_second, NANOSECONDS_PER_SECO= ND); frames =3D (bytes - rate->bytes_sent) / info->bytes_per_frame; - if (frames < 0 || frames > 65536) { - AUD_log(NULL, "Resetting rate control (%" PRId64 " frames)\n", fra= mes); - audio_rate_start(rate); - frames =3D 0; - } + rate->peeked_frames =3D frames; =20 - return frames * info->bytes_per_frame; + return frames < 0 ? 0 : frames * info->bytes_per_frame; } =20 void audio_rate_add_bytes(RateCtl *rate, size_t bytes_used) { + if (rate->peeked_frames < 0 || rate->peeked_frames > 65536) { + AUD_log(NULL, "Resetting rate control (%" PRId64 " frames)\n", + rate->peeked_frames); + audio_rate_start(rate); + } + rate->bytes_sent +=3D bytes_used; } =20 --=20 2.49.0