From nobody Sun Apr 12 05:56:29 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1771243414; cv=none; d=zohomail.com; s=zohoarc; b=Ds7l9WhbYKvud/tOVXsa/TIwdQBWm4ZtAo3pWh6HvzqNZK0hG0YNEzq4UyrGu376sduxWWSay8MwFNw++tbzSvELWbqsINQsOuWMbp10tJtdx5kGREJF8Q+dzSdLMAZhA9HtPdb3h8bCkLqKhEvsSDAOn167gzySWI+ErU4EIZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771243414; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ewz4+F8wLEtvaEcONlL4Y8tX4BoVoh7SgRY5ARaYuAk=; b=Y6ESCjQW8IYwarmVRwM3D7BbVITjQYEa3jwo5JF5jQP2DhpAtRNkZWo00P1+9+ta9d4Ci699zsvCFUTypy6evy2HV1RMxjzW6ebh71dSkAg86IMXklHyatF3vvLm89FhZ93RGhHB6C5BqmhJzdvdG/8R1R4MGwZJyGz2HEQbtnU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771243414951899.5521552576761; Mon, 16 Feb 2026 04:03:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vrwfm-0001Fn-OM; Mon, 16 Feb 2026 06:21: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 1vrwdc-0000za-5a for qemu-devel@nongnu.org; Mon, 16 Feb 2026 06:19: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 1vrwdZ-00006K-T1 for qemu-devel@nongnu.org; Mon, 16 Feb 2026 06:19:35 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688-NFnMI7v4M2qG1oNPCa19nQ-1; Mon, 16 Feb 2026 06:19:29 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4065519560A7; Mon, 16 Feb 2026 11:19:27 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E991C1800668; Mon, 16 Feb 2026 11:19:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771240772; 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=Ewz4+F8wLEtvaEcONlL4Y8tX4BoVoh7SgRY5ARaYuAk=; b=WEgjcK5Hsbw1wuJum+vlaXNcPNmHm5XIkh9ZwRrtOweREICuhTICnlJto37Vk8MVtcRTpZ Kf8oOuMIGe+ADCWQGz9Gp37rUwu578AQphW2DuhMl5LP+4HuVhvmda/AqqKmYR/OQiS27m Tn2UHaXBVS/9Eop5o4FFFtL8IOq2Q1c= X-MC-Unique: NFnMI7v4M2qG1oNPCa19nQ-1 X-Mimecast-MFC-AGG-ID: NFnMI7v4M2qG1oNPCa19nQ_1771240767 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Mon, 16 Feb 2026 12:16:10 +0100 Subject: [PATCH 81/85] audio: rework audio_bug() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260216-audio-v1-81-e676662e4514@redhat.com> References: <20260216-audio-v1-0-e676662e4514@redhat.com> In-Reply-To: <20260216-audio-v1-0-e676662e4514@redhat.com> To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Eduardo Habkost , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , John Snow , Cleber Rosa , Christian Schoenebeck , Akihiko Odaki , Thomas Huth , Alexandre Ratchov , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier , "Michael S. Tsirkin" , Manos Pitsidianakis , Alistair Francis , "Edgar E. Iglesias" , Peter Maydell , qemu-arm@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Mark Cave-Ayland X-Developer-Signature: v=1; a=openpgp-sha256; l=11037; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=/3V2T6+AVOssg4wHpZHYi8m0iDkSaDhsu7P35DaXrLk=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBpkvxSkgYNzhg230arsEiJ36msyQOTDWB/1rWp2 jCud6Nb6SqJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaZL8UgAKCRDa6OEJdZac 5ZARD/4ng5KqzsGHx2AdN1Bn1SUQy3SQMGz031sYQKws8JP6i5rivPPufw0sjMHaUuws8zjBmJJ 4be9tI1HZqcH8MZrS7w2qaBbGsRPo9B2aYeIAC5BYRGbpmXwkyi1Ns/YylOSIvLoWQry2aHWYPE ftbl1RLU+fDVskVEGhrxk8sSKwRZRI0rNGvoXYKkXBNJp1zTDFuQSSGy66Gm2/JhCxJqx4krECa kfDyY7Xy0zvkjOEvH7huW6VCQHqwG9V1dph0RUvIbbd5tNZtcDp+gBUIVOIPydmGQJWez/eCV7H qvlROvh7Tr7WAASbPzNm0BWsrOT7QA0pVDRJUUwiJfJ2enwhRvh6XLfBMtdL6K+0AlGO+Ne+T82 8arzr/T+7IOHZmHuy5tY0ZHp1gS/dmM4SeGdaAEKYgWf7EjtEU6Xc1HT4APbzkSl/pq7Huz1t7n zMtt3E4Xvn+fRpcxnzIUDV+k6jkmNELA4aJsVsPp6P+FMBB/b4KAqZphssV9mZD+JqaqzaGPbqO Ghas7HORNNilgMzzK583KgqNxod9QXmjQfg/iKHTZj8mA7k4BCjlDUt4QFLWvM4Dxq/kw6b3ju2 SxXEzYoyOh6/j6ihKbqPDAKTCs/mWHYjKKL7PMeVSlX9B5Ndu9l3fzEwqpqE+/+DxphMjH4ZV08 7yOZ06a2ngjYkoA== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771243416738154100 audio_bug() is a bit unconventional, it is meant to be used as a condition expression, passing the actual condition as second argument (and __func__ as first argument). If the condition is true, it uses AUD_log() to print to stderr, and has some dubious recommendations printed only once. This change: - clears the control flow, and make the condition directly visible in the 'if' statement. - uses standard QEMU error_report() - audio_bug() now captures __func__ - remove the "Save all your work and restart..." once hint Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Mark Cave-Ayland --- audio/audio_int.h | 2 -- audio/audio_template.h | 38 +++++++++++++-------------- audio/audio-mixeng-be.c | 69 +++++++++++++++++++--------------------------= ---- 3 files changed, 46 insertions(+), 63 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index e0ed6af67ed..20ec7883aab 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -244,8 +244,6 @@ extern const char *audio_prio_list[]; void audio_pcm_init_info (struct audio_pcm_info *info, const struct audset= tings *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_run(AudioMixengBackend *s, const char *msg); =20 typedef struct RateCtl { diff --git a/audio/audio_template.h b/audio/audio_template.h index 5711f4a26e1..9dde36738bc 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -64,15 +64,15 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioMixe= ngBackend *s, min_voices); } =20 - if (audio_bug(__func__, !voice_size && max_voices)) { - dolog("drv=3D`%s' voice_size=3D0 max_voices=3D%d\n", - k->name, max_voices); + if (!voice_size && max_voices) { + audio_bug("drv=3D`%s' voice_size=3D0 max_voices=3D%d", + k->name, max_voices); glue(s->nb_hw_voices_, TYPE) =3D 0; } =20 - if (audio_bug(__func__, voice_size && !max_voices)) { - dolog("drv=3D`%s' voice_size=3D%zu max_voices=3D0\n", - k->name, voice_size); + if (voice_size && !max_voices) { + audio_bug("drv=3D`%s' voice_size=3D%zu max_voices=3D0", + k->name, voice_size); } } =20 @@ -88,8 +88,8 @@ static void glue(audio_pcm_hw_alloc_resources_, TYPE)(HW = *hw) { if (glue(audio_get_pdo_, TYPE)(hw->s->dev)->mixing_engine) { size_t samples =3D hw->samples; - if (audio_bug(__func__, samples =3D=3D 0)) { - dolog("Attempted to allocate empty buffer\n"); + if (samples =3D=3D 0) { + audio_bug("Attempted to allocate empty buffer"); } =20 HWBUF.buffer =3D g_new0(st_sample, samples); @@ -275,8 +275,8 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMixen= gBackend *s, return NULL; } =20 - if (audio_bug(__func__, !glue(k->init_, TYPE))) { - dolog("No host audio driver or missing init_%s\n", NAME); + if (!glue(k->init_, TYPE)) { + audio_bug("No host audio driver or missing init_%s", NAME); return NULL; } =20 @@ -295,8 +295,8 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMixen= gBackend *s, goto err0; } =20 - if (audio_bug(__func__, hw->samples <=3D 0)) { - dolog("hw->samples=3D%zd\n", hw->samples); + if (hw->samples <=3D 0) { + audio_bug("hw->samples=3D%zd", hw->samples); goto err1; } =20 @@ -477,8 +477,8 @@ static void glue (audio_close_, TYPE) (SW *sw) static void glue(audio_mixeng_backend_close_, TYPE)(AudioBackend *be, SW *= sw) { if (sw) { - if (audio_bug(__func__, !be)) { - dolog("backend=3D%p\n", be); + if (!be) { + audio_bug("backend=3D%p", be); return; } =20 @@ -498,9 +498,9 @@ static SW *glue(audio_mixeng_backend_open_, TYPE) ( AudioMixengBackendClass *k; AudiodevPerDirectionOptions *pdo; =20 - if (audio_bug(__func__, !be || !name || !callback_fn || !as)) { - dolog("backend=3D%p name=3D%p callback_fn=3D%p as=3D%p\n", - be, name, callback_fn, as); + if (!be || !name || !callback_fn || !as) { + audio_bug("backend=3D%p name=3D%p callback_fn=3D%p as=3D%p", + be, name, callback_fn, as); goto fail; } =20 @@ -519,8 +519,8 @@ static SW *glue(audio_mixeng_backend_open_, TYPE) ( goto fail; } =20 - if (audio_bug(__func__, !glue(k->init_, TYPE))) { - dolog("Can not open `%s' (no host audio driver)\n", name); + if (!glue(k->init_, TYPE)) { + error_report("audio: Can not open `%s' (no host audio driver)", na= me); goto fail; } =20 diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index bb8c0b56f78..45bcfb74338 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -31,6 +31,8 @@ =20 #define SW_NAME(sw) (sw)->name ? (sw)->name : "unknown" =20 +#define audio_bug(fmt, ...) error_report("%s: " fmt, __func__, ##__VA_ARGS= __) + const struct mixeng_volume nominal_volume =3D { .mute =3D 0, #ifdef FLOAT_MIXENG @@ -42,23 +44,6 @@ const struct mixeng_volume nominal_volume =3D { #endif }; =20 -int audio_bug (const char *funcname, int cond) -{ - if (cond) { - static int shown; - - AUD_log (NULL, "A bug was just triggered in %s\n", funcname); - if (!shown) { - shown =3D 1; - AUD_log (NULL, "Save all your work and restart without audio\n= "); - AUD_log (NULL, "I am sorry\n"); - } - AUD_log (NULL, "Context:\n"); - } - - return cond; -} - /* * Convert audio format to mixeng_clip index. Used by audio_pcm_sw_init_ a= nd * audio_mixeng_backend_add_capture() @@ -332,8 +317,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.s= ize); + if (live > hw->conv_buf.size) { + audio_bug("live=3D%zu hw->conv_buf.size=3D%zu", live, hw->conv_buf= .size); return 0; } return live; @@ -402,8 +387,8 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *bu= f, size_t buf_len) 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_bu= f.size); + if (live > hw->conv_buf.size) { + audio_bug("live=3D%zu hw->conv_buf.size=3D%zu", live, hw->conv_buf= .size); return 0; } =20 @@ -454,8 +439,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_buf= .size); + if (live > hw->mix_buf.size) { + audio_bug("live=3D%zu hw->mix_buf.size=3D%zu", live, hw->mix_b= uf.size); return 0; } return live; @@ -533,8 +518,8 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t buf_len) 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)) { - dolog("live=3D%zu hw->mix_buf.size=3D%zu\n", live, hw->mix_buf.siz= e); + if (live > hw->mix_buf.size) { + audio_bug("live=3D%zu hw->mix_buf.size=3D%zu", live, hw->mix_buf.s= ize); return 0; } =20 @@ -824,9 +809,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 (live > sw->hw->conv_buf.size) { + audio_bug("live=3D%zu sw->hw->conv_buf.size=3D%zu", live, + sw->hw->conv_buf.size); return 0; } =20 @@ -845,9 +830,9 @@ 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 (live > sw->hw->mix_buf.size) { + audio_bug("live=3D%zu sw->hw->mix_buf.size=3D%zu", live, + sw->hw->mix_buf.size); return 0; } =20 @@ -1002,8 +987,8 @@ static void audio_run_out(AudioMixengBackend *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_buf= .size); + if (live > hw->mix_buf.size) { + audio_bug("live=3D%zu hw->mix_buf.size=3D%zu", live, hw->mix_b= uf.size); continue; } =20 @@ -1033,9 +1018,9 @@ static void audio_run_out(AudioMixengBackend *s) 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); + if (hw->mix_buf.pos >=3D hw->mix_buf.size) { + audio_bug("hw->mix_buf.pos=3D%zu hw->mix_buf.size=3D%zu played= =3D%zu", + hw->mix_buf.pos, hw->mix_buf.size, played); hw->mix_buf.pos =3D 0; } =20 @@ -1050,9 +1035,9 @@ static void audio_run_out(AudioMixengBackend *s) continue; } =20 - if (audio_bug(__func__, played > sw->total_hw_samples_mixed)) { - dolog("played=3D%zu sw->total_hw_samples_mixed=3D%zu\n", - played, sw->total_hw_samples_mixed); + if (played > sw->total_hw_samples_mixed) { + audio_bug("played=3D%zu sw->total_hw_samples_mixed=3D%zu", + played, sw->total_hw_samples_mixed); played =3D sw->total_hw_samples_mixed; } =20 @@ -1195,9 +1180,9 @@ static void audio_run_capture(AudioMixengBackend *s) continue; } =20 - if (audio_bug(__func__, captured > sw->total_hw_samples_mixed)= ) { - dolog("captured=3D%zu sw->total_hw_samples_mixed=3D%zu\n", - captured, sw->total_hw_samples_mixed); + if (captured > sw->total_hw_samples_mixed) { + audio_bug("captured=3D%zu sw->total_hw_samples_mixed=3D%zu= ", + captured, sw->total_hw_samples_mixed); captured =3D sw->total_hw_samples_mixed; } =20 --=20 2.53.0