From nobody Fri Apr 19 13:51:30 2024 Delivered-To: importer2@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+importer2=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 1674294514304777.6787841810662; Sat, 21 Jan 2023 01:48:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJATr-0006hE-Q0; Sat, 21 Jan 2023 04:48:11 -0500 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 1pJATY-0006d5-Lm for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:59 -0500 Received: from mailout06.t-online.de ([194.25.134.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pJATW-00038c-4u for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:52 -0500 Received: from fwd70.dcpf.telekom.de (fwd70.aul.t-online.de [10.223.144.96]) by mailout06.t-online.de (Postfix) with SMTP id 5D8E428351; Sat, 21 Jan 2023 10:47:38 +0100 (CET) Received: from linpower.localnet ([79.208.25.151]) by fwd70.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1pJATH-3H3nAv0; Sat, 21 Jan 2023 10:47:35 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 3B7A320061B; Sat, 21 Jan 2023 10:47:35 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , qemu-devel@nongnu.org Subject: [PATCH v2 01/11] audio: log unimplemented audio device sample rates Date: Sat, 21 Jan 2023 10:47:25 +0100 Message-Id: <20230121094735.11644-1-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> References: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1674294455-157FF778-CAA3406D/0/0 CLEAN NORMAL X-TOI-MSGID: 191918ec-9d9f-46a6-ada9-e4dccae03e68 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.19; envelope-from=volker.ruemelin@t-online.de; helo=mailout06.t-online.de X-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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1674294515886100001 Some emulated audio devices allow guests to select very low sample rates that the audio subsystem doesn't support. The lowest supported sample rate depends on the audio backend used and in most cases can be changed with various -audiodev arguments. Until now, the audio_bug function emits an error message similar to the following error message A bug was just triggered in audio_calloc Save all your work and restart without audio I am sorry Context: audio_pcm_sw_alloc_resources_out passed invalid arguments to audio_calloc nmemb=3D0 size=3D16 (len=3D0) audio: Could not allocate buffer for `ac97.po' (0 samples) and the audio subsystem continues without sound for the affected device. The fact that the selected sample rate is not supported is not a guest error. Instead of displaying an error message, the missing audio support is now logged. Simply continuing without sound is correct, since the audio stream won't transport anything reasonable at such high resample ratios anyway. The AUD_open_* functions return NULL like before. The opened audio device will not be registered in the audio subsystem and consequently the audio frontend callback functions will not be called. The AUD_read and AUD_write functions return early in this case. This is necessary because, for example, the Sound Blaster 16 emulation calls AUD_write from the DMA callback function. Acked-by: Christian Schoenebeck Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio.c | 1 + audio/audio_template.h | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/audio/audio.c b/audio/audio.c index d849a94a81..f6b420688d 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -31,6 +31,7 @@ #include "qapi/qobject-input-visitor.h" #include "qapi/qapi-visit-audio.h" #include "qemu/cutils.h" +#include "qemu/log.h" #include "qemu/module.h" #include "qemu/help_option.h" #include "sysemu/sysemu.h" diff --git a/audio/audio_template.h b/audio/audio_template.h index 720a32e57e..bfa94b4d22 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -115,6 +115,19 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) = (SW *sw) #else samples =3D (int64_t)sw->HWBUF->size * sw->ratio >> 32; #endif + if (samples =3D=3D 0) { + HW *hw =3D sw->hw; + size_t f_fe_min; + + /* f_fe_min =3D ceil(1 [frames] * f_be [Hz] / size_be [frames]) */ + f_fe_min =3D (hw->info.freq + HWBUF->size - 1) / HWBUF->size; + qemu_log_mask(LOG_UNIMP, + AUDIO_CAP ": The guest selected a " NAME " sample ra= te" + " of %d Hz for %s. Only sample rates >=3D %zu Hz are" + " supported.\n", + sw->info.freq, sw->name, f_fe_min); + return -1; + } =20 sw->buf =3D audio_calloc(__func__, samples, sizeof(struct st_sample)); if (!sw->buf) { --=20 2.35.3 From nobody Fri Apr 19 13:51:30 2024 Delivered-To: importer2@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+importer2=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 1674294667978910.9451509566337; Sat, 21 Jan 2023 01:51:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJATp-0006fj-TO; Sat, 21 Jan 2023 04:48:09 -0500 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 1pJATR-0006cp-T3 for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:58 -0500 Received: from mailout08.t-online.de ([194.25.134.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pJATP-00037K-VW for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:45 -0500 Received: from fwd83.dcpf.telekom.de (fwd83.aul.t-online.de [10.223.144.109]) by mailout08.t-online.de (Postfix) with SMTP id C7E9624B5C; Sat, 21 Jan 2023 10:47:38 +0100 (CET) Received: from linpower.localnet ([79.208.25.151]) by fwd83.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1pJATJ-1CXczB0; Sat, 21 Jan 2023 10:47:38 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 3D909200625; Sat, 21 Jan 2023 10:47:35 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , qemu-devel@nongnu.org Subject: [PATCH v2 02/11] audio: don't show unnecessary error messages Date: Sat, 21 Jan 2023 10:47:26 +0100 Message-Id: <20230121094735.11644-2-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> References: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1674294458-422C1378-19DE3AF6/0/0 CLEAN NORMAL X-TOI-MSGID: aba94bb6-ca4e-4615-9bd1-db7656018a60 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.20; envelope-from=volker.ruemelin@t-online.de; helo=mailout08.t-online.de X-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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1674294668480100001 Let the audio_pcm_create_voice_pair_* functions handle error reporting. This avoids an additional error message in case the guest selected an unimplemented sample rate. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio_template.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index bfa94b4d22..ee320a2e3f 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -421,6 +421,7 @@ static SW *glue(audio_pcm_create_voice_pair_, TYPE)( =20 hw =3D glue(audio_pcm_hw_add_, TYPE)(s, &hw_as); if (!hw) { + dolog("Could not create a backend for voice `%s'\n", sw_name); goto err2; } =20 @@ -520,7 +521,6 @@ SW *glue (AUD_open_, TYPE) ( } else { sw =3D glue(audio_pcm_create_voice_pair_, TYPE)(s, name, as); if (!sw) { - dolog ("Failed to create voice `%s'\n", name); return NULL; } } --=20 2.35.3 From nobody Fri Apr 19 13:51:30 2024 Delivered-To: importer2@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+importer2=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 167429480517032.171417996759715; Sat, 21 Jan 2023 01:53:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJATq-0006g9-Hw; Sat, 21 Jan 2023 04:48:10 -0500 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 1pJATW-0006d1-4C for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:58 -0500 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 1pJATS-000387-W0 for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:48 -0500 Received: from fwd89.dcpf.telekom.de (fwd89.aul.t-online.de [10.223.144.115]) by mailout09.t-online.de (Postfix) with SMTP id 783661FDA7; Sat, 21 Jan 2023 10:47:44 +0100 (CET) Received: from linpower.localnet ([79.208.25.151]) by fwd89.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1pJATM-4fCE0P0; Sat, 21 Jan 2023 10:47:40 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 3FD3020062C; Sat, 21 Jan 2023 10:47:35 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , qemu-devel@nongnu.org Subject: [PATCH v2 03/11] audio: rename hardware store to backend Date: Sat, 21 Jan 2023 10:47:27 +0100 Message-Id: <20230121094735.11644-3-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> References: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1674294460-CF7FE046-A7E163BD/0/0 CLEAN NORMAL X-TOI-MSGID: 67b8d07f-9b34-4b8f-ad5d-cdbae661f8e5 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none 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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1674294807274100001 Use a consistent friendly name for the HWVoiceOut and HWVoiceIn structures. Reviewed-by: Thomas Huth Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- audio/audio_template.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index ee320a2e3f..ac744d3484 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -509,8 +509,8 @@ SW *glue (AUD_open_, TYPE) ( HW *hw =3D sw->hw; =20 if (!hw) { - dolog ("Internal logic error voice `%s' has no hardware store\= n", - SW_NAME (sw)); + dolog("Internal logic error: voice `%s' has no backend\n", + SW_NAME(sw)); goto fail; } =20 --=20 2.35.3 From nobody Fri Apr 19 13:51:30 2024 Delivered-To: importer2@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+importer2=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 1674294507646382.37114876169335; Sat, 21 Jan 2023 01:48:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJATo-0006fX-Eu; Sat, 21 Jan 2023 04:48:08 -0500 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 1pJATT-0006cs-5r for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:58 -0500 Received: from mailout08.t-online.de ([194.25.134.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pJATR-00037g-Ai for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:46 -0500 Received: from fwd78.dcpf.telekom.de (fwd78.aul.t-online.de [10.223.144.104]) by mailout08.t-online.de (Postfix) with SMTP id F27FB24B58; Sat, 21 Jan 2023 10:47:42 +0100 (CET) Received: from linpower.localnet ([79.208.25.151]) by fwd78.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1pJATO-1GqdTV0; Sat, 21 Jan 2023 10:47:42 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 4277B200635; Sat, 21 Jan 2023 10:47:35 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , qemu-devel@nongnu.org Subject: [PATCH v2 04/11] audio: remove unused #define AUDIO_STRINGIFY Date: Sat, 21 Jan 2023 10:47:28 +0100 Message-Id: <20230121094735.11644-4-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> References: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1674294462-C7FEA4E4-886EA4E2/0/0 CLEAN NORMAL X-TOI-MSGID: f9eedda5-da35-4253-801d-aa6bd3ab7f9e 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.20; envelope-from=volker.ruemelin@t-online.de; helo=mailout08.t-online.de X-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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1674294508036100003 Remove the unused #define AUDIO_STRINGIFY. It was last used before commit 470bcabd8f ("audio: Replace AUDIO_FUNC with __func__"). Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index e87ce014a0..4632cdf9cc 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -294,9 +294,6 @@ static inline size_t audio_ring_posb(size_t pos, size_t= dist, size_t len) #define ldebug(fmt, ...) (void)0 #endif =20 -#define AUDIO_STRINGIFY_(n) #n -#define AUDIO_STRINGIFY(n) AUDIO_STRINGIFY_(n) - typedef struct AudiodevListEntry { Audiodev *dev; QSIMPLEQ_ENTRY(AudiodevListEntry) next; --=20 2.35.3 From nobody Fri Apr 19 13:51:30 2024 Delivered-To: importer2@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+importer2=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 1674294508437705.0912715593855; Sat, 21 Jan 2023 01:48:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJATq-0006fn-1e; Sat, 21 Jan 2023 04:48:10 -0500 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 1pJATW-0006d2-5C for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:58 -0500 Received: from mailout08.t-online.de ([194.25.134.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pJATT-00038D-5N for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:48 -0500 Received: from fwd72.dcpf.telekom.de (fwd72.aul.t-online.de [10.223.144.98]) by mailout08.t-online.de (Postfix) with SMTP id A2BDE24B64; Sat, 21 Jan 2023 10:47:45 +0100 (CET) Received: from linpower.localnet ([79.208.25.151]) by fwd72.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1pJATR-1KL2xt0; Sat, 21 Jan 2023 10:47:45 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 45671200638; Sat, 21 Jan 2023 10:47:35 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , qemu-devel@nongnu.org Subject: [PATCH v2 05/11] audio/mixeng: use g_new0() instead of audio_calloc() Date: Sat, 21 Jan 2023 10:47:29 +0100 Message-Id: <20230121094735.11644-5-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> References: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1674294465-812ECD99-4F6A3A14/0/0 CLEAN NORMAL X-TOI-MSGID: 04682b54-739a-48ca-97f8-4d49b838e5a9 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.20; envelope-from=volker.ruemelin@t-online.de; helo=mailout08.t-online.de X-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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1674294509840100007 Replace audio_calloc() with the equivalent g_new0(). With a n_structs argument of 1, g_new0() never returns NULL. Also remove the unnecessary NULL checks. Reviewed-by: Richard Henderson Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio.c | 5 ----- audio/audio_template.h | 6 +----- audio/mixeng.c | 7 +------ 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index f6b420688d..ac5434a13c 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -507,11 +507,6 @@ static int audio_attach_capture (HWVoiceOut *hw) sw->ratio =3D ((int64_t) hw_cap->info.freq << 32) / sw->info.freq; sw->vol =3D nominal_volume; sw->rate =3D st_rate_start (sw->info.freq, hw_cap->info.freq); - if (!sw->rate) { - dolog ("Could not start rate conversion for `%s'\n", SW_NAME (= sw)); - g_free (sw); - return -1; - } QLIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries); QLIST_INSERT_HEAD (&hw->cap_head, sc, entries); #ifdef DEBUG_CAPTURE diff --git a/audio/audio_template.h b/audio/audio_template.h index ac744d3484..d343a1dcb3 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -141,11 +141,7 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) = (SW *sw) #else sw->rate =3D st_rate_start (sw->hw->info.freq, sw->info.freq); #endif - if (!sw->rate) { - g_free (sw->buf); - sw->buf =3D NULL; - return -1; - } + return 0; } =20 diff --git a/audio/mixeng.c b/audio/mixeng.c index 100a306d6f..fe454e0725 100644 --- a/audio/mixeng.c +++ b/audio/mixeng.c @@ -414,12 +414,7 @@ struct rate { */ void *st_rate_start (int inrate, int outrate) { - struct rate *rate =3D audio_calloc(__func__, 1, sizeof(*rate)); - - if (!rate) { - dolog ("Could not allocate resampler (%zu bytes)\n", sizeof (*rate= )); - return NULL; - } + struct rate *rate =3D g_new0(struct rate, 1); =20 rate->opos =3D 0; =20 --=20 2.35.3 From nobody Fri Apr 19 13:51:30 2024 Delivered-To: importer2@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+importer2=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 1674294736890501.68799453814495; Sat, 21 Jan 2023 01:52:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJATq-0006gP-Og; Sat, 21 Jan 2023 04:48:10 -0500 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 1pJATX-0006d4-Ii for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:58 -0500 Received: from mailout08.t-online.de ([194.25.134.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pJATV-00038Z-Tx for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:51 -0500 Received: from fwd78.dcpf.telekom.de (fwd78.aul.t-online.de [10.223.144.104]) by mailout08.t-online.de (Postfix) with SMTP id D5B0E24B5A; Sat, 21 Jan 2023 10:47:47 +0100 (CET) Received: from linpower.localnet ([79.208.25.151]) by fwd78.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1pJATT-1pTyOP0; Sat, 21 Jan 2023 10:47:47 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 4815E2006E0; Sat, 21 Jan 2023 10:47:35 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , qemu-devel@nongnu.org Subject: [PATCH v2 06/11] audio/alsaaudio: use g_new0() instead of audio_calloc() Date: Sat, 21 Jan 2023 10:47:30 +0100 Message-Id: <20230121094735.11644-6-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> References: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1674294467-C7FEA4E4-78E50816/0/0 CLEAN NORMAL X-TOI-MSGID: 5051f4cd-fac0-4d01-ae22-343e22ba7983 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.20; envelope-from=volker.ruemelin@t-online.de; helo=mailout08.t-online.de X-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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1674294738795100005 Replace audio_calloc() with the equivalent g_new0(). The value of the g_new0() argument count is >=3D 1, which means g_new0() will never return NULL. Also remove the unnecessary NULL check. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/alsaaudio.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 714bfb6453..5f50dfa0bf 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -222,11 +222,7 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct= pollhlp *hlp, int mask) return -1; } =20 - pfds =3D audio_calloc ("alsa_poll_helper", count, sizeof (*pfds)); - if (!pfds) { - dolog ("Could not initialize poll mode\n"); - return -1; - } + pfds =3D g_new0(struct pollfd, count); =20 err =3D snd_pcm_poll_descriptors (handle, pfds, count); if (err < 0) { --=20 2.35.3 From nobody Fri Apr 19 13:51:30 2024 Delivered-To: importer2@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+importer2=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 1674294668157800.7650130578382; Sat, 21 Jan 2023 01:51:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJATs-0006hF-Hx; Sat, 21 Jan 2023 04:48:12 -0500 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 1pJATf-0006eN-Hd for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:59 -0500 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 1pJATd-00039D-8F for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:59 -0500 Received: from fwd85.dcpf.telekom.de (fwd85.aul.t-online.de [10.223.144.111]) by mailout10.t-online.de (Postfix) with SMTP id 4C95419A01; Sat, 21 Jan 2023 10:47:52 +0100 (CET) Received: from linpower.localnet ([79.208.25.151]) by fwd85.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1pJATW-1YMoev0; Sat, 21 Jan 2023 10:47:50 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 4AB7D2006E4; Sat, 21 Jan 2023 10:47:35 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , qemu-devel@nongnu.org Subject: [PATCH v2 07/11] audio/audio_template: use g_malloc0() to replace audio_calloc() Date: Sat, 21 Jan 2023 10:47:31 +0100 Message-Id: <20230121094735.11644-7-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> References: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1674294470-ABFF3DFF-AE0859C9/0/0 CLEAN NORMAL X-TOI-MSGID: d8250eb3-a9d1-40a5-8b1b-c1026ce751b0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.21; envelope-from=volker.ruemelin@t-online.de; helo=mailout10.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1674294668498100002 Use g_malloc0() as a direct replacement for audio_calloc(). Since the type of the parameter n_bytes of the function g_malloc0() is unsigned, the type of the variables voice_size_out and voice_size_in has been changed to size_t. This means that the function argument no longer has to be checked for negative values. Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 4 ++-- audio/audio_template.h | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 4632cdf9cc..ce2d6bf92c 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -151,8 +151,8 @@ struct audio_driver { int can_be_default; int max_voices_out; int max_voices_in; - int voice_size_out; - int voice_size_in; + size_t voice_size_out; + size_t voice_size_in; QLIST_ENTRY(audio_driver) next; }; =20 diff --git a/audio/audio_template.h b/audio/audio_template.h index d343a1dcb3..6b7d1fea83 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -40,7 +40,7 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioState = *s, struct audio_driver *drv) { int max_voices =3D glue (drv->max_voices_, TYPE); - int voice_size =3D glue (drv->voice_size_, TYPE); + size_t voice_size =3D glue(drv->voice_size_, TYPE); =20 if (glue (s->nb_hw_voices_, TYPE) > max_voices) { if (!max_voices) { @@ -63,8 +63,8 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioState = *s, } =20 if (audio_bug(__func__, voice_size && !max_voices)) { - dolog ("drv=3D`%s' voice_size=3D%d max_voices=3D0\n", - drv->name, voice_size); + dolog("drv=3D`%s' voice_size=3D%zu max_voices=3D0\n", + drv->name, voice_size); } } =20 @@ -273,13 +273,11 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioSta= te *s, return NULL; } =20 - hw =3D audio_calloc(__func__, 1, glue(drv->voice_size_, TYPE)); - if (!hw) { - dolog ("Can not allocate voice `%s' size %d\n", - drv->name, glue (drv->voice_size_, TYPE)); - return NULL; - } - + /* + * Since glue(s->nb_hw_voices_, TYPE) is !=3D 0, glue(drv->voice_size_= , TYPE) + * is guaranteed to be !=3D 0. See the audio_init_nb_voices_* function= s. + */ + hw =3D g_malloc0(glue(drv->voice_size_, TYPE)); hw->s =3D s; hw->pcm_ops =3D drv->pcm_ops; =20 --=20 2.35.3 From nobody Fri Apr 19 13:51:30 2024 Delivered-To: importer2@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+importer2=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 167429473628780.50628442947402; Sat, 21 Jan 2023 01:52:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJATs-0006hH-TM; Sat, 21 Jan 2023 04:48:12 -0500 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 1pJATf-0006e4-GO for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:59 -0500 Received: from mailout06.t-online.de ([194.25.134.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pJATd-00039L-9J for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:47:59 -0500 Received: from fwd86.dcpf.telekom.de (fwd86.aul.t-online.de [10.223.144.112]) by mailout06.t-online.de (Postfix) with SMTP id C7FDB1E64C; Sat, 21 Jan 2023 10:47:52 +0100 (CET) Received: from linpower.localnet ([79.208.25.151]) by fwd86.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1pJATY-3bbmlN0; Sat, 21 Jan 2023 10:47:52 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 4DAB02006E5; Sat, 21 Jan 2023 10:47:35 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , qemu-devel@nongnu.org Subject: [PATCH v2 08/11] audio/audio_template: use g_new0() to replace audio_calloc() Date: Sat, 21 Jan 2023 10:47:32 +0100 Message-Id: <20230121094735.11644-8-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> References: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1674294472-937ED95E-8FB0A7DD/0/0 CLEAN NORMAL X-TOI-MSGID: 18be475b-01c7-46bc-a71c-7d47a984183c 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.19; envelope-from=volker.ruemelin@t-online.de; helo=mailout06.t-online.de X-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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1674294736964100003 Replace audio_calloc() with the equivalent g_new0(). With a n_structs argument >=3D 1, g_new0() never returns NULL. Also remove the unnecessary NULL checks. Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio_template.h | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index 6b7d1fea83..ba010d7e21 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -115,6 +115,12 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) = (SW *sw) #else samples =3D (int64_t)sw->HWBUF->size * sw->ratio >> 32; #endif + if (audio_bug(__func__, samples < 0)) { + dolog("Can not allocate buffer for `%s' (%d samples)\n", + SW_NAME(sw), samples); + return -1; + } + if (samples =3D=3D 0) { HW *hw =3D sw->hw; size_t f_fe_min; @@ -129,12 +135,7 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) = (SW *sw) return -1; } =20 - sw->buf =3D audio_calloc(__func__, samples, sizeof(struct st_sample)); - if (!sw->buf) { - dolog ("Could not allocate buffer for `%s' (%d samples)\n", - SW_NAME (sw), samples); - return -1; - } + sw->buf =3D g_new0(st_sample, samples); =20 #ifdef DAC sw->rate =3D st_rate_start (sw->info.freq, sw->hw->info.freq); @@ -405,34 +406,28 @@ static SW *glue(audio_pcm_create_voice_pair_, TYPE)( hw_as =3D *as; } =20 - sw =3D audio_calloc(__func__, 1, sizeof(*sw)); - if (!sw) { - dolog ("Could not allocate soft voice `%s' (%zu bytes)\n", - sw_name ? sw_name : "unknown", sizeof (*sw)); - goto err1; - } + sw =3D g_new0(SW, 1); sw->s =3D s; =20 hw =3D glue(audio_pcm_hw_add_, TYPE)(s, &hw_as); if (!hw) { dolog("Could not create a backend for voice `%s'\n", sw_name); - goto err2; + goto err1; } =20 glue (audio_pcm_hw_add_sw_, TYPE) (hw, sw); =20 if (glue (audio_pcm_sw_init_, TYPE) (sw, hw, sw_name, as)) { - goto err3; + goto err2; } =20 return sw; =20 -err3: +err2: glue (audio_pcm_hw_del_sw_, TYPE) (sw); glue (audio_pcm_hw_gc_, TYPE) (&hw); -err2: - g_free (sw); err1: + g_free(sw); return NULL; } =20 --=20 2.35.3 From nobody Fri Apr 19 13:51:30 2024 Delivered-To: importer2@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+importer2=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 167429460909074.38640922829802; Sat, 21 Jan 2023 01:50:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJATs-0006hG-M5; Sat, 21 Jan 2023 04:48:12 -0500 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 1pJATg-0006en-N2 for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:48:01 -0500 Received: from mailout06.t-online.de ([194.25.134.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pJATe-00039u-Or for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:48:00 -0500 Received: from fwd70.dcpf.telekom.de (fwd70.aul.t-online.de [10.223.144.96]) by mailout06.t-online.de (Postfix) with SMTP id 7A2D91E649; Sat, 21 Jan 2023 10:47:57 +0100 (CET) Received: from linpower.localnet ([79.208.25.151]) by fwd70.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1pJATa-0lI8Uz0; Sat, 21 Jan 2023 10:47:54 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 5043C2006E6; Sat, 21 Jan 2023 10:47:35 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , qemu-devel@nongnu.org Subject: [PATCH v2 09/11] audio: remove audio_calloc() function Date: Sat, 21 Jan 2023 10:47:33 +0100 Message-Id: <20230121094735.11644-9-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> References: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1674294474-16FFC778-9EAF997E/0/0 CLEAN NORMAL X-TOI-MSGID: 2f3ab365-bfb9-4c7f-ab5d-53c525beb429 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.19; envelope-from=volker.ruemelin@t-online.de; helo=mailout06.t-online.de X-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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1674294610252100001 Now that the last call site of audio_calloc() was removed, remove the unused audio_calloc() function. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/audio.c | 20 -------------------- audio/audio_int.h | 1 - 2 files changed, 21 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index ac5434a13c..fb0d4a2cac 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -147,26 +147,6 @@ static inline int audio_bits_to_index (int bits) } } =20 -void *audio_calloc (const char *funcname, int nmemb, size_t size) -{ - int cond; - size_t len; - - len =3D nmemb * size; - cond =3D !nmemb || !size; - cond |=3D nmemb < 0; - cond |=3D len < size; - - if (audio_bug ("audio_calloc", cond)) { - AUD_log (NULL, "%s passed invalid arguments to audio_calloc\n", - funcname); - AUD_log (NULL, "nmemb=3D%d size=3D%zu (len=3D%zu)\n", nmemb, size,= len); - return NULL; - } - - return g_malloc0 (len); -} - void AUD_vlog (const char *cap, const char *fmt, va_list ap) { if (cap) { diff --git a/audio/audio_int.h b/audio/audio_int.h index ce2d6bf92c..5028f2354a 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -251,7 +251,6 @@ void audio_pcm_init_info (struct audio_pcm_info *info, = struct audsettings *as); void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int= len); =20 int audio_bug (const char *funcname, int cond); -void *audio_calloc (const char *funcname, int nmemb, size_t size); =20 void audio_run(AudioState *s, const char *msg); =20 --=20 2.35.3 From nobody Fri Apr 19 13:51:30 2024 Delivered-To: importer2@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+importer2=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 1674294571305815.3102370881368; Sat, 21 Jan 2023 01:49:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJATr-0006h4-GP; Sat, 21 Jan 2023 04:48:11 -0500 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 1pJATg-0006ep-Oe for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:48:01 -0500 Received: from mailout08.t-online.de ([194.25.134.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pJATe-00039w-Va for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:48:00 -0500 Received: from fwd85.dcpf.telekom.de (fwd85.aul.t-online.de [10.223.144.111]) by mailout08.t-online.de (Postfix) with SMTP id 927FB493D; Sat, 21 Jan 2023 10:47:57 +0100 (CET) Received: from linpower.localnet ([79.208.25.151]) by fwd85.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1pJATd-2MjW3F0; Sat, 21 Jan 2023 10:47:57 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 52EAC2006E7; Sat, 21 Jan 2023 10:47:35 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , qemu-devel@nongnu.org Subject: [PATCH v2 10/11] alsaaudio: change default playback settings Date: Sat, 21 Jan 2023 10:47:34 +0100 Message-Id: <20230121094735.11644-10-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> References: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1674294477-ABFF3DFF-DB886478/0/0 CLEAN NORMAL X-TOI-MSGID: 7363a95b-47c9-4380-90f0-e9510398da10 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.20; envelope-from=volker.ruemelin@t-online.de; helo=mailout08.t-online.de X-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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1674294572061100002 The currently used default playback settings in the ALSA audio backend are a bit unfortunate. With a few emulated audio devices, audio playback does not work properly. Here is a short part of the debug log while audio is playing (elapsed time in seconds). audio: Elapsed since last alsa run (running): 0.046244 audio: Elapsed since last alsa run (running): 0.023137 audio: Elapsed since last alsa run (running): 0.023170 audio: Elapsed since last alsa run (running): 0.023650 audio: Elapsed since last alsa run (running): 0.060802 audio: Elapsed since last alsa run (running): 0.031931 For some audio devices the time of more than 23ms between updates is too long. Set the period time to 5.8ms so that the maximum time between two updates typically does not exceed 11ms. This roughly matches the 10ms period time when doing playback with the audio timer. After this patch the debug log looks like this. audio: Elapsed since last alsa run (running): 0.011919 audio: Elapsed since last alsa run (running): 0.005788 audio: Elapsed since last alsa run (running): 0.005995 audio: Elapsed since last alsa run (running): 0.011069 audio: Elapsed since last alsa run (running): 0.005901 audio: Elapsed since last alsa run (running): 0.006084 Acked-by: Christian Schoenebeck Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/alsaaudio.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 5f50dfa0bf..0cc982e61f 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -913,17 +913,14 @@ static void *alsa_audio_init(Audiodev *dev) alsa_init_per_direction(aopts->in); alsa_init_per_direction(aopts->out); =20 - /* - * need to define them, as otherwise alsa produces no sound - * doesn't set has_* so alsa_open can identify it wasn't set by the us= er - */ + /* don't set has_* so alsa_open can identify it wasn't set by the user= */ if (!dev->u.alsa.out->has_period_length) { - /* 1024 frames assuming 44100Hz */ - dev->u.alsa.out->period_length =3D 1024 * 1000000 / 44100; + /* 256 frames assuming 44100Hz */ + dev->u.alsa.out->period_length =3D 5805; } if (!dev->u.alsa.out->has_buffer_length) { /* 4096 frames assuming 44100Hz */ - dev->u.alsa.out->buffer_length =3D 4096ll * 1000000 / 44100; + dev->u.alsa.out->buffer_length =3D 92880; } =20 /* --=20 2.35.3 From nobody Fri Apr 19 13:51:30 2024 Delivered-To: importer2@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+importer2=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 167429457025610.365363961021444; Sat, 21 Jan 2023 01:49:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJATp-0006fk-T4; Sat, 21 Jan 2023 04:48:09 -0500 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 1pJATi-0006f6-Rx for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:48:03 -0500 Received: from mailout08.t-online.de ([194.25.134.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pJATh-0003AP-Dl for qemu-devel@nongnu.org; Sat, 21 Jan 2023 04:48:02 -0500 Received: from fwd72.dcpf.telekom.de (fwd72.aul.t-online.de [10.223.144.98]) by mailout08.t-online.de (Postfix) with SMTP id ACAB7493A; Sat, 21 Jan 2023 10:47:59 +0100 (CET) Received: from linpower.localnet ([79.208.25.151]) by fwd72.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1pJATf-0bakXR0; Sat, 21 Jan 2023 10:47:59 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 55AD02006E8; Sat, 21 Jan 2023 10:47:35 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , qemu-devel@nongnu.org Subject: [PATCH v2 11/11] alsaaudio: reintroduce default recording settings Date: Sat, 21 Jan 2023 10:47:35 +0100 Message-Id: <20230121094735.11644-11-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> References: <0a4007dc-e11c-f16e-0e21-dbc4e60caa59@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1674294479-81AEBD99-2A0AC74F/0/0 CLEAN NORMAL X-TOI-MSGID: f1d963d0-ac9f-4b0b-9f73-95df7cb0242f 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=194.25.134.20; envelope-from=volker.ruemelin@t-online.de; helo=mailout08.t-online.de X-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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1674294572058100001 Audio recording with ALSA default settings currently doesn't work. The debug log shows updates every 0.75s and 1.5s. audio: Elapsed since last alsa run (running): 0.743030 audio: Elapsed since last alsa run (running): 1.486048 audio: Elapsed since last alsa run (running): 0.743008 audio: Elapsed since last alsa run (running): 1.485878 audio: Elapsed since last alsa run (running): 1.486040 audio: Elapsed since last alsa run (running): 1.485886 The time between updates should be in the 10ms range. Audio recording with ALSA has the same timing contraints as playback. Reintroduce the default recording settings and use the same default settings for recording as for playback. The term "reintroduce" is correct because commit a93f328177 ("alsaaudio: port to -audiodev config") removed the default settings for recording. Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Marc-Andr=C3=A9 Lureau --- audio/alsaaudio.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 0cc982e61f..057571dd1e 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -923,15 +923,13 @@ static void *alsa_audio_init(Audiodev *dev) dev->u.alsa.out->buffer_length =3D 92880; } =20 - /* - * OptsVisitor sets unspecified optional fields to zero, but do not de= pend - * on it... - */ if (!dev->u.alsa.in->has_period_length) { - dev->u.alsa.in->period_length =3D 0; + /* 256 frames assuming 44100Hz */ + dev->u.alsa.in->period_length =3D 5805; } if (!dev->u.alsa.in->has_buffer_length) { - dev->u.alsa.in->buffer_length =3D 0; + /* 4096 frames assuming 44100Hz */ + dev->u.alsa.in->buffer_length =3D 92880; } =20 return dev; --=20 2.35.3