From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085589; cv=none; d=zohomail.com; s=zohoarc; b=Nvd/1zbRu4cCmdeT7K7jdCux275Y8TrHeNcMI/ggssMbLzO4f/rU45ZGHqw9yJ1DpsvSPpuy2lxlCQss9n0F0CO5JgIO+9/WgzRaqHQePWCOdk4evM8h9EtAiR7nwFQcYqirZxYOzGrOG9W7WURXPUvPHVMZkq4Cb8vsQINLmww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085589; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RoT2ocySfuUdupR8Y1c2SMrsgYF+Xh1R9POvfIB59Yc=; b=CtOLg9sMSuQzL8bbBwDom+4lAEdshH0SEbUyX9TJPZsRgQxrOgG4afK+6FDzwsIDMs42+j1F71aBO1Sr6F412xUnnafORz1Cg882/g/EObrFX5RbroECNsGVzCK1x8ZE4EfI2mSjLxu34ifUNjBpkjlrfqCp1IpgzsnsKmwepnU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167808558967364.95580278780471; Sun, 5 Mar 2023 22:53:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4i2-0003Kl-VU; Mon, 06 Mar 2023 01:52:35 -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 1pZ4hw-0003DH-KB for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4ht-0000VX-Sw for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:27 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-607--gGierQTNRyZZUH_f21nfw-1; Mon, 06 Mar 2023 01:52:11 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F0DEC848D91; Mon, 6 Mar 2023 06:52:10 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 205E6C16029; Mon, 6 Mar 2023 06:52:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085534; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RoT2ocySfuUdupR8Y1c2SMrsgYF+Xh1R9POvfIB59Yc=; b=fqYDICEGcpH8XPT650Rc60srB6J7O9ey88ZFypWQMVHzA7qaY+qfU4Ru0/HT2MVWUlArby vgs1yBECHmjkw1LtsVsTnTpJgcXHL5o9L4lux9lhAkaxa8Vq4ONREuvOs+UKjWgWh90eoW 0ktddUIRSI8sxxWfVQjRsGSSRadQ/Bk= X-MC-Unique: -gGierQTNRyZZUH_f21nfw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck Subject: [PULL 01/27] MAINTAINERS: add myself to ui/ and audio/ Date: Mon, 6 Mar 2023 10:51:36 +0400 Message-Id: <20230306065202.2160066-2-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085591164100015 From: Marc-Andr=C3=A9 Lureau Helping out with patch review & queue handling. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20230207085610.1033536-1-marcandre.lureau@redhat.com> --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 011fd85a09..da29661b37 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2490,6 +2490,7 @@ Subsystems ---------- Overall Audio backends M: Gerd Hoffmann +M: Marc-Andr=C3=A9 Lureau S: Odd Fixes F: audio/ X: audio/alsaaudio.c @@ -2785,6 +2786,7 @@ F: docs/spice-port-fqdn.txt =20 Graphics M: Gerd Hoffmann +M: Marc-Andr=C3=A9 Lureau S: Odd Fixes F: ui/ F: include/ui/ --=20 2.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085625; cv=none; d=zohomail.com; s=zohoarc; b=Bp8X21RC4fs0Yerh96zH41qJtLtHTNRY4QtYn+B5hsawgMbodaJYTOBbEyfhLxJdb/9vzCTV2Nu0sU0JJDNuqJwpXfLTuSZuvLDmT+FRAfwcGlN6aY0CuaD85zdOErhmLlHEA54dBJ281LBrBEF2wRuUe46WwU9gUd17MFuRyU0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085625; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RTVBPGWDXMSiGlBN4LJCAIMna71BvDdy9/poKt2/1Gs=; b=hyqirEvHcsDydR76QV1prK3Qua3ugRfv7nD/Au0LB1aI+fJm7y1jJ641C73ErrQ87IdHrqEd5Hol7M3mox8sR7i/uaCuGt7+hnNb2Mzakf7X+SsBmkAfSLWXwDr+QzOotC+RRqYouio+S49jmpFMQVN1dz/A/OHZSwsIkWAJreA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085625550608.6998819530029; Sun, 5 Mar 2023 22:53:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4i4-0003MF-6W; Mon, 06 Mar 2023 01:52:36 -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 1pZ4hw-0003Dc-Lg for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4ht-0000Vh-TD for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:28 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-659-tFiDXoJAOF-dkScaXoVzGw-1; Mon, 06 Mar 2023 01:52:15 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27F443C10681; Mon, 6 Mar 2023 06:52:15 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEAAF2026D76; Mon, 6 Mar 2023 06:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RTVBPGWDXMSiGlBN4LJCAIMna71BvDdy9/poKt2/1Gs=; b=LSUucOx6AxGNubS+onOhJFb78wDWcxc9Nbne6b5DcgIcHV1wjh0SJ5aweJOcQdh4Kn1Jv/ TzL4yePELyetxUaHdYpExfSUo/JpSeEz00SQ7Mg7gA6IU3EDNtdALFfc02fgQr+VTtavJs 5hGRmBEHgUuiAmbYUBk3zB1bIuRYH0s= X-MC-Unique: tFiDXoJAOF-dkScaXoVzGw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 02/27] audio: log unimplemented audio device sample rates Date: Mon, 6 Mar 2023 10:51:37 +0400 Message-Id: <20230306065202.2160066-3-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085627322100007 From: Volker R=C3=BCmelin 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 Message-Id: <20230121094735.11644-1-vr_qemu@t-online.de> --- audio/audio_template.h | 13 +++++++++++++ audio/audio.c | 1 + 2 files changed, 14 insertions(+) diff --git a/audio/audio_template.h b/audio/audio_template.h index 42b4712acb..dbfb4fee4c 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) { diff --git a/audio/audio.c b/audio/audio.c index 4290309d18..81f5c0bb1e 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -33,6 +33,7 @@ #include "qapi/qapi-visit-audio.h" #include "qapi/qapi-commands-audio.h" #include "qemu/cutils.h" +#include "qemu/log.h" #include "qemu/module.h" #include "qemu/help_option.h" #include "sysemu/sysemu.h" --=20 2.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085567; cv=none; d=zohomail.com; s=zohoarc; b=N6kp/7im1GiaVWYe6tTVf6oyEgIbSDRS6tV0HTK/E8FrAHiW5q7y1tucclf95vy0Z1gA45+dQa8HOuD3T5J7ZmXSU/NCDOY7KKrwgY88+OCeXP987sqFY0LYfdzlPTrngb9foUyCMd7JJIeakIWl7Tm1r+v2DLAmccbp49QdmAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085567; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ix89SOn3kFUzdITz4q+MOEVr5Kf8KxXaqghk1tmoFQs=; b=G/h4bcwVyT2w3z87nyygDt8IV8+SFo98nn3PB/S907YsgMdXvcU/PMETvE+3fRgagbzBT7xcUK20vkBYubsGACPlhe9BFWqIOpX+mOSIRNqca6KCImlhf4C1to3WRGwOZL7+4JGwoux9Ie6pY0iHcnduG7P2y5fkPwwn47RIAqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085567957909.8278608751915; Sun, 5 Mar 2023 22:52:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4i2-0003JZ-89; Mon, 06 Mar 2023 01:52:34 -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 1pZ4hw-0003DF-K9 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4ht-0000Vs-TD for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:27 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-36-YldT6Y2jMWil1E4rxbTEmA-1; Mon, 06 Mar 2023 01:52:20 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 892C185A5A3; Mon, 6 Mar 2023 06:52:19 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9280B40C10FA; Mon, 6 Mar 2023 06:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085543; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ix89SOn3kFUzdITz4q+MOEVr5Kf8KxXaqghk1tmoFQs=; b=SofLepHICysMoxyfsIbrinAQyHmbuYVqY9zizAcJwkheSJfVHbKTRBnlt75ORbyOAyRCYY Tp1f+8bz3MMOKWHbXYdELKF5uO6kqMKkNvzC9qOXohuMsfo/v47+c+YrBafX9TrShLlEhw 4KvhNMv7OcLQhR6obGTT3aod1deVH5s= X-MC-Unique: YldT6Y2jMWil1E4rxbTEmA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 03/27] audio: don't show unnecessary error messages Date: Mon, 6 Mar 2023 10:51:38 +0400 Message-Id: <20230306065202.2160066-4-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085568595100001 From: Volker R=C3=BCmelin 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 Message-Id: <20230121094735.11644-2-vr_qemu@t-online.de> --- 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 dbfb4fee4c..f0ef262ab3 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -441,6 +441,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 @@ -540,7 +541,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.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085591; cv=none; d=zohomail.com; s=zohoarc; b=Muf1xGcqthF6kKo3+WVDA9ZHCDrM7Z2Naypq/WmE3qerdE4kkIk9NpwfG3LtiniYju9qcL1OWTZ7V/h2IQXurNF5qAzPCaUfdC4grJehL20Vd69LVfb/ox0YoH3QrMVvRML3GivdJvKAOswJovAQwe8gV+BYP9WC6t0hFhVMOD0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085591; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7y/D8sGqubS+tmtkakPYx2BKdnm+kQe5y0cy7kKK5aM=; b=kthfTLCF50Co2F6yvjicWcGF4t6Pnc+2AG4rU9v3zjWQ/IowD9OxXqhOeRWXD2+tCpa8IumfKaIMytl6AVRJYvwYFPa2cHXRz6ED1HTOcE/FWLG2BT6XNdFj1Qj9cIPKw+QeE9Km4J8WdUkhzsE4kmC7HWD00lcuysm/qTcvQ2Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085591215985.6171786286687; Sun, 5 Mar 2023 22:53:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4iH-0003Yl-VQ; Mon, 06 Mar 2023 01:52:50 -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 1pZ4hy-0003GJ-01 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4hw-0000Wb-Cc for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:29 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-230-93IEcLLVOYu45k1F21raWQ-1; Mon, 06 Mar 2023 01:52:24 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B3D93185A7A4; Mon, 6 Mar 2023 06:52:23 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80B7C140EBF4; Mon, 6 Mar 2023 06:52:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7y/D8sGqubS+tmtkakPYx2BKdnm+kQe5y0cy7kKK5aM=; b=dRzwImzwQS42kCQO6O27vEZSOYQDixnMvNWKJGpmMlL5Q76G0m8Ee0iZHlyvZmHFXVGsKP AHv1Y+Elp/C/O10zIdkS33LMbMDJCCZAls6yeChcZk03FlJxx4Gq82PtBpt5JuzzpmcyKo d7OG2AMbIRm7QG5WpKfmYTnL/QrZ6IQ= X-MC-Unique: 93IEcLLVOYu45k1F21raWQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 04/27] audio: rename hardware store to backend Date: Mon, 6 Mar 2023 10:51:39 +0400 Message-Id: <20230306065202.2160066-5-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085593001100017 From: Volker R=C3=BCmelin 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 Message-Id: <20230121094735.11644-3-vr_qemu@t-online.de> --- 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 f0ef262ab3..33af42ed8b 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -529,8 +529,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.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085586; cv=none; d=zohomail.com; s=zohoarc; b=ON4vF9dVh5oIqAEAIkCnooCkMopZNlwYmo4jAhKz4Xoo+1QGLomin+sSxhWHl7SR+bNRBhzMMgCIoB663K8CjU2rxOwU0qgEMbFvmvPtnXR9OvRVV/BM/0PvxRXBjWQAV5zgWsuOLyQr7cXCGEpnamXKMOQypQQ7038L9RtejHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085586; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CXnqUQ3a5MMoFN3hdy+qceuR41iK87G67yUFCseFxmU=; b=SJz81imVtOHhvpoC8HK9iE8MJ/zS4lAfUispT4XKWs7hfpGy5SFYP+jEfIIkdEnDGbVJjxgVuvLQrUuKmgycTvhVzq9rT8nnaUa6GM5Qzd+/bGyVpczM+cedS2F1UsvP7TjhPJyUrjCHbRIOIOZf4635Awcs7qG4Umm3GD+wMz4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085586593898.5179209294668; Sun, 5 Mar 2023 22:53:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4i4-0003Mh-Ce; Mon, 06 Mar 2023 01:52:36 -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 1pZ4i1-0003Gs-LB for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4hz-0000XD-3R for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:32 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-618-grY5596lPESd9X4juy9VjQ-1; Mon, 06 Mar 2023 01:52:28 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6EB3C1C04326; Mon, 6 Mar 2023 06:52:28 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D2F02166B26; Mon, 6 Mar 2023 06:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085550; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CXnqUQ3a5MMoFN3hdy+qceuR41iK87G67yUFCseFxmU=; b=bPs62roGunODl1BTTmBFjhX6f79jgJB8rAyG5Q3Pit8s6aJ3a+u2fAgwqNQx8nhYhPAUsf aVTtnxGOnls0YxB55JpKpzbFWSvfX7TzxyDNxHTb53uwe9DAZLYDBUVeTtNUG+BOtaP2gS W26lZ4mf5jtx/3jpyAg12sJOKeYvCcs= X-MC-Unique: grY5596lPESd9X4juy9VjQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 05/27] audio: remove unused #define AUDIO_STRINGIFY Date: Mon, 6 Mar 2023 10:51:40 +0400 Message-Id: <20230306065202.2160066-6-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085586976100009 From: Volker R=C3=BCmelin 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 Message-Id: <20230121094735.11644-4-vr_qemu@t-online.de> --- 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.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085584; cv=none; d=zohomail.com; s=zohoarc; b=SMQOikwSd+qdGb+0XoygZJ/s5C85TNHGhbPBrcaR/v9He6xLj1xnCGZodyEFeRaVQ9odW3GRHVBFcAFV1NgQpxhhSSdhVU8fZBr5UKVTTFFO3EV99lrQ4EJwkOLlir5O+aba2qYzYag2jQZH7gaBlr6as+3GtjcUQwu+utvJ82s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085584; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EEK4Ke9sTNOLkOdNaNV6/DX7YOr0f8MCkCxyJOVC/TY=; b=KyJrGnMQtXpET0YABpT7D8rO60buHTB6iatb9FwKLq76SVouuyeKo216MS64pOOnnTnOn2vKqKN6eNxWMqbi2/qRKGCHKtA23UU2xB1MxqqnM44aFLTfVbAg8xNqh2yyUoFzGau2GxURFDug1tCTxMzNCormqDyjc6h4XtTzrRg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085584039699.7350713898936; Sun, 5 Mar 2023 22:53:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4iJ-0003g9-Df; Mon, 06 Mar 2023 01:52:51 -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 1pZ4i6-0003Qo-IC for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4i4-0000Xl-W3 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:38 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-402-qIIcZhr2PCuWpdxPQQsXRQ-1; Mon, 06 Mar 2023 01:52:32 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F9743C025B1; Mon, 6 Mar 2023 06:52:32 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E6622166B26; Mon, 6 Mar 2023 06:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085556; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EEK4Ke9sTNOLkOdNaNV6/DX7YOr0f8MCkCxyJOVC/TY=; b=YdYXwJqsXOw6lfAS7gruuD4xbzde0W5vMKFsAkKQgOWrO2vBdMQ3Vh0Xg8V6Da0FS1FCc3 tdfQJZLanpGlqQwzOK3sXbfV3V3WQZTpV5OO2bameXkF8/AuiMHE+65qGXmtc5g3YOTNF8 wvafhmMZeiwlIoNsP/V5DXAdgvLNgCg= X-MC-Unique: qIIcZhr2PCuWpdxPQQsXRQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 06/27] audio/mixeng: use g_new0() instead of audio_calloc() Date: Mon, 6 Mar 2023 10:51:41 +0400 Message-Id: <20230306065202.2160066-7-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085584972100004 From: Volker R=C3=BCmelin 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 Message-Id: <20230121094735.11644-5-vr_qemu@t-online.de> --- audio/audio_template.h | 6 +----- audio/audio.c | 5 ----- audio/mixeng.c | 7 +------ 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index 33af42ed8b..dfa440f778 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/audio.c b/audio/audio.c index 81f5c0bb1e..012d10996b 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -509,11 +509,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/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.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085577; cv=none; d=zohomail.com; s=zohoarc; b=T0D6hyetZ+A9U3uGHZdIXGLyVdh+Ccm2yRwTn9eo5/NQu3HMJm82IFcthALt6YNd3QW1lCyWY1pmRgp8eRaejm5bBejVUJKemnut3v95EEWOJ15fsCqbHnTqk1WNKooMIifuNjOCXISUIake+LrNEojauU3MAY9ROFz64q6ij/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085577; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fG9U1MaaUWFTE10JMj8Gyb8MxHvQncPQmeyyT/rFDkA=; b=Z4RyyX3M2xFJOEymVFzRN/FwBgSDDTf10KpiHmRKLoALUASU1x6wCVaIho1zx0iZjFhrbBAOsbx7Qnb81CB0/HH/9IEVizOGjYFmdaYTIoFNQ+1mbodGOlGe+4IN7wvka8XlOGcRLJIXriXva1x7tosISqf1vIW9Zb1nPzSIM70= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085577615731.7454828351373; Sun, 5 Mar 2023 22:52:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4iJ-0003gB-IK; Mon, 06 Mar 2023 01:52:51 -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 1pZ4iA-0003Vk-6u for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4i8-0000Xy-Ia for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:41 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-169-kbyWYvhJNkaruk27mrp2Iw-1; Mon, 06 Mar 2023 01:52:38 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 02CE13C10681; Mon, 6 Mar 2023 06:52:38 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id F20612166B26; Mon, 6 Mar 2023 06:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085559; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fG9U1MaaUWFTE10JMj8Gyb8MxHvQncPQmeyyT/rFDkA=; b=UF6giT3g+2Y3cGq+R65fbFGySSiY/tFGTjJIdeNehXUX4bdcqfjB+QXakeWWd8Fs/P6UBk BaFxcsRRokLo4Da0unEq2q5TUm/i9d7InWixLY3Y0GZby5kWfwmENcWuJKmE6vxXNSOYsy RxT+IngYzEkVPcneWnJn0bJA0mblX54= X-MC-Unique: kbyWYvhJNkaruk27mrp2Iw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 07/27] audio/alsaaudio: use g_new0() instead of audio_calloc() Date: Mon, 6 Mar 2023 10:51:42 +0400 Message-Id: <20230306065202.2160066-8-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085578935100003 From: Volker R=C3=BCmelin 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 Message-Id: <20230121094735.11644-6-vr_qemu@t-online.de> --- 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.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085624; cv=none; d=zohomail.com; s=zohoarc; b=QD9r1Eb3kqH5zlV07GkeDaL3EhEj4405Az3T2zPrvO/RHWn5OLgs0A7MNDfWjdsC+C2F4wNT5QPZtaXouqMdxlUGKcREWDBVZwuWqwgiGAgpJsFrgFLBUHUiRVZlfbxZEHMGX4CwMJWn8skaHBJXQiAxrnfkaH93OLUKtM3h+48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085624; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Qs85+lNX1CIt1d17yJJi1YhLfEiUe41EDq6IGo6LhSY=; b=Lu7GBRkOv15rAQSraaNx2vQGwHBLf9G8WmoTVR1UmB4kgyPhbw2+B3LMPoDID/mAc3fqegmtTN4B2WcrrU2cl5K509C7nQIVPhcZZyBk5HZwYKNCbX8ftCFyMxTepN0npgL0FbzQNbAVuKy3DkLSurRL8NyngVaCptK1fyMNN6A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085624706426.07541204678466; Sun, 5 Mar 2023 22:53:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4iT-00043h-KG; Mon, 06 Mar 2023 01:53:01 -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 1pZ4iG-0003cs-EO for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4iE-0000YZ-Ob for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:48 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-186-rLDtAhNLOL20WXgMjy0OVw-1; Mon, 06 Mar 2023 01:52:42 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 03570811E6E; Mon, 6 Mar 2023 06:52:42 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41D07175AD; Mon, 6 Mar 2023 06:52:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Qs85+lNX1CIt1d17yJJi1YhLfEiUe41EDq6IGo6LhSY=; b=JTTU+zcd1+myU7XevjFhh4bQVNyZLK/YI7+zlU+UbnPsR+O48J7FWZjpyMk2sD40ODZmY3 cOXCSvpPtkpowF+fTIPLLeZIwSYsagtYBlg+ErnkvhIcC/2rS52kK6s0HPQ/3yJODhYSMx xlv3AltwmclniZdluSaggqa3Y/5tJCs= X-MC-Unique: rLDtAhNLOL20WXgMjy0OVw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 08/27] audio/audio_template: use g_malloc0() to replace audio_calloc() Date: Mon, 6 Mar 2023 10:51:43 +0400 Message-Id: <20230306065202.2160066-9-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085625263100001 From: Volker R=C3=BCmelin 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 Message-Id: <20230121094735.11644-7-vr_qemu@t-online.de> --- 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 dfa440f778..592866f14a 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.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085583; cv=none; d=zohomail.com; s=zohoarc; b=IwHKDVelJO3+og+wAdk0prd9Hdn89mwcg/LPBd021+/JfJLd5txjBLaWbyQhXpNbbyR7x1iKKiDjGIrpc42od3u/oNEaoWGpKLExuxlZG9+VHcYaB1k57jf7fSH4ezyFYGU77W7y9SFkuMt1SGmg4qWxOhFn9bP/KneaD8V/DOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085583; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v9U2rnkH56RGiYZ1YG5+/56tL3XbQI3JHqSlBjinnv4=; b=YAF/4pWaZAoNBPy8DaDVlkK2lPPubr74dtE2NiQDZtNB7BXOqZs5lIoNcwyfvXgs1N3Y6KfdLaXc6Lr9Vmyct1le0ms+H3gqMfhbBOdhqBPwB839ECunoOmGpXqISeogg+DyXqNndD+JOSUrA7tntSs8PZjssYFpWh+od/jM41Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085583611359.6828664384251; Sun, 5 Mar 2023 22:53:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4iM-0003o7-0x; Mon, 06 Mar 2023 01:52:54 -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 1pZ4iI-0003em-Cb for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4iG-0000Yn-E2 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:49 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-354-h8ktXhfBOzO537ZV36JH7Q-1; Mon, 06 Mar 2023 01:52:46 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DE998101A521; Mon, 6 Mar 2023 06:52:45 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 265E240C83B6; Mon, 6 Mar 2023 06:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v9U2rnkH56RGiYZ1YG5+/56tL3XbQI3JHqSlBjinnv4=; b=RDPagj6G8cR7g/6Cz9c8AKp9n5v7wP+PgCp2ztDB+cKRSDPq73zmOi7PlJZZsJra0Wkmu8 QzLI8YShbLtR9/W9sk4aSdivKgnu8JfXLG9q23OpFiKQYnDygG7xDLkFOTNZIGZuypf7Xk SoIoQCPJbh6tcVxO5OlZGvC6ndv176Q= X-MC-Unique: h8ktXhfBOzO537ZV36JH7Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 09/27] audio/audio_template: use g_new0() to replace audio_calloc() Date: Mon, 6 Mar 2023 10:51:44 +0400 Message-Id: <20230306065202.2160066-10-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085584967100003 From: Volker R=C3=BCmelin 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 Message-Id: <20230121094735.11644-8-vr_qemu@t-online.de> --- 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 592866f14a..980e1f4bd0 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); @@ -425,34 +426,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.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085603; cv=none; d=zohomail.com; s=zohoarc; b=lei0B08YGwciTFUl6TYCQHGkgMUmyLssT0tnkaovx/PqsBleTT24TOKj4aYPUSZkvrGWak307UMsVcizB6mTp9OeTMkbXN4ei+Kxxw5lqLDhXJTU1sUerRvfS9UkpspUTGD597fl0q/po/EFZFrv1tKk/hi+VTiQfnV1tPWAz0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085603; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZyQk7Dp5S1xzmSZ9xu8TSWoGZV/pWY8kmf5wDtWsnCs=; b=AFc866HcssxvkXEin5BSPR5kpuYfoK4c2hBle5+voAy2I904eBGXZLcO38V+BW2J8+8/Xc4XSYDZUEqPlbIXuBOwTmIm9WtF5n3L6TOoXT6AqHASx6tw30gNegosl2DbSX90QsL1x/+BjD8N3bdG+ZIls7zJV/PKfIT4jTnTZJU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16780856037017.05306153403501; Sun, 5 Mar 2023 22:53:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4iP-0003wP-2N; Mon, 06 Mar 2023 01:52:59 -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 1pZ4iL-0003o8-OS for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4iK-0000ZM-8m for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:53 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-277-2jy7idXwPyq5MYpT1_q0gg-1; Mon, 06 Mar 2023 01:52:49 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76E3D2A59562; Mon, 6 Mar 2023 06:52:49 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id AACDB175AD; Mon, 6 Mar 2023 06:52:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZyQk7Dp5S1xzmSZ9xu8TSWoGZV/pWY8kmf5wDtWsnCs=; b=btLrfeY/TBlIeTHeLwlzRP4BbEi+vKw0Ea5rOhsiWcoG6U44jvrex+gX3vMsPciOES8Iij hUI+8c+1/d9/3c73FujPc4yiYvUIOcw+oe2ZICLnY8LXRnRSQYWVZst6VNZHlbj8pQxtZc YHGLxPRTT2Lc1u7I1drRqgnVskSGFcY= X-MC-Unique: 2jy7idXwPyq5MYpT1_q0gg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 10/27] audio: remove audio_calloc() function Date: Mon, 6 Mar 2023 10:51:45 +0400 Message-Id: <20230306065202.2160066-11-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085605077100003 From: Volker R=C3=BCmelin 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 Message-Id: <20230121094735.11644-9-vr_qemu@t-online.de> --- audio/audio_int.h | 1 - audio/audio.c | 20 -------------------- 2 files changed, 21 deletions(-) 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 diff --git a/audio/audio.c b/audio/audio.c index 012d10996b..772c3cc320 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -149,26 +149,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) { --=20 2.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085770; cv=none; d=zohomail.com; s=zohoarc; b=j1NZecS0zFc2JVqbkCD0Xc5iiBgpsuuuoSP8JjZwbJzp81cjYk/+oRRkYjcO8DShgcmBQq/gGa1y1CQYayefp2Mlnp+u52mMm0AUX/JJuV/dbPnxEA5dwMjfbdAhHf5OyvTYVGmJaFdggUdChaLKkJs8yDT/cNBO+nRKeBiy3Ck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085770; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rCL/WlePjR2JAgRav/VzbVd4RjkGQvCfc7x11pY5c+o=; b=b1tl5DebDBoBWADNlB0rpiimk6ZqyigERoXphWvgtkir0Yg2M82aoI4QxLiMa+241byMJDUIxlCQU+mP8LRv4h6ocAMM/xdNSzMEngBShJr1uUfLspPFjlqyPI9f+oAvkXMc0gHEfocvXqqqmma22l1LRqHc3jE7S6wzNwt5lfI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085770655201.8221199300316; Sun, 5 Mar 2023 22:56:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4ib-0004Qp-SZ; Mon, 06 Mar 2023 01:53: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 1pZ4iR-000403-HW for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4iQ-0000Zv-13 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:52:59 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-662-uK-HJgAkPT-qzsOGjSArLQ-1; Mon, 06 Mar 2023 01:52:54 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D1413802D2A; Mon, 6 Mar 2023 06:52:53 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id D019EC1602A; Mon, 6 Mar 2023 06:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rCL/WlePjR2JAgRav/VzbVd4RjkGQvCfc7x11pY5c+o=; b=g0w7Vj3CZxnZdtVdUUbxbNUSz75q3TmUJdk2xOiUdXU+4/6SlwWYFYOYqjrQ0c69FTABPB 8P5fw7SggOT5gVGsJ1MSrM/aQc02svK6kAS8abw+LhBC7gioFT199rfOazwSIjBe0T2gXQ 54+JKcrjb08g1qf+0csFM3WcS/FoQMs= X-MC-Unique: uK-HJgAkPT-qzsOGjSArLQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 11/27] alsaaudio: change default playback settings Date: Mon, 6 Mar 2023 10:51:46 +0400 Message-Id: <20230306065202.2160066-12-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085770859100001 From: Volker R=C3=BCmelin 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 Message-Id: <20230121094735.11644-10-vr_qemu@t-online.de> --- 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.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085751; cv=none; d=zohomail.com; s=zohoarc; b=PB9QAeNZlXMKbdVsSC6/dTy9y1jPQ67hVr5u2pL2/s31laSUGP1bHk1YG2UP6IU7BBq7jGZ7Osyd4VDkRN2EbBnP5XdA5EZIf6i1hRn0QeHxfXpHL+uJwJRq4eingwn2eOGplZKQfztsnYBpEiLy4oARkaUSU3j5wsRc9lh42ZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085751; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Gh6cAGLogsZGQMOi8ZarRPa2XwTwEITG4QFnno4k2CM=; b=HIXMJAMRCN4qRLVnYHqcy5MZ3wpeOYfPi4Y6pL3IcneRO/7h8I0wVOWI/4PiVDjQT27ucGWczTiZzfMFxLhuLPpGU7mgCshjurr7Pq3JEgGByfGSdOjt0UdFE7V0LkcpjzCeRfcm25h8OrJ+Gbm7q1HMsD/9hCtfVWL8g6RqSoc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085751208856.4523517840692; Sun, 5 Mar 2023 22:55:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4ic-0004Tk-CL; Mon, 06 Mar 2023 01:53: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 1pZ4iW-0004Ej-PA for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4iU-0000aA-Ce for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:03 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-367-3_tCTucqPdKQlQDnN1Hb0w-1; Mon, 06 Mar 2023 01:52:58 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C06963C025B1; Mon, 6 Mar 2023 06:52:57 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2BCE2166B26; Mon, 6 Mar 2023 06:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gh6cAGLogsZGQMOi8ZarRPa2XwTwEITG4QFnno4k2CM=; b=XTr/DEBwE8+yOhBQkJaMO+ViizefyFl5NgqGPDlxGnx79n01uBgUeRvOaU+w5eBBpoCrjD a9MZl/vA8mVQng1REFcFyOhJgIxMWJX+MyO2GpnaI6mAMD8uyK66HapQg/GV39ghNbtyc7 2eEghyK08Dwb2yuadhyAa4X0jgHpUgo= X-MC-Unique: 3_tCTucqPdKQlQDnN1Hb0w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 12/27] alsaaudio: reintroduce default recording settings Date: Mon, 6 Mar 2023 10:51:47 +0400 Message-Id: <20230306065202.2160066-13-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085752764100001 From: Volker R=C3=BCmelin 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 Message-Id: <20230121094735.11644-11-vr_qemu@t-online.de> --- 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.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085674; cv=none; d=zohomail.com; s=zohoarc; b=IAG4tIvy8IOFBFX3moVvpgBhRgrcVKsC82ybQSs9KYap+Tm1AUH/m/lpgBtCTNBzG196ghvDKcm/6OqxRfmwXwttqFFwlSXjswieHbYkNEgFWB8N+Qk3U1wM6da+8BRlA+nfk/LLIzx29abxwwZPI21aZnJRai93wYG5yeAdvUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085674; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fXVhEI3VV9QdaCsWCNydqkF5yjII5yuFrvj0HQWqhyQ=; b=asnOpqXiDuu4vw4so+cCTVDixsox0N8CuRQJJrmlHF4wHX8NTXsYLmpcEK6fJti0mVZzWYzUMzvr3Vzd5ys4F59UFRFkh3/LmCQcT7QPvg64AqaPnZ3Y/S5XfbTnOsUIiSgMr49my3oXDNsWePcGfzT/ZqJXS3TMtwX4X/y+eeM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085674629613.3644606870284; Sun, 5 Mar 2023 22:54:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4ih-0004fO-7t; Mon, 06 Mar 2023 01:53:15 -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 1pZ4ib-0004TK-T7 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4iZ-0000ad-9b for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:09 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-635-eKXjPZNwOoulrx6cVT4_Og-1; Mon, 06 Mar 2023 01:53:03 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D29BC101A55E; Mon, 6 Mar 2023 06:53:02 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21E68C1602A; Mon, 6 Mar 2023 06:53:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085586; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fXVhEI3VV9QdaCsWCNydqkF5yjII5yuFrvj0HQWqhyQ=; b=DGXiFG7iJtpnq+zzEO/KO5dvgOytx6mJd7oz7X0tL/OF3JdBFdIYy3BxUIohojAyxa08KK rva3EGXFXNVAaXo/kij0UKPJniYtu/nspJA0okJ/ByqSQYTW92J3k/LN0xfrYZIWuljrK2 uJt8OyqH9+mYv9zGRUPmeOkRS9lRDoE= X-MC-Unique: eKXjPZNwOoulrx6cVT4_Og-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 13/27] audio: change type of mix_buf and conv_buf Date: Mon, 6 Mar 2023 10:51:48 +0400 Message-Id: <20230306065202.2160066-14-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085675631100010 From: Volker R=C3=BCmelin Change the type of mix_buf in struct HWVoiceOut and conv_buf in struct HWVoiceIn from STSampleBuffer * to STSampleBuffer. However, a buffer pointer is still needed. For this reason in struct STSampleBuffer samples[] is changed to *buffer. This is a preparation for the next patch. The next patch will add this line, which is not possible with the current struct STSampleBuffer definition. + sw->resample_buf.buffer =3D hw->mix_buf.buffer + rpos2; There are no functional changes. Acked-by: Mark Cave-Ayland Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-1-vr_qemu@t-online.de> --- audio/audio_int.h | 6 +-- audio/audio_template.h | 19 ++++---- audio/audio.c | 106 ++++++++++++++++++++--------------------- 3 files changed, 67 insertions(+), 64 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 5028f2354a..061845dcc2 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -58,7 +58,7 @@ typedef struct SWVoiceCap SWVoiceCap; =20 typedef struct STSampleBuffer { size_t pos, size; - st_sample samples[]; + st_sample *buffer; } STSampleBuffer; =20 typedef struct HWVoiceOut { @@ -71,7 +71,7 @@ typedef struct HWVoiceOut { f_sample *clip; uint64_t ts_helper; =20 - STSampleBuffer *mix_buf; + STSampleBuffer mix_buf; void *buf_emul; size_t pos_emul, pending_emul, size_emul; =20 @@ -93,7 +93,7 @@ typedef struct HWVoiceIn { size_t total_samples_captured; uint64_t ts_helper; =20 - STSampleBuffer *conv_buf; + STSampleBuffer conv_buf; void *buf_emul; size_t pos_emul, pending_emul, size_emul; =20 diff --git a/audio/audio_template.h b/audio/audio_template.h index 980e1f4bd0..dd87170cbd 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -71,8 +71,9 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioState = *s, static void glue (audio_pcm_hw_free_resources_, TYPE) (HW *hw) { g_free(hw->buf_emul); - g_free (HWBUF); - HWBUF =3D NULL; + g_free(HWBUF.buffer); + HWBUF.buffer =3D NULL; + HWBUF.size =3D 0; } =20 static void glue(audio_pcm_hw_alloc_resources_, TYPE)(HW *hw) @@ -83,10 +84,12 @@ static void glue(audio_pcm_hw_alloc_resources_, TYPE)(H= W *hw) dolog("Attempted to allocate empty buffer\n"); } =20 - HWBUF =3D g_malloc0(sizeof(STSampleBuffer) + sizeof(st_sample) * s= amples); - HWBUF->size =3D samples; + HWBUF.buffer =3D g_new0(st_sample, samples); + HWBUF.size =3D samples; + HWBUF.pos =3D 0; } else { - HWBUF =3D NULL; + HWBUF.buffer =3D NULL; + HWBUF.size =3D 0; } } =20 @@ -111,9 +114,9 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) (= SW *sw) } =20 #ifdef DAC - samples =3D ((int64_t) sw->HWBUF->size << 32) / sw->ratio; + samples =3D ((int64_t)sw->HWBUF.size << 32) / sw->ratio; #else - samples =3D (int64_t)sw->HWBUF->size * sw->ratio >> 32; + 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", @@ -126,7 +129,7 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) (= SW *sw) size_t f_fe_min; =20 /* 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; + 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" diff --git a/audio/audio.c b/audio/audio.c index 772c3cc320..a0b54e4a2e 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -523,8 +523,8 @@ static size_t audio_pcm_hw_find_min_in (HWVoiceIn *hw) static size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw) { size_t live =3D hw->total_samples_captured - audio_pcm_hw_find_min_in = (hw); - if (audio_bug(__func__, live > hw->conv_buf->size)) { - dolog("live=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_buf-= >size); + if (audio_bug(__func__, live > hw->conv_buf.size)) { + dolog("live=3D%zu hw->conv_buf.size=3D%zu\n", live, hw->conv_buf.s= ize); return 0; } return live; @@ -533,13 +533,13 @@ static size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw) static size_t audio_pcm_hw_conv_in(HWVoiceIn *hw, void *pcm_buf, size_t sa= mples) { size_t conv =3D 0; - STSampleBuffer *conv_buf =3D hw->conv_buf; + STSampleBuffer *conv_buf =3D &hw->conv_buf; =20 while (samples) { uint8_t *src =3D advance(pcm_buf, conv * hw->info.bytes_per_frame); size_t proc =3D MIN(samples, conv_buf->size - conv_buf->pos); =20 - hw->conv(conv_buf->samples + conv_buf->pos, src, proc); + hw->conv(conv_buf->buffer + conv_buf->pos, src, proc); conv_buf->pos =3D (conv_buf->pos + proc) % conv_buf->size; samples -=3D proc; conv +=3D proc; @@ -561,12 +561,12 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *= buf, size_t size) if (!live) { return 0; } - if (audio_bug(__func__, live > hw->conv_buf->size)) { - dolog("live_in=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_b= uf->size); + if (audio_bug(__func__, live > hw->conv_buf.size)) { + dolog("live_in=3D%zu hw->conv_buf.size=3D%zu\n", live, hw->conv_bu= f.size); return 0; } =20 - rpos =3D audio_ring_posb(hw->conv_buf->pos, live, hw->conv_buf->size); + rpos =3D audio_ring_posb(hw->conv_buf.pos, live, hw->conv_buf.size); =20 samples =3D size / sw->info.bytes_per_frame; =20 @@ -574,11 +574,11 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *= buf, size_t size) swlim =3D MIN (swlim, samples); =20 while (swlim) { - src =3D hw->conv_buf->samples + rpos; - if (hw->conv_buf->pos > rpos) { - isamp =3D hw->conv_buf->pos - rpos; + src =3D hw->conv_buf.buffer + rpos; + if (hw->conv_buf.pos > rpos) { + isamp =3D hw->conv_buf.pos - rpos; } else { - isamp =3D hw->conv_buf->size - rpos; + isamp =3D hw->conv_buf.size - rpos; } =20 if (!isamp) { @@ -588,7 +588,7 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *bu= f, size_t size) =20 st_rate_flow (sw->rate, src, dst, &isamp, &osamp); swlim -=3D osamp; - rpos =3D (rpos + isamp) % hw->conv_buf->size; + rpos =3D (rpos + isamp) % hw->conv_buf.size; dst +=3D osamp; ret +=3D osamp; total +=3D isamp; @@ -636,8 +636,8 @@ static size_t audio_pcm_hw_get_live_out (HWVoiceOut *hw= , int *nb_live) if (nb_live1) { size_t live =3D smin; =20 - if (audio_bug(__func__, live > hw->mix_buf->size)) { - dolog("live=3D%zu hw->mix_buf->size=3D%zu\n", live, hw->mix_bu= f->size); + if (audio_bug(__func__, live > hw->mix_buf.size)) { + dolog("live=3D%zu hw->mix_buf.size=3D%zu\n", live, hw->mix_buf= .size); return 0; } return live; @@ -654,17 +654,17 @@ static size_t audio_pcm_hw_get_free(HWVoiceOut *hw) static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, size_t le= n) { size_t clipped =3D 0; - size_t pos =3D hw->mix_buf->pos; + size_t pos =3D hw->mix_buf.pos; =20 while (len) { - st_sample *src =3D hw->mix_buf->samples + pos; + st_sample *src =3D hw->mix_buf.buffer + pos; uint8_t *dst =3D advance(pcm_buf, clipped * hw->info.bytes_per_fra= me); - size_t samples_till_end_of_buf =3D hw->mix_buf->size - pos; + size_t samples_till_end_of_buf =3D hw->mix_buf.size - pos; size_t samples_to_clip =3D MIN(len, samples_till_end_of_buf); =20 hw->clip(dst, src, samples_to_clip); =20 - pos =3D (pos + samples_to_clip) % hw->mix_buf->size; + pos =3D (pos + samples_to_clip) % hw->mix_buf.size; len -=3D samples_to_clip; clipped +=3D samples_to_clip; } @@ -683,11 +683,11 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void= *buf, size_t size) return size; } =20 - hwsamples =3D sw->hw->mix_buf->size; + hwsamples =3D sw->hw->mix_buf.size; =20 live =3D sw->total_hw_samples_mixed; if (audio_bug(__func__, live > hwsamples)) { - dolog("live=3D%zu hw->mix_buf->size=3D%zu\n", live, hwsamples); + dolog("live=3D%zu hw->mix_buf.size=3D%zu\n", live, hwsamples); return 0; } =20 @@ -698,7 +698,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t size) return 0; } =20 - wpos =3D (sw->hw->mix_buf->pos + live) % hwsamples; + wpos =3D (sw->hw->mix_buf.pos + live) % hwsamples; =20 dead =3D hwsamples - live; hw_free =3D audio_pcm_hw_get_free(sw->hw); @@ -725,7 +725,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t size) st_rate_flow_mix ( sw->rate, sw->buf + pos, - sw->hw->mix_buf->samples + wpos, + sw->hw->mix_buf.buffer + wpos, &isamp, &osamp ); @@ -989,9 +989,9 @@ static size_t audio_get_avail (SWVoiceIn *sw) } =20 live =3D sw->hw->total_samples_captured - sw->total_hw_samples_acquire= d; - if (audio_bug(__func__, live > sw->hw->conv_buf->size)) { - dolog("live=3D%zu sw->hw->conv_buf->size=3D%zu\n", live, - sw->hw->conv_buf->size); + if (audio_bug(__func__, live > sw->hw->conv_buf.size)) { + dolog("live=3D%zu sw->hw->conv_buf.size=3D%zu\n", live, + sw->hw->conv_buf.size); return 0; } =20 @@ -1026,13 +1026,13 @@ static size_t audio_get_free(SWVoiceOut *sw) =20 live =3D sw->total_hw_samples_mixed; =20 - if (audio_bug(__func__, live > sw->hw->mix_buf->size)) { - dolog("live=3D%zu sw->hw->mix_buf->size=3D%zu\n", live, - sw->hw->mix_buf->size); + if (audio_bug(__func__, live > sw->hw->mix_buf.size)) { + dolog("live=3D%zu sw->hw->mix_buf.size=3D%zu\n", live, + sw->hw->mix_buf.size); return 0; } =20 - dead =3D sw->hw->mix_buf->size - live; + dead =3D sw->hw->mix_buf.size - live; =20 #ifdef DEBUG_OUT dolog("%s: get_free live %zu dead %zu frontend frames %zu\n", @@ -1056,12 +1056,12 @@ static void audio_capture_mix_and_clear(HWVoiceOut = *hw, size_t rpos, =20 n =3D samples; while (n) { - size_t till_end_of_hw =3D hw->mix_buf->size - rpos2; + size_t till_end_of_hw =3D hw->mix_buf.size - rpos2; size_t to_write =3D MIN(till_end_of_hw, n); size_t bytes =3D to_write * hw->info.bytes_per_frame; size_t written; =20 - sw->buf =3D hw->mix_buf->samples + rpos2; + sw->buf =3D hw->mix_buf.buffer + rpos2; written =3D audio_pcm_sw_write (sw, NULL, bytes); if (written - bytes) { dolog("Could not mix %zu bytes into a capture " @@ -1070,14 +1070,14 @@ static void audio_capture_mix_and_clear(HWVoiceOut = *hw, size_t rpos, break; } n -=3D to_write; - rpos2 =3D (rpos2 + to_write) % hw->mix_buf->size; + rpos2 =3D (rpos2 + to_write) % hw->mix_buf.size; } } } =20 - n =3D MIN(samples, hw->mix_buf->size - rpos); - mixeng_clear(hw->mix_buf->samples + rpos, n); - mixeng_clear(hw->mix_buf->samples, samples - n); + n =3D MIN(samples, hw->mix_buf.size - rpos); + mixeng_clear(hw->mix_buf.buffer + rpos, n); + mixeng_clear(hw->mix_buf.buffer, samples - n); } =20 static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, size_t live) @@ -1103,7 +1103,7 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, si= ze_t live) =20 live -=3D proc; clipped +=3D proc; - hw->mix_buf->pos =3D (hw->mix_buf->pos + proc) % hw->mix_buf->size; + hw->mix_buf.pos =3D (hw->mix_buf.pos + proc) % hw->mix_buf.size; =20 if (proc =3D=3D 0 || proc < decr) { break; @@ -1174,8 +1174,8 @@ static void audio_run_out (AudioState *s) live =3D 0; } =20 - if (audio_bug(__func__, live > hw->mix_buf->size)) { - dolog("live=3D%zu hw->mix_buf->size=3D%zu\n", live, hw->mix_bu= f->size); + if (audio_bug(__func__, live > hw->mix_buf.size)) { + dolog("live=3D%zu hw->mix_buf.size=3D%zu\n", live, hw->mix_buf= .size); continue; } =20 @@ -1203,13 +1203,13 @@ static void audio_run_out (AudioState *s) continue; } =20 - prev_rpos =3D hw->mix_buf->pos; + prev_rpos =3D hw->mix_buf.pos; played =3D audio_pcm_hw_run_out(hw, live); replay_audio_out(&played); - if (audio_bug(__func__, hw->mix_buf->pos >=3D hw->mix_buf->size)) { - dolog("hw->mix_buf->pos=3D%zu hw->mix_buf->size=3D%zu played= =3D%zu\n", - hw->mix_buf->pos, hw->mix_buf->size, played); - hw->mix_buf->pos =3D 0; + if (audio_bug(__func__, hw->mix_buf.pos >=3D hw->mix_buf.size)) { + dolog("hw->mix_buf.pos=3D%zu hw->mix_buf.size=3D%zu played=3D%= zu\n", + hw->mix_buf.pos, hw->mix_buf.size, played); + hw->mix_buf.pos =3D 0; } =20 #ifdef DEBUG_OUT @@ -1290,10 +1290,10 @@ static void audio_run_in (AudioState *s) =20 if (replay_mode !=3D REPLAY_MODE_PLAY) { captured =3D audio_pcm_hw_run_in( - hw, hw->conv_buf->size - audio_pcm_hw_get_live_in(hw)); + hw, hw->conv_buf.size - audio_pcm_hw_get_live_in(hw)); } - replay_audio_in(&captured, hw->conv_buf->samples, &hw->conv_buf->p= os, - hw->conv_buf->size); + replay_audio_in(&captured, hw->conv_buf.buffer, &hw->conv_buf.pos, + hw->conv_buf.size); =20 min =3D audio_pcm_hw_find_min_in (hw); hw->total_samples_captured +=3D captured - min; @@ -1326,14 +1326,14 @@ static void audio_run_capture (AudioState *s) SWVoiceOut *sw; =20 captured =3D live =3D audio_pcm_hw_get_live_out (hw, NULL); - rpos =3D hw->mix_buf->pos; + rpos =3D hw->mix_buf.pos; while (live) { - size_t left =3D hw->mix_buf->size - rpos; + size_t left =3D hw->mix_buf.size - rpos; size_t to_capture =3D MIN(live, left); struct st_sample *src; struct capture_callback *cb; =20 - src =3D hw->mix_buf->samples + rpos; + src =3D hw->mix_buf.buffer + rpos; hw->clip (cap->buf, src, to_capture); mixeng_clear (src, to_capture); =20 @@ -1341,10 +1341,10 @@ static void audio_run_capture (AudioState *s) cb->ops.capture (cb->opaque, cap->buf, to_capture * hw->info.bytes_per_frame); } - rpos =3D (rpos + to_capture) % hw->mix_buf->size; + rpos =3D (rpos + to_capture) % hw->mix_buf.size; live -=3D to_capture; } - hw->mix_buf->pos =3D rpos; + hw->mix_buf.pos =3D rpos; =20 for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { if (!sw->active && sw->empty) { @@ -1903,7 +1903,7 @@ CaptureVoiceOut *AUD_add_capture( =20 audio_pcm_init_info (&hw->info, as); =20 - cap->buf =3D g_malloc0_n(hw->mix_buf->size, hw->info.bytes_per_fra= me); + cap->buf =3D g_malloc0_n(hw->mix_buf.size, hw->info.bytes_per_fram= e); =20 if (hw->info.is_float) { hw->clip =3D mixeng_clip_float[hw->info.nchannels =3D=3D 2]; @@ -1955,7 +1955,7 @@ void AUD_del_capture (CaptureVoiceOut *cap, void *cb_= opaque) sw =3D sw1; } QLIST_REMOVE (cap, entries); - g_free (cap->hw.mix_buf); + g_free(cap->hw.mix_buf.buffer); g_free (cap->buf); g_free (cap); } --=20 2.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085627; cv=none; d=zohomail.com; s=zohoarc; b=ng5bbINDk2nVXMrut9f5sP85PCCbTWwk2BZGg5FwVStF1K85XMYwX68lZnvlwz7XE3DiW4rK7Hnnp4LXWyXIB1QF8ECs6LcCVnWvvznF87c9SI3noPAtv8O6PJigH29zDIkr82oH2ng5fAss6dHhGkb1fhR5FiGn1AS5bsJXFFw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085627; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=D2FQpTcG1yhg6uUjwvVLwrL4wtemMxEs9MOgcxFL1hE=; b=KxrIYeDn6IoKc+/0ehcj8dle7PJG2fMdXluMCiyplBVfuW3g/U6n9tvX1kC39WttyrQANfNNK8C98+jmqobLo2WDIBm/pS6uYgzdw0xN8fdnHcTh6VC52RsU1TFbv4iMkrXN6ZodZNSjhQFy0kzvDKU5inITKesvVbqsRPxTOi4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085627695979.5476987710535; Sun, 5 Mar 2023 22:53:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4ii-0004k9-N6; Mon, 06 Mar 2023 01:53: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 1pZ4ie-0004dl-Tv for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4id-0000cT-9O for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:12 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-16-x86T3C7QNH-5JYGz5puodA-1; Mon, 06 Mar 2023 01:53:07 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DDD3C885620; Mon, 6 Mar 2023 06:53:06 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99CAB492C14; Mon, 6 Mar 2023 06:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D2FQpTcG1yhg6uUjwvVLwrL4wtemMxEs9MOgcxFL1hE=; b=Q1Viuui0xqLJu3WO1zH0em5joLveBAx9iTeLNQ4I/Stx49hH8W8HDab6tkSCGl9ZDnyFHS mh7jY8NpFZYpLv1RAoYV3g+/V7b/6TG9MOX9Qu2Rgx4zKwtlTL1RTfKDV7ULKTYPgA8sW/ SHPsdSQ5qC8Up+qXY03dzEn396EfBl0= X-MC-Unique: x86T3C7QNH-5JYGz5puodA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 14/27] audio: change type and name of the resample buffer Date: Mon, 6 Mar 2023 10:51:49 +0400 Message-Id: <20230306065202.2160066-15-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085629339100011 From: Volker R=C3=BCmelin Change the type of the resample buffer from struct st_sample * to STSampleBuffer. Also change the name from buf to resample_buf for better readability. The new variables resample_buf.size and resample_buf.pos will be used after the next patches. There is no functional change. Acked-by: Mark Cave-Ayland Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-2-vr_qemu@t-online.de> --- audio/audio_int.h | 4 ++-- audio/audio_template.h | 10 ++++++---- audio/audio.c | 15 ++++++++------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 061845dcc2..8b163e1759 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -109,7 +109,7 @@ struct SWVoiceOut { struct audio_pcm_info info; t_sample *conv; int64_t ratio; - struct st_sample *buf; + STSampleBuffer resample_buf; void *rate; size_t total_hw_samples_mixed; int active; @@ -129,7 +129,7 @@ struct SWVoiceIn { int64_t ratio; void *rate; size_t total_hw_samples_acquired; - struct st_sample *buf; + STSampleBuffer resample_buf; f_sample *clip; HWVoiceIn *hw; char *name; diff --git a/audio/audio_template.h b/audio/audio_template.h index dd87170cbd..a0b653f52c 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -95,13 +95,13 @@ static void glue(audio_pcm_hw_alloc_resources_, TYPE)(H= W *hw) =20 static void glue (audio_pcm_sw_free_resources_, TYPE) (SW *sw) { - g_free (sw->buf); + g_free(sw->resample_buf.buffer); + sw->resample_buf.buffer =3D NULL; + sw->resample_buf.size =3D 0; =20 if (sw->rate) { st_rate_stop (sw->rate); } - - sw->buf =3D NULL; sw->rate =3D NULL; } =20 @@ -138,7 +138,9 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) (= SW *sw) return -1; } =20 - sw->buf =3D g_new0(st_sample, samples); + sw->resample_buf.buffer =3D g_new0(st_sample, samples); + sw->resample_buf.size =3D samples; + sw->resample_buf.pos =3D 0; =20 #ifdef DAC sw->rate =3D st_rate_start (sw->info.freq, sw->hw->info.freq); diff --git a/audio/audio.c b/audio/audio.c index a0b54e4a2e..a399147486 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -555,7 +555,7 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *bu= f, size_t size) { HWVoiceIn *hw =3D sw->hw; size_t samples, live, ret =3D 0, swlim, isamp, osamp, rpos, total =3D = 0; - struct st_sample *src, *dst =3D sw->buf; + struct st_sample *src, *dst =3D sw->resample_buf.buffer; =20 live =3D hw->total_samples_captured - sw->total_hw_samples_acquired; if (!live) { @@ -595,10 +595,10 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *= buf, size_t size) } =20 if (!hw->pcm_ops->volume_in) { - mixeng_volume (sw->buf, ret, &sw->vol); + mixeng_volume(sw->resample_buf.buffer, ret, &sw->vol); } =20 - sw->clip (buf, sw->buf, ret); + sw->clip(buf, sw->resample_buf.buffer, ret); sw->total_hw_samples_acquired +=3D total; return ret * sw->info.bytes_per_frame; } @@ -706,10 +706,10 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void= *buf, size_t size) samples =3D ((int64_t)MIN(dead, hw_free) << 32) / sw->ratio; samples =3D MIN(samples, size / sw->info.bytes_per_frame); if (samples) { - sw->conv(sw->buf, buf, samples); + sw->conv(sw->resample_buf.buffer, buf, samples); =20 if (!sw->hw->pcm_ops->volume_out) { - mixeng_volume(sw->buf, samples, &sw->vol); + mixeng_volume(sw->resample_buf.buffer, samples, &sw->vol); } } =20 @@ -724,7 +724,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t size) osamp =3D blck; st_rate_flow_mix ( sw->rate, - sw->buf + pos, + sw->resample_buf.buffer + pos, sw->hw->mix_buf.buffer + wpos, &isamp, &osamp @@ -1061,7 +1061,8 @@ static void audio_capture_mix_and_clear(HWVoiceOut *h= w, size_t rpos, size_t bytes =3D to_write * hw->info.bytes_per_frame; size_t written; =20 - sw->buf =3D hw->mix_buf.buffer + rpos2; + sw->resample_buf.buffer =3D hw->mix_buf.buffer + rpos2; + sw->resample_buf.size =3D to_write; written =3D audio_pcm_sw_write (sw, NULL, bytes); if (written - bytes) { dolog("Could not mix %zu bytes into a capture " --=20 2.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085611; cv=none; d=zohomail.com; s=zohoarc; b=SQ9kQZzLa7XG/m1bIgAGtodx1xhxvEmBvkSsSGBlmN0i4B2rRQ+/WqzEjfmwC9xbFrf8acxMDy1FSq4NFzylfyxhTbMFQbE5LZ54dppeCTiJL9wtcsyzjWbvqbFP6/jgUwA+Hwnmp3sTExWd1rFvYAcTjo8jXyMIw1Gq6W6bWgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085611; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sQ9+mo9N6X1dx7pB9GOrfGo4mTgvCi6rRd/ddPf4sk8=; b=K9Agjt4XMW8dcY+nr10jlXWuqrcKEzVe+H9o3WMibHkCXNeuJqmaHEjPz0lyg+uaISTRMh05hd04Bby1N/u2XozKAGmVvrLPNWeju9sFxiS4nRjoupZtu1O1rx0B8qCeq4g1zm/4SbuRQqObvRXd7zVKQa4lfL1ND2tmR/1XeaI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085611676350.29622212149354; Sun, 5 Mar 2023 22:53:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4im-0005FQ-P6; Mon, 06 Mar 2023 01:53:20 -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 1pZ4il-00057C-25 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4ij-0000cs-Iz for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:18 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-486-l5lh--aBPlKbJgv0fEymUw-1; Mon, 06 Mar 2023 01:53:12 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4A9A4803513; Mon, 6 Mar 2023 06:53:12 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7416F40C10FA; Mon, 6 Mar 2023 06:53:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085597; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sQ9+mo9N6X1dx7pB9GOrfGo4mTgvCi6rRd/ddPf4sk8=; b=f0vwBkZP96swREZ6KaUzQHXkMcUn7muu1VpAT326LAI2ldedBjr84rczxIFpzoQhI404Oq T0OylF9flm7ffXWIMRPl74VPKMuje/rypCI0epY+hv+gzOWuWAaoirPo1cMaleZ7x42kOy XT0qIihgppGHzViPC0h5f+IoH8+zMNs= X-MC-Unique: l5lh--aBPlKbJgv0fEymUw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 15/27] audio: make the resampling code greedy Date: Mon, 6 Mar 2023 10:51:50 +0400 Message-Id: <20230306065202.2160066-16-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085613103100003 From: Volker R=C3=BCmelin Read the maximum possible number of audio frames instead of the minimum necessary number of frames when the audio stream is downsampled and the output buffer is limited. This makes the function symmetrical to upsampling when the input buffer is limited. The maximum possible number of frames is written here. With this change it's easier to calculate the exact number of audio frames the resample function will read or write. These two functions will be introduced later. Acked-by: Mark Cave-Ayland Acked-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-3-vr_qemu@t-online.de> --- audio/rate_template.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/audio/rate_template.h b/audio/rate_template.h index b432719ebb..6648f0d2e5 100644 --- a/audio/rate_template.h +++ b/audio/rate_template.h @@ -40,8 +40,6 @@ void NAME (void *opaque, struct st_sample *ibuf, struct s= t_sample *obuf, int64_t t; #endif =20 - ilast =3D rate->ilast; - istart =3D ibuf; iend =3D ibuf + *isamp; =20 @@ -59,15 +57,17 @@ void NAME (void *opaque, struct st_sample *ibuf, struct= st_sample *obuf, return; } =20 - while (obuf < oend) { + /* without input samples, there's nothing to do */ + if (ibuf >=3D iend) { + *osamp =3D 0; + return; + } =20 - /* Safety catch to make sure we have input samples. */ - if (ibuf >=3D iend) { - break; - } + ilast =3D rate->ilast; =20 - /* read as many input samples so that ipos > opos */ + while (true) { =20 + /* read as many input samples so that ipos > opos */ while (rate->ipos <=3D (rate->opos >> 32)) { ilast =3D *ibuf++; rate->ipos++; @@ -78,6 +78,11 @@ void NAME (void *opaque, struct st_sample *ibuf, struct = st_sample *obuf, } } =20 + /* make sure that the next output sample can be written */ + if (obuf >=3D oend) { + break; + } + icur =3D *ibuf; =20 /* wrap ipos and opos around long before they overflow */ --=20 2.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085781; cv=none; d=zohomail.com; s=zohoarc; b=jpUJFZcxvUrOxF6tEN8kr+usuGPL8RqlivfWGR6UI9wQVDK5L9T7QAP9ThhibkZ+7Y3d7G0C9q8LLMDUezXhIvstRLpr1dus6ab6bN9byL/nMni933D/dnsrNRt1vd7Ha6sZ27q9lj6Fwlx4gmgTt95JFtUd/wR4YfOQIpnUlyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085781; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=x6zt1uSG9X48dgL0Tay8tYwYpJZ8bknuKc0j3o61R/s=; b=oECtWnzzheun91glQFmNE2BSl4qS8YVYI6Z5A3q+J74DLVGlkTpbEl7dBukyrvtzgLVm6pCMel+UQIfT5hDHubcZlcxafqNwoVA8QGbep/GoR0euOisQ5pCsgrA7NKNvMtEQlIzLcGReaz/si0EHnrarPDQ0Lfq1/qsI++6yLK4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085781906131.22203977735285; Sun, 5 Mar 2023 22:56:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4in-0005LU-Ms; Mon, 06 Mar 2023 01:53:21 -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 1pZ4il-00059i-W1 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4ik-0000cw-GF for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:19 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-70-Cgm9DpW7OG2pQARExHyTjw-1; Mon, 06 Mar 2023 01:53:16 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4CEE6101A521; Mon, 6 Mar 2023 06:53:16 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BA5A40CF8F0; Mon, 6 Mar 2023 06:53:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085597; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x6zt1uSG9X48dgL0Tay8tYwYpJZ8bknuKc0j3o61R/s=; b=dzFSGKChAJwod8s0pdlxXqwQdYaYRSx6SiZQxMDhzirJ8IGdXCW7Zfv48EFtzwqKjP8lcg 2hxJJP5C9R0qx9n35cv15fbUwxYGnOAC3jc/B61XqQruke+S0uOaxkzz+j3fcTHdupzypl U+egsnmSVooiV2dMY0SCAydDMtdnKxY= X-MC-Unique: Cgm9DpW7OG2pQARExHyTjw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 16/27] audio: replace the resampling loop in audio_pcm_sw_write() Date: Mon, 6 Mar 2023 10:51:51 +0400 Message-Id: <20230306065202.2160066-17-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085782969100003 From: Volker R=C3=BCmelin Replace the resampling loop in audio_pcm_sw_write() with the new function audio_pcm_sw_resample_out(). Unlike the old resample loop the new function will try to consume input frames even if the output buffer is full. This is necessary when downsampling to avoid reading less audio frames than calculated in advance. The loop was unrolled to avoid complicated loop control conditions in this case. Acked-by: Mark Cave-Ayland Acked-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-4-vr_qemu@t-online.de> --- audio/audio.c | 63 +++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index a399147486..4412b5fad8 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -673,11 +673,44 @@ static void audio_pcm_hw_clip_out(HWVoiceOut *hw, voi= d *pcm_buf, size_t len) /* * Soft voice (playback) */ +static void audio_pcm_sw_resample_out(SWVoiceOut *sw, + size_t frames_in_max, size_t frames_out_max, + size_t *total_in, size_t *total_out) +{ + HWVoiceOut *hw =3D sw->hw; + struct st_sample *src, *dst; + size_t live, wpos, frames_in, frames_out; + + live =3D sw->total_hw_samples_mixed; + wpos =3D (hw->mix_buf.pos + live) % hw->mix_buf.size; + + /* write to mix_buf from wpos to end of buffer */ + src =3D sw->resample_buf.buffer; + frames_in =3D frames_in_max; + dst =3D hw->mix_buf.buffer + wpos; + frames_out =3D MIN(frames_out_max, hw->mix_buf.size - wpos); + st_rate_flow_mix(sw->rate, src, dst, &frames_in, &frames_out); + wpos +=3D frames_out; + *total_in =3D frames_in; + *total_out =3D frames_out; + + /* write to mix_buf from start of buffer if there are input frames lef= t */ + if (frames_in_max - frames_in > 0 && wpos =3D=3D hw->mix_buf.size) { + src +=3D frames_in; + frames_in =3D frames_in_max - frames_in; + dst =3D hw->mix_buf.buffer; + frames_out =3D frames_out_max - frames_out; + st_rate_flow_mix(sw->rate, src, dst, &frames_in, &frames_out); + *total_in +=3D frames_in; + *total_out +=3D frames_out; + } +} + static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t size) { - size_t hwsamples, samples, isamp, osamp, wpos, live, dead, left, blck; + size_t hwsamples, samples, live, dead; size_t hw_free; - size_t ret =3D 0, pos =3D 0, total =3D 0; + size_t ret, total; =20 if (!sw) { return size; @@ -698,8 +731,6 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t size) return 0; } =20 - wpos =3D (sw->hw->mix_buf.pos + live) % hwsamples; - dead =3D hwsamples - live; hw_free =3D audio_pcm_hw_get_free(sw->hw); hw_free =3D hw_free > live ? hw_free - live : 0; @@ -713,29 +744,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void = *buf, size_t size) } } =20 - while (samples) { - dead =3D hwsamples - live; - left =3D hwsamples - wpos; - blck =3D MIN (dead, left); - if (!blck) { - break; - } - isamp =3D samples; - osamp =3D blck; - st_rate_flow_mix ( - sw->rate, - sw->resample_buf.buffer + pos, - sw->hw->mix_buf.buffer + wpos, - &isamp, - &osamp - ); - ret +=3D isamp; - samples -=3D isamp; - pos +=3D isamp; - live +=3D osamp; - wpos =3D (wpos + osamp) % hwsamples; - total +=3D osamp; - } + audio_pcm_sw_resample_out(sw, samples, MIN(dead, hw_free), &ret, &tota= l); =20 sw->total_hw_samples_mixed +=3D total; sw->empty =3D sw->total_hw_samples_mixed =3D=3D 0; --=20 2.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085781; cv=none; d=zohomail.com; s=zohoarc; b=GQesRqaZT2A5xytqoG3IPI/cGn2xlE2gEb25H1GNIfJkuuSA5l7LxAOOnZzTK6mOoKcRX45yKYNTvsRAbEzwMIPV1VW+TVyXSgIcocBmNmnaEa3lQyx0gWewoiFOCXa0yQY8ug6QQ0E1XLh0W+bdPmojztnoVVqwKXbhlSxt2w0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085781; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LRgh7gqTlapuM/T75jMyqX+au6Vnzvk9fonlNVaCLwI=; b=k6frZ2gTYs2WGBZ2wbMjNy5pVIQXj/QFFzLSEnEhOH8l+A4JuKrgxFgNWCyoY1eO9FNFiRE6Px7VQ0b43wd7KUBs+ZX0eyo3X7mE0wtqlTkVCVOW7LhXzlCgHhGmiN8PAJ/1TPdCjFJq0LfxVUQykulo8kONnaUn+r9cI1ZxWbs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085781415442.2235348353514; Sun, 5 Mar 2023 22:56:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4ix-0006UN-GB; Mon, 06 Mar 2023 01:53:32 -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 1pZ4iu-0006Lr-3C for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4is-0000dJ-9E for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:27 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-497-7mAj4NbZNc2ccFEWfPbj8g-1; Mon, 06 Mar 2023 01:53:22 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CAE583C10C60; Mon, 6 Mar 2023 06:53:21 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 902AE40C945A; Mon, 6 Mar 2023 06:53:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085605; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LRgh7gqTlapuM/T75jMyqX+au6Vnzvk9fonlNVaCLwI=; b=Ri9nKxtnWlHzL0t1DAD/FC6vJLsQBNZE3SH3bQMrAsKkYuTjmDTh+WFG+xgTrFwTNehssi obFWzL8EH4yPcUAbqi2f8OeSxL0XqhSC81gjJD4wdJCkiM7tX2nobnXdqfhyH2T85MzosE iTOvxzVz6r381DP8OqMlkEuyykdT7vQ= X-MC-Unique: 7mAj4NbZNc2ccFEWfPbj8g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 17/27] audio: remove sw == NULL check Date: Mon, 6 Mar 2023 10:51:52 +0400 Message-Id: <20230306065202.2160066-18-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085782912100001 From: Volker R=C3=BCmelin All call sites of audio_pcm_sw_write() guarantee that sw is not NULL. Remove the unnecessary NULL check. Acked-by: Mark Cave-Ayland Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-5-vr_qemu@t-online.de> --- audio/audio.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 4412b5fad8..8f1c0e77b0 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -712,10 +712,6 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void = *buf, size_t size) size_t hw_free; size_t ret, total; =20 - if (!sw) { - return size; - } - hwsamples =3D sw->hw->mix_buf.size; =20 live =3D sw->total_hw_samples_mixed; --=20 2.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085674; cv=none; d=zohomail.com; s=zohoarc; b=kNQtzIUl5n+4yLY3wG21ELJG6qfabWBuXdfd+IWbzeLnHKcc0pkJV/9kMmvsQEpG9r8aV/Cxnr5ZbvGfhE1PIvBvoT5Da0crtZyaxcUus9IC+ed8ausCv6sOPA3WeadPgWMKWo9Bt0BexnRU4G7asw3/6VHT/uhp/VBo03lSChg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085674; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PwPNwQ6pIL7uo3U78G1rhRJbhPeTDa4bhCJn1pXt4bA=; b=Lkbhvu7p0elnCVftTZMbmPowubzxr+GsJijQWR+N437PECA5DrKVjGgq8zhdyZ6TxYhHD/RchW0ifXiB71vKA4MKO6TJR7qaJWFN95ExUyA0QJ3cge+2NWYDhvFFvQJCG6kfCVnXC/UJNm1AQ9Uyby0dz7++RD5gASZm6R+SBXk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085674549775.6682930546359; Sun, 5 Mar 2023 22:54:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4j0-0006m7-Jt; Mon, 06 Mar 2023 01:53:34 -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 1pZ4iz-0006Yz-0e for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4iw-0000dh-MF for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:32 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-418-pRhmG3t8MTGFXbKl7lwKVQ-1; Mon, 06 Mar 2023 01:53:26 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 649E585A588; Mon, 6 Mar 2023 06:53:26 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id A33A2C16029; Mon, 6 Mar 2023 06:53:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085610; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PwPNwQ6pIL7uo3U78G1rhRJbhPeTDa4bhCJn1pXt4bA=; b=I+deaeitnznXvHkT6lRDnjCbnWkipCpa3N/b56urOsF9Vi7Q54YHmnKGXEeHjl5UBh5YGd 1qAo/NgqQo/9/Ra2DSaSEShQ8NrMZI/jGvAQ5DdHmhRderIj4QexoGEAMAbn2eXU0nXLyP eSJMhpS9vnKGVNumUjGWtEVhyupl3+Y= X-MC-Unique: pRhmG3t8MTGFXbKl7lwKVQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 18/27] audio: rename variables in audio_pcm_sw_write() Date: Mon, 6 Mar 2023 10:51:53 +0400 Message-Id: <20230306065202.2160066-19-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085675606100009 From: Volker R=C3=BCmelin The audio_pcm_sw_write() function uses a lot of very unspecific variable names. Rename them for better readability. ret =3D> total_in total =3D> total_out size =3D> buf_len hwsamples =3D> hw->mix_buf.size samples =3D> frames_in_max Acked-by: Mark Cave-Ayland Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-6-vr_qemu@t-online.de> --- audio/audio.c | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 8f1c0e77b0..cd10f1ec10 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -706,56 +706,55 @@ static void audio_pcm_sw_resample_out(SWVoiceOut *sw, } } =20 -static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t size) +static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t buf_len) { - size_t hwsamples, samples, live, dead; - size_t hw_free; - size_t ret, total; - - hwsamples =3D sw->hw->mix_buf.size; + HWVoiceOut *hw =3D sw->hw; + size_t live, dead, hw_free; + size_t frames_in_max, total_in, total_out; =20 live =3D sw->total_hw_samples_mixed; - if (audio_bug(__func__, live > hwsamples)) { - dolog("live=3D%zu hw->mix_buf.size=3D%zu\n", live, hwsamples); + if (audio_bug(__func__, live > hw->mix_buf.size)) { + dolog("live=3D%zu hw->mix_buf.size=3D%zu\n", live, hw->mix_buf.siz= e); return 0; } =20 - if (live =3D=3D hwsamples) { + if (live =3D=3D hw->mix_buf.size) { #ifdef DEBUG_OUT dolog ("%s is full %zu\n", sw->name, live); #endif return 0; } =20 - dead =3D hwsamples - live; - hw_free =3D audio_pcm_hw_get_free(sw->hw); + dead =3D hw->mix_buf.size - live; + hw_free =3D audio_pcm_hw_get_free(hw); hw_free =3D hw_free > live ? hw_free - live : 0; - samples =3D ((int64_t)MIN(dead, hw_free) << 32) / sw->ratio; - samples =3D MIN(samples, size / sw->info.bytes_per_frame); - if (samples) { - sw->conv(sw->resample_buf.buffer, buf, samples); + frames_in_max =3D ((int64_t)MIN(dead, hw_free) << 32) / sw->ratio; + frames_in_max =3D MIN(frames_in_max, buf_len / sw->info.bytes_per_fram= e); + if (frames_in_max) { + sw->conv(sw->resample_buf.buffer, buf, frames_in_max); =20 if (!sw->hw->pcm_ops->volume_out) { - mixeng_volume(sw->resample_buf.buffer, samples, &sw->vol); + mixeng_volume(sw->resample_buf.buffer, frames_in_max, &sw->vol= ); } } =20 - audio_pcm_sw_resample_out(sw, samples, MIN(dead, hw_free), &ret, &tota= l); + audio_pcm_sw_resample_out(sw, frames_in_max, MIN(dead, hw_free), + &total_in, &total_out); =20 - sw->total_hw_samples_mixed +=3D total; + sw->total_hw_samples_mixed +=3D total_out; sw->empty =3D sw->total_hw_samples_mixed =3D=3D 0; =20 #ifdef DEBUG_OUT dolog ( - "%s: write size %zu ret %zu total sw %zu\n", - SW_NAME (sw), - size / sw->info.bytes_per_frame, - ret, + "%s: write size %zu written %zu total mixed %zu\n", + SW_NAME(sw), + buf_len / sw->info.bytes_per_frame, + total_in, sw->total_hw_samples_mixed ); #endif =20 - return ret * sw->info.bytes_per_frame; + return total_in * sw->info.bytes_per_frame; } =20 #ifdef DEBUG_AUDIO --=20 2.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085748; cv=none; d=zohomail.com; s=zohoarc; b=MuqOLNM9brZkdpHSSWr6/yKU1YnnxHgWkbXuv6ukrpnLVIknzc/6Hcauob9fT/RneQOkWyKG8chMm7LNGUJvxSv676JczvH3KZ3jz9XNMoyIbqqyIJl3dqRQ9sCLOlttpE1cIB+Tvs5fdWVLe2yd+VqEdEkfYpOfon2ou21AHyY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085748; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rYCMrgTy8xVD/anHHjp9hzJPi1IH/Ms6Zyu0fMQd86g=; b=FbAFjjMFryQ5sEzizeNINN7bQnBHLkfJa/Rw/fC17eAK0k17gEfRDnKPk7DuX8TD62jMoAEcVFyk9cCikEDSdYjd7q2LioHxXwYVE9tzw4sQnqGBKNawF9nSFkEha/q4hR92sqbykCeZOOYXwj9c1TX3d5ymq0SujG9ajs6Cly4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085748299671.4753741846341; Sun, 5 Mar 2023 22:55:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4jA-00079b-BW; Mon, 06 Mar 2023 01:53:45 -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 1pZ4j2-00074D-OS for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4j0-0000e6-Sd for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:36 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-546-UZ6Jv4zEMoCpS1kVA00l6Q-1; Mon, 06 Mar 2023 01:53:30 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8122C885623; Mon, 6 Mar 2023 06:53:30 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF9D2C16029; Mon, 6 Mar 2023 06:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085614; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rYCMrgTy8xVD/anHHjp9hzJPi1IH/Ms6Zyu0fMQd86g=; b=fdX0Ply+00sULtEvg8ajzrympFOV2/sZUw3Vyd0cuqcuRHX4KjJ8ovK68wd+oCRLh8mpsT HCVufxP4vTuyJ1Pzyu/VJxQXwov+6s7C9zGfj2ssSkO55MRqABdYp5miKQI0FMDh41p9uO lWsGsfviaWDtPc3oFeV1Jz+vEWiWbmU= X-MC-Unique: UZ6Jv4zEMoCpS1kVA00l6Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 19/27] audio: don't misuse audio_pcm_sw_write() Date: Mon, 6 Mar 2023 10:51:54 +0400 Message-Id: <20230306065202.2160066-20-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085750205100003 From: Volker R=C3=BCmelin The audio_pcm_sw_write() function is intended to convert a PCM audio stream to the internal representation, adjust the volume, and then mix it with the other audio streams with a possibly changed sample rate in mix_buf. In order for the audio_capture_mix_and_clear() function to use audio_pcm_sw_write(), it must bypass the first two tasks of audio_pcm_sw_write(). Since patch "audio: split out the resampling loop in audio_pcm_sw_write()" this is no longer necessary, because now the audio_pcm_sw_resample_out() function can be used instead of audio_pcm_sw_write(). Acked-by: Mark Cave-Ayland Acked-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-7-vr_qemu@t-online.de> --- audio/audio.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index cd10f1ec10..44eb7b63b4 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1056,26 +1056,33 @@ static void audio_capture_mix_and_clear(HWVoiceOut = *hw, size_t rpos, =20 for (sc =3D hw->cap_head.lh_first; sc; sc =3D sc->entries.le_next)= { SWVoiceOut *sw =3D &sc->sw; - int rpos2 =3D rpos; + size_t rpos2 =3D rpos; =20 n =3D samples; while (n) { size_t till_end_of_hw =3D hw->mix_buf.size - rpos2; - size_t to_write =3D MIN(till_end_of_hw, n); - size_t bytes =3D to_write * hw->info.bytes_per_frame; - size_t written; + size_t to_read =3D MIN(till_end_of_hw, n); + size_t live, frames_in, frames_out; =20 sw->resample_buf.buffer =3D hw->mix_buf.buffer + rpos2; - sw->resample_buf.size =3D to_write; - written =3D audio_pcm_sw_write (sw, NULL, bytes); - if (written - bytes) { - dolog("Could not mix %zu bytes into a capture " + sw->resample_buf.size =3D to_read; + live =3D sw->total_hw_samples_mixed; + + audio_pcm_sw_resample_out(sw, + to_read, sw->hw->mix_buf.size - = live, + &frames_in, &frames_out); + + sw->total_hw_samples_mixed +=3D frames_out; + sw->empty =3D sw->total_hw_samples_mixed =3D=3D 0; + + if (to_read - frames_in) { + dolog("Could not mix %zu frames into a capture " "buffer, mixed %zu\n", - bytes, written); + to_read, frames_in); break; } - n -=3D to_write; - rpos2 =3D (rpos2 + to_write) % hw->mix_buf.size; + n -=3D to_read; + rpos2 =3D (rpos2 + to_read) % hw->mix_buf.size; } } } --=20 2.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085655; cv=none; d=zohomail.com; s=zohoarc; b=H7ayJZKheJbvfbwCwuOfouMJzC80hyTo0MZfvjapk+i9bbT6CM+1aEdYq1KoNZ+ON9Fxlfw9GmqWyjs2dMb0mnQ2wvB+hNVSRhdYf0HMYtdzOXZ+knAT+TpJUwD/OPWOaExck4By9ee/i3DZQnFvm73xYZgXbwuDUeG9fOyu7X4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085655; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Bh6wdhO+WouvYQ/SQj4MSPyJuPYWqKs6U5t/o0h6ePY=; b=Hu90egUJ08DVgv02N2zFshxbjy/dpTdzBxk44pxYYJ74tKYU/r/C0XiQbcE9I/9PljRuLvCGYWFV3qVx1nQDaMtESighJD0DXa5D2HjcKwcd6ijUgewGvHq6c/xxTUBl70SNzgJi5yi8IkP4/rX4vR3VVL7yEuAuPHQMgsc0PG4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085655158231.67423393509705; Sun, 5 Mar 2023 22:54:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4jG-0007Ms-4k; Mon, 06 Mar 2023 01:53:50 -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 1pZ4j5-00079c-A2 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4j2-0000eJ-OT for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:39 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-631-ex4SeQXGNgSNL0IJDUJhJA-1; Mon, 06 Mar 2023 01:53:34 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 31B7A3828884; Mon, 6 Mar 2023 06:53:34 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F2BD492C14; Mon, 6 Mar 2023 06:53:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085615; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bh6wdhO+WouvYQ/SQj4MSPyJuPYWqKs6U5t/o0h6ePY=; b=UdMNe6qGLerW93TStRmS9VxUy0uunisWd0DbQQfRiMByDTkPeiz2Opeex7lExVlvu0draN c03fdc5xeSVzHN/Ek9nV20iWZTAmtnLmkOVJFMXKE6QwSPJ3YEtsYM74WvJdvkfZr0kQ+5 cvS55aU0X2nkOH7v7fZ2Kb61leohU2o= X-MC-Unique: ex4SeQXGNgSNL0IJDUJhJA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 20/27] audio: remove unused noop_conv() function Date: Mon, 6 Mar 2023 10:51:55 +0400 Message-Id: <20230306065202.2160066-21-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085655418100005 From: Volker R=C3=BCmelin The function audio_capture_mix_and_clear() no longer uses audio_pcm_sw_write() to resample audio frames from one internal buffer to another. For this reason, the noop_conv() function is now unused. Remove it. Acked-by: Mark Cave-Ayland Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-8-vr_qemu@t-online.de> --- audio/audio.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 44eb7b63b4..556696b095 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -381,13 +381,6 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *= info, void *buf, int len) /* * Capture */ -static void noop_conv (struct st_sample *dst, const void *src, int samples) -{ - (void) src; - (void) dst; - (void) samples; -} - static CaptureVoiceOut *audio_pcm_capture_find_specific(AudioState *s, struct audsettings= *as) { @@ -485,7 +478,6 @@ static int audio_attach_capture (HWVoiceOut *hw) sw->info =3D hw->info; sw->empty =3D 1; sw->active =3D hw->enabled; - sw->conv =3D noop_conv; 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); --=20 2.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085671; cv=none; d=zohomail.com; s=zohoarc; b=kF+mZd+Sy9B6IAFxKlGu0dEnKME4+vFF6x5N3GTXdUA7YY9nOWejbEVEox/znQGA7P8bla5Im4i4M/+c2YmZ2Ff8jCQdo0EQzgzVRwF4hXK9miXOqH4eWi0dIB0dfprDmwgcc3Hi1y1zPQ8s07THWKBTw3uo3wopgy65rVUcpM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085671; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Dh8U8ZI9KBza+k43IZOFEFVeIbZ12o7LeRarBtaovhY=; b=mG2IsojI5VIK0Z4X5tqFfeBDoUdp9nHGJSDGwygS0vqhKc61n3b+/nr2Ao8GMO2YbRod39rg9Xi9SFvWJ76zeNV2rW4eYlnhAV1OfXYswtRUOjiibasbI5elYEuQamXRdWyNBcBlauxAbM/ivxmtCXGCvZiX05KNfG6LORr3CDo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085671956509.7402951337069; Sun, 5 Mar 2023 22:54:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4jG-0007W0-RM; Mon, 06 Mar 2023 01:53:50 -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 1pZ4jB-0007Js-G8 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4j9-0000fg-Mk for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:45 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-580-S_t4StiCMdqGdLNl85vrnw-1; Mon, 06 Mar 2023 01:53:39 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 02A7C1C05153; Mon, 6 Mar 2023 06:53:39 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F44E140EBF4; Mon, 6 Mar 2023 06:53:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085622; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dh8U8ZI9KBza+k43IZOFEFVeIbZ12o7LeRarBtaovhY=; b=io0ODfOzinwnuTuyJDGis5K2jo9XD0DPnbLuUvE1fNfx+JYb0k/GduRQw5HlkybrCdnUMi NNA9KFZPnoxSwPzQTHZ9jAZh1Z3vWqZeCW0mwIvGZBuLMUPuJ79QsnFHPGPiv1rcpeCGqW f3XNWXDWM6KYR5CnbJ9P34AeqlUUn9c= X-MC-Unique: S_t4StiCMdqGdLNl85vrnw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 21/27] audio: make playback packet length calculation exact Date: Mon, 6 Mar 2023 10:51:56 +0400 Message-Id: <20230306065202.2160066-22-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085673601100006 From: Volker R=C3=BCmelin Introduce the new function st_rate_frames_in() to calculate the exact number of audio input frames needed to get a given number of audio output frames. The exact number of frames depends only on the difference of opos - ipos and the number of output frames. When downsampling, this function returns the maximum number of input frames needed. This new function replaces the audio_frontend_frames_out() function, which calculated the average number of input frames rounded down to the nearest integer. Because audio_frontend_frames_out() also limited the number of input frames to the size of the resample buffer, st_rate_frames_in() is not a direct replacement and two additional MIN() functions are needed. One to prevent resample buffer overflows and one to limit the available bytes for the audio frontends. After this patch the audio packet length calculation for playback is exact. When upsampling, it's still possible that the audio frontends can't write the last audio frame. This will be fixed later. Acked-by: Mark Cave-Ayland Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-9-vr_qemu@t-online.de> --- audio/mixeng.h | 1 + audio/audio.c | 43 ++++++++++++++++++------------------------- audio/mixeng.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 25 deletions(-) diff --git a/audio/mixeng.h b/audio/mixeng.h index 2dcd6df245..64c1e231cc 100644 --- a/audio/mixeng.h +++ b/audio/mixeng.h @@ -52,6 +52,7 @@ void st_rate_flow(void *opaque, st_sample *ibuf, st_sampl= e *obuf, void st_rate_flow_mix(void *opaque, st_sample *ibuf, st_sample *obuf, size_t *isamp, size_t *osamp); void st_rate_stop (void *opaque); +uint32_t st_rate_frames_in(void *opaque, uint32_t frames_out); void mixeng_clear (struct st_sample *buf, int len); void mixeng_volume (struct st_sample *buf, int len, struct mixeng_volume *= vol); =20 diff --git a/audio/audio.c b/audio/audio.c index 556696b095..e18b5e98c5 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -701,8 +701,8 @@ static void audio_pcm_sw_resample_out(SWVoiceOut *sw, static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t buf_len) { HWVoiceOut *hw =3D sw->hw; - size_t live, dead, hw_free; - size_t frames_in_max, total_in, total_out; + size_t live, dead, hw_free, sw_max, fe_max; + size_t frames_in_max, frames_out_max, total_in, total_out; =20 live =3D sw->total_hw_samples_mixed; if (audio_bug(__func__, live > hw->mix_buf.size)) { @@ -720,17 +720,21 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void= *buf, size_t buf_len) dead =3D hw->mix_buf.size - live; hw_free =3D audio_pcm_hw_get_free(hw); hw_free =3D hw_free > live ? hw_free - live : 0; - frames_in_max =3D ((int64_t)MIN(dead, hw_free) << 32) / sw->ratio; - frames_in_max =3D MIN(frames_in_max, buf_len / sw->info.bytes_per_fram= e); - if (frames_in_max) { - sw->conv(sw->resample_buf.buffer, buf, frames_in_max); + frames_out_max =3D MIN(dead, hw_free); + sw_max =3D st_rate_frames_in(sw->rate, frames_out_max); + fe_max =3D MIN(buf_len / sw->info.bytes_per_frame, sw->resample_buf.si= ze); + frames_in_max =3D MIN(sw_max, fe_max); =20 - if (!sw->hw->pcm_ops->volume_out) { - mixeng_volume(sw->resample_buf.buffer, frames_in_max, &sw->vol= ); - } + if (!frames_in_max) { + return 0; } =20 - audio_pcm_sw_resample_out(sw, frames_in_max, MIN(dead, hw_free), + sw->conv(sw->resample_buf.buffer, buf, frames_in_max); + if (!sw->hw->pcm_ops->volume_out) { + mixeng_volume(sw->resample_buf.buffer, frames_in_max, &sw->vol); + } + + audio_pcm_sw_resample_out(sw, frames_in_max, frames_out_max, &total_in, &total_out); =20 sw->total_hw_samples_mixed +=3D total_out; @@ -1000,18 +1004,6 @@ static size_t audio_get_avail (SWVoiceIn *sw) return live; } =20 -/** - * audio_frontend_frames_out() - returns the number of frames needed to - * get frames_out frames after resampling - * - * @sw: audio playback frontend - * @frames_out: number of frames - */ -static size_t audio_frontend_frames_out(SWVoiceOut *sw, size_t frames_out) -{ - return ((int64_t)frames_out << 32) / sw->ratio; -} - static size_t audio_get_free(SWVoiceOut *sw) { size_t live, dead; @@ -1031,8 +1023,8 @@ static size_t audio_get_free(SWVoiceOut *sw) dead =3D sw->hw->mix_buf.size - live; =20 #ifdef DEBUG_OUT - dolog("%s: get_free live %zu dead %zu frontend frames %zu\n", - SW_NAME(sw), live, dead, audio_frontend_frames_out(sw, dead)); + dolog("%s: get_free live %zu dead %zu frontend frames %u\n", + SW_NAME(sw), live, dead, st_rate_frames_in(sw->rate, dead)); #endif =20 return dead; @@ -1161,12 +1153,13 @@ static void audio_run_out (AudioState *s) size_t free; =20 if (hw_free > sw->total_hw_samples_mixed) { - free =3D audio_frontend_frames_out(sw, + free =3D st_rate_frames_in(sw->rate, MIN(sw_free, hw_free - sw->total_hw_samples_mixed)= ); } else { free =3D 0; } if (free > 0) { + free =3D MIN(free, sw->resample_buf.size); sw->callback.fn(sw->callback.opaque, free * sw->info.bytes_per_frame); } diff --git a/audio/mixeng.c b/audio/mixeng.c index fe454e0725..a24c8c45a7 100644 --- a/audio/mixeng.c +++ b/audio/mixeng.c @@ -440,6 +440,45 @@ void st_rate_stop (void *opaque) g_free (opaque); } =20 +/** + * st_rate_frames_in() - returns the number of frames needed to + * get frames_out frames after resampling + * + * @opaque: pointer to struct rate + * @frames_out: number of frames + * + * When downsampling, there may be more than one correct result. In this + * case, the function returns the maximum number of input frames needed. + */ +uint32_t st_rate_frames_in(void *opaque, uint32_t frames_out) +{ + struct rate *rate =3D opaque; + uint64_t opos_start, opos_end; + uint32_t ipos_start, ipos_end; + + if (rate->opos_inc =3D=3D 1ULL << 32) { + return frames_out; + } + + if (frames_out) { + opos_start =3D rate->opos; + ipos_start =3D rate->ipos; + } else { + uint64_t offset; + + /* add offset =3D ceil(opos_inc) to opos and ipos to avoid an unde= rflow */ + offset =3D (rate->opos_inc + (1ULL << 32) - 1) & ~((1ULL << 32) - = 1); + opos_start =3D rate->opos + offset; + ipos_start =3D rate->ipos + (offset >> 32); + } + /* last frame written was at opos_start - rate->opos_inc */ + opos_end =3D opos_start - rate->opos_inc + rate->opos_inc * frames_out; + ipos_end =3D (opos_end >> 32) + 1; + + /* last frame read was at ipos_start - 1 */ + return ipos_end + 1 > ipos_start ? ipos_end + 1 - ipos_start : 0; +} + void mixeng_clear (struct st_sample *buf, int len) { memset (buf, 0, len * sizeof (struct st_sample)); --=20 2.39.2 From nobody Fri May 3 12:02:30 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085651; cv=none; d=zohomail.com; s=zohoarc; b=R0UJdLtpC4PUuho4riAxHXbHHVKoegbqa8UEIKnd+FKuNvYuMJA03C35cWkLfmazxkwhoGLOzTgsEU1LtLEWhpTL7nN7qArmwhea5ydx/xY5CgaC41CDqNL6Q0a5tf3GxEVqyu9HKpW5xrjDCZq1t8Z0XbrByu6s3rEYR7PlRHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085651; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tf6vk0J2A9SG+DdZ+7X7ukWjXXOcBJkt01MctJforQo=; b=cg8t6dx3G4WX4t0vcwj9M3tKEd5VekkCCOKEVdVe5VZPPlmkuIrz9DGeEvQ/CPYwlIqva0Q1I1363SgLvwFU2xP4QO6oEzbk7WmA+iqz1u6oWd7NVC193Ds3pKjJVrephHBhpgJU1aJZEvouDEqM0iTbLGjaXP3OEDmyG8piIR0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085651812420.95128118045477; Sun, 5 Mar 2023 22:54:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4jI-0007jo-7w; Mon, 06 Mar 2023 01:53:52 -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 1pZ4jG-0007Rm-3X for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4jE-0000iK-J8 for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:49 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-527-VLTiCfzNMGq7t6AJwMF_uw-1; Mon, 06 Mar 2023 01:53:44 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EDB538588E3; Mon, 6 Mar 2023 06:53:43 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5AF9492C14; Mon, 6 Mar 2023 06:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085627; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tf6vk0J2A9SG+DdZ+7X7ukWjXXOcBJkt01MctJforQo=; b=Mp1mI9Oi4SZRfYPyEztXXApxVLFgW0D2F0RL9uQHkqaPxpywAgNhUTkledGEpVTnO8hIZx vvuM48ok++ORRtbbEV9kA5pufixZwt3fMJqJD6kWTxJAOXIs7GGZ+H6N5HPqoZhPELWJEe EPZsHDPK+BLbtne/mshpnNf+2RVps9k= X-MC-Unique: VLTiCfzNMGq7t6AJwMF_uw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 22/27] audio: replace the resampling loop in audio_pcm_sw_read() Date: Mon, 6 Mar 2023 10:51:57 +0400 Message-Id: <20230306065202.2160066-23-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085653454100003 From: Volker R=C3=BCmelin Replace the resampling loop in audio_pcm_sw_read() with the new function audio_pcm_sw_resample_in(). Unlike the old resample loop the new function will try to consume input frames even if the output buffer is full. This is necessary when downsampling to avoid reading less audio frames than calculated in advance. The loop was unrolled to avoid complicated loop control conditions in this case. Acked-by: Mark Cave-Ayland Acked-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-10-vr_qemu@t-online.de> --- audio/audio.c | 59 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index e18b5e98c5..9e9c03a42e 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -543,11 +543,43 @@ static size_t audio_pcm_hw_conv_in(HWVoiceIn *hw, voi= d *pcm_buf, size_t samples) /* * Soft voice (capture) */ +static void audio_pcm_sw_resample_in(SWVoiceIn *sw, + size_t frames_in_max, size_t frames_out_max, + size_t *total_in, size_t *total_out) +{ + HWVoiceIn *hw =3D sw->hw; + struct st_sample *src, *dst; + size_t live, rpos, frames_in, frames_out; + + live =3D hw->total_samples_captured - sw->total_hw_samples_acquired; + rpos =3D audio_ring_posb(hw->conv_buf.pos, live, hw->conv_buf.size); + + /* resample conv_buf from rpos to end of buffer */ + src =3D hw->conv_buf.buffer + rpos; + frames_in =3D MIN(frames_in_max, hw->conv_buf.size - rpos); + dst =3D sw->resample_buf.buffer; + frames_out =3D frames_out_max; + st_rate_flow(sw->rate, src, dst, &frames_in, &frames_out); + rpos +=3D frames_in; + *total_in =3D frames_in; + *total_out =3D frames_out; + + /* resample conv_buf from start of buffer if there are input frames le= ft */ + if (frames_in_max - frames_in && rpos =3D=3D hw->conv_buf.size) { + src =3D hw->conv_buf.buffer; + frames_in =3D frames_in_max - frames_in; + dst +=3D frames_out; + frames_out =3D frames_out_max - frames_out; + st_rate_flow(sw->rate, src, dst, &frames_in, &frames_out); + *total_in +=3D frames_in; + *total_out +=3D frames_out; + } +} + static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t size) { HWVoiceIn *hw =3D sw->hw; - size_t samples, live, ret =3D 0, swlim, isamp, osamp, rpos, total =3D = 0; - struct st_sample *src, *dst =3D sw->resample_buf.buffer; + size_t samples, live, ret, swlim, total; =20 live =3D hw->total_samples_captured - sw->total_hw_samples_acquired; if (!live) { @@ -558,33 +590,12 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *= buf, size_t size) return 0; } =20 - rpos =3D audio_ring_posb(hw->conv_buf.pos, live, hw->conv_buf.size); - samples =3D size / sw->info.bytes_per_frame; =20 swlim =3D (live * sw->ratio) >> 32; swlim =3D MIN (swlim, samples); =20 - while (swlim) { - src =3D hw->conv_buf.buffer + rpos; - if (hw->conv_buf.pos > rpos) { - isamp =3D hw->conv_buf.pos - rpos; - } else { - isamp =3D hw->conv_buf.size - rpos; - } - - if (!isamp) { - break; - } - osamp =3D swlim; - - st_rate_flow (sw->rate, src, dst, &isamp, &osamp); - swlim -=3D osamp; - rpos =3D (rpos + isamp) % hw->conv_buf.size; - dst +=3D osamp; - ret +=3D osamp; - total +=3D isamp; - } + audio_pcm_sw_resample_in(sw, live, swlim, &total, &ret); =20 if (!hw->pcm_ops->volume_in) { mixeng_volume(sw->resample_buf.buffer, ret, &sw->vol); --=20 2.39.2 From nobody Fri May 3 12:02:31 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085813; cv=none; d=zohomail.com; s=zohoarc; b=RMPNhIcm4cREMelGe6pNiqO+ZmjXtCT/JOTbMUEpgYnhmFmqidoe7HLcutfUcREXptjl2miwHY579FebgEdQ9K63k8zSl/MQeU4/AZPSIibMYlvDeZv1BcuJU3U0JHvICNIM67SJ7ObPKz/fPTJG1wSqyYuDvb/k96kDlug/8qM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085813; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8NqWQI79MCAj9hoRz4fbSI9k2RbTZEpAHjv0JP+qiFE=; b=maK8uzxcdsWaRAldEoj37ymRbVNzn+4Zvf95l+Vsneszc8Sn1YngJSlKTNFdbD9h9EpGqkOkVGOBuWAAoxJ/haVw+tpdXWLhBJG5qiLX+l0Wt4+q95mfIGApk1SM+vL7V0+LUm0Yr9hkjN/9xc0kS4ZfDk7LgTAckRp1mA7/7og= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085813610900.6113333364202; Sun, 5 Mar 2023 22:56:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4jK-0007tP-2U; Mon, 06 Mar 2023 01:53:54 -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 1pZ4jH-0007g5-Pg for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4jG-0000jD-2y for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:51 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-271-94OgoeOXNtq1KQ3nNXd-KA-1; Mon, 06 Mar 2023 01:53:48 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B9A7985A588; Mon, 6 Mar 2023 06:53:47 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0337D492C3E; Mon, 6 Mar 2023 06:53:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085629; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8NqWQI79MCAj9hoRz4fbSI9k2RbTZEpAHjv0JP+qiFE=; b=XezDOlpBZMjlqSsqpO0bPNr7cA6s4eTBv4QiVEQGrrXNoGDqqqIsvReFAcKz1aZe1M8KRT eCQBAtRahfznTRmzYk3eW7ospUC19iRhGNIRlcnXYctmxeH+1z6Kc/pK48AVDA+3CN4Md7 2dtqjnV+rdMFgkSGJDGAA05Iw+7LVJo= X-MC-Unique: 94OgoeOXNtq1KQ3nNXd-KA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 23/27] audio: rename variables in audio_pcm_sw_read() Date: Mon, 6 Mar 2023 10:51:58 +0400 Message-Id: <20230306065202.2160066-24-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085815173100001 From: Volker R=C3=BCmelin The audio_pcm_sw_read() function uses a few very unspecific variable names. Rename them for better readability. ret =3D> total_out total =3D> total_in size =3D> buf_len samples =3D> frames_out_max Acked-by: Mark Cave-Ayland Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-11-vr_qemu@t-online.de> --- audio/audio.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 9e9c03a42e..22c36d6660 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -576,10 +576,10 @@ static void audio_pcm_sw_resample_in(SWVoiceIn *sw, } } =20 -static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t size) +static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t buf_len) { HWVoiceIn *hw =3D sw->hw; - size_t samples, live, ret, swlim, total; + size_t live, frames_out_max, swlim, total_in, total_out; =20 live =3D hw->total_samples_captured - sw->total_hw_samples_acquired; if (!live) { @@ -590,20 +590,20 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *= buf, size_t size) return 0; } =20 - samples =3D size / sw->info.bytes_per_frame; + frames_out_max =3D buf_len / sw->info.bytes_per_frame; =20 swlim =3D (live * sw->ratio) >> 32; - swlim =3D MIN (swlim, samples); + swlim =3D MIN(swlim, frames_out_max); =20 - audio_pcm_sw_resample_in(sw, live, swlim, &total, &ret); + audio_pcm_sw_resample_in(sw, live, swlim, &total_in, &total_out); =20 if (!hw->pcm_ops->volume_in) { - mixeng_volume(sw->resample_buf.buffer, ret, &sw->vol); + mixeng_volume(sw->resample_buf.buffer, total_out, &sw->vol); } + sw->clip(buf, sw->resample_buf.buffer, total_out); =20 - sw->clip(buf, sw->resample_buf.buffer, ret); - sw->total_hw_samples_acquired +=3D total; - return ret * sw->info.bytes_per_frame; + sw->total_hw_samples_acquired +=3D total_in; + return total_out * sw->info.bytes_per_frame; } =20 /* --=20 2.39.2 From nobody Fri May 3 12:02:31 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085671; cv=none; d=zohomail.com; s=zohoarc; b=T8qBiUHkyhrAhWjJjuk3dG7iIXY4hmympdEtTHtbWYzGlL5LXlQeYt1hiIpjlEnVDAF4WSfwRInp/SDVTDSt9u1qb6U2oMWrHLW4bZE37HQueQ5774u+op2UrRxbMkR7A4Ni50BtNKzFUsbSepdm3i+7+EAGHBK0ssZIlBoimS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085671; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cJXjHqOaJmXezEr8+WeFwy1oafqmAHSOmKRe9b+lF+E=; b=PzUrQEHC1yfL9ghFoo9yKy+zs2Ba8lgdm3TAFsisZjgu9H+zYjV6IFSOYaSONByMim/iAbvnwm8B12FzaKa3Bo+t8NTwPGygxoWgRt7FN8EsK0YJWauCgx37DqiUlrNsLmeKnpF33uTj6pOuP+/m+ByvADYiNEZrPlhEnl8oac4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085671876424.6731035825294; Sun, 5 Mar 2023 22:54:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4jR-0000Yn-An; Mon, 06 Mar 2023 01:54:01 -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 1pZ4jP-0000Kw-Iz for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4jN-0000lJ-Lw for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:53:59 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-567-M5rZdlGYOd6OzU2Fmq7oGg-1; Mon, 06 Mar 2023 01:53:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D835858F0E; Mon, 6 Mar 2023 06:53:52 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14C26175AD; Mon, 6 Mar 2023 06:53:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cJXjHqOaJmXezEr8+WeFwy1oafqmAHSOmKRe9b+lF+E=; b=a5jf0eUsj/HcfwF/4qP1ft+rci6fo0C9RY4/95oJB1cx7HxBazTKQLg20FrU13r96WarOs vs52A/El2ZRAbqh+2PcoGQhvWE4seRpsj8/YgupT34O7PTTNwpS7JpHtrTvXE1dO60i9lt U3Vfb9WhX+ZNhvzZm5t51KPcj1Wwc4s= X-MC-Unique: M5rZdlGYOd6OzU2Fmq7oGg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 24/27] audio: make recording packet length calculation exact Date: Mon, 6 Mar 2023 10:51:59 +0400 Message-Id: <20230306065202.2160066-25-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085673572100005 From: Volker R=C3=BCmelin Introduce the new function st_rate_frames_out() to calculate the exact number of audio output frames the resampling code can generate from a given number of audio input frames. When upsampling, this function returns the maximum number of output frames. This new function replaces the audio_frontend_frames_in() function, which calculated the average number of output frames rounded down to the nearest integer. The audio_frontend_frames_in() function was additionally used to limit the number of output frames to the resample buffer size. In audio_pcm_sw_read() the variable resample_buf.size replaces the open coded audio_frontend_frames_in() function. In audio_run_in() an additional MIN() function is necessary. After this patch the audio packet length calculation for audio recording is exact. Acked-by: Mark Cave-Ayland Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-12-vr_qemu@t-online.de> --- audio/mixeng.h | 1 + audio/audio.c | 29 ++++++++--------------------- audio/mixeng.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 21 deletions(-) diff --git a/audio/mixeng.h b/audio/mixeng.h index 64c1e231cc..f9de7cffeb 100644 --- a/audio/mixeng.h +++ b/audio/mixeng.h @@ -52,6 +52,7 @@ void st_rate_flow(void *opaque, st_sample *ibuf, st_sampl= e *obuf, void st_rate_flow_mix(void *opaque, st_sample *ibuf, st_sample *obuf, size_t *isamp, size_t *osamp); void st_rate_stop (void *opaque); +uint32_t st_rate_frames_out(void *opaque, uint32_t frames_in); uint32_t st_rate_frames_in(void *opaque, uint32_t frames_out); void mixeng_clear (struct st_sample *buf, int len); void mixeng_volume (struct st_sample *buf, int len, struct mixeng_volume *= vol); diff --git a/audio/audio.c b/audio/audio.c index 22c36d6660..dad17e59b8 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -579,7 +579,7 @@ static void audio_pcm_sw_resample_in(SWVoiceIn *sw, static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t buf_len) { HWVoiceIn *hw =3D sw->hw; - size_t live, frames_out_max, swlim, total_in, total_out; + size_t live, frames_out_max, total_in, total_out; =20 live =3D hw->total_samples_captured - sw->total_hw_samples_acquired; if (!live) { @@ -590,12 +590,10 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *= buf, size_t buf_len) return 0; } =20 - frames_out_max =3D buf_len / sw->info.bytes_per_frame; + frames_out_max =3D MIN(buf_len / sw->info.bytes_per_frame, + sw->resample_buf.size); =20 - swlim =3D (live * sw->ratio) >> 32; - swlim =3D MIN(swlim, frames_out_max); - - audio_pcm_sw_resample_in(sw, live, swlim, &total_in, &total_out); + audio_pcm_sw_resample_in(sw, live, frames_out_max, &total_in, &total_o= ut); =20 if (!hw->pcm_ops->volume_in) { mixeng_volume(sw->resample_buf.buffer, total_out, &sw->vol); @@ -979,18 +977,6 @@ void AUD_set_active_in (SWVoiceIn *sw, int on) } } =20 -/** - * audio_frontend_frames_in() - returns the number of frames the resampling - * code generates from frames_in frames - * - * @sw: audio recording frontend - * @frames_in: number of frames - */ -static size_t audio_frontend_frames_in(SWVoiceIn *sw, size_t frames_in) -{ - return (int64_t)frames_in * sw->ratio >> 32; -} - static size_t audio_get_avail (SWVoiceIn *sw) { size_t live; @@ -1007,9 +993,9 @@ static size_t audio_get_avail (SWVoiceIn *sw) } =20 ldebug ( - "%s: get_avail live %zu frontend frames %zu\n", + "%s: get_avail live %zu frontend frames %u\n", SW_NAME (sw), - live, audio_frontend_frames_in(sw, live) + live, st_rate_frames_out(sw->rate, live) ); =20 return live; @@ -1314,8 +1300,9 @@ static void audio_run_in (AudioState *s) size_t sw_avail =3D audio_get_avail(sw); size_t avail; =20 - avail =3D audio_frontend_frames_in(sw, sw_avail); + avail =3D st_rate_frames_out(sw->rate, sw_avail); if (avail > 0) { + avail =3D MIN(avail, sw->resample_buf.size); sw->callback.fn(sw->callback.opaque, avail * sw->info.bytes_per_frame); } diff --git a/audio/mixeng.c b/audio/mixeng.c index a24c8c45a7..69f6549224 100644 --- a/audio/mixeng.c +++ b/audio/mixeng.c @@ -440,6 +440,47 @@ void st_rate_stop (void *opaque) g_free (opaque); } =20 +/** + * st_rate_frames_out() - returns the number of frames the resampling code + * generates from frames_in frames + * + * @opaque: pointer to struct rate + * @frames_in: number of frames + * + * When upsampling, there may be more than one correct result. In this cas= e, + * the function returns the maximum number of output frames the resampling + * code can generate. + */ +uint32_t st_rate_frames_out(void *opaque, uint32_t frames_in) +{ + struct rate *rate =3D opaque; + uint64_t opos_end, opos_delta; + uint32_t ipos_end; + uint32_t frames_out; + + if (rate->opos_inc =3D=3D 1ULL << 32) { + return frames_in; + } + + /* no output frame without at least one input frame */ + if (!frames_in) { + return 0; + } + + /* last frame read was at rate->ipos - 1 */ + ipos_end =3D rate->ipos - 1 + frames_in; + opos_end =3D (uint64_t)ipos_end << 32; + + /* last frame written was at rate->opos - rate->opos_inc */ + if (opos_end + rate->opos_inc <=3D rate->opos) { + return 0; + } + opos_delta =3D opos_end - rate->opos + rate->opos_inc; + frames_out =3D opos_delta / rate->opos_inc; + + return opos_delta % rate->opos_inc ? frames_out : frames_out - 1; +} + /** * st_rate_frames_in() - returns the number of frames needed to * get frames_out frames after resampling --=20 2.39.2 From nobody Fri May 3 12:02:31 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085815; cv=none; d=zohomail.com; s=zohoarc; b=QMun1Ku6icXA5rQb10Y4eC/VQn4iBgCe+Svx84toAaADRIlYbpQKijfOknTa9m0wDJnajHX9BNMMTSKpa5BNlHD7zrja1kR5IqP5CSr5gG116PhqMhdDbrZKzmDx9gZpX3FDpJsM3QrLynptzFwlpgys3r61lX5uyBgvet7nQp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085815; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MuimzO/d8VJ2BRE0OUsGJPQw9elHxlAH19Orsoeh4xM=; b=cZO/aph5vxLre0C3z/vuJxQuLjs2LQJi32rXQqioFMFdH05Gcq4YQja5ZxwWwRV6hMsGsNoA7q1NuAhkfki26x4NeBXlFnKYYhzUa1f4WLoCgPNAN1A2ROV2BxCAD7GslJUgGLF1RDgivqy4NpoNrNOx1LpbuMTFIP81VAUuACg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085815629318.5795860086715; Sun, 5 Mar 2023 22:56:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4jV-0001D5-DW; Mon, 06 Mar 2023 01:54:05 -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 1pZ4jT-0000rr-8k for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:54:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4jR-0000li-AI for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:54:02 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-168-VTnorYBjNfGnapAUZ3X_cQ-1; Mon, 06 Mar 2023 01:53:57 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27E043828884; Mon, 6 Mar 2023 06:53:57 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE33C40C10FA; Mon, 6 Mar 2023 06:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085640; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MuimzO/d8VJ2BRE0OUsGJPQw9elHxlAH19Orsoeh4xM=; b=ZhVZen/HcJIzZwwemFhFM0HcQ8fgH/HTGARib4A1tLHY87Rn3haeoNGCdQ4j8w2s0AJ/jn KQKzCN0BTKGiLbtETpiiRGbnmJoPumNZTUz2DRtJ7Q22QQrfbdbFhlKYCxnL8ST5ZhtBt0 WCay2yrMr2BSqrFC7UG869gvw4SXXvY= X-MC-Unique: VTnorYBjNfGnapAUZ3X_cQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 25/27] audio: handle leftover audio frame from upsampling Date: Mon, 6 Mar 2023 10:52:00 +0400 Message-Id: <20230306065202.2160066-26-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085817183100007 From: Volker R=C3=BCmelin Upsampling may leave one remaining audio frame in the input buffer. The emulated audio playback devices are currently resposible to write this audio frame again in the next write cycle. Push that task down to audio_pcm_sw_write. This is another step towards an audio callback interface that guarantees that when audio frontends are told they can write n audio frames, they can actually do so. Acked-by: Mark Cave-Ayland Acked-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-13-vr_qemu@t-online.de> --- audio/audio_template.h | 6 ++++++ audio/audio.c | 34 ++++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index a0b653f52c..0d8aab6fad 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -138,6 +138,12 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) = (SW *sw) return -1; } =20 + /* + * Allocate one additional audio frame that is needed for upsampling + * if the resample buffer size is small. For large buffer sizes take + * care of overflows. + */ + samples =3D samples < INT_MAX ? samples + 1 : INT_MAX; sw->resample_buf.buffer =3D g_new0(st_sample, samples); sw->resample_buf.size =3D samples; sw->resample_buf.pos =3D 0; diff --git a/audio/audio.c b/audio/audio.c index dad17e59b8..4836ab8ca8 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -731,16 +731,21 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void= *buf, size_t buf_len) hw_free =3D hw_free > live ? hw_free - live : 0; frames_out_max =3D MIN(dead, hw_free); sw_max =3D st_rate_frames_in(sw->rate, frames_out_max); - fe_max =3D MIN(buf_len / sw->info.bytes_per_frame, sw->resample_buf.si= ze); + fe_max =3D MIN(buf_len / sw->info.bytes_per_frame + sw->resample_buf.p= os, + sw->resample_buf.size); frames_in_max =3D MIN(sw_max, fe_max); =20 if (!frames_in_max) { return 0; } =20 - sw->conv(sw->resample_buf.buffer, buf, frames_in_max); - if (!sw->hw->pcm_ops->volume_out) { - mixeng_volume(sw->resample_buf.buffer, frames_in_max, &sw->vol); + if (frames_in_max > sw->resample_buf.pos) { + sw->conv(sw->resample_buf.buffer + sw->resample_buf.pos, + buf, frames_in_max - sw->resample_buf.pos); + if (!sw->hw->pcm_ops->volume_out) { + mixeng_volume(sw->resample_buf.buffer + sw->resample_buf.pos, + frames_in_max - sw->resample_buf.pos, &sw->vol); + } } =20 audio_pcm_sw_resample_out(sw, frames_in_max, frames_out_max, @@ -749,6 +754,22 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void = *buf, size_t buf_len) sw->total_hw_samples_mixed +=3D total_out; sw->empty =3D sw->total_hw_samples_mixed =3D=3D 0; =20 + /* + * Upsampling may leave one audio frame in the resample buffer. Decrem= ent + * total_in by one if there was a leftover frame from the previous res= ample + * pass in the resample buffer. Increment total_in by one if the curre= nt + * resample pass left one frame in the resample buffer. + */ + if (frames_in_max - total_in =3D=3D 1) { + /* copy one leftover audio frame to the beginning of the buffer */ + *sw->resample_buf.buffer =3D *(sw->resample_buf.buffer + total_in); + total_in +=3D 1 - sw->resample_buf.pos; + sw->resample_buf.pos =3D 1; + } else if (total_in >=3D sw->resample_buf.pos) { + total_in -=3D sw->resample_buf.pos; + sw->resample_buf.pos =3D 0; + } + #ifdef DEBUG_OUT dolog ( "%s: write size %zu written %zu total mixed %zu\n", @@ -1155,8 +1176,9 @@ static void audio_run_out (AudioState *s) } else { free =3D 0; } - if (free > 0) { - free =3D MIN(free, sw->resample_buf.size); + if (free > sw->resample_buf.pos) { + free =3D MIN(free, sw->resample_buf.size) + - sw->resample_buf.pos; sw->callback.fn(sw->callback.opaque, free * sw->info.bytes_per_frame); } --=20 2.39.2 From nobody Fri May 3 12:02:31 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085657; cv=none; d=zohomail.com; s=zohoarc; b=mkarc3g7eJMRSyyqozTwTQYykyq33ds5xhvm6f81meIMzcJ135ctED4Rl3tfaGv98P2Qh6ryOK6NHBsgtSkpleGyUcFEf8QF8XBoxAipiV3oI9mfI9/ddTqf+NI40t6NrCCNHDKefZZG1i5W3A+xyWQrmuEqcGPChYvvy2JafUA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085657; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HF65SJRLcmD1BZEkBuHNjZmgrFQItRq/7E7fKp0fdPM=; b=TUkv6Us0hmcszRp7UrBZB1izZF3mawz6+u6U1vy0xokw1fpw0lL1NF3lN7xoo4vJZmnijQ/SxqS9pve72zgMfIMnQ12kid5QX7Wyy7OZ7ufiPLy/agrlPI4Bbo9gW5whMXBtcU1ukDtJeuUVVVUzqUKx7xXZW7m8ecH0Qh2gZig= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678085657300914.1822179708066; Sun, 5 Mar 2023 22:54:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4jY-0001fJ-P6; Mon, 06 Mar 2023 01:54: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 1pZ4jX-0001Sx-9B for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:54:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4jV-0000mU-Kr for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:54:06 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-360-XVBWNL3vPFOAZDQflGoLUw-1; Mon, 06 Mar 2023 01:54:01 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5ACFE3C10C6A; Mon, 6 Mar 2023 06:54:01 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9963B40C10FA; Mon, 6 Mar 2023 06:54:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085645; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HF65SJRLcmD1BZEkBuHNjZmgrFQItRq/7E7fKp0fdPM=; b=Gd74GXc8IyDRSynCeEKC1gO3PsBQdZ2cSH8gdmeEGApvTSKJ43qAgCTTD+D88WMVKhkTOc tZlwkVmXjrwBcYFXKdi2Ej3CfdtzT64HI+zKc49fwp0v5h2OtBAi1toXTYVe6h0lSOH4H8 p8M1U3TIMEE/mBNONN+tWUi5mrhc8bk= X-MC-Unique: XVBWNL3vPFOAZDQflGoLUw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 26/27] audio/audio_template: substitute sw->hw with hw Date: Mon, 6 Mar 2023 10:52:01 +0400 Message-Id: <20230306065202.2160066-27-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085659449100011 From: Volker R=C3=BCmelin Substitute sw->hw with hw in the audio_pcm_sw_alloc_resources_* functions. Acked-by: Mark Cave-Ayland Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-14-vr_qemu@t-online.de> --- audio/audio_template.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index 0d8aab6fad..7e116426c7 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -107,6 +107,7 @@ static void glue (audio_pcm_sw_free_resources_, TYPE) (= SW *sw) =20 static int glue (audio_pcm_sw_alloc_resources_, TYPE) (SW *sw) { + HW *hw =3D sw->hw; int samples; =20 if (!glue(audio_get_pdo_, TYPE)(sw->s->dev)->mixing_engine) { @@ -125,7 +126,6 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) (= SW *sw) } =20 if (samples =3D=3D 0) { - HW *hw =3D sw->hw; size_t f_fe_min; =20 /* f_fe_min =3D ceil(1 [frames] * f_be [Hz] / size_be [frames]) */ @@ -149,9 +149,9 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) (= SW *sw) sw->resample_buf.pos =3D 0; =20 #ifdef DAC - sw->rate =3D st_rate_start (sw->info.freq, sw->hw->info.freq); + sw->rate =3D st_rate_start(sw->info.freq, hw->info.freq); #else - sw->rate =3D st_rate_start (sw->hw->info.freq, sw->info.freq); + sw->rate =3D st_rate_start(hw->info.freq, sw->info.freq); #endif =20 return 0; --=20 2.39.2 From nobody Fri May 3 12:02:31 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678085771; cv=none; d=zohomail.com; s=zohoarc; b=GHdwcaK/A6muTq7SZcP8DwjgfD8i88mrXvAUmm3L+KxgxNUdQgX7rj++JMhpEVnqmjlHVcnOOqiCnolPvenf5nwtnDZ1G4Ppm/Se4dXntCodwmbhU003+qCKd3/79ZSdJMgrkp/HaxC62TzSftHAixVQKcBK1BgOc2K2Dc/mLmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678085771; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ggt8FwJW8zLOr7hMWJ5Ndtn7i62j3eDjXuDyuKvWV/k=; b=V/Im2yQJilzDXVRwTyzWz1MaWhajgs2zOXSi6SM7LvrLajJfucOUu6RwNWL1BFih8RPpUKF4uBrrQLdle7n79qQDxeOxWSsYYZnauQXm3pb0Pg+LD2vAzMSAXYrouGrZ5G9utnskNRadIIIgxouP87edIFZpoLjd7vgmE3BwHt8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167808577155736.23784073440811; Sun, 5 Mar 2023 22:56:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ4jp-0003Zp-Tf; Mon, 06 Mar 2023 01:54: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 1pZ4jh-0003UQ-RK for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:54:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ4jg-0000oY-2S for qemu-devel@nongnu.org; Mon, 06 Mar 2023 01:54:17 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-504-HOTDyiwWPtKpPoHkCCBHLg-1; Mon, 06 Mar 2023 01:54:10 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A1E6A1C068C1; Mon, 6 Mar 2023 06:54:05 +0000 (UTC) Received: from localhost (unknown [10.39.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E8B9175AD; Mon, 6 Mar 2023 06:54:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678085655; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ggt8FwJW8zLOr7hMWJ5Ndtn7i62j3eDjXuDyuKvWV/k=; b=e3KMWvbqjZzgD7EdM+innvH/nsAFE1ANSx6Hw71o/gWCOM1be7SLuw+MQYri2f1ouYu4za zFcaLnS9RwdE/H7WS3qjN+LNMA8eJu1WwqYMgZuibQW25LHCx06YWdoiHqeElvQNOObt+H xcWEyXZN5f19S7HyN3x/ppHc/YEQyfQ= X-MC-Unique: HOTDyiwWPtKpPoHkCCBHLg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , =?UTF-8?q?Volker=20R=C3=BCmelin?= Subject: [PULL 27/27] audio: remove sw->ratio Date: Mon, 6 Mar 2023 10:52:02 +0400 Message-Id: <20230306065202.2160066-28-marcandre.lureau@redhat.com> In-Reply-To: <20230306065202.2160066-1-marcandre.lureau@redhat.com> References: <20230306065202.2160066-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678085772903100005 From: Volker R=C3=BCmelin Simplify the resample buffer size calculation. For audio playback we have sw->ratio =3D ((int64_t)sw->hw->info.freq << 32) / sw->info.freq; samples =3D ((int64_t)sw->HWBUF.size << 32) / sw->ratio; This can be simplified to samples =3D muldiv64(sw->HWBUF.size, sw->info.freq, sw->hw->info.freq); For audio recording we have sw->ratio =3D ((int64_t)sw->info.freq << 32) / sw->hw->info.freq; samples =3D (int64_t)sw->HWBUF.size * sw->ratio >> 32; This can be simplified to samples =3D muldiv64(sw->HWBUF.size, sw->info.freq, sw->hw->info.freq); With hw =3D sw->hw this becomes in both cases samples =3D muldiv64(HWBUF.size, sw->info.freq, hw->info.freq); Now that sw->ratio is no longer needed, remove sw->ratio. Acked-by: Mark Cave-Ayland Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Volker R=C3=BCmelin Message-Id: <20230224190555.7409-15-vr_qemu@t-online.de> --- audio/audio_int.h | 2 -- audio/audio_template.h | 30 +++++++++--------------------- audio/audio.c | 1 - 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 8b163e1759..d51d63f08d 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -108,7 +108,6 @@ struct SWVoiceOut { AudioState *s; struct audio_pcm_info info; t_sample *conv; - int64_t ratio; STSampleBuffer resample_buf; void *rate; size_t total_hw_samples_mixed; @@ -126,7 +125,6 @@ struct SWVoiceIn { AudioState *s; int active; struct audio_pcm_info info; - int64_t ratio; void *rate; size_t total_hw_samples_acquired; STSampleBuffer resample_buf; diff --git a/audio/audio_template.h b/audio/audio_template.h index 7e116426c7..e42326c20d 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -108,32 +108,23 @@ static void glue (audio_pcm_sw_free_resources_, TYPE)= (SW *sw) static int glue (audio_pcm_sw_alloc_resources_, TYPE) (SW *sw) { HW *hw =3D sw->hw; - int samples; + uint64_t samples; =20 if (!glue(audio_get_pdo_, TYPE)(sw->s->dev)->mixing_engine) { return 0; } =20 -#ifdef DAC - samples =3D ((int64_t)sw->HWBUF.size << 32) / sw->ratio; -#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; - } - + samples =3D muldiv64(HWBUF.size, sw->info.freq, hw->info.freq); if (samples =3D=3D 0) { - size_t f_fe_min; + uint64_t f_fe_min; + uint64_t f_be =3D (uint32_t)hw->info.freq; =20 /* 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; + f_fe_min =3D (f_be + 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", + " of %d Hz for %s. Only sample rates >=3D %" PRIu64 = " Hz" + " are supported.\n", sw->info.freq, sw->name, f_fe_min); return -1; } @@ -141,9 +132,9 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) (= SW *sw) /* * Allocate one additional audio frame that is needed for upsampling * if the resample buffer size is small. For large buffer sizes take - * care of overflows. + * care of overflows and truncation. */ - samples =3D samples < INT_MAX ? samples + 1 : INT_MAX; + samples =3D samples < SIZE_MAX ? samples + 1 : SIZE_MAX; sw->resample_buf.buffer =3D g_new0(st_sample, samples); sw->resample_buf.size =3D samples; sw->resample_buf.pos =3D 0; @@ -170,11 +161,8 @@ static int glue (audio_pcm_sw_init_, TYPE) ( sw->hw =3D hw; sw->active =3D 0; #ifdef DAC - sw->ratio =3D ((int64_t) sw->hw->info.freq << 32) / sw->info.freq; sw->total_hw_samples_mixed =3D 0; sw->empty =3D 1; -#else - sw->ratio =3D ((int64_t) sw->info.freq << 32) / sw->hw->info.freq; #endif =20 if (sw->info.is_float) { diff --git a/audio/audio.c b/audio/audio.c index 4836ab8ca8..70b096713c 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -478,7 +478,6 @@ static int audio_attach_capture (HWVoiceOut *hw) sw->info =3D hw->info; sw->empty =3D 1; sw->active =3D hw->enabled; - 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); QLIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries); --=20 2.39.2