From nobody Mon Feb 9 07:04:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747288003755462.46547730820896; Wed, 14 May 2025 22:46:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFRPT-0005QS-ML; Thu, 15 May 2025 01:45:35 -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 1uFRPR-0005FO-CW for qemu-devel@nongnu.org; Thu, 15 May 2025 01:45:33 -0400 Received: from mailout11.t-online.de ([194.25.134.85]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFRPO-00006N-IX for qemu-devel@nongnu.org; Thu, 15 May 2025 01:45:33 -0400 Received: from fwd80.aul.t-online.de (fwd80.aul.t-online.de [10.223.144.106]) by mailout11.t-online.de (Postfix) with SMTP id DE62DE13; Thu, 15 May 2025 07:44:30 +0200 (CEST) Received: from linpower.localnet ([84.175.230.13]) by fwd80.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1uFROP-0PkGuH0; Thu, 15 May 2025 07:44:29 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 6633520063C; Thu, 15 May 2025 07:44:29 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: qemu-devel@nongnu.org, Richard Henderson , Mark Cave-Ayland , Thomas Huth Subject: [PATCH v2 1/7] tests/functional: use 'none' audio driver for q800 tests Date: Thu, 15 May 2025 07:44:23 +0200 Message-ID: <20250515054429.7385-1-vr_qemu@t-online.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <0bb1a55e-70f1-410b-8b59-78eed7f4c8f7@t-online.de> References: <0bb1a55e-70f1-410b-8b59-78eed7f4c8f7@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1747287869-77FFD538-7F28586A/10/29118861210 SUSPECT URL X-TOI-MSGID: 7b9e6b7a-cfd4-400d-af41-7ace724a56bf 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=194.25.134.85; envelope-from=volker.ruemelin@t-online.de; helo=mailout11.t-online.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=0.001, 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-ZM-MESSAGEID: 1747288006141116600 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 --- 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.43.0 From nobody Mon Feb 9 07:04:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747287992698470.17623364798374; Wed, 14 May 2025 22:46:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFRPW-0005hU-SD; Thu, 15 May 2025 01:45:38 -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 1uFRPQ-0005CI-AD for qemu-devel@nongnu.org; Thu, 15 May 2025 01:45:32 -0400 Received: from mailout11.t-online.de ([194.25.134.85]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFRPO-00006Q-IQ for qemu-devel@nongnu.org; Thu, 15 May 2025 01:45:31 -0400 Received: from fwd87.aul.t-online.de (fwd87.aul.t-online.de [10.223.144.113]) by mailout11.t-online.de (Postfix) with SMTP id 78147EA1; Thu, 15 May 2025 07:44:35 +0200 (CEST) Received: from linpower.localnet ([84.175.230.13]) by fwd87.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1uFROS-2ukuDh0; Thu, 15 May 2025 07:44:32 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 68B1220063D; Thu, 15 May 2025 07:44:29 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: qemu-devel@nongnu.org, Richard Henderson , Mark Cave-Ayland , Thomas Huth Subject: [PATCH v2 2/7] audio: fix SIGSEGV in AUD_get_buffer_size_out() Date: Thu, 15 May 2025 07:44:24 +0200 Message-ID: <20250515054429.7385-2-vr_qemu@t-online.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <0bb1a55e-70f1-410b-8b59-78eed7f4c8f7@t-online.de> References: <0bb1a55e-70f1-410b-8b59-78eed7f4c8f7@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1747287872-88FF7520-79457593/0/0 CLEAN NORMAL X-TOI-MSGID: 4607cb52-6af9-4dad-a815-701b9a1a0469 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=194.25.134.85; envelope-from=volker.ruemelin@t-online.de; helo=mailout11.t-online.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=0.001, 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-ZM-MESSAGEID: 1747287993350019000 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 --- 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.43.0 From nobody Mon Feb 9 07:04:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747287903623446.04101669039824; Wed, 14 May 2025 22:45:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFROg-0003u3-C4; Thu, 15 May 2025 01:44:46 -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 1uFROZ-0003hS-G0 for qemu-devel@nongnu.org; Thu, 15 May 2025 01:44:39 -0400 Received: from mailout09.t-online.de ([194.25.134.84]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFROX-0008In-Rw for qemu-devel@nongnu.org; Thu, 15 May 2025 01:44:39 -0400 Received: from fwd76.aul.t-online.de (fwd76.aul.t-online.de [10.223.144.102]) by mailout09.t-online.de (Postfix) with SMTP id C1E1B4E8; Thu, 15 May 2025 07:44:34 +0200 (CEST) Received: from linpower.localnet ([84.175.230.13]) by fwd76.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1uFROU-0RrABd0; Thu, 15 May 2025 07:44:34 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 6B2402006C7; Thu, 15 May 2025 07:44:29 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: qemu-devel@nongnu.org, Richard Henderson , Mark Cave-Ayland , Thomas Huth Subject: [PATCH v2 3/7] audio: fix size calculation in AUD_get_buffer_size_out() Date: Thu, 15 May 2025 07:44:25 +0200 Message-ID: <20250515054429.7385-3-vr_qemu@t-online.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <0bb1a55e-70f1-410b-8b59-78eed7f4c8f7@t-online.de> References: <0bb1a55e-70f1-410b-8b59-78eed7f4c8f7@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1747287874-10FF75CE-DC28E3E1/0/0 CLEAN NORMAL X-TOI-MSGID: 898b0449-2a18-4904-b9eb-109642239755 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=194.25.134.84; envelope-from=volker.ruemelin@t-online.de; helo=mailout09.t-online.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZM-MESSAGEID: 1747287905060116600 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 --- 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.43.0 From nobody Mon Feb 9 07:04:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747287929850574.8575228622026; Wed, 14 May 2025 22:45:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFROy-0004Hf-Jq; Thu, 15 May 2025 01:45:06 -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 1uFROn-000407-JZ for qemu-devel@nongnu.org; Thu, 15 May 2025 01:44:53 -0400 Received: from mailout10.t-online.de ([194.25.134.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFROl-0008JK-Uq for qemu-devel@nongnu.org; Thu, 15 May 2025 01:44:53 -0400 Received: from fwd86.aul.t-online.de (fwd86.aul.t-online.de [10.223.144.112]) by mailout10.t-online.de (Postfix) with SMTP id 79536169E; Thu, 15 May 2025 07:44:39 +0200 (CEST) Received: from linpower.localnet ([84.175.230.13]) by fwd86.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1uFROW-3vuNc10; Thu, 15 May 2025 07:44:36 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 6E8862006C9; Thu, 15 May 2025 07:44:29 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: qemu-devel@nongnu.org, Richard Henderson , Mark Cave-Ayland , Thomas Huth Subject: [PATCH v2 4/7] hw/audio/asc: fix SIGSEGV in asc_realize() Date: Thu, 15 May 2025 07:44:26 +0200 Message-ID: <20250515054429.7385-4-vr_qemu@t-online.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <0bb1a55e-70f1-410b-8b59-78eed7f4c8f7@t-online.de> References: <0bb1a55e-70f1-410b-8b59-78eed7f4c8f7@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1747287876-BDFF94E5-B7FD30BC/0/0 CLEAN NORMAL X-TOI-MSGID: 059305e8-ef0e-4daf-882d-811905b25ee4 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=194.25.134.21; envelope-from=volker.ruemelin@t-online.de; helo=mailout10.t-online.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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-ZM-MESSAGEID: 1747287931190019000 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 --- 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.43.0 From nobody Mon Feb 9 07:04:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747287916066802.6501440341219; Wed, 14 May 2025 22:45:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFRP2-0004Tr-EV; Thu, 15 May 2025 01:45:08 -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 1uFROq-000499-Uw for qemu-devel@nongnu.org; Thu, 15 May 2025 01:44:58 -0400 Received: from mailout07.t-online.de ([194.25.134.83]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFROp-0008JP-4c for qemu-devel@nongnu.org; Thu, 15 May 2025 01:44:56 -0400 Received: from fwd73.aul.t-online.de (fwd73.aul.t-online.de [10.223.144.99]) by mailout07.t-online.de (Postfix) with SMTP id 5563313FD; Thu, 15 May 2025 07:44:42 +0200 (CEST) Received: from linpower.localnet ([84.175.230.13]) by fwd73.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1uFROZ-1EbUjB0; Thu, 15 May 2025 07:44:39 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 723B42006CE; Thu, 15 May 2025 07:44:29 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: qemu-devel@nongnu.org, Richard Henderson , Mark Cave-Ayland , Thomas Huth Subject: [PATCH v2 5/7] hw/audio/asc: replace g_malloc0() with g_malloc() Date: Thu, 15 May 2025 07:44:27 +0200 Message-ID: <20250515054429.7385-5-vr_qemu@t-online.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <0bb1a55e-70f1-410b-8b59-78eed7f4c8f7@t-online.de> References: <0bb1a55e-70f1-410b-8b59-78eed7f4c8f7@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1747287879-EBFFD49F-65FBA01C/0/0 CLEAN NORMAL X-TOI-MSGID: 1303351f-99cf-48bc-92cf-9f865715ffbb 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=194.25.134.83; envelope-from=volker.ruemelin@t-online.de; helo=mailout07.t-online.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=0.001, 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-ZM-MESSAGEID: 1747287917110116600 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 --- 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.43.0 From nobody Mon Feb 9 07:04:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747287972413481.80180395257287; Wed, 14 May 2025 22:46:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFRP3-0004ao-To; Thu, 15 May 2025 01:45:09 -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 1uFROu-0004FW-EW for qemu-devel@nongnu.org; Thu, 15 May 2025 01:45:01 -0400 Received: from mailout02.t-online.de ([194.25.134.17]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFROs-0008Jo-Np for qemu-devel@nongnu.org; Thu, 15 May 2025 01:45:00 -0400 Received: from fwd71.aul.t-online.de (fwd71.aul.t-online.de [10.223.144.97]) by mailout02.t-online.de (Postfix) with SMTP id 0792A1DDB; Thu, 15 May 2025 07:44:42 +0200 (CEST) Received: from linpower.localnet ([84.175.230.13]) by fwd71.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1uFROb-0WT93B0; Thu, 15 May 2025 07:44:41 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 758462006CF; Thu, 15 May 2025 07:44:29 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: qemu-devel@nongnu.org, Richard Henderson , Mark Cave-Ayland , Thomas Huth Subject: [PATCH v2 6/7] audio/mixeng: remove unnecessary pointer type casts Date: Thu, 15 May 2025 07:44:28 +0200 Message-ID: <20250515054429.7385-6-vr_qemu@t-online.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <0bb1a55e-70f1-410b-8b59-78eed7f4c8f7@t-online.de> References: <0bb1a55e-70f1-410b-8b59-78eed7f4c8f7@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1747287881-09FF955F-D0D75273/0/0 CLEAN NORMAL X-TOI-MSGID: 0b9464b5-c8c9-4c99-9e87-c71a181284d3 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=194.25.134.17; envelope-from=volker.ruemelin@t-online.de; helo=mailout02.t-online.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZM-MESSAGEID: 1747287973820019000 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 --- 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.43.0 From nobody Mon Feb 9 07:04:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747288004486986.1527486897975; Wed, 14 May 2025 22:46:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFRPm-00068a-0F; Thu, 15 May 2025 01:45:56 -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 1uFRPV-0005eP-95 for qemu-devel@nongnu.org; Thu, 15 May 2025 01:45:37 -0400 Received: from mailout11.t-online.de ([194.25.134.85]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uFRPT-00006n-47 for qemu-devel@nongnu.org; Thu, 15 May 2025 01:45:36 -0400 Received: from fwd83.aul.t-online.de (fwd83.aul.t-online.de [10.223.144.109]) by mailout11.t-online.de (Postfix) with SMTP id 91A89147A; Thu, 15 May 2025 07:44:46 +0200 (CEST) Received: from linpower.localnet ([84.175.230.13]) by fwd83.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1uFROe-2G3OOf0; Thu, 15 May 2025 07:44:44 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 78E6E2006D0; Thu, 15 May 2025 07:44:29 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= Cc: qemu-devel@nongnu.org, Richard Henderson , Mark Cave-Ayland , Thomas Huth Subject: [PATCH v2 7/7] audio: add float sample endianness converters Date: Thu, 15 May 2025 07:44:29 +0200 Message-ID: <20250515054429.7385-7-vr_qemu@t-online.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <0bb1a55e-70f1-410b-8b59-78eed7f4c8f7@t-online.de> References: <0bb1a55e-70f1-410b-8b59-78eed7f4c8f7@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1747287884-7EA2A5E4-A66AE5F8/0/0 CLEAN NORMAL X-TOI-MSGID: 3af5b955-3819-4479-82ad-dcb9ccf90b85 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=194.25.134.85; envelope-from=volker.ruemelin@t-online.de; helo=mailout11.t-online.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=0.001, 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-ZM-MESSAGEID: 1747288005655019000 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 --- audio/audio.c | 3 +- audio/audio_template.h | 12 ++++--- audio/mixeng.c | 75 ++++++++++++++++++++++++++++++++++++++---- audio/mixeng.h | 6 ++-- 4 files changed, 82 insertions(+), 14 deletions(-) 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/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.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, 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, --=20 2.43.0