From patchwork Sun Dec 18 17:15:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 13076058 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F6C2C4332F for ; Sun, 18 Dec 2022 17:16:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6xGN-0007Sa-Sm; Sun, 18 Dec 2022 12:15:48 -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 1p6xGL-0007Pe-2Y for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:15:45 -0500 Received: from mailout12.t-online.de ([194.25.134.22]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6xGJ-0002PP-GA for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:15:44 -0500 Received: from fwd80.dcpf.telekom.de (fwd80.aul.t-online.de [10.223.144.106]) by mailout12.t-online.de (Postfix) with SMTP id A76EC1B493; Sun, 18 Dec 2022 18:15:40 +0100 (CET) Received: from linpower.localnet ([79.208.21.92]) by fwd80.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1p6xGF-1ACA770; Sun, 18 Dec 2022 18:15:39 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 11E04200456; Sun, 18 Dec 2022 18:15:39 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 01/11] audio: log unimplemented audio device sample rates Date: Sun, 18 Dec 2022 18:15:29 +0100 Message-Id: <20221218171539.11193-1-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> References: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> MIME-Version: 1.0 X-TOI-EXPURGATEID: 150726::1671383739-C13271D1-2B90A431/0/0 CLEAN NORMAL X-TOI-MSGID: a3cb6a37-baab-43bc-b539-907d21a05788 Received-SPF: none client-ip=194.25.134.22; envelope-from=volker.ruemelin@t-online.de; helo=mailout12.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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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=0 size=16 (len=0) 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. Signed-off-by: Volker Rümelin Acked-by: Christian Schoenebeck --- 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 = (int64_t)sw->HWBUF->size * sw->ratio >> 32; #endif + if (samples == 0) { + HW *hw = sw->hw; + size_t f_fe_min; + + /* f_fe_min = ceil(1 [frames] * f_be [Hz] / size_be [frames]) */ + f_fe_min = (hw->info.freq + HWBUF->size - 1) / HWBUF->size; + qemu_log_mask(LOG_UNIMP, + AUDIO_CAP ": The guest selected a " NAME " sample rate" + " of %d Hz for %s. Only sample rates >= %zu Hz are" + " supported.\n", + sw->info.freq, sw->name, f_fe_min); + return -1; + } sw->buf = audio_calloc(__func__, samples, sizeof(struct st_sample)); if (!sw->buf) { From patchwork Sun Dec 18 17:15:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 13076066 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2364CC4332F for ; Sun, 18 Dec 2022 17:17:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6xGk-0007nL-Bz; Sun, 18 Dec 2022 12:16: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 1p6xGg-0007gI-K5 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:06 -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 1p6xGf-0002XX-1x for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:06 -0500 Received: from fwd86.dcpf.telekom.de (fwd86.aul.t-online.de [10.223.144.112]) by mailout08.t-online.de (Postfix) with SMTP id 552754D9D; Sun, 18 Dec 2022 18:15:44 +0100 (CET) Received: from linpower.localnet ([79.208.21.92]) by fwd86.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1p6xGH-12kBwv0; Sun, 18 Dec 2022 18:15:41 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 143FE20045A; Sun, 18 Dec 2022 18:15:39 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 02/11] audio: don't show unnecessary error messages Date: Sun, 18 Dec 2022 18:15:30 +0100 Message-Id: <20221218171539.11193-2-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> References: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> MIME-Version: 1.0 X-TOI-EXPURGATEID: 150726::1671383741-D9A4E9D3-8DBE0184/0/0 CLEAN NORMAL X-TOI-MSGID: 293c7602-e4a2-4123-a5da-c2ae87c1a525 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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. Signed-off-by: Volker Rümelin Reviewed-by: Philippe Mathieu-Daudé --- 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)( hw = 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; } @@ -520,7 +521,6 @@ SW *glue (AUD_open_, TYPE) ( } else { sw = glue(audio_pcm_create_voice_pair_, TYPE)(s, name, as); if (!sw) { - dolog ("Failed to create voice `%s'\n", name); return NULL; } } From patchwork Sun Dec 18 17:15:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 13076062 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0B6CEC4332F for ; Sun, 18 Dec 2022 17:16:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6xGp-0007r2-17; Sun, 18 Dec 2022 12:16:16 -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 1p6xGl-0007pp-VY for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:11 -0500 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 1p6xGk-0002YN-C7 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:11 -0500 Received: from fwd83.dcpf.telekom.de (fwd83.aul.t-online.de [10.223.144.109]) by mailout11.t-online.de (Postfix) with SMTP id 60B65B768; Sun, 18 Dec 2022 18:15:48 +0100 (CET) Received: from linpower.localnet ([79.208.21.92]) by fwd83.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1p6xGK-396kU50; Sun, 18 Dec 2022 18:15:44 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 1634F20062A; Sun, 18 Dec 2022 18:15:39 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 03/11] audio: rename hardware store to backend Date: Sun, 18 Dec 2022 18:15:31 +0100 Message-Id: <20221218171539.11193-3-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> References: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> MIME-Version: 1.0 X-TOI-EXPURGATEID: 150726::1671383744-6120D2DC-582C0E53/0/0 CLEAN NORMAL X-TOI-MSGID: 4f3278b0-4997-498e-88a1-b9bcb8ab5616 Received-SPF: none 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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Use a consistent friendly name for the HWVoiceOut and HWVoiceIn structures. Signed-off-by: Volker Rümelin Reviewed-by: Thomas Huth --- 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 = sw->hw; 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; } From patchwork Sun Dec 18 17:15:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 13076064 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA757C4332F for ; Sun, 18 Dec 2022 17:17:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6xGt-00080s-QV; Sun, 18 Dec 2022 12:16:19 -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 1p6xGm-0007qP-HW for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:13 -0500 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 1p6xGk-0002YR-V4 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:12 -0500 Received: from fwd73.dcpf.telekom.de (fwd73.aul.t-online.de [10.223.144.99]) by mailout11.t-online.de (Postfix) with SMTP id 68800535F; Sun, 18 Dec 2022 18:15:50 +0100 (CET) Received: from linpower.localnet ([79.208.21.92]) by fwd73.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1p6xGM-2RNQG10; Sun, 18 Dec 2022 18:15:46 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 1907F200635; Sun, 18 Dec 2022 18:15:39 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 04/11] audio: remove unused #define AUDIO_STRINGIFY Date: Sun, 18 Dec 2022 18:15:32 +0100 Message-Id: <20221218171539.11193-4-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> References: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> MIME-Version: 1.0 X-TOI-EXPURGATEID: 150726::1671383746-2508E98D-1B3C2835/0/0 CLEAN NORMAL X-TOI-MSGID: 7ec173ef-a7fd-4a65-b181-311aae9c3e90 Received-SPF: none 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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Remove the unused #define AUDIO_STRINGIFY. It was last used before commit 470bcabd8f ("audio: Replace AUDIO_FUNC with __func__"). Signed-off-by: Volker Rümelin Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- 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 -#define AUDIO_STRINGIFY_(n) #n -#define AUDIO_STRINGIFY(n) AUDIO_STRINGIFY_(n) - typedef struct AudiodevListEntry { Audiodev *dev; QSIMPLEQ_ENTRY(AudiodevListEntry) next; From patchwork Sun Dec 18 17:15:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 13076059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 796E9C4332F for ; Sun, 18 Dec 2022 17:16:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6xGh-0007h7-W4; Sun, 18 Dec 2022 12:16: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 1p6xGZ-0007fF-Lc for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:15:59 -0500 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 1p6xGX-0002Tw-QP for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:15:59 -0500 Received: from fwd79.dcpf.telekom.de (fwd79.aul.t-online.de [10.223.144.105]) by mailout02.t-online.de (Postfix) with SMTP id 76CBB1E5B8; Sun, 18 Dec 2022 18:15:49 +0100 (CET) Received: from linpower.localnet ([79.208.21.92]) by fwd79.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1p6xGO-12xwOX0; Sun, 18 Dec 2022 18:15:49 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 1BC8A200637; Sun, 18 Dec 2022 18:15:39 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 05/11] audio/mixeng: use g_new0() instead of audio_calloc() Date: Sun, 18 Dec 2022 18:15:33 +0100 Message-Id: <20221218171539.11193-5-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> References: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> MIME-Version: 1.0 X-TOI-EXPURGATEID: 150726::1671383749-09691417-2C016715/0/0 CLEAN NORMAL X-TOI-MSGID: 3c0dacc7-fb90-49e1-9f85-250426c6333c Received-SPF: none 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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. Signed-off-by: Volker Rümelin Reviewed-by: Richard Henderson --- 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 = ((int64_t) hw_cap->info.freq << 32) / sw->info.freq; sw->vol = nominal_volume; sw->rate = 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 = st_rate_start (sw->hw->info.freq, sw->info.freq); #endif - if (!sw->rate) { - g_free (sw->buf); - sw->buf = NULL; - return -1; - } + return 0; } 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 = audio_calloc(__func__, 1, sizeof(*rate)); - - if (!rate) { - dolog ("Could not allocate resampler (%zu bytes)\n", sizeof (*rate)); - return NULL; - } + struct rate *rate = g_new0(struct rate, 1); rate->opos = 0; From patchwork Sun Dec 18 17:15:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 13076068 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A2C0C4332F for ; Sun, 18 Dec 2022 17:19:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6xGs-0007yQ-9x; Sun, 18 Dec 2022 12:16:18 -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 1p6xGo-0007r1-GJ for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:14 -0500 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 1p6xGn-0002Yb-3w for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:14 -0500 Received: from fwd83.dcpf.telekom.de (fwd83.aul.t-online.de [10.223.144.109]) by mailout11.t-online.de (Postfix) with SMTP id A07A260F2; Sun, 18 Dec 2022 18:15:55 +0100 (CET) Received: from linpower.localnet ([79.208.21.92]) by fwd83.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1p6xGR-3nC2Vd0; Sun, 18 Dec 2022 18:15:51 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 1E76F200638; Sun, 18 Dec 2022 18:15:39 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 06/11] audio/alsaaudio: use g_new0() instead of audio_calloc() Date: Sun, 18 Dec 2022 18:15:34 +0100 Message-Id: <20221218171539.11193-6-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> References: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> MIME-Version: 1.0 X-TOI-EXPURGATEID: 150726::1671383751-6120D2DC-1C3D1ACA/0/0 CLEAN NORMAL X-TOI-MSGID: 812b2cd9-ecb1-41b5-b13a-f5445178e41d Received-SPF: none 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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Replace audio_calloc() with the equivalent g_new0(). The value of the g_new0() argument count is >= 1, which means g_new0() will never return NULL. Also remove the unnecessary NULL check. Signed-off-by: Volker Rümelin Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- 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; } - pfds = audio_calloc ("alsa_poll_helper", count, sizeof (*pfds)); - if (!pfds) { - dolog ("Could not initialize poll mode\n"); - return -1; - } + pfds = g_new0(struct pollfd, count); err = snd_pcm_poll_descriptors (handle, pfds, count); if (err < 0) { From patchwork Sun Dec 18 17:15:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 13076065 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2DE2C4332F for ; Sun, 18 Dec 2022 17:17:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6xGi-0007jo-VE; Sun, 18 Dec 2022 12:16: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 1p6xGZ-0007fD-H9 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:15:59 -0500 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 1p6xGX-0002Vd-U4 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:15:59 -0500 Received: from fwd78.dcpf.telekom.de (fwd78.aul.t-online.de [10.223.144.104]) by mailout02.t-online.de (Postfix) with SMTP id E013913CF0; Sun, 18 Dec 2022 18:15:53 +0100 (CET) Received: from linpower.localnet ([79.208.21.92]) by fwd78.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1p6xGT-2SdF690; Sun, 18 Dec 2022 18:15:53 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 210B720063B; Sun, 18 Dec 2022 18:15:39 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 07/11] audio/audio_template: use g_malloc0() to replace audio_calloc() Date: Sun, 18 Dec 2022 18:15:35 +0100 Message-Id: <20221218171539.11193-7-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> References: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> MIME-Version: 1.0 X-TOI-EXPURGATEID: 150726::1671383753-793AD9DD-D542E205/0/0 CLEAN NORMAL X-TOI-MSGID: c2a017f4-8f42-4098-b3d3-602be6f7368e Received-SPF: none 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Use g_malloc0() as a direct replacement for audio_calloc(). Signed-off-by: Volker Rümelin Reviewed-by: Christian Schoenebeck Reviewed-by: Philippe Mathieu-Daudé --- 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 d343a1dcb3..5f51ef26b2 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -273,7 +273,7 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s, return NULL; } - hw = audio_calloc(__func__, 1, glue(drv->voice_size_, TYPE)); + hw = g_malloc0(glue(drv->voice_size_, TYPE)); if (!hw) { dolog ("Can not allocate voice `%s' size %d\n", drv->name, glue (drv->voice_size_, TYPE)); From patchwork Sun Dec 18 17:15:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 13076060 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1A62C4332F for ; Sun, 18 Dec 2022 17:16:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6xGs-0007y8-2H; Sun, 18 Dec 2022 12:16:18 -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 1p6xGp-0007r5-12 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:16 -0500 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 1p6xGn-0002Yp-Fq for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:14 -0500 Received: from fwd73.dcpf.telekom.de (fwd73.aul.t-online.de [10.223.144.99]) by mailout11.t-online.de (Postfix) with SMTP id 72713FBE8; Sun, 18 Dec 2022 18:16:01 +0100 (CET) Received: from linpower.localnet ([79.208.21.92]) by fwd73.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1p6xGW-3Xics50; Sun, 18 Dec 2022 18:15:56 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 23E222006CE; Sun, 18 Dec 2022 18:15:39 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 08/11] audio/audio_template: use g_new0() to replace audio_calloc() Date: Sun, 18 Dec 2022 18:15:36 +0100 Message-Id: <20221218171539.11193-8-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> References: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> MIME-Version: 1.0 X-TOI-EXPURGATEID: 150726::1671383756-2508E98D-2AAB9185/0/0 CLEAN NORMAL X-TOI-MSGID: 7e00ca6c-556a-4a26-8ae3-a7f038c24679 Received-SPF: none 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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Replace audio_calloc() with the equivalent g_new0(). With a n_structs argument >= 1, g_new0() never returns NULL. Also remove the unnecessary NULL checks. Signed-off-by: Volker Rümelin Reviewed-by: Richard Henderson --- audio/audio_template.h | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index 5f51ef26b2..9c600448fb 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -129,12 +129,7 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) (SW *sw) return -1; } - sw->buf = 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 = g_new0(st_sample, samples); #ifdef DAC sw->rate = st_rate_start (sw->info.freq, sw->hw->info.freq); @@ -407,34 +402,28 @@ static SW *glue(audio_pcm_create_voice_pair_, TYPE)( hw_as = *as; } - sw = 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 = g_new0(SW, 1); sw->s = s; hw = 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; } glue (audio_pcm_hw_add_sw_, TYPE) (hw, sw); if (glue (audio_pcm_sw_init_, TYPE) (sw, hw, sw_name, as)) { - goto err3; + goto err2; } return sw; -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; } From patchwork Sun Dec 18 17:15:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 13076067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 92B97C4332F for ; Sun, 18 Dec 2022 17:19:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6xHM-0000UQ-7E; Sun, 18 Dec 2022 12:16:48 -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 1p6xHL-0000T1-0U for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:47 -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 1p6xHJ-0002ge-AY for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:46 -0500 Received: from fwd73.dcpf.telekom.de (fwd73.aul.t-online.de [10.223.144.99]) by mailout09.t-online.de (Postfix) with SMTP id 744F322C8; Sun, 18 Dec 2022 18:16:01 +0100 (CET) Received: from linpower.localnet ([79.208.21.92]) by fwd73.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1p6xGY-3lsv570; Sun, 18 Dec 2022 18:15:58 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 268562006D9; Sun, 18 Dec 2022 18:15:39 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 09/11] audio: remove audio_calloc() function Date: Sun, 18 Dec 2022 18:15:37 +0100 Message-Id: <20221218171539.11193-9-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> References: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> MIME-Version: 1.0 X-TOI-EXPURGATEID: 150726::1671383758-2508E98D-E068F48A/0/0 CLEAN NORMAL X-TOI-MSGID: 87654a05-633e-44bf-a4c0-3ee706f9b758 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Now that the last call site of audio_calloc() was removed, remove the unused audio_calloc() function. Signed-off-by: Volker Rümelin Reviewed-by: Philippe Mathieu-Daudé --- 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) } } -void *audio_calloc (const char *funcname, int nmemb, size_t size) -{ - int cond; - size_t len; - - len = nmemb * size; - cond = !nmemb || !size; - cond |= nmemb < 0; - cond |= len < size; - - if (audio_bug ("audio_calloc", cond)) { - AUD_log (NULL, "%s passed invalid arguments to audio_calloc\n", - funcname); - AUD_log (NULL, "nmemb=%d size=%zu (len=%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 4632cdf9cc..9d04be9128 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); int audio_bug (const char *funcname, int cond); -void *audio_calloc (const char *funcname, int nmemb, size_t size); void audio_run(AudioState *s, const char *msg); From patchwork Sun Dec 18 17:15:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 13076061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C83D8C10F1E for ; Sun, 18 Dec 2022 17:16:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6xH1-0008Dc-Jd; Sun, 18 Dec 2022 12:16:27 -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 1p6xGy-000883-7D for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:24 -0500 Received: from mailout04.t-online.de ([194.25.134.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6xGw-0002Zx-3O for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:23 -0500 Received: from fwd77.dcpf.telekom.de (fwd77.aul.t-online.de [10.223.144.103]) by mailout04.t-online.de (Postfix) with SMTP id CE25E131A0; Sun, 18 Dec 2022 18:16:01 +0100 (CET) Received: from linpower.localnet ([79.208.21.92]) by fwd77.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1p6xGa-0G2Kqf0; Sun, 18 Dec 2022 18:16:00 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 292E92006DB; Sun, 18 Dec 2022 18:15:39 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 10/11] alsaaudio: change default playback settings Date: Sun, 18 Dec 2022 18:15:38 +0100 Message-Id: <20221218171539.11193-10-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> References: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> MIME-Version: 1.0 X-TOI-EXPURGATEID: 150726::1671383760-88EA281F-43087515/0/0 CLEAN NORMAL X-TOI-MSGID: 7a3a9bcc-2621-4f0b-a0de-cc81c2da8e1d Received-SPF: none client-ip=194.25.134.18; envelope-from=volker.ruemelin@t-online.de; helo=mailout04.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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 Signed-off-by: Volker Rümelin Acked-by: Christian Schoenebeck --- 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); - /* - * 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 user - */ + /* 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 = 1024 * 1000000 / 44100; + /* 256 frames assuming 44100Hz */ + dev->u.alsa.out->period_length = 5805; } if (!dev->u.alsa.out->has_buffer_length) { /* 4096 frames assuming 44100Hz */ - dev->u.alsa.out->buffer_length = 4096ll * 1000000 / 44100; + dev->u.alsa.out->buffer_length = 92880; } /* From patchwork Sun Dec 18 17:15:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 13076063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79C3CC4332F for ; Sun, 18 Dec 2022 17:17:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6xGr-0007xp-Nr; Sun, 18 Dec 2022 12:16:17 -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 1p6xGp-0007rI-Kl for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:16 -0500 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 1p6xGn-0002Yu-QR for qemu-devel@nongnu.org; Sun, 18 Dec 2022 12:16:15 -0500 Received: from fwd72.dcpf.telekom.de (fwd72.aul.t-online.de [10.223.144.98]) by mailout11.t-online.de (Postfix) with SMTP id 80E12FBEE; Sun, 18 Dec 2022 18:16:04 +0100 (CET) Received: from linpower.localnet ([79.208.21.92]) by fwd72.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1p6xGd-0pE2sb0; Sun, 18 Dec 2022 18:16:03 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 2C14A2006DC; Sun, 18 Dec 2022 18:15:39 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Cc: Christian Schoenebeck , Thomas Huth , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-devel@nongnu.org Subject: [PATCH 11/11] alsaaudio: reintroduce default recording settings Date: Sun, 18 Dec 2022 18:15:39 +0100 Message-Id: <20221218171539.11193-11-vr_qemu@t-online.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> References: <3b1404eb-a7c5-f64c-3e47-1397c54c45bb@t-online.de> MIME-Version: 1.0 X-TOI-EXPURGATEID: 150726::1671383763-69DEC991-85389DF5/0/0 CLEAN NORMAL X-TOI-MSGID: 39131f35-84df-48bc-a5ba-787a96676045 Received-SPF: none 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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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ümelin --- 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 = 92880; } - /* - * OptsVisitor sets unspecified optional fields to zero, but do not depend - * on it... - */ if (!dev->u.alsa.in->has_period_length) { - dev->u.alsa.in->period_length = 0; + /* 256 frames assuming 44100Hz */ + dev->u.alsa.in->period_length = 5805; } if (!dev->u.alsa.in->has_buffer_length) { - dev->u.alsa.in->buffer_length = 0; + /* 4096 frames assuming 44100Hz */ + dev->u.alsa.in->buffer_length = 92880; } return dev;