From nobody Mon Feb 9 20:12:08 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=1769538371; cv=none; d=zohomail.com; s=zohoarc; b=HDICaxfi1m2PN3yYVWuUZIRiJqUfHbS1BPtKZjwxVsDxZXaeqdJswiun0QVVtydH2SXRaVWi8h6qBYxG4hqFd/9wPac801qXaQbiaDqZpS2T0MKGuITpB+gRW+V7JJKLSCFh9uxiN7njzYvBLylMXBCt28sYMsK7sKovGaGltSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538371; 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=aEHrvY8yd2JZlqk4fgMH1xzo+z6VThEVCotB3+GpdtA=; b=ez29KAU6KR3FpjgxfTbvzGG4DPGbIJqpmRx0E7Mf1bFbUhu4mi9hVLw9P3LAjmXB5xCKZ7cSDF7mWbYwCSS8+ZPIlQyZhK2m+MIpcuqwZpjvm5JT2R1N9ZFnyPLxugENwAhBGB6YT+bsZLm5FbXgkvNcsAKX/OrZePQNaZgyD+w= 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 1769538371535820.4698148526741; Tue, 27 Jan 2026 10:26:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknl8-0004d1-49; Tue, 27 Jan 2026 13:25: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 1vknkr-0004ZD-No for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:25: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 1vknkp-0002tc-Nc for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:25:33 -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-90-DzaB0nIMOlOUaaqq7wVjTQ-1; Tue, 27 Jan 2026 13:25:28 -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 9F0C01944B0C; Tue, 27 Jan 2026 18:25:27 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3E7681800665; Tue, 27 Jan 2026 18:25:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538330; 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=aEHrvY8yd2JZlqk4fgMH1xzo+z6VThEVCotB3+GpdtA=; b=jGmEScdsSNF9wzQdgUj9tZDz1KhkNDJdqzFDrs2ltzq/gpuQf8ymhRmD1TKZTgXETJa7mE AaUxtjtNehPJ6coWKNjx1ay5prFLPi8V6p0yqCl/y8AeHbjcmUsAstQdUevj0BiOUy3/On sZmNyeBG9M8uogYGPfwCQgH9U2Spyzw= X-MC-Unique: DzaB0nIMOlOUaaqq7wVjTQ-1 X-Mimecast-MFC-AGG-ID: DzaB0nIMOlOUaaqq7wVjTQ_1769538327 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 01/43] audio/dbus: convert to QOM lifecycle methods Date: Tue, 27 Jan 2026 22:24:28 +0400 Message-ID: <20260127182516.289834-2-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538373231154100 From: Marc-Andr=C3=A9 Lureau Migrate the D-Bus audio backend from the legacy driver init/fini callbacks to proper QOM realize and finalize methods. The DBusAudio struct fields are now embedded directly in the AudioDbus QOM object instead of being allocated separately as drv_opaque. This allows accessing the backend state through proper QOM type casting with AUDIO_DBUS() rather than casting drv_opaque pointers. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/dbusaudio.c | 76 ++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index 2e76d650df1..b31bfd88d81 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -48,21 +48,20 @@ #define TYPE_AUDIO_DBUS "audio-dbus" OBJECT_DECLARE_SIMPLE_TYPE(AudioDbus, AUDIO_DBUS) =20 +static AudioBackendClass *audio_dbus_parent_class; + struct AudioDbus { AudioMixengBackend parent; -}; - -static struct audio_driver dbus_audio_driver; =20 -typedef struct DBusAudio { - Audiodev *dev; GDBusObjectManagerServer *server; bool p2p; GDBusObjectSkeleton *audio; QemuDBusDisplay1Audio *iface; GHashTable *out_listeners; GHashTable *in_listeners; -} DBusAudio; +}; + +static struct audio_driver dbus_audio_driver; =20 typedef struct DBusVoiceOut { HWVoiceOut hw; @@ -105,7 +104,7 @@ static void *dbus_get_buffer_out(HWVoiceOut *hw, size_t= *size) =20 static size_t dbus_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size) { - DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + AudioDbus *da =3D AUDIO_DBUS(hw->s); DBusVoiceOut *vo =3D container_of(hw, DBusVoiceOut, hw); GHashTableIter iter; QemuDBusDisplay1AudioOutListener *listener =3D NULL; @@ -162,9 +161,9 @@ dbus_init_out_listener(QemuDBusDisplay1AudioOutListener= *listener, } =20 static guint -dbus_audio_get_nsamples(DBusAudio *da) +dbus_audio_get_nsamples(AudioDbus *da) { - AudiodevDBusOptions *opts =3D &da->dev->u.dbus; + AudiodevDBusOptions *opts =3D &AUDIO_MIXENG_BACKEND(da)->dev->u.dbus; =20 if (opts->has_nsamples && opts->nsamples) { return opts->nsamples; @@ -176,7 +175,7 @@ dbus_audio_get_nsamples(DBusAudio *da) static int dbus_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque) { - DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + AudioDbus *da =3D AUDIO_DBUS(hw->s); DBusVoiceOut *vo =3D container_of(hw, DBusVoiceOut, hw); GHashTableIter iter; QemuDBusDisplay1AudioOutListener *listener =3D NULL; @@ -195,7 +194,7 @@ dbus_init_out(HWVoiceOut *hw, struct audsettings *as, v= oid *drv_opaque) static void dbus_fini_out(HWVoiceOut *hw) { - DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + AudioDbus *da =3D AUDIO_DBUS(hw->s); DBusVoiceOut *vo =3D container_of(hw, DBusVoiceOut, hw); GHashTableIter iter; QemuDBusDisplay1AudioOutListener *listener =3D NULL; @@ -214,7 +213,7 @@ dbus_fini_out(HWVoiceOut *hw) static void dbus_enable_out(HWVoiceOut *hw, bool enable) { - DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + AudioDbus *da =3D AUDIO_DBUS(hw->s); DBusVoiceOut *vo =3D container_of(hw, DBusVoiceOut, hw); GHashTableIter iter; QemuDBusDisplay1AudioOutListener *listener =3D NULL; @@ -256,7 +255,7 @@ dbus_volume_out_listener(HWVoiceOut *hw, static void dbus_volume_out(HWVoiceOut *hw, Volume *vol) { - DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + AudioDbus *da =3D AUDIO_DBUS(hw->s); DBusVoiceOut *vo =3D container_of(hw, DBusVoiceOut, hw); GHashTableIter iter; QemuDBusDisplay1AudioOutListener *listener =3D NULL; @@ -290,7 +289,7 @@ dbus_init_in_listener(QemuDBusDisplay1AudioInListener *= listener, HWVoiceIn *hw) static int dbus_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) { - DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + AudioDbus *da =3D AUDIO_DBUS(hw->s); DBusVoiceIn *vo =3D container_of(hw, DBusVoiceIn, hw); GHashTableIter iter; QemuDBusDisplay1AudioInListener *listener =3D NULL; @@ -309,7 +308,7 @@ dbus_init_in(HWVoiceIn *hw, struct audsettings *as, voi= d *drv_opaque) static void dbus_fini_in(HWVoiceIn *hw) { - DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + AudioDbus *da =3D AUDIO_DBUS(hw->s); GHashTableIter iter; QemuDBusDisplay1AudioInListener *listener =3D NULL; =20 @@ -346,7 +345,7 @@ dbus_volume_in_listener(HWVoiceIn *hw, static void dbus_volume_in(HWVoiceIn *hw, Volume *vol) { - DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + AudioDbus *da =3D AUDIO_DBUS(hw->s); DBusVoiceIn *vo =3D container_of(hw, DBusVoiceIn, hw); GHashTableIter iter; QemuDBusDisplay1AudioInListener *listener =3D NULL; @@ -363,7 +362,7 @@ dbus_volume_in(HWVoiceIn *hw, Volume *vol) static size_t dbus_read(HWVoiceIn *hw, void *buf, size_t size) { - DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + AudioDbus *da =3D AUDIO_DBUS(hw->s); /* DBusVoiceIn *vo =3D container_of(hw, DBusVoiceIn, hw); */ GHashTableIter iter; QemuDBusDisplay1AudioInListener *listener =3D NULL; @@ -398,7 +397,7 @@ dbus_read(HWVoiceIn *hw, void *buf, size_t size) static void dbus_enable_in(HWVoiceIn *hw, bool enable) { - DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + AudioDbus *da =3D AUDIO_DBUS(hw->s); DBusVoiceIn *vo =3D container_of(hw, DBusVoiceIn, hw); GHashTableIter iter; QemuDBusDisplay1AudioInListener *listener =3D NULL; @@ -416,28 +415,31 @@ dbus_enable_in(HWVoiceIn *hw, bool enable) } } =20 -static void * -dbus_audio_init(Audiodev *dev, Error **errp) +static bool +audio_dbus_realize(AudioBackend *abe, Audiodev *dev, Error **errp) { - DBusAudio *da; + AudioDbus *da =3D AUDIO_DBUS(abe); =20 if (!qemu_using_dbus_display(errp)) { - return NULL; + qapi_free_Audiodev(dev); + return false; + } + + if (!audio_dbus_parent_class->realize(abe, dev, errp)) { + return false; } =20 - da =3D g_new0(DBusAudio, 1); - da->dev =3D dev; da->out_listeners =3D g_hash_table_new_full(g_str_hash, g_str_equal, - g_free, g_object_unref); + g_free, g_object_unref); da->in_listeners =3D g_hash_table_new_full(g_str_hash, g_str_equal, - g_free, g_object_unref); - return da; + g_free, g_object_unref); + return true; } =20 static void -dbus_audio_fini(void *opaque) +audio_dbus_finalize(Object *obj) { - DBusAudio *da =3D opaque; + AudioDbus *da =3D AUDIO_DBUS(obj); =20 if (da->server) { g_dbus_object_manager_server_unexport(da->server, @@ -448,14 +450,13 @@ dbus_audio_fini(void *opaque) g_clear_pointer(&da->in_listeners, g_hash_table_unref); g_clear_pointer(&da->out_listeners, g_hash_table_unref); g_clear_object(&da->server); - g_free(da); } =20 static void listener_out_vanished_cb(GDBusConnection *connection, gboolean remote_peer_vanished, GError *error, - DBusAudio *da) + AudioDbus *da) { char *name =3D g_object_get_data(G_OBJECT(connection), "name"); =20 @@ -466,7 +467,7 @@ static void listener_in_vanished_cb(GDBusConnection *connection, gboolean remote_peer_vanished, GError *error, - DBusAudio *da) + AudioDbus *da) { char *name =3D g_object_get_data(G_OBJECT(connection), "name"); =20 @@ -482,7 +483,7 @@ dbus_audio_register_listener(AudioMixengBackend *s, GVariant *arg_listener, bool out) { - DBusAudio *da =3D s->drv_opaque; + AudioDbus *da =3D AUDIO_DBUS(s); const char *sender =3D da->p2p ? "p2p" : g_dbus_method_invocation_get_sender(invocation); g_autoptr(GDBusConnection) listener_conn =3D NULL; @@ -667,9 +668,8 @@ dbus_audio_set_server(AudioBackend *s, bool p2p, Error **errp) { - DBusAudio *da =3D AUDIO_MIXENG_BACKEND(s)->drv_opaque; + AudioDbus *da =3D AUDIO_DBUS(s); =20 - g_assert(da); g_assert(!da->server); =20 da->server =3D g_object_ref(server); @@ -711,8 +711,6 @@ static struct audio_pcm_ops dbus_pcm_ops =3D { =20 static struct audio_driver dbus_audio_driver =3D { .name =3D "dbus", - .init =3D dbus_audio_init, - .fini =3D dbus_audio_fini, .pcm_ops =3D &dbus_pcm_ops, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, @@ -725,6 +723,9 @@ static void audio_dbus_class_init(ObjectClass *klass, c= onst void *data) AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); =20 + audio_dbus_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_paren= t(klass)); + + b->realize =3D audio_dbus_realize; b->set_dbus_server =3D dbus_audio_set_server; k->driver =3D &dbus_audio_driver; } @@ -733,6 +734,7 @@ static const TypeInfo audio_dbus_info =3D { .name =3D TYPE_AUDIO_DBUS, .parent =3D TYPE_AUDIO_MIXENG_BACKEND, .instance_size =3D sizeof(AudioDbus), + .instance_finalize =3D audio_dbus_finalize, .class_init =3D audio_dbus_class_init, }; =20 --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538357; cv=none; d=zohomail.com; s=zohoarc; b=N9cV12GhsZf7rnHhmhE7qQh5m5mFdft9TdR6aYThiciLjNJB8nT1iqsIpL3d814C4+FO0Tj/uIad/GeOvsY7nLlH1c9dwRkOjg7aToWeTfKYIex1e7R4BHWisVoSkyL0zNbMXrBqP7QH8cr0VznxS2W9+srs3IvS4ChWGuSj1L8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538357; 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=OHcNbZBbdFqS4bgJPI6TG4KnB1h9E9YaTOVkHKy7n30=; b=Bvkvq+mhyw5z1adUuCI7BZ1mnewBzzW5sHoS0aKtkH7Z+SYC7nrk7fQ31OnjIOMOSErrBsXbLbbme4KQuBOl7sHpo0NGsT/1kHt78ghPbh13bt/ZEha0Rjn/9phxhqpmabnpLnJoifcqkj4JLWH8a00KkAT/VKmMX0XYPAahSA8= 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 1769538357896744.883760356139; Tue, 27 Jan 2026 10:25:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknl5-0004cZ-4P; Tue, 27 Jan 2026 13:25:47 -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 1vknl0-0004ax-WA for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:25:44 -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 1vknkw-0002xF-DI for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:25:39 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-440-42LLiUtXN5GhjdQ4sGzL4g-1; Tue, 27 Jan 2026 13:25:34 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3AB2D18005B0; Tue, 27 Jan 2026 18:25:33 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DD52419560B2; Tue, 27 Jan 2026 18:25:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538337; 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=OHcNbZBbdFqS4bgJPI6TG4KnB1h9E9YaTOVkHKy7n30=; b=Qjuwu7YRUrYx3ZVW/Rbs6bAjrpty76GwXMHIZUcLVr3cICcwStmvTrUz/ZVjq3bSpH2ZXL HxKQ7rCFNtfUDSubFMghkU8wlGHYsUUKk5nzb0WOHYRoFDzH5nvsA7jITGj5cMEBF18eA2 phB73ZWcuJwetUdqmoTMlyZhuMsbfD0= X-MC-Unique: 42LLiUtXN5GhjdQ4sGzL4g-1 X-Mimecast-MFC-AGG-ID: 42LLiUtXN5GhjdQ4sGzL4g_1769538333 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 02/43] audio/spice: convert to QOM lifecycle methods Date: Tue, 27 Jan 2026 22:24:29 +0400 Message-ID: <20260127182516.289834-3-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.12 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538360892154100 From: Marc-Andr=C3=A9 Lureau Migrate the SPICE audio backend from the legacy driver init/fini callbacks to proper QOM realize method. The spice_audio_init() function is replaced with spice_audio_realize(), which validates that SPICE is enabled before delegating to the parent class realize method. The empty spice_audio_fini() is removed as no cleanup is needed. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/spiceaudio.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index db9158284ce..b72424055c0 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -33,16 +33,33 @@ #define TYPE_AUDIO_SPICE "audio-spice" OBJECT_DECLARE_SIMPLE_TYPE(AudioSpice, AUDIO_SPICE) =20 +static AudioBackendClass *audio_spice_parent_class; + struct AudioSpice { AudioMixengBackend parent; }; =20 static struct audio_driver spice_audio_driver; =20 +static bool spice_audio_realize(AudioBackend *abe, Audiodev *dev, Error **= errp) +{ + if (!using_spice) { + error_setg(errp, "Cannot use spice audio without -spice"); + qapi_free_Audiodev(dev); + return false; + } + + return audio_spice_parent_class->realize(abe, dev, errp); +} + static void audio_spice_class_init(ObjectClass *klass, const void *data) { + AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); =20 + audio_spice_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_pare= nt(klass)); + + b->realize =3D spice_audio_realize; k->driver =3D &spice_audio_driver; } =20 @@ -89,21 +106,6 @@ static const SpiceRecordInterface record_sif =3D { .base.minor_version =3D SPICE_INTERFACE_RECORD_MINOR, }; =20 -static void *spice_audio_init(Audiodev *dev, Error **errp) -{ - if (!using_spice) { - error_setg(errp, "Cannot use spice audio without -spice"); - return NULL; - } - - return &spice_audio_init; -} - -static void spice_audio_fini (void *opaque) -{ - /* nothing */ -} - /* playback */ =20 static int line_out_init(HWVoiceOut *hw, struct audsettings *as, @@ -333,8 +335,6 @@ static struct audio_pcm_ops audio_callbacks =3D { =20 static struct audio_driver spice_audio_driver =3D { .name =3D "spice", - .init =3D spice_audio_init, - .fini =3D spice_audio_fini, .pcm_ops =3D &audio_callbacks, .max_voices_out =3D 1, .max_voices_in =3D 1, --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538380; cv=none; d=zohomail.com; s=zohoarc; b=CRZu3Iu7GrsI+jRLIsCIPXaj+e2oTGhoYb5Viu1m1N+oKAzvGFtJhb7DDlAezyUrSS0uLPOXEBvQRvixMGFxyhZ1eUe0QJYQoZ9rMNqRx7LKU8ZTFAStzatqt8aEwj/QfbMhaim9RTPHW8uLsD+cKMouobGeq81u0UjYuk7QSSw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538380; 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=24qpWigG2GNSCQleCjAMvy9qyjCTVpZdRudo8IJcojA=; b=NnVAPGG+ldlCDUuHjv6CgOcG1o1IPTHKthB2L6/K5bbloDkmm3ocn/skSKs4o2xIJe9+f0b2ueI+t6taJKJv5o3kVq7udMDdSaOF/AAzZUQlqT73vYpgizdU41IMxiVH6kLL1Zz6ggH8LgU95Aw+e8d1zQyZxNy3gF/O2Fvgeic= 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 1769538380921320.26811046058083; Tue, 27 Jan 2026 10:26:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknlT-0004pa-1f; Tue, 27 Jan 2026 13:26:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vknl4-0004cK-UR for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:25: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 1vknl2-0002zb-75 for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:25:45 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-160-4drjPHfIOx-VZpJRH4h2Gg-1; Tue, 27 Jan 2026 13:25:39 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 12FF718002C2; Tue, 27 Jan 2026 18:25:39 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A6AE51800665; Tue, 27 Jan 2026 18:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538343; 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=24qpWigG2GNSCQleCjAMvy9qyjCTVpZdRudo8IJcojA=; b=Zx8VMqnkzOLc3SBs1FbDkFcxdoWaX/3MihxND3a0W0t55JNok5Ey4fc1i3EO/PvmV36vho vj0R7mPuEd+kuS4BxZ+7jjNtzxNwIN7P/Le49+fSYj6Y81AFwVP729GiAYhlhrwV6ccL3k b0vYTUElC0BPob1xpltBC25riJwsJd8= X-MC-Unique: 4drjPHfIOx-VZpJRH4h2Gg-1 X-Mimecast-MFC-AGG-ID: 4drjPHfIOx-VZpJRH4h2Gg_1769538339 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 03/43] audio/wav: convert to QOM lifecycle methods Date: Tue, 27 Jan 2026 22:24:30 +0400 Message-ID: <20260127182516.289834-4-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538382862158500 From: Marc-Andr=C3=A9 Lureau Remove the legacy driver init/fini callbacks from the WAV audio backend. The wav_audio_init() just returned the Audiodev pointer and wav_audio_fini() only logged a debug message. Access to the Audiodev is now through hw->s->dev instead of the drv_opaque pointer. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/wavaudio.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 50b0fb93936..2a7703831f3 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -89,7 +89,7 @@ static int wav_init_out(HWVoiceOut *hw, struct audsetting= s *as, 0x02, 0x00, 0x44, 0xac, 0x00, 0x00, 0x10, 0xb1, 0x02, 0x00, 0x04, 0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x00 }; - Audiodev *dev =3D drv_opaque; + Audiodev *dev =3D hw->s->dev; AudiodevWavOptions *wopts =3D &dev->u.wav; struct audsettings wav_as =3D audiodev_to_audsettings(dev->u.wav.out); const char *wav_path =3D wopts->path ?: "qemu.wav"; @@ -200,17 +200,6 @@ static void wav_enable_out(HWVoiceOut *hw, bool enable) } } =20 -static void *wav_audio_init(Audiodev *dev, Error **errp) -{ - assert(dev->driver =3D=3D AUDIODEV_DRIVER_WAV); - return dev; -} - -static void wav_audio_fini (void *opaque) -{ - ldebug ("wav_fini"); -} - static struct audio_pcm_ops wav_pcm_ops =3D { .init_out =3D wav_init_out, .fini_out =3D wav_fini_out, @@ -222,8 +211,6 @@ static struct audio_pcm_ops wav_pcm_ops =3D { =20 static struct audio_driver wav_audio_driver =3D { .name =3D "wav", - .init =3D wav_audio_init, - .fini =3D wav_audio_fini, .pcm_ops =3D &wav_pcm_ops, .max_voices_out =3D 1, .max_voices_in =3D 0, --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538403; cv=none; d=zohomail.com; s=zohoarc; b=B5FQXiKp5MeyHteiGrFfEv2ficNue1ltSL1K4ejRxqBGuGPEt4yH/h3TXZrILzwBP6CmpWrHEVEKtLkupQ8GKyo83QYLF1OAUVYysa8oBMcQBhdFQI7QthdrNJ/NyCos6a/JeELCBsXjnJSsQIX4qNPO8fTkv+e4GByZ/X8oJIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538403; 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=Jke7ivabbc+2yet1zoG3ZgVnhEvUNQkOHIhPsJWfMPU=; b=YXbIexzEhHp2W8CispE0q2hn4jb9f5iKUw+Rbs+z0KTqJZqj9Bj+IQS5mLram9NMPJ/Q3Qrvm0a7WL6b19Nbh01kucqbf0125AmOY+27DfBwxjaauou07rCY2idZTHvnbC+oMWrVgrLw84Xgj75qiqJRSkieiEAC/MyAVOwLoHw= 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 176953840329555.49417211102036; Tue, 27 Jan 2026 10:26:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknlY-0004uJ-7D; Tue, 27 Jan 2026 13:26: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 1vknl8-0004dP-MD for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:25:53 -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 1vknl6-00035U-OU for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:25:49 -0500 Received: from mx-prod-mc-05.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-524-WkPFKr2FNy6qgDveHKHefg-1; Tue, 27 Jan 2026 13:25:46 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A439119775E8; Tue, 27 Jan 2026 18:25:45 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 97E4830001A2; Tue, 27 Jan 2026 18:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538348; 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=Jke7ivabbc+2yet1zoG3ZgVnhEvUNQkOHIhPsJWfMPU=; b=WD5mKWzn7AaBam7XMl2mGPz+Si2abyn6FEn+pkNXrepAZ4PrfE29ikxOYq+ngQ0sDsBqeZ SBNq9VjE8UH71kXSQvSGCp6W2fbIZFVGJjNT3wZElUHF54BFyI/6coXNmXyIw9wQ9pgb/r la0T8rMIXYDej85tFZBaZfHAM9WgOHs= X-MC-Unique: WkPFKr2FNy6qgDveHKHefg-1 X-Mimecast-MFC-AGG-ID: WkPFKr2FNy6qgDveHKHefg_1769538345 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 04/43] audio/noaudio: convert to QOM lifecycle methods Date: Tue, 27 Jan 2026 22:24:31 +0400 Message-ID: <20260127182516.289834-5-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.4.1 on 10.30.177.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+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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538405628154100 From: Marc-Andr=C3=A9 Lureau Remove the legacy driver init/fini callbacks from the null audio backend. Both no_audio_init() and no_audio_fini() were no-ops that performed no real initialization or cleanup work. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/noaudio.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/audio/noaudio.c b/audio/noaudio.c index fe649523e88..fd032ee6e09 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -119,16 +119,6 @@ static void no_enable_in(HWVoiceIn *hw, bool enable) } } =20 -static void *no_audio_init(Audiodev *dev, Error **errp) -{ - return &no_audio_init; -} - -static void no_audio_fini (void *opaque) -{ - (void) opaque; -} - static struct audio_pcm_ops no_pcm_ops =3D { .init_out =3D no_init_out, .fini_out =3D no_fini_out, @@ -146,8 +136,6 @@ static struct audio_pcm_ops no_pcm_ops =3D { =20 static struct audio_driver no_audio_driver =3D { .name =3D "none", - .init =3D no_audio_init, - .fini =3D no_audio_fini, .pcm_ops =3D &no_pcm_ops, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538446; cv=none; d=zohomail.com; s=zohoarc; b=gWgaHjKt5HdsOwSOOWcb3Rrp7dyTUW4yjXiG8t/8rjaeyLViv0SxQKKELnr4fNMrnfOvgHL/kCq2biZV83vnaGhDgDltCTmOb4VYlBo09RhiGsSYfdxr2ZTpQMBDNK7T/XufKdU5Kym1dwC3RWlvphUeWg5NqR37+FkEHRQZL60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538446; 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=/cZUKddlupLighI/o9Jsls2yq4HB9P8QKW//U1lf5uk=; b=iwD8papdMtOuxoB5DFTwTaDqWCFPmATC7Xxk6YS8/9tDrjgIst5JOzoxvlClilU/A0H5E3YDxiF0zF+7if8my/hLZoYJO/l0v0ZR00m+Uw3hhmy2AADTRsDFl5q66bzEQ4RUQJJaQg9C0nWcVO2dQiC5ivx3KrXQh0pjGZ32VVo= 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 176953844676942.04419026262701; Tue, 27 Jan 2026 10:27:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknm7-0005UQ-Q5; Tue, 27 Jan 2026 13:26: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 1vknlH-0004iY-TV for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:00 -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 1vknlF-00039L-4g for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:25:58 -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-640-vRUVh-PoNIOM3u638rdw8A-1; Tue, 27 Jan 2026 13:25:53 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 D05A81944B10; Tue, 27 Jan 2026 18:25:51 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5D793195419A; Tue, 27 Jan 2026 18:25:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538356; 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=/cZUKddlupLighI/o9Jsls2yq4HB9P8QKW//U1lf5uk=; b=WnPBzovpwrlv5GpkCJiaf+3ByGsFgvVcNaxZBpwzKgcqyMajs94joCyZVw1wRP1W3S4y9S m0GzpgXJwGR4rFldX1ERsl1KYiepd07xhaYa4jfVsqG3/TtqbxfeWD8p9/w9rGE4hRvAPN SuUHGJUZaRg8XJYJPx9towPSOWZbazA= X-MC-Unique: vRUVh-PoNIOM3u638rdw8A-1 X-Mimecast-MFC-AGG-ID: vRUVh-PoNIOM3u638rdw8A_1769538352 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck Subject: [PATCH 05/43] audio/alsa: convert to QOM lifecycle methods Date: Tue, 27 Jan 2026 22:24:32 +0400 Message-ID: <20260127182516.289834-6-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.17 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538449110158500 From: Marc-Andr=C3=A9 Lureau Migrate the ALSA audio backend from the legacy driver init/fini callbacks to proper QOM realize method. The alsa_audio_init() function is replaced with audio_alsa_realize(), which performs the same ALSA option initialization before delegating to the parent class realize method. The empty alsa_audio_fini() is removed. The Audiodev pointer stored in ALSAVoiceOut and ALSAVoiceIn is removed as it can now be accessed through hw->s->dev. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/alsaaudio.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index e8541e1a2a3..42bfea2515d 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -40,19 +40,14 @@ #define TYPE_AUDIO_ALSA "audio-alsa" OBJECT_DECLARE_SIMPLE_TYPE(AudioALSA, AUDIO_ALSA) =20 +static AudioBackendClass *audio_alsa_parent_class; + struct AudioALSA { AudioMixengBackend parent; }; =20 static struct audio_driver alsa_audio_driver; =20 -static void audio_alsa_class_init(ObjectClass *klass, const void *data) -{ - AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); - - k->driver =3D &alsa_audio_driver; -} - struct pollhlp { snd_pcm_t *handle; struct pollfd *pfds; @@ -65,14 +60,12 @@ typedef struct ALSAVoiceOut { HWVoiceOut hw; snd_pcm_t *handle; struct pollhlp pollhlp; - Audiodev *dev; } ALSAVoiceOut; =20 typedef struct ALSAVoiceIn { HWVoiceIn hw; snd_pcm_t *handle; struct pollhlp pollhlp; - Audiodev *dev; } ALSAVoiceIn; =20 struct alsa_params_req { @@ -707,7 +700,7 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsett= ings *as, struct alsa_params_obt obt; snd_pcm_t *handle; struct audsettings obt_as; - Audiodev *dev =3D drv_opaque; + Audiodev *dev =3D hw->s->dev; =20 req.fmt =3D aud_to_alsafmt (as->fmt, as->endianness); req.freq =3D as->freq; @@ -727,7 +720,6 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsett= ings *as, =20 alsa->pollhlp.s =3D hw->s; alsa->handle =3D handle; - alsa->dev =3D dev; return 0; } =20 @@ -766,7 +758,7 @@ static int alsa_voice_ctl (snd_pcm_t *handle, const cha= r *typ, int ctl) static void alsa_enable_out(HWVoiceOut *hw, bool enable) { ALSAVoiceOut *alsa =3D (ALSAVoiceOut *) hw; - AudiodevAlsaPerDirectionOptions *apdo =3D alsa->dev->u.alsa.out; + AudiodevAlsaPerDirectionOptions *apdo =3D hw->s->dev->u.alsa.out; =20 if (enable) { bool poll_mode =3D apdo->try_poll; @@ -794,7 +786,7 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettin= gs *as, void *drv_opaque) struct alsa_params_obt obt; snd_pcm_t *handle; struct audsettings obt_as; - Audiodev *dev =3D drv_opaque; + Audiodev *dev =3D hw->s->dev; =20 req.fmt =3D aud_to_alsafmt (as->fmt, as->endianness); req.freq =3D as->freq; @@ -814,7 +806,6 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettin= gs *as, void *drv_opaque) =20 alsa->pollhlp.s =3D hw->s; alsa->handle =3D handle; - alsa->dev =3D dev; return 0; } =20 @@ -871,7 +862,7 @@ static size_t alsa_read(HWVoiceIn *hw, void *buf, size_= t len) static void alsa_enable_in(HWVoiceIn *hw, bool enable) { ALSAVoiceIn *alsa =3D (ALSAVoiceIn *) hw; - AudiodevAlsaPerDirectionOptions *apdo =3D alsa->dev->u.alsa.in; + AudiodevAlsaPerDirectionOptions *apdo =3D hw->s->dev->u.alsa.in; =20 if (enable) { bool poll_mode =3D apdo->try_poll; @@ -901,7 +892,8 @@ static void alsa_init_per_direction(AudiodevAlsaPerDire= ctionOptions *apdo) } } =20 -static void *alsa_audio_init(Audiodev *dev, Error **errp) +static bool +audio_alsa_realize(AudioBackend *abe, Audiodev *dev, Error **errp) { AudiodevAlsaOptions *aopts; assert(dev->driver =3D=3D AUDIODEV_DRIVER_ALSA); @@ -929,11 +921,7 @@ static void *alsa_audio_init(Audiodev *dev, Error **er= rp) dev->u.alsa.in->buffer_length =3D 92880; } =20 - return dev; -} - -static void alsa_audio_fini (void *opaque) -{ + return audio_alsa_parent_class->realize(abe, dev, errp); } =20 static struct audio_pcm_ops alsa_pcm_ops =3D { @@ -953,8 +941,6 @@ static struct audio_pcm_ops alsa_pcm_ops =3D { =20 static struct audio_driver alsa_audio_driver =3D { .name =3D "alsa", - .init =3D alsa_audio_init, - .fini =3D alsa_audio_fini, .pcm_ops =3D &alsa_pcm_ops, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, @@ -962,6 +948,17 @@ static struct audio_driver alsa_audio_driver =3D { .voice_size_in =3D sizeof (ALSAVoiceIn) }; =20 +static void audio_alsa_class_init(ObjectClass *klass, const void *data) +{ + AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + audio_alsa_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_paren= t(klass)); + + b->realize =3D audio_alsa_realize; + k->driver =3D &alsa_audio_driver; +} + static const TypeInfo audio_alsa_info =3D { .name =3D TYPE_AUDIO_ALSA, .parent =3D TYPE_AUDIO_MIXENG_BACKEND, --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538519; cv=none; d=zohomail.com; s=zohoarc; b=gWvXuw2j8ea+eqSmgeeQzteYK6brmblkZsw4U6mUnU7QlYuUyrEDxzCRExR163jEuZPsEFwKapQ5aQQvx1WzS/0VQGTocVv6a5LzFQBVyXlxL1o0JsYw938HBPcakE4F3hBHAsV1+Orm1DfVEvqN3rmCK7ahbXYlzYGqQKA0Beg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538519; 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=+LhYG95rMNfTV5nVAhsB5H02K12KrRQKkVDNuf0MyFM=; b=NJNG6nEU8QhJr5AjdJpJAS+OEUccepAZbT2i/nEFzergQfqvgftzARBV15CPPCARcPELqiu2llv9XGxG5tZfw0dmOsTYjYf3QwvcPp5XVpKy11yp3e4lUfRlCalxYwSiJwz5wnJ6qL5hYWFMbK5E8E9WTkA4Y42ofGe3dLYnuws= 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 1769538519530661.7464885740092; Tue, 27 Jan 2026 10:28:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknly-0005DZ-QV; Tue, 27 Jan 2026 13:26: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 1vknlL-0004jD-L8 for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26: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 1vknlI-00039c-Lb for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:01 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-684-NIfgcEMQNHeEebE-8z9Hyw-1; Tue, 27 Jan 2026 13:25:58 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 67A301800378; Tue, 27 Jan 2026 18:25:57 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 229E030001A2; Tue, 27 Jan 2026 18:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538359; 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=+LhYG95rMNfTV5nVAhsB5H02K12KrRQKkVDNuf0MyFM=; b=GWq8UlHCFFlQY+SKLq3xRpd8bF0aTc5iZvqz1tRyNRnVu8BP4JrXiyTK7sbr9Uh66KW53h 3RYYz3AxdS9AuWDbvp3VvIH4LS9Hn15/PPySXDsC+ah4Q7rlJFMNQFcdiTATX+FU0oh4TR BSEHgwp7paraSlKjUjz8wF+B2P+CxVY= X-MC-Unique: NIfgcEMQNHeEebE-8z9Hyw-1 X-Mimecast-MFC-AGG-ID: NIfgcEMQNHeEebE-8z9Hyw_1769538357 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 06/43] audio/oss: convert to QOM lifecycle methods Date: Tue, 27 Jan 2026 22:24:33 +0400 Message-ID: <20260127182516.289834-7-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.4.1 on 10.30.177.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+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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538521478158500 From: Marc-Andr=C3=A9 Lureau Migrate the OSS audio backend from the legacy driver init/fini callbacks to proper QOM realize method. The oss_audio_init() function is replaced with audio_oss_realize(), which performs the same device accessibility check before delegating to the parent class realize method. The empty oss_audio_fini() is removed. Access to the Audiodev is now through hw->s->dev instead of the drv_opaque pointer. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/ossaudio.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 013958e1344..e745149ca39 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -23,6 +23,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi-types-audio.h" #include #include #include "qemu/main-loop.h" @@ -39,19 +40,14 @@ #define TYPE_AUDIO_OSS "audio-oss" OBJECT_DECLARE_SIMPLE_TYPE(AudioOss, AUDIO_OSS) =20 +static AudioBackendClass *audio_oss_parent_class; + struct AudioOss { AudioMixengBackend parent; }; =20 static struct audio_driver oss_audio_driver; =20 -static void audio_oss_class_init(ObjectClass *klass, const void *data) -{ - AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); - - k->driver =3D &oss_audio_driver; -} - #if defined OSS_GETVERSION && defined SNDCTL_DSP_POLICY #define USE_DSP_POLICY #endif @@ -505,7 +501,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, int err; int fd; struct audsettings obt_as; - Audiodev *dev =3D drv_opaque; + Audiodev *dev =3D hw->s->dev; AudiodevOssOptions *oopts =3D &dev->u.oss; =20 oss->fd =3D -1; @@ -636,7 +632,7 @@ static int oss_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) int err; int fd; struct audsettings obt_as; - Audiodev *dev =3D drv_opaque; + Audiodev *dev =3D hw->s->dev; =20 oss->fd =3D -1; =20 @@ -737,7 +733,8 @@ static void oss_init_per_direction(AudiodevOssPerDirect= ionOptions *opdo) } } =20 -static void *oss_audio_init(Audiodev *dev, Error **errp) +static bool +audio_oss_realize(AudioBackend *abe, Audiodev *dev, Error **errp) { AudiodevOssOptions *oopts; assert(dev->driver =3D=3D AUDIODEV_DRIVER_OSS); @@ -748,17 +745,16 @@ static void *oss_audio_init(Audiodev *dev, Error **er= rp) =20 if (access(oopts->in->dev ?: "/dev/dsp", R_OK | W_OK) < 0) { error_setg_errno(errp, errno, "%s not accessible", oopts->in->dev = ?: "/dev/dsp"); + qapi_free_Audiodev(dev); return NULL; } if (access(oopts->out->dev ?: "/dev/dsp", R_OK | W_OK) < 0) { error_setg_errno(errp, errno, "%s not accessible", oopts->out->dev= ?: "/dev/dsp"); + qapi_free_Audiodev(dev); return NULL; } - return dev; -} =20 -static void oss_audio_fini (void *opaque) -{ + return audio_oss_parent_class->realize(abe, dev, errp); } =20 static struct audio_pcm_ops oss_pcm_ops =3D { @@ -780,8 +776,6 @@ static struct audio_pcm_ops oss_pcm_ops =3D { =20 static struct audio_driver oss_audio_driver =3D { .name =3D "oss", - .init =3D oss_audio_init, - .fini =3D oss_audio_fini, .pcm_ops =3D &oss_pcm_ops, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, @@ -789,6 +783,17 @@ static struct audio_driver oss_audio_driver =3D { .voice_size_in =3D sizeof (OSSVoiceIn) }; =20 +static void audio_oss_class_init(ObjectClass *klass, const void *data) +{ + AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + audio_oss_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_parent= (klass)); + + b->realize =3D audio_oss_realize; + k->driver =3D &oss_audio_driver; +} + static const TypeInfo audio_oss_info =3D { .name =3D TYPE_AUDIO_OSS, .parent =3D TYPE_AUDIO_MIXENG_BACKEND, --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538497; cv=none; d=zohomail.com; s=zohoarc; b=PuS25usQFSUb/0nspaGGldh5K1n84m4CqlFN0mj74ymWoX0r6Sqo5OFMPKVJbM0/GN1jViWgeFB6cbNU0XQFpBqydZHK8qIA4ZjYSkRdiHqXUMlB9m3TsD4tzuZJJyIV3AovcxVKX/4dhUvJSK4Ybp2wiJpqF481TPYIe/BB5IU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538497; 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=iUPKZYunnyjW69HX4kTg15VsTIbDDAfDvBNpFL58zUQ=; b=Es36Eph9UH89t6kjuITABoKfbkjUBoV03Dn0ecoUZ7cTqI2GsSTVpbbq9QzjsrKQuYYdpzbzqM/B8vz9UPZYvCLaZwUKj9r1Go1xjf4ZKcRgBrn5mJookKisqduw40EXE9daP9GZTjkWIfD1AEDwRAP9dLeoRuhmKapeRnxLxGM= 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 176953849745865.16014307806665; Tue, 27 Jan 2026 10:28:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknmH-0005pv-TZ; Tue, 27 Jan 2026 13:27: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 1vknlT-0004sG-RT for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:14 -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 1vknlR-0003AH-W7 for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:11 -0500 Received: from mx-prod-mc-05.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-59-QcVmLsMaONCS4MhkME7blg-1; Tue, 27 Jan 2026 13:26:04 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 338D519560AA; Tue, 27 Jan 2026 18:26:03 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 907911956095; Tue, 27 Jan 2026 18:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538369; 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=iUPKZYunnyjW69HX4kTg15VsTIbDDAfDvBNpFL58zUQ=; b=EjJEjdZ/P2MWV+M1KhjDT+SxaF3kmtKrH2+q/HtlmqCI77+Kw7DXsaRm9oavurz8V/Xmx2 7aZO1qtmBl9cqZibHjJ2OxIBhkai6oSQ1Gtiz+y49aKNdk+Bf9U/+oJ5FnOSOhQUAXk2ux HFdIf5EnbxU2Qa0bGk2UDg3oEyHvaeM= X-MC-Unique: QcVmLsMaONCS4MhkME7blg-1 X-Mimecast-MFC-AGG-ID: QcVmLsMaONCS4MhkME7blg_1769538363 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 07/43] audio/pa: convert to QOM lifecycle methods Date: Tue, 27 Jan 2026 22:24:34 +0400 Message-ID: <20260127182516.289834-8-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.17 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538499388158500 From: Marc-Andr=C3=A9 Lureau Migrate the PulseAudio backend from the legacy driver init/fini callbacks to proper QOM realize and finalize methods. The paaudio struct fields are now embedded directly in the AudioPa QOM object instead of being allocated separately as drv_opaque. This allows accessing the backend state through proper QOM type casting with AUDIO_PA() rather than casting drv_opaque pointers. The PulseAudio connection is now managed through the QOM lifecycle, with the connection reference acquired in realize and released in finalize. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/paaudio.c | 109 +++++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 52 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 941f75f25e8..8191b54468e 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -14,19 +14,10 @@ #define TYPE_AUDIO_PA "audio-pa" OBJECT_DECLARE_SIMPLE_TYPE(AudioPa, AUDIO_PA) =20 -struct AudioPa { - AudioMixengBackend parent; -}; +static AudioBackendClass *audio_pa_parent_class; =20 static struct audio_driver pa_audio_driver; =20 -static void audio_pa_class_init(ObjectClass *klass, const void *data) -{ - AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); - - k->driver =3D &pa_audio_driver; -} - typedef struct PAConnection { char *server; int refcount; @@ -36,18 +27,19 @@ typedef struct PAConnection { pa_context *context; } PAConnection; =20 -static QTAILQ_HEAD(PAConnectionHead, PAConnection) pa_conns =3D - QTAILQ_HEAD_INITIALIZER(pa_conns); +struct AudioPa { + AudioMixengBackend parent; =20 -typedef struct { - Audiodev *dev; PAConnection *conn; -} paaudio; +}; + +static QTAILQ_HEAD(PAConnectionHead, PAConnection) pa_conns =3D + QTAILQ_HEAD_INITIALIZER(pa_conns); =20 typedef struct { HWVoiceOut hw; pa_stream *stream; - paaudio *g; + AudioPa *g; } PAVoiceOut; =20 typedef struct { @@ -55,7 +47,7 @@ typedef struct { pa_stream *stream; const void *read_data; size_t read_length; - paaudio *g; + AudioPa *g; } PAVoiceIn; =20 static void qpa_conn_fini(PAConnection *c); @@ -529,23 +521,25 @@ fail: static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque) { + AudioMixengBackend *amb =3D hw->s; + AudioPa *apa =3D AUDIO_PA(amb); int error; pa_sample_spec ss; pa_buffer_attr ba; struct audsettings obt_as =3D *as; PAVoiceOut *pa =3D (PAVoiceOut *) hw; - paaudio *g =3D pa->g =3D drv_opaque; - AudiodevPaOptions *popts =3D &g->dev->u.pa; + AudiodevPaOptions *popts =3D &amb->dev->u.pa; AudiodevPaPerDirectionOptions *ppdo =3D popts->out; - PAConnection *c =3D g->conn; + PAConnection *c =3D apa->conn; =20 + pa->g =3D apa; ss.format =3D audfmt_to_pa (as->fmt, as->endianness); ss.channels =3D as->nchannels; ss.rate =3D as->freq; =20 ba.tlength =3D pa_usec_to_bytes(ppdo->latency, &ss); ba.minreq =3D pa_usec_to_bytes(MIN(ppdo->latency >> 2, - (g->dev->timer_period >> 2) * 3), &ss= ); + (amb->dev->timer_period >> 2) * 3), &= ss); ba.maxlength =3D -1; ba.prebuf =3D -1; =20 @@ -553,7 +547,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, =20 pa->stream =3D qpa_simple_new ( c, - ppdo->stream_name ?: g->dev->id, + ppdo->stream_name ?: amb->dev->id, PA_STREAM_PLAYBACK, ppdo->name, &ss, @@ -578,23 +572,25 @@ static int qpa_init_out(HWVoiceOut *hw, struct audset= tings *as, =20 static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_op= aque) { + AudioMixengBackend *amb =3D hw->s; + AudioPa *apa =3D AUDIO_PA(amb); int error; pa_sample_spec ss; pa_buffer_attr ba; struct audsettings obt_as =3D *as; PAVoiceIn *pa =3D (PAVoiceIn *) hw; - paaudio *g =3D pa->g =3D drv_opaque; - AudiodevPaOptions *popts =3D &g->dev->u.pa; + AudiodevPaOptions *popts =3D &amb->dev->u.pa; AudiodevPaPerDirectionOptions *ppdo =3D popts->in; - PAConnection *c =3D g->conn; + PAConnection *c =3D apa->conn; =20 + pa->g =3D apa; ss.format =3D audfmt_to_pa (as->fmt, as->endianness); ss.channels =3D as->nchannels; ss.rate =3D as->freq; =20 - ba.fragsize =3D pa_usec_to_bytes((g->dev->timer_period >> 1) * 3, &ss); + ba.fragsize =3D pa_usec_to_bytes((amb->dev->timer_period >> 1) * 3, &s= s); ba.maxlength =3D pa_usec_to_bytes( - MAX(ppdo->latency, g->dev->timer_period * 3), &ss); + MAX(ppdo->latency, amb->dev->timer_period * 3), &ss); ba.minreq =3D -1; ba.prebuf =3D -1; =20 @@ -602,7 +598,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) =20 pa->stream =3D qpa_simple_new ( c, - ppdo->stream_name ?: g->dev->id, + ppdo->stream_name ?: amb->dev->id, PA_STREAM_RECORD, ppdo->name, &ss, @@ -834,15 +830,20 @@ fail: return NULL; } =20 -static void *qpa_audio_init(Audiodev *dev, Error **errp) +static bool +audio_pa_realize(AudioBackend *abe, Audiodev *dev, Error **errp) { - paaudio *g; + AudioPa *apa =3D AUDIO_PA(abe); AudiodevPaOptions *popts =3D &dev->u.pa; const char *server; PAConnection *c; =20 assert(dev->driver =3D=3D AUDIODEV_DRIVER_PA); =20 + if (!audio_pa_parent_class->realize(abe, dev, errp)) { + return false; + } + if (!popts->server) { char pidfile[64]; char *runtime; @@ -851,42 +852,38 @@ static void *qpa_audio_init(Audiodev *dev, Error **er= rp) runtime =3D getenv("XDG_RUNTIME_DIR"); if (!runtime) { error_setg(errp, "XDG_RUNTIME_DIR not set"); - return NULL; + return false; } snprintf(pidfile, sizeof(pidfile), "%s/pulse/pid", runtime); if (stat(pidfile, &st) !=3D 0) { error_setg_errno(errp, errno, "could not stat pidfile %s", pid= file); - return NULL; + return false; } } =20 qpa_validate_per_direction_opts(dev, popts->in); qpa_validate_per_direction_opts(dev, popts->out); =20 - g =3D g_new0(paaudio, 1); server =3D popts->server; - - g->dev =3D dev; - QTAILQ_FOREACH(c, &pa_conns, list) { if (server =3D=3D NULL || c->server =3D=3D NULL ? server =3D=3D c->server : strcmp(server, c->server) =3D=3D 0) { - g->conn =3D c; + apa->conn =3D c; break; } } - if (!g->conn) { - g->conn =3D qpa_conn_init(server); + if (!apa->conn) { + apa->conn =3D qpa_conn_init(server); } - if (!g->conn) { - g_free(g); + if (!apa->conn) { error_setg(errp, "could not connect to PulseAudio server"); - return NULL; + return false; } =20 - ++g->conn->refcount; - return g; + ++apa->conn->refcount; + + return true; } =20 static void qpa_conn_fini(PAConnection *c) @@ -908,16 +905,14 @@ static void qpa_conn_fini(PAConnection *c) g_free(c); } =20 -static void qpa_audio_fini (void *opaque) +static void audio_pa_finalize(Object *obj) { - paaudio *g =3D opaque; - PAConnection *c =3D g->conn; + AudioPa *apa =3D AUDIO_PA(obj); + PAConnection *c =3D apa->conn; =20 - if (--c->refcount =3D=3D 0) { + if (c && --c->refcount =3D=3D 0) { qpa_conn_fini(c); } - - g_free(g); } =20 static struct audio_pcm_ops qpa_pcm_ops =3D { @@ -939,8 +934,6 @@ static struct audio_pcm_ops qpa_pcm_ops =3D { =20 static struct audio_driver pa_audio_driver =3D { .name =3D "pa", - .init =3D qpa_audio_init, - .fini =3D qpa_audio_fini, .pcm_ops =3D &qpa_pcm_ops, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, @@ -948,11 +941,23 @@ static struct audio_driver pa_audio_driver =3D { .voice_size_in =3D sizeof (PAVoiceIn), }; =20 +static void audio_pa_class_init(ObjectClass *klass, const void *data) +{ + AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + audio_pa_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_parent(= klass)); + + b->realize =3D audio_pa_realize; + k->driver =3D &pa_audio_driver; +} + static const TypeInfo audio_pa_info =3D { .name =3D TYPE_AUDIO_PA, .parent =3D TYPE_AUDIO_MIXENG_BACKEND, .instance_size =3D sizeof(AudioPa), .class_init =3D audio_pa_class_init, + .instance_finalize =3D audio_pa_finalize, }; =20 static void register_audio_pa(void) --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538422; cv=none; d=zohomail.com; s=zohoarc; b=Rvnno0OVuRDYdDJCXdBLum4p3Y9ovBx4WuNBmKxIUSfCvF8Bao6rHjRpboRXqbyENxUfNGFSYsVqbZ06LsxliirPKFwIXBlwBRlgMuKTGO3jiKjsvp8SwWbxUVyYmlv3NssOnF++jTH8fgqjymsFs57kwf7UlLjT3vY3xLr28aU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538422; 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=fS3T4O1PRrTwsu6XVAFDaMf2ISKjTmRlWlJh8Tm7cGQ=; b=CiaEP9VoxzTiqlKcgPdg9esZCXxTzLhmDyHZWq41pW4f/E2vnuVcd2JWonsi40m5j81nxJnJrWi/+UmxBIn5k2GWFBB6r74A6YGZrat4dXJVtXs/iqqdMo4ME/1TzS9adjvbaSqAxpKNBjpoA1HLUs7Fqi/bUKuNwoNYDRibzkk= 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 1769538422015344.4206227686285; Tue, 27 Jan 2026 10:27:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknlx-000596-3O; Tue, 27 Jan 2026 13:26:42 -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 1vknlY-0004uT-02 for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:16 -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 1vknlW-0003Ae-EJ for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:15 -0500 Received: from mx-prod-mc-05.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-683-doJ7yYmTM1izu4SzCCJ6UQ-1; Tue, 27 Jan 2026 13:26:10 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2E01A1956096; Tue, 27 Jan 2026 18:26:09 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8E71C1956095; Tue, 27 Jan 2026 18:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538373; 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=fS3T4O1PRrTwsu6XVAFDaMf2ISKjTmRlWlJh8Tm7cGQ=; b=DFZcrbOakeVCmFCyVbYbShU6rTHu6sqErben5iMk9XVCaiGGa7hyt+m1DeafmZYzmvwk6x ZyBxTneoqtzu6f1BTv2KzCisYq80Mc0tlTCeOpoa92RMd/qIZnnkSwTN9hYeQ8t/UPAs9A LmnRuDQrZSUad6DtWQD8QuFNQhVwocw= X-MC-Unique: doJ7yYmTM1izu4SzCCJ6UQ-1 X-Mimecast-MFC-AGG-ID: doJ7yYmTM1izu4SzCCJ6UQ_1769538369 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 08/43] audio/sdl: convert to QOM lifecycle methods Date: Tue, 27 Jan 2026 22:24:35 +0400 Message-ID: <20260127182516.289834-9-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.17 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538423451158500 From: Marc-Andr=C3=A9 Lureau Migrate the SDL audio backend from the legacy driver init/fini callbacks to proper QOM realize and finalize methods. The sdl_audio_init() function is replaced with audio_sdl_realize(), which initializes the SDL audio subsystem before delegating to the parent class realize method. The sdl_audio_fini() is replaced with audio_sdl_finalize() to properly clean up the SDL audio subsystem. Access to the Audiodev is now through hw->s->dev instead of the drv_opaque pointer. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/sdlaudio.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 1a5e3f8a969..aa3c0922199 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -44,19 +44,14 @@ #define TYPE_AUDIO_SDL "audio-sdl" OBJECT_DECLARE_SIMPLE_TYPE(AudioSdl, AUDIO_SDL) =20 +static AudioBackendClass *audio_sdl_parent_class; + struct AudioSdl { AudioMixengBackend parent; }; =20 static struct audio_driver sdl_audio_driver; =20 -static void audio_sdl_class_init(ObjectClass *klass, const void *data) -{ - AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); - - k->driver =3D &sdl_audio_driver; -} - typedef struct SDLVoiceOut { HWVoiceOut hw; int exit; @@ -356,7 +351,7 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, SDLVoiceOut *sdl =3D (SDLVoiceOut *)hw; SDL_AudioSpec req, obt; int err; - Audiodev *dev =3D drv_opaque; + Audiodev *dev =3D hw->s->dev; AudiodevSdlPerDirectionOptions *spdo =3D dev->u.sdl.out; struct audsettings obt_as; =20 @@ -412,7 +407,7 @@ static int sdl_init_in(HWVoiceIn *hw, audsettings *as, = void *drv_opaque) SDLVoiceIn *sdl =3D (SDLVoiceIn *)hw; SDL_AudioSpec req, obt; int err; - Audiodev *dev =3D drv_opaque; + Audiodev *dev =3D hw->s->dev; AudiodevSdlPerDirectionOptions *spdo =3D dev->u.sdl.in; struct audsettings obt_as; =20 @@ -459,19 +454,20 @@ static void sdl_enable_in(HWVoiceIn *hw, bool enable) SDL_PauseAudioDevice(sdl->devid, !enable); } =20 -static void *sdl_audio_init(Audiodev *dev, Error **errp) +static bool audio_sdl_realize(AudioBackend *abe, Audiodev *dev, Error **er= rp) { - if (SDL_InitSubSystem (SDL_INIT_AUDIO)) { + if (SDL_InitSubSystem(SDL_INIT_AUDIO)) { error_setg(errp, "SDL failed to initialize audio subsystem"); - return NULL; + qapi_free_Audiodev(dev); + return false; } =20 - return dev; + return audio_sdl_parent_class->realize(abe, dev, errp); } =20 -static void sdl_audio_fini (void *opaque) +static void audio_sdl_finalize(Object *obj) { - SDL_QuitSubSystem (SDL_INIT_AUDIO); + SDL_QuitSubSystem(SDL_INIT_AUDIO); } =20 static struct audio_pcm_ops sdl_pcm_ops =3D { @@ -499,8 +495,6 @@ static struct audio_pcm_ops sdl_pcm_ops =3D { =20 static struct audio_driver sdl_audio_driver =3D { .name =3D "sdl", - .init =3D sdl_audio_init, - .fini =3D sdl_audio_fini, .pcm_ops =3D &sdl_pcm_ops, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, @@ -508,11 +502,23 @@ static struct audio_driver sdl_audio_driver =3D { .voice_size_in =3D sizeof(SDLVoiceIn), }; =20 +static void audio_sdl_class_init(ObjectClass *klass, const void *data) +{ + AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + audio_sdl_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_parent= (klass)); + + b->realize =3D audio_sdl_realize; + k->driver =3D &sdl_audio_driver; +} + static const TypeInfo audio_sdl_info =3D { .name =3D TYPE_AUDIO_SDL, .parent =3D TYPE_AUDIO_MIXENG_BACKEND, .instance_size =3D sizeof(AudioSdl), .class_init =3D audio_sdl_class_init, + .instance_finalize =3D audio_sdl_finalize, }; =20 static void register_audio_sdl(void) --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538471; cv=none; d=zohomail.com; s=zohoarc; b=IIMcKEtno0vI9OuFsh9UxE9BSgEFH6psRXtV4Na7UK60m+ryh0GCZve0yCjtbitSQpc+4XXgebaaehfF1Ot6MYSS3jKLrnkxwidp6SVD0+A/1gtBs/Mn36J3ZEeQkIjRA2oOpUIjN6GRWLLo3PwozG6KMHPK51L1518BgxQ9Lps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538471; 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=APoRaYo9Exx/5FoFG2t8IvvAHsrxIzTAySQhFWOHYaA=; b=Sv/9rZfSox288/CAYzSTu3vyY6HqiyP7dMtiyeSRh0JfReEjc6O2llmBfFjzc1dulT7BHLTurnipHW1Dcy0lAxK5q/OzvdHTVfMAK+UMM8xq9e5jWQscndLJnKiOzGeEBeNNVdmxXbgo/9NT2MNHzDFuCLKctGnwtCDneXyn/YQ= 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 1769538471818528.5539384550564; Tue, 27 Jan 2026 10:27:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknmK-00062S-6E; Tue, 27 Jan 2026 13:27:04 -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 1vknlc-000500-Ox for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:24 -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 1vknla-0003Av-9k for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:20 -0500 Received: from mx-prod-mc-03.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-79-PgNZSBoxNRGtxeFrQ5QymA-1; Tue, 27 Jan 2026 13:26:15 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1BE4B19560B5; Tue, 27 Jan 2026 18:26:15 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A1CAB18004D8; Tue, 27 Jan 2026 18:26:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538377; 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=APoRaYo9Exx/5FoFG2t8IvvAHsrxIzTAySQhFWOHYaA=; b=dM2nMekZMXiLgJrpJIupraqsvSwcXiE6HWzsoNjqbD8gZuUQnz2wgNrSxi8pjHOCbs2U+q 53MabvqzmM7gkk+mZXXvTdvTrM0v0041e00D5r3yPlFFMO6NqZgKUZnNKcYoG0ysc9whus DiOJkhVQOgta1eG2qXtEqonEVWthppc= X-MC-Unique: PgNZSBoxNRGtxeFrQ5QymA-1 X-Mimecast-MFC-AGG-ID: PgNZSBoxNRGtxeFrQ5QymA_1769538375 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 09/43] audio/pw: convert to QOM lifecycle methods Date: Tue, 27 Jan 2026 22:24:36 +0400 Message-ID: <20260127182516.289834-10-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538472758154100 From: Marc-Andr=C3=A9 Lureau Migrate the PipeWire audio backend from the legacy driver init/fini callbacks to proper QOM realize and finalize methods. The pwaudio struct fields are now embedded directly in the AudioPw QOM object instead of being allocated separately as drv_opaque. This allows accessing the backend state through proper QOM type casting with AUDIO_PW() rather than casting drv_opaque pointers. The PipeWire thread loop and context are now managed through the QOM lifecycle, with initialization in realize and cleanup in finalize. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/pwaudio.c | 119 +++++++++++++++++++++++------------------------- 1 file changed, 58 insertions(+), 61 deletions(-) diff --git a/audio/pwaudio.c b/audio/pwaudio.c index ed48a9754fe..ddf5f2c70f7 100644 --- a/audio/pwaudio.c +++ b/audio/pwaudio.c @@ -31,36 +31,27 @@ #define TYPE_AUDIO_PW "audio-pipewire" OBJECT_DECLARE_SIMPLE_TYPE(AudioPw, AUDIO_PW) =20 +static AudioBackendClass *audio_pw_parent_class; + struct AudioPw { AudioMixengBackend parent; -}; =20 -static struct audio_driver pw_audio_driver; + struct pw_thread_loop *thread_loop; + struct pw_context *context; =20 -static void audio_pw_class_init(ObjectClass *klass, const void *data) -{ - AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + struct pw_core *core; + struct spa_hook core_listener; + int last_seq, pending_seq, error; +}; =20 - k->driver =3D &pw_audio_driver; -} +static struct audio_driver pw_audio_driver; =20 typedef struct pwvolume { uint32_t channels; float values[SPA_AUDIO_MAX_CHANNELS]; } pwvolume; =20 -typedef struct pwaudio { - Audiodev *dev; - struct pw_thread_loop *thread_loop; - struct pw_context *context; - - struct pw_core *core; - struct spa_hook core_listener; - int last_seq, pending_seq, error; -} pwaudio; - typedef struct PWVoice { - pwaudio *g; struct pw_stream *stream; struct spa_hook stream_listener; struct spa_audio_info_raw info; @@ -236,9 +227,9 @@ static const struct pw_stream_events playback_stream_ev= ents =3D { static size_t qpw_read(HWVoiceIn *hw, void *data, size_t len) { + AudioPw *c =3D AUDIO_PW(hw->s); PWVoiceIn *pw =3D (PWVoiceIn *) hw; PWVoice *v =3D &pw->v; - pwaudio *c =3D v->g; const char *error =3D NULL; size_t l; int32_t avail; @@ -273,9 +264,9 @@ done_unlock: =20 static size_t qpw_buffer_get_free(HWVoiceOut *hw) { + AudioPw *c =3D AUDIO_PW(hw->s); PWVoiceOut *pw =3D (PWVoiceOut *)hw; PWVoice *v =3D &pw->v; - pwaudio *c =3D v->g; const char *error =3D NULL; int32_t filled, avail; uint32_t index; @@ -298,9 +289,9 @@ done_unlock: static size_t qpw_write(HWVoiceOut *hw, void *data, size_t len) { + AudioPw *c =3D AUDIO_PW(hw->s); PWVoiceOut *pw =3D (PWVoiceOut *) hw; PWVoice *v =3D &pw->v; - pwaudio *c =3D v->g; const char *error =3D NULL; int32_t filled, avail; uint32_t index; @@ -434,7 +425,7 @@ pw_to_audfmt(enum spa_audio_format fmt, int *endianness, } =20 static int -qpw_stream_new(pwaudio *c, PWVoice *v, const char *stream_name, +qpw_stream_new(AudioPw *c, PWVoice *v, const char *stream_name, const char *name, enum spa_direction dir) { int res; @@ -452,8 +443,8 @@ qpw_stream_new(pwaudio *c, PWVoice *v, const char *stre= am_name, } =20 /* 75% of the timer period for faster updates */ - buf_samples =3D (uint64_t)v->g->dev->timer_period * v->info.rate - * 3 / 4 / 1000000; + buf_samples =3D (uint64_t)AUDIO_MIXENG_BACKEND(c)->dev->timer_period + * v->info.rate * 3 / 4 / 1000000; pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%" PRIu64 "/%u", buf_samples, v->info.rate); =20 @@ -535,11 +526,11 @@ qpw_set_position(uint32_t channels, uint32_t position= [SPA_AUDIO_MAX_CHANNELS]) static int qpw_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque) { + AudioPw *c =3D AUDIO_PW(hw->s); PWVoiceOut *pw =3D (PWVoiceOut *) hw; PWVoice *v =3D &pw->v; struct audsettings obt_as =3D *as; - pwaudio *c =3D v->g =3D drv_opaque; - AudiodevPipewireOptions *popts =3D &c->dev->u.pipewire; + AudiodevPipewireOptions *popts =3D &AUDIO_MIXENG_BACKEND(c)->dev->u.pi= pewire; AudiodevPipewirePerDirectionOptions *ppdo =3D popts->out; int r; =20 @@ -554,11 +545,11 @@ qpw_init_out(HWVoiceOut *hw, struct audsettings *as, = void *drv_opaque) pw_to_audfmt(v->info.format, &obt_as.endianness, &v->frame_size); v->frame_size *=3D as->nchannels; =20 - v->req =3D (uint64_t)c->dev->timer_period * v->info.rate + v->req =3D (uint64_t)AUDIO_MIXENG_BACKEND(c)->dev->timer_period * v->i= nfo.rate * 1 / 2 / 1000000 * v->frame_size; =20 /* call the function that creates a new stream for playback */ - r =3D qpw_stream_new(c, v, ppdo->stream_name ? : c->dev->id, + r =3D qpw_stream_new(c, v, ppdo->stream_name ?: AUDIO_MIXENG_BACKEND(c= )->dev->id, ppdo->name, SPA_DIRECTION_OUTPUT); if (r < 0) { pw_thread_loop_unlock(c->thread_loop); @@ -582,11 +573,11 @@ qpw_init_out(HWVoiceOut *hw, struct audsettings *as, = void *drv_opaque) static int qpw_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) { + AudioPw *c =3D AUDIO_PW(hw->s); PWVoiceIn *pw =3D (PWVoiceIn *) hw; PWVoice *v =3D &pw->v; struct audsettings obt_as =3D *as; - pwaudio *c =3D v->g =3D drv_opaque; - AudiodevPipewireOptions *popts =3D &c->dev->u.pipewire; + AudiodevPipewireOptions *popts =3D &AUDIO_MIXENG_BACKEND(c)->dev->u.pi= pewire; AudiodevPipewirePerDirectionOptions *ppdo =3D popts->in; int r; =20 @@ -602,7 +593,7 @@ qpw_init_in(HWVoiceIn *hw, struct audsettings *as, void= *drv_opaque) v->frame_size *=3D as->nchannels; =20 /* call the function that creates a new stream for recording */ - r =3D qpw_stream_new(c, v, ppdo->stream_name ? : c->dev->id, + r =3D qpw_stream_new(c, v, ppdo->stream_name ? : AUDIO_MIXENG_BACKEND(= c)->dev->id, ppdo->name, SPA_DIRECTION_INPUT); if (r < 0) { pw_thread_loop_unlock(c->thread_loop); @@ -621,10 +612,8 @@ qpw_init_in(HWVoiceIn *hw, struct audsettings *as, voi= d *drv_opaque) } =20 static void -qpw_voice_fini(PWVoice *v) +qpw_voice_fini(AudioPw *c, PWVoice *v) { - pwaudio *c =3D v->g; - if (!v->stream) { return; } @@ -637,19 +626,18 @@ qpw_voice_fini(PWVoice *v) static void qpw_fini_out(HWVoiceOut *hw) { - qpw_voice_fini(&PW_VOICE_OUT(hw)->v); + qpw_voice_fini(AUDIO_PW(hw->s), &PW_VOICE_OUT(hw)->v); } =20 static void qpw_fini_in(HWVoiceIn *hw) { - qpw_voice_fini(&PW_VOICE_IN(hw)->v); + qpw_voice_fini(AUDIO_PW(hw->s), &PW_VOICE_IN(hw)->v); } =20 static void -qpw_voice_set_enabled(PWVoice *v, bool enable) +qpw_voice_set_enabled(AudioPw *c, PWVoice *v, bool enable) { - pwaudio *c =3D v->g; pw_thread_loop_lock(c->thread_loop); pw_stream_set_active(v->stream, enable); pw_thread_loop_unlock(c->thread_loop); @@ -658,19 +646,18 @@ qpw_voice_set_enabled(PWVoice *v, bool enable) static void qpw_enable_out(HWVoiceOut *hw, bool enable) { - qpw_voice_set_enabled(&PW_VOICE_OUT(hw)->v, enable); + qpw_voice_set_enabled(AUDIO_PW(hw->s), &PW_VOICE_OUT(hw)->v, enable); } =20 static void qpw_enable_in(HWVoiceIn *hw, bool enable) { - qpw_voice_set_enabled(&PW_VOICE_IN(hw)->v, enable); + qpw_voice_set_enabled(AUDIO_PW(hw->s), &PW_VOICE_IN(hw)->v, enable); } =20 static void -qpw_voice_set_volume(PWVoice *v, Volume *vol) +qpw_voice_set_volume(AudioPw *c, PWVoice *v, Volume *vol) { - pwaudio *c =3D v->g; int i, ret; =20 pw_thread_loop_lock(c->thread_loop); @@ -693,16 +680,16 @@ qpw_voice_set_volume(PWVoice *v, Volume *vol) static void qpw_volume_out(HWVoiceOut *hw, Volume *vol) { - qpw_voice_set_volume(&PW_VOICE_OUT(hw)->v, vol); + qpw_voice_set_volume(AUDIO_PW(hw->s), &PW_VOICE_OUT(hw)->v, vol); } =20 static void qpw_volume_in(HWVoiceIn *hw, Volume *vol) { - qpw_voice_set_volume(&PW_VOICE_IN(hw)->v, vol); + qpw_voice_set_volume(AUDIO_PW(hw->s), &PW_VOICE_IN(hw)->v, vol); } =20 -static int wait_resync(pwaudio *pw) +static int wait_resync(AudioPw *pw) { int res; pw->pending_seq =3D pw_core_sync(pw->core, PW_ID_CORE, pw->pending_seq= ); @@ -725,7 +712,7 @@ static int wait_resync(pwaudio *pw) static void on_core_error(void *data, uint32_t id, int seq, int res, const char *messa= ge) { - pwaudio *pw =3D data; + AudioPw *pw =3D data; =20 error_report("error id:%u seq:%d res:%d (%s): %s", id, seq, res, spa_strerror(res), message); @@ -737,7 +724,7 @@ on_core_error(void *data, uint32_t id, int seq, int res= , const char *message) static void on_core_done(void *data, uint32_t id, int seq) { - pwaudio *pw =3D data; + AudioPw *pw =3D data; assert(id =3D=3D PW_ID_CORE); pw->last_seq =3D seq; if (pw->pending_seq =3D=3D seq) { @@ -752,17 +739,20 @@ static const struct pw_core_events core_events =3D { .error =3D on_core_error, }; =20 -static void * -qpw_audio_init(Audiodev *dev, Error **errp) +static bool +audio_pw_realize(AudioBackend *abe, Audiodev *dev, Error **errp) { - g_autofree pwaudio *pw =3D g_new0(pwaudio, 1); + AudioPw *pw =3D AUDIO_PW(abe); =20 assert(dev->driver =3D=3D AUDIODEV_DRIVER_PIPEWIRE); trace_pw_audio_init(); =20 + if (!audio_pw_parent_class->realize(abe, dev, errp)) { + return false; + } + pw_init(NULL, NULL); =20 - pw->dev =3D dev; pw->thread_loop =3D pw_thread_loop_new("PipeWire thread loop", NULL); if (pw->thread_loop =3D=3D NULL) { error_setg_errno(errp, errno, "Could not create PipeWire loop"); @@ -801,8 +791,7 @@ qpw_audio_init(Audiodev *dev, Error **errp) } =20 pw_thread_loop_unlock(pw->thread_loop); - - return g_steal_pointer(&pw); + return true; =20 fail: if (pw->thread_loop) { @@ -810,13 +799,13 @@ fail: } g_clear_pointer(&pw->context, pw_context_destroy); g_clear_pointer(&pw->thread_loop, pw_thread_loop_destroy); - return NULL; + return false; } =20 static void -qpw_audio_fini(void *opaque) +audio_pw_finalize(Object *obj) { - pwaudio *pw =3D opaque; + AudioPw *pw =3D AUDIO_PW(obj); =20 if (pw->thread_loop) { pw_thread_loop_stop(pw->thread_loop); @@ -831,9 +820,7 @@ qpw_audio_fini(void *opaque) if (pw->context) { pw_context_destroy(pw->context); } - pw_thread_loop_destroy(pw->thread_loop); - - g_free(pw); + g_clear_pointer(&pw->thread_loop, pw_thread_loop_destroy); } =20 static struct audio_pcm_ops qpw_pcm_ops =3D { @@ -855,8 +842,6 @@ static struct audio_pcm_ops qpw_pcm_ops =3D { =20 static struct audio_driver pw_audio_driver =3D { .name =3D "pipewire", - .init =3D qpw_audio_init, - .fini =3D qpw_audio_fini, .pcm_ops =3D &qpw_pcm_ops, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, @@ -864,11 +849,23 @@ static struct audio_driver pw_audio_driver =3D { .voice_size_in =3D sizeof(PWVoiceIn), }; =20 +static void audio_pw_class_init(ObjectClass *klass, const void *data) +{ + AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + audio_pw_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_parent(= klass)); + + b->realize =3D audio_pw_realize; + k->driver =3D &pw_audio_driver; +} + static const TypeInfo audio_pw_info =3D { .name =3D TYPE_AUDIO_PW, .parent =3D TYPE_AUDIO_MIXENG_BACKEND, .instance_size =3D sizeof(AudioPw), .class_init =3D audio_pw_class_init, + .instance_finalize =3D audio_pw_finalize, }; =20 static void --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538500; cv=none; d=zohomail.com; s=zohoarc; b=Bo3HiSRJB5NSVc4kTQeB3U4J2ugOn0tkym66XJx8NhF3HvB/Ke4vaifl0WyN3vUq9qUt+nQXfMGyeBo/fCk62t3mRG0aauWNowOi2yte8KNz5JE0W4ghbfqg8ySKhBEmC7QwkDIe0Kd2w1EmBbnUm/M2B7aNh/5jyrbEZsk6ea4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538500; 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=EdzwouDik6V/Awhn+E1/BRpujcFmP6BtpS6cpARtJ60=; b=AU52TFd8H7tsqVAM9o/zLGpU+YQPvSF7EVe/mV5wPXrVYNwOWR++TlPcnYyp8+ORGCCIv1dlzI+h0hcqQ7Dgg7D/FVMJrKccv4N3pM8mrLF2o7n2mfTJDfwSyVmE70rUbrhcOb4U1IkLAvEtnihL6h3rkGwIw9LMsNLHha/5HcE= 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 1769538500290175.49780474525926; Tue, 27 Jan 2026 10:28:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknmM-0006K8-Em; Tue, 27 Jan 2026 13:27: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 1vknlj-00058G-4w for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:32 -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 1vknlg-0003BS-Ca for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:26 -0500 Received: from mx-prod-mc-03.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-630-Jnqtci_lOkSKhFiu03IOBg-1; Tue, 27 Jan 2026 13:26:22 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E96761955D8E; Tue, 27 Jan 2026 18:26:20 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 89E3918007D2; Tue, 27 Jan 2026 18:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538383; 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=EdzwouDik6V/Awhn+E1/BRpujcFmP6BtpS6cpARtJ60=; b=DMIZRCKBZQi8lU2q3nfshlKiksVuh+sIzYWkjkhzjKxk4+omsjN3jOJ67WU5zExN+cIHZP g9vTyYHk/jPAUuqLwSXwCWdVXdoPGRCVbbFUAo+lnvr8K0r2sS7CCO1ZjJyvPkwHqaJv/Q /qNt0jqhVwEOTJrwobQv2CNY3PTclhk= X-MC-Unique: Jnqtci_lOkSKhFiu03IOBg-1 X-Mimecast-MFC-AGG-ID: Jnqtci_lOkSKhFiu03IOBg_1769538381 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck Subject: [PATCH 10/43] audio/jack: convert to QOM lifecycle methods Date: Tue, 27 Jan 2026 22:24:37 +0400 Message-ID: <20260127182516.289834-11-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538503419158500 From: Marc-Andr=C3=A9 Lureau Remove the legacy driver init/fini callbacks from the JACK audio backend. Both qjack_init() and qjack_fini() were no-ops that performed no real initialization or cleanup work. Access to the Audiodev is now through hw->s->dev instead of the drv_opaque pointer. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/jackaudio.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/audio/jackaudio.c b/audio/jackaudio.c index dc86724d28f..7fbc37ef4f2 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -44,13 +44,6 @@ struct AudioJack { =20 static struct audio_driver jack_driver; =20 -static void audio_jack_class_init(ObjectClass *klass, const void *data) -{ - AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); - - k->driver =3D &jack_driver; -} - struct QJack; =20 typedef enum QJackState { @@ -518,7 +511,7 @@ static int qjack_init_out(HWVoiceOut *hw, struct audset= tings *as, void *drv_opaque) { QJackOut *jo =3D (QJackOut *)hw; - Audiodev *dev =3D (Audiodev *)drv_opaque; + Audiodev *dev =3D hw->s->dev; =20 jo->c.out =3D true; jo->c.enabled =3D false; @@ -555,7 +548,7 @@ static int qjack_init_in(HWVoiceIn *hw, struct audsetti= ngs *as, void *drv_opaque) { QJackIn *ji =3D (QJackIn *)hw; - Audiodev *dev =3D (Audiodev *)drv_opaque; + Audiodev *dev =3D hw->s->dev; =20 ji->c.out =3D false; ji->c.enabled =3D false; @@ -662,16 +655,6 @@ static int qjack_thread_creator(jack_native_thread_t *= thread, } #endif =20 -static void *qjack_init(Audiodev *dev, Error **errp) -{ - assert(dev->driver =3D=3D AUDIODEV_DRIVER_JACK); - return dev; -} - -static void qjack_fini(void *opaque) -{ -} - static struct audio_pcm_ops jack_pcm_ops =3D { .init_out =3D qjack_init_out, .fini_out =3D qjack_fini_out, @@ -689,8 +672,6 @@ static struct audio_pcm_ops jack_pcm_ops =3D { =20 static struct audio_driver jack_driver =3D { .name =3D "jack", - .init =3D qjack_init, - .fini =3D qjack_fini, .pcm_ops =3D &jack_pcm_ops, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, @@ -708,6 +689,13 @@ static void qjack_info(const char *msg) dolog("I: %s\n", msg); } =20 +static void audio_jack_class_init(ObjectClass *klass, const void *data) +{ + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + k->driver =3D &jack_driver; +} + static const TypeInfo audio_jack_info =3D { .name =3D TYPE_AUDIO_JACK, .parent =3D TYPE_AUDIO_MIXENG_BACKEND, --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538424; cv=none; d=zohomail.com; s=zohoarc; b=mn/p6yWsFqxWs9JPlCxD36mztNyi22Ucp5a1kjGz8O6jAkJF/XJCU+7bv7ZiaUcWJ0we43Dr4ptLNGh3nCG0AxMAS16LCnZKgEjFv9o6ekei7HpD4ODWAVbyh0lu2qugAJsfVsp8U/N56K3fEXGXD61BGVpfRDm3dnAI0/h6bYs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538424; 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=09TL7tvh6lOv6CeNPlS0z5iL5YXibgmDP7u50Fd1/sY=; b=QRpT/jw43VFPZrk0UQ2vlklSKTM/ukZD3xHTtmo21EX6qqnO0djb8QWiihTLGCxguVyuNGBUaipb/utY/oHash/PuTtOsg9wqIdKNJimQBWyxWfaX6XgTrTPFhaIVhEx2xEzeHXI91lamzLNcmPJ1NMH+6WVe7gK8gz9krVon1s= 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 1769538424207817.0294146372804; Tue, 27 Jan 2026 10:27:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknmD-0005hj-Dy; Tue, 27 Jan 2026 13:26:57 -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 1vknln-00058r-TR for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:35 -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 1vknlm-0003By-Gj for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:31 -0500 Received: from mx-prod-mc-05.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-374-iSSYoTZ4MPqDQUvvHyd8_Q-1; Tue, 27 Jan 2026 13:26:28 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DB91319775A9; Tue, 27 Jan 2026 18:26:26 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 76A491800665; Tue, 27 Jan 2026 18:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538389; 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=09TL7tvh6lOv6CeNPlS0z5iL5YXibgmDP7u50Fd1/sY=; b=Nisuk0KRgaqufI5YsD2NQPxvd+6w7zov4eHzKyzSu7joX1DeaG/KQckBKRYRLfFq45ywyl KUJQOzTNwADNsS7qHHK9PANXRY3zy6/OqY/tCbcIJ3krcxROY+WbodvR0pulVl65Zo4Pmb iq1Y7bSs6dffymA1t1PoG9ohbfDz/X0= X-MC-Unique: iSSYoTZ4MPqDQUvvHyd8_Q-1 X-Mimecast-MFC-AGG-ID: iSSYoTZ4MPqDQUvvHyd8_Q_1769538387 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Alexandre Ratchov Subject: [PATCH 11/43] audio/sndio: convert to QOM lifecycle methods Date: Tue, 27 Jan 2026 22:24:38 +0400 Message-ID: <20260127182516.289834-12-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538426197154100 From: Marc-Andr=C3=A9 Lureau Remove the legacy driver init/fini callbacks from the sndio audio backend. Both sndio_audio_init() and sndio_audio_fini() were no-ops that performed no real initialization or cleanup work. Access to the Audiodev is now through hw->s->dev instead of the drv_opaque pointer. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/sndioaudio.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c index 2fa519e3eab..4c2acbcbb4b 100644 --- a/audio/sndioaudio.c +++ b/audio/sndioaudio.c @@ -499,7 +499,7 @@ static int sndio_init_out(HWVoiceOut *hw, struct audset= tings *as, void *opaque) { SndioVoice *self =3D (SndioVoice *) hw; =20 - if (sndio_init(self, as, SIO_PLAY, opaque) =3D=3D -1) { + if (sndio_init(self, as, SIO_PLAY, hw->s->dev) =3D=3D -1) { return -1; } =20 @@ -512,7 +512,7 @@ static int sndio_init_in(HWVoiceIn *hw, struct audsetti= ngs *as, void *opaque) { SndioVoice *self =3D (SndioVoice *) hw; =20 - if (sndio_init(self, as, SIO_REC, opaque) =3D=3D -1) { + if (sndio_init(self, as, SIO_REC, hw->s->dev) =3D=3D -1) { return -1; } =20 @@ -535,16 +535,6 @@ static void sndio_fini_in(HWVoiceIn *hw) sndio_fini(self); } =20 -static void *sndio_audio_init(Audiodev *dev, Error **errp) -{ - assert(dev->driver =3D=3D AUDIODEV_DRIVER_SNDIO); - return dev; -} - -static void sndio_audio_fini(void *opaque) -{ -} - static struct audio_pcm_ops sndio_pcm_ops =3D { .init_out =3D sndio_init_out, .fini_out =3D sndio_fini_out, @@ -563,8 +553,6 @@ static struct audio_pcm_ops sndio_pcm_ops =3D { =20 static struct audio_driver sndio_audio_driver =3D { .name =3D "sndio", - .init =3D sndio_audio_init, - .fini =3D sndio_audio_fini, .pcm_ops =3D &sndio_pcm_ops, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538473; cv=none; d=zohomail.com; s=zohoarc; b=iSFMSFRgzTMDqWGcYujQgO7cOLnIwSWqMF17jGaF61SxkRWybaQcLt7ceFVy7mSl+h4y3XM/2T/5p4JxLa/m7VOut8i8RigEWDIW7jLLZZ4GNRwl/s8a+1UOIhIgknEWeUguDoXQTYu48RexpuQ+r5gPNuU6aBle8TYNFjgYfUo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538473; 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=STon/K6FlcPtSAh2Iz0I8FBdGgDnZLn7bndBwNF3rXE=; b=ZME0iKBrnmYk9v0vzor9P33ckDjCY6XSYkZ6TDmBwaTrgOgAt9jH3mAfPX7bC3jPB1sAyf2RUpTVXDveuAo/NlMEIhsMCv4UgfNIRP4zwIIlSMHiICFU8qVVp+dMWk4a6PsvNW00XYsvLhaPnjWHMPeSXmAIYVH4KxYX5IQMmx8= 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 1769538473379926.8072961557959; Tue, 27 Jan 2026 10:27:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknmm-0006hk-AN; Tue, 27 Jan 2026 13:27:39 -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 1vknm1-0005N5-VP for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:48 -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 1vknm0-0003Ci-IY for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:45 -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-223-JS-3zxwaN9WW39juTvbE0Q-1; Tue, 27 Jan 2026 13:26:35 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 9554B1944F12; Tue, 27 Jan 2026 18:26:32 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 305861955F66; Tue, 27 Jan 2026 18:26:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538396; 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=STon/K6FlcPtSAh2Iz0I8FBdGgDnZLn7bndBwNF3rXE=; b=RSSku1xG4otMB2Oj6kr9BJILmML/75eYFtFK6LS5TXpxkfTglSlzTj4FP33a8zEbwRNrGI mK8kTStjePmqn3Oja3b+VmoILLgLaQ4Ed+4JK8JIWBpuceovT/Jc0ml25u3+8vzowvu6va q8omBnIoHvrUKW2Ww56+Jme9zAwpjJY= X-MC-Unique: JS-3zxwaN9WW39juTvbE0Q-1 X-Mimecast-MFC-AGG-ID: JS-3zxwaN9WW39juTvbE0Q_1769538393 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , Akihiko Odaki Subject: [PATCH 12/43] audio/coreaudio: convert to QOM lifecycle methods Date: Tue, 27 Jan 2026 22:24:39 +0400 Message-ID: <20260127182516.289834-13-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.12 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538475573158500 From: Marc-Andr=C3=A9 Lureau Remove the legacy driver init/fini callbacks from the CoreAudio backend. Both coreaudio_audio_init() and coreaudio_audio_fini() were no-ops that performed no real initialization or cleanup work. Access to the Audiodev is now through hw->s->dev instead of the drv_opaque pointer. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki --- audio/coreaudio.m | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/audio/coreaudio.m b/audio/coreaudio.m index 710ef0fe6ba..4ab2abfc6f7 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -579,7 +579,7 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct au= dsettings *as, OSStatus status; coreaudioVoiceOut *core =3D (coreaudioVoiceOut *) hw; int err; - Audiodev *dev =3D drv_opaque; + Audiodev *dev =3D hw->s->dev; AudiodevCoreaudioPerDirectionOptions *cpdo =3D dev->u.coreaudio.out; struct audsettings obt_as; =20 @@ -656,15 +656,6 @@ static void coreaudio_enable_out(HWVoiceOut *hw, bool = enable) update_device_playback_state(core); } =20 -static void *coreaudio_audio_init(Audiodev *dev, Error **errp) -{ - return dev; -} - -static void coreaudio_audio_fini (void *opaque) -{ -} - static struct audio_pcm_ops coreaudio_pcm_ops =3D { .init_out =3D coreaudio_init_out, .fini_out =3D coreaudio_fini_out, @@ -681,8 +672,6 @@ static void coreaudio_audio_fini (void *opaque) =20 static struct audio_driver coreaudio_audio_driver =3D { .name =3D "coreaudio", - .init =3D coreaudio_audio_init, - .fini =3D coreaudio_audio_fini, .pcm_ops =3D &coreaudio_pcm_ops, .max_voices_out =3D 1, .max_voices_in =3D 0, --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538466; cv=none; d=zohomail.com; s=zohoarc; b=oJz6izHQqesSfMU2a0EhL03G6ZLbujX4FgZi6VE381UyGxSptDzridlS+KsdakjPqmY3n5gajpdG4aAQY341NvOlQl4tkrB45HfBSxisBdJ3oPLcpnBPZe4xzE5hDpvneArsAwkvaXUs3bN6nXGTH2W1dL8xYXNcE8kSYulKawk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538466; 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=Fs9pXiZt6pd+MQSmZMWOyuZI56C6GMSXThuXvAdIcFY=; b=Qq57t4+jG+bPYrMXcRIwrhMNziZ6Je2MFihIGYwoovSZc5QNMAA3slZWrxbmfdVmI2EtGPjEtsNY64K87b5PX1/5K6bJCwP7J/pwVKbSP2yJccuWC2svhC+2PgyCRb/EXBCAx1Y5dgZ64r1HSAucI9K9UitwkExafdT2NcuOeOE= 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 1769538466444664.8708754284698; Tue, 27 Jan 2026 10:27:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknmS-0006UA-A3; Tue, 27 Jan 2026 13:27: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 1vknm2-0005Nr-EF for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:48 -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 1vknm0-0003Cx-IT for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:46 -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-417-QdxnWZWvMUSKYT6F4gVXPg-1; Tue, 27 Jan 2026 13:26:39 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 59DA91944EB7; Tue, 27 Jan 2026 18:26:38 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BEAB218001D5; Tue, 27 Jan 2026 18:26:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538402; 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=Fs9pXiZt6pd+MQSmZMWOyuZI56C6GMSXThuXvAdIcFY=; b=hM1geX0+Xb1Om8ybPUEnuKQ4qrYDdAwHwA/8syDpdvzu3uuuFIZeql6W/WT/f10xQMwDgC rdN4nWhP9r6KMTnb7R+dYmjdxfoVelXxNWBvx/0x4YmVKk/bzXZWuvHPq1mMVHHzVbQDSR nUOMPtxWjDJAoV1urbvFlDDUoNUpOEY= X-MC-Unique: QdxnWZWvMUSKYT6F4gVXPg-1 X-Mimecast-MFC-AGG-ID: QdxnWZWvMUSKYT6F4gVXPg_1769538398 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 13/43] audio/dsound: convert to QOM lifecycle methods Date: Tue, 27 Jan 2026 22:24:40 +0400 Message-ID: <20260127182516.289834-14-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.4.1 on 10.30.177.111 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538468594154100 From: Marc-Andr=C3=A9 Lureau Migrate the DirectSound audio backend from the legacy driver init/fini callbacks to proper QOM realize and finalize methods. The dsound struct fields are now embedded directly in the AudioDsound QOM object instead of being allocated separately as drv_opaque. This allows accessing the backend state through proper QOM type casting with AUDIO_DSOUND() rather than casting drv_opaque pointers. The DirectSound and DirectSoundCapture COM objects are now managed through the QOM lifecycle, with initialization in realize and cleanup in finalize. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/dsound_template.h | 9 ++--- audio/dsoundaudio.c | 87 +++++++++++++++++++---------------------- 2 files changed, 45 insertions(+), 51 deletions(-) diff --git a/audio/dsound_template.h b/audio/dsound_template.h index 0678f2de38b..7979773eb86 100644 --- a/audio/dsound_template.h +++ b/audio/dsound_template.h @@ -72,7 +72,7 @@ static int glue (dsound_lock_, TYPE) ( DWORD *blen1p, DWORD *blen2p, int entire, - dsound *s + AudioDsound *s ) { HRESULT hr; @@ -166,7 +166,7 @@ static int dsound_init_out(HWVoiceOut *hw, struct audse= ttings *as, { int err; HRESULT hr; - dsound *s =3D drv_opaque; + AudioDsound *s =3D AUDIO_DSOUND(hw->s); WAVEFORMATEX wfx; struct audsettings obt_as; #ifdef DSBTYPE_IN @@ -174,13 +174,13 @@ static int dsound_init_out(HWVoiceOut *hw, struct aud= settings *as, DSoundVoiceIn *ds =3D (DSoundVoiceIn *) hw; DSCBUFFERDESC bd; DSCBCAPS bc; - AudiodevPerDirectionOptions *pdo =3D s->dev->u.dsound.in; + AudiodevPerDirectionOptions *pdo =3D hw->s->dev->u.dsound.in; #else const char *typ =3D "DAC"; DSoundVoiceOut *ds =3D (DSoundVoiceOut *) hw; DSBUFFERDESC bd; DSBCAPS bc; - AudiodevPerDirectionOptions *pdo =3D s->dev->u.dsound.out; + AudiodevPerDirectionOptions *pdo =3D hw->s->dev->u.dsound.out; #endif =20 if (!s->FIELD2) { @@ -256,7 +256,6 @@ static int dsound_init_out(HWVoiceOut *hw, struct audse= ttings *as, } hw->size_emul =3D bc.dwBufferBytes; hw->samples =3D bc.dwBufferBytes / hw->info.bytes_per_frame; - ds->s =3D s; =20 #ifdef DEBUG_DSOUND dolog ("caps %ld, desc %ld\n", diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 3de6a3dee9c..4ecf2ade003 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -45,40 +45,30 @@ #define TYPE_AUDIO_DSOUND "audio-dsound" OBJECT_DECLARE_SIMPLE_TYPE(AudioDsound, AUDIO_DSOUND) =20 +static AudioBackendClass *audio_dsound_parent_class; + struct AudioDsound { AudioMixengBackend parent; + + LPDIRECTSOUND dsound; + LPDIRECTSOUNDCAPTURE dsound_capture; + struct audsettings settings; }; =20 static struct audio_driver dsound_audio_driver; =20 -static void audio_dsound_class_init(ObjectClass *klass, const void *data) -{ - AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); - - k->driver =3D &dsound_audio_driver; -} - /* #define DEBUG_DSOUND */ =20 -typedef struct { - LPDIRECTSOUND dsound; - LPDIRECTSOUNDCAPTURE dsound_capture; - struct audsettings settings; - Audiodev *dev; -} dsound; - typedef struct { HWVoiceOut hw; LPDIRECTSOUNDBUFFER dsound_buffer; bool first_time; - dsound *s; } DSoundVoiceOut; =20 typedef struct { HWVoiceIn hw; LPDIRECTSOUNDCAPTUREBUFFER dsound_capture_buffer; bool first_time; - dsound *s; } DSoundVoiceIn; =20 static const char *dserror(HRESULT hr) @@ -276,7 +266,7 @@ static void print_wave_format (WAVEFORMATEX *wfx) } #endif =20 -static int dsound_restore_out (LPDIRECTSOUNDBUFFER dsb, dsound *s) +static int dsound_restore_out (LPDIRECTSOUNDBUFFER dsb, AudioDsound *s) { HRESULT hr; =20 @@ -295,7 +285,7 @@ static int dsound_restore_out (LPDIRECTSOUNDBUFFER dsb,= dsound *s) #undef DSBTYPE_IN =20 static int dsound_get_status_out (LPDIRECTSOUNDBUFFER dsb, DWORD *statusp, - dsound *s) + AudioDsound *s) { HRESULT hr; =20 @@ -328,7 +318,7 @@ static int dsound_get_status_in (LPDIRECTSOUNDCAPTUREBU= FFER dscb, } =20 static void dsound_clear_sample (HWVoiceOut *hw, LPDIRECTSOUNDBUFFER dsb, - dsound *s) + AudioDsound *s) { int err; LPVOID p1, p2; @@ -372,9 +362,9 @@ static void dsound_enable_out(HWVoiceOut *hw, bool enab= le) { HRESULT hr; DWORD status; + AudioDsound *s =3D AUDIO_DSOUND(hw->s); DSoundVoiceOut *ds =3D (DSoundVoiceOut *) hw; LPDIRECTSOUNDBUFFER dsb =3D ds->dsound_buffer; - dsound *s =3D ds->s; =20 if (!dsb) { dolog ("Attempt to control voice without a buffer\n"); @@ -450,7 +440,7 @@ static void *dsound_get_buffer_out(HWVoiceOut *hw, size= _t *size) assert(req_size > 0); =20 err =3D dsound_lock_out(dsb, &hw->info, hw->pos_emul, req_size, &ret, = NULL, - &act_size, NULL, false, ds->s); + &act_size, NULL, false, AUDIO_DSOUND(hw->s)); if (err) { dolog("Failed to lock buffer\n"); *size =3D 0; @@ -553,7 +543,7 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t= *size) } =20 err =3D dsound_lock_in(dscb, &hw->info, hw->pos_emul, req_size, &ret, = NULL, - &act_size, NULL, false, ds->s); + &act_size, NULL, false, AUDIO_DSOUND(hw->s)); if (err) { dolog("Failed to lock buffer\n"); *size =3D 0; @@ -577,13 +567,12 @@ static void dsound_put_buffer_in(HWVoiceIn *hw, void = *buf, size_t len) hw->pos_emul =3D (hw->pos_emul + len) % hw->size_emul; } =20 -static void dsound_audio_fini (void *opaque) +static void audio_dsound_finalize(Object *obj) { + AudioDsound *s =3D AUDIO_DSOUND(obj); HRESULT hr; - dsound *s =3D opaque; =20 if (!s->dsound) { - g_free(s); return; } =20 @@ -594,7 +583,6 @@ static void dsound_audio_fini (void *opaque) s->dsound =3D NULL; =20 if (!s->dsound_capture) { - g_free(s); return; } =20 @@ -603,18 +591,21 @@ static void dsound_audio_fini (void *opaque) dsound_logerr (hr, "Could not release DirectSoundCapture\n"); } s->dsound_capture =3D NULL; - - g_free(s); } =20 -static void *dsound_audio_init(Audiodev *dev, Error **errp) +static bool +audio_dsound_realize(AudioBackend *abe, Audiodev *dev, Error **errp) { + AudioDsound *s =3D AUDIO_DSOUND(abe); HRESULT hr; - dsound *s =3D g_new0(dsound, 1); AudiodevDsoundOptions *dso; =20 assert(dev->driver =3D=3D AUDIODEV_DRIVER_DSOUND); - s->dev =3D dev; + + if (!audio_dsound_parent_class->realize(abe, dev, errp)) { + return false; + } + dso =3D &dev->u.dsound; =20 if (!dso->has_latency) { @@ -625,8 +616,7 @@ static void *dsound_audio_init(Audiodev *dev, Error **e= rrp) hr =3D CoInitialize (NULL); if (FAILED (hr)) { dserror_set(errp, hr, "Could not initialize COM"); - dsound_audio_fini(s); - return NULL; + return false; } =20 hr =3D CoCreateInstance ( @@ -638,15 +628,13 @@ static void *dsound_audio_init(Audiodev *dev, Error *= *errp) ); if (FAILED (hr)) { dserror_set(errp, hr, "Could not create DirectSound instance"); - dsound_audio_fini(s); - return NULL; + return false; } =20 hr =3D IDirectSound_Initialize (s->dsound, NULL); if (FAILED (hr)) { dserror_set(errp, hr, "Could not initialize DirectSound"); - dsound_audio_fini(s); - return NULL; + return false; } =20 hr =3D CoCreateInstance ( @@ -658,15 +646,13 @@ static void *dsound_audio_init(Audiodev *dev, Error *= *errp) ); if (FAILED (hr)) { dserror_set(errp, hr, "Could not create DirectSoundCapture instanc= e"); - dsound_audio_fini(s); - return NULL; + return false; } =20 hr =3D IDirectSoundCapture_Initialize (s->dsound_capture, NULL); if (FAILED(hr)) { dserror_set(errp, hr, "Could not initialize DirectSoundCapture"); - dsound_audio_fini(s); - return NULL; + return false; } =20 hr =3D IDirectSound_SetCooperativeLevel ( @@ -676,11 +662,10 @@ static void *dsound_audio_init(Audiodev *dev, Error *= *errp) ); if (FAILED(hr)) { dserror_set(errp, hr, "Could not set cooperative level"); - dsound_audio_fini(s); - return NULL; + return false; } =20 - return s; + return true; } =20 static struct audio_pcm_ops dsound_pcm_ops =3D { @@ -702,8 +687,6 @@ static struct audio_pcm_ops dsound_pcm_ops =3D { =20 static struct audio_driver dsound_audio_driver =3D { .name =3D "dsound", - .init =3D dsound_audio_init, - .fini =3D dsound_audio_fini, .pcm_ops =3D &dsound_pcm_ops, .max_voices_out =3D INT_MAX, .max_voices_in =3D 1, @@ -711,11 +694,23 @@ static struct audio_driver dsound_audio_driver =3D { .voice_size_in =3D sizeof (DSoundVoiceIn) }; =20 +static void audio_dsound_class_init(ObjectClass *klass, const void *data) +{ + AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + audio_dsound_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_par= ent(klass)); + + b->realize =3D audio_dsound_realize; + k->driver =3D &dsound_audio_driver; +} + static const TypeInfo audio_dsound_info =3D { .name =3D TYPE_AUDIO_DSOUND, .parent =3D TYPE_AUDIO_MIXENG_BACKEND, .instance_size =3D sizeof(AudioDsound), .class_init =3D audio_dsound_class_init, + .instance_finalize =3D audio_dsound_finalize, }; =20 static void register_audio_dsound(void) --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538500; cv=none; d=zohomail.com; s=zohoarc; b=mdJZCJAnKr8hDaqo+lhcRWvQodsHZqvLNTGCnc2K+2rCXbaRxNrL86B5IGqLtLiXnoql4qa/kfIrfM2HohArGwlMZwAMKjX0gdMj1OIKEOKSBuQs3BE8CiCOyPsFcYyzR2iRI39pnXcD4pC/pfd2QjJpfzZ6tJh3ZJQ3+OEmUJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538500; 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=kyKmc102v21b6I9WW7W8KwGGxvCbroklvaSgfGJz8t8=; b=jXP+P7hdJoZExvMK9UC/spTfPwfllq9tgBvuoBhvp2DwW2718wmJaeHxFjozu5phBKZU0IzbZWE2kQ6g8LI4J2o64NrmHTk/TA7AUQ3dCVowlwT3bt1PMVP0sgcB+/0xubDQ7u/mme0Mdt/03q4XVVt3ty6Fr95rud1DlZe0bI8= 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 1769538500043364.43768804308127; Tue, 27 Jan 2026 10:28:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknmP-0006M7-Kl; Tue, 27 Jan 2026 13:27:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vknm7-0005Wl-Gm for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26: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 1vknm5-0003DO-4A for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:26:51 -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-607-9iMponq2MImPFLQ5xPk74g-1; Tue, 27 Jan 2026 13:26:46 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 CA5251944F2F; Tue, 27 Jan 2026 18:26:44 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DDA9219560B4; Tue, 27 Jan 2026 18:26:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538407; 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=kyKmc102v21b6I9WW7W8KwGGxvCbroklvaSgfGJz8t8=; b=B3g2nZhuez83KFlpSbN26KjuZJUGrTrwjtMQrOzxsmC+saD/40W0ohHosA8UwVOD6Atg3z /rmgc86wScUdUOgFZgxc63qpwyjRu6HndaRkTkUHCDDF5yKgiXfFanBI9v2wgkCuc/Akzz g6P2W/mqvj7DzsVywdAHcGk36xvFoc0= X-MC-Unique: 9iMponq2MImPFLQ5xPk74g-1 X-Mimecast-MFC-AGG-ID: 9iMponq2MImPFLQ5xPk74g_1769538404 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , Akihiko Odaki , Thomas Huth , Alexandre Ratchov Subject: [PATCH 14/43] audio: remove audio_driver init/fini/next Date: Tue, 27 Jan 2026 22:24:41 +0400 Message-ID: <20260127182516.289834-15-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.12 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538504072158500 From: Marc-Andr=C3=A9 Lureau They are no longer used after conversion to QOM. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki --- audio/audio_int.h | 8 ++------ audio/audio_template.h | 2 +- audio/dsound_template.h | 6 ++---- audio/alsaaudio.c | 5 ++--- audio/audio-mixeng-be.c | 15 +-------------- audio/dbusaudio.c | 4 ++-- audio/jackaudio.c | 6 ++---- audio/noaudio.c | 4 ++-- audio/ossaudio.c | 5 ++--- audio/paaudio.c | 5 ++--- audio/pwaudio.c | 4 ++-- audio/sdlaudio.c | 5 ++--- audio/sndioaudio.c | 4 ++-- audio/spiceaudio.c | 5 ++--- audio/wavaudio.c | 3 +-- audio/coreaudio.m | 3 +-- 16 files changed, 28 insertions(+), 56 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 6ecd75c4fbf..fb5a9dd871e 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -139,18 +139,15 @@ struct SWVoiceIn { typedef struct audio_driver audio_driver; struct audio_driver { const char *name; - void *(*init) (Audiodev *, Error **); - void (*fini) (void *); struct audio_pcm_ops *pcm_ops; int max_voices_out; int max_voices_in; size_t voice_size_out; size_t voice_size_in; - QLIST_ENTRY(audio_driver) next; }; =20 struct audio_pcm_ops { - int (*init_out)(HWVoiceOut *hw, audsettings *as, void *drv_opaque); + int (*init_out)(HWVoiceOut *hw, audsettings *as); void (*fini_out)(HWVoiceOut *hw); size_t (*write) (HWVoiceOut *hw, void *buf, size_t size); void (*run_buffer_out)(HWVoiceOut *hw); @@ -173,7 +170,7 @@ struct audio_pcm_ops { void (*enable_out)(HWVoiceOut *hw, bool enable); void (*volume_out)(HWVoiceOut *hw, Volume *vol); =20 - int (*init_in) (HWVoiceIn *hw, audsettings *as, void *drv_opaque); + int (*init_in) (HWVoiceIn *hw, audsettings *as); void (*fini_in) (HWVoiceIn *hw); size_t (*read) (HWVoiceIn *hw, void *buf, size_t size); void (*run_buffer_in)(HWVoiceIn *hw); @@ -240,7 +237,6 @@ struct AudioMixengBackend { =20 struct audio_driver *drv; Audiodev *dev; - void *drv_opaque; =20 QEMUTimer *ts; QLIST_HEAD (hw_in_listhead, HWVoiceIn) hw_head_in; diff --git a/audio/audio_template.h b/audio/audio_template.h index 77a70d6e56a..6c2d2ad5dca 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -295,7 +295,7 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMixen= gBackend *s, #ifdef DAC QLIST_INIT (&hw->cap_head); #endif - if (glue (hw->pcm_ops->init_, TYPE) (hw, as, s->drv_opaque)) { + if (glue (hw->pcm_ops->init_, TYPE) (hw, as)) { goto err0; } =20 diff --git a/audio/dsound_template.h b/audio/dsound_template.h index 7979773eb86..022a7307c99 100644 --- a/audio/dsound_template.h +++ b/audio/dsound_template.h @@ -157,11 +157,9 @@ static void dsound_fini_out (HWVoiceOut *hw) } =20 #ifdef DSBTYPE_IN -static int dsound_init_in(HWVoiceIn *hw, struct audsettings *as, - void *drv_opaque) +static int dsound_init_in(HWVoiceIn *hw, struct audsettings *as) #else -static int dsound_init_out(HWVoiceOut *hw, struct audsettings *as, - void *drv_opaque) +static int dsound_init_out(HWVoiceOut *hw, struct audsettings *as) #endif { int err; diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 42bfea2515d..0bb2ab5c462 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -692,8 +692,7 @@ static void alsa_fini_out (HWVoiceOut *hw) alsa_anal_close (&alsa->handle, &alsa->pollhlp); } =20 -static int alsa_init_out(HWVoiceOut *hw, struct audsettings *as, - void *drv_opaque) +static int alsa_init_out(HWVoiceOut *hw, struct audsettings *as) { ALSAVoiceOut *alsa =3D (ALSAVoiceOut *) hw; struct alsa_params_req req; @@ -779,7 +778,7 @@ static void alsa_enable_out(HWVoiceOut *hw, bool enable) } } =20 -static int alsa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_o= paque) +static int alsa_init_in(HWVoiceIn *hw, struct audsettings *as) { ALSAVoiceIn *alsa =3D (ALSAVoiceIn *) hw; struct alsa_params_req req; diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index c814a178f94..8024ca6bf9f 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -1521,13 +1521,6 @@ static bool audio_mixeng_backend_realize(AudioBacken= d *abe, audio_driver *drv =3D AUDIO_MIXENG_BACKEND_GET_CLASS(be)->driver; =20 be->dev =3D dev; - if (drv->init !=3D NULL) { - be->drv_opaque =3D drv->init(be->dev, errp); - if (!be->drv_opaque) { - return false; - } - } - if (!drv->pcm_ops->get_buffer_in) { drv->pcm_ops->get_buffer_in =3D audio_generic_get_buffer_in; drv->pcm_ops->put_buffer_in =3D audio_generic_put_buffer_in; @@ -1665,13 +1658,7 @@ static void audio_mixeng_backend_finalize(Object *ob= j) QLIST_REMOVE(hwi, entries); } =20 - if (s->drv) { - if (s->drv->fini) { - s->drv->fini (s->drv_opaque); - } - s->drv =3D NULL; - } - + s->drv =3D NULL; if (s->dev) { qapi_free_Audiodev(s->dev); s->dev =3D NULL; diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index b31bfd88d81..a69baad4aec 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -173,7 +173,7 @@ dbus_audio_get_nsamples(AudioDbus *da) } =20 static int -dbus_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque) +dbus_init_out(HWVoiceOut *hw, struct audsettings *as) { AudioDbus *da =3D AUDIO_DBUS(hw->s); DBusVoiceOut *vo =3D container_of(hw, DBusVoiceOut, hw); @@ -287,7 +287,7 @@ dbus_init_in_listener(QemuDBusDisplay1AudioInListener *= listener, HWVoiceIn *hw) } =20 static int -dbus_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) +dbus_init_in(HWVoiceIn *hw, struct audsettings *as) { AudioDbus *da =3D AUDIO_DBUS(hw->s); DBusVoiceIn *vo =3D container_of(hw, DBusVoiceIn, hw); diff --git a/audio/jackaudio.c b/audio/jackaudio.c index 7fbc37ef4f2..650ec230846 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -507,8 +507,7 @@ static int qjack_client_init(QJackClient *c) return 0; } =20 -static int qjack_init_out(HWVoiceOut *hw, struct audsettings *as, - void *drv_opaque) +static int qjack_init_out(HWVoiceOut *hw, struct audsettings *as) { QJackOut *jo =3D (QJackOut *)hw; Audiodev *dev =3D hw->s->dev; @@ -544,8 +543,7 @@ static int qjack_init_out(HWVoiceOut *hw, struct audset= tings *as, return 0; } =20 -static int qjack_init_in(HWVoiceIn *hw, struct audsettings *as, - void *drv_opaque) +static int qjack_init_in(HWVoiceIn *hw, struct audsettings *as) { QJackIn *ji =3D (QJackIn *)hw; Audiodev *dev =3D hw->s->dev; diff --git a/audio/noaudio.c b/audio/noaudio.c index fd032ee6e09..5c721ed69d0 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -62,7 +62,7 @@ static size_t no_write(HWVoiceOut *hw, void *buf, size_t = len) return audio_rate_get_bytes(&no->rate, &hw->info, len); } =20 -static int no_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_o= paque) +static int no_init_out(HWVoiceOut *hw, struct audsettings *as) { NoVoiceOut *no =3D (NoVoiceOut *) hw; =20 @@ -86,7 +86,7 @@ static void no_enable_out(HWVoiceOut *hw, bool enable) } } =20 -static int no_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opa= que) +static int no_init_in(HWVoiceIn *hw, struct audsettings *as) { NoVoiceIn *no =3D (NoVoiceIn *) hw; =20 diff --git a/audio/ossaudio.c b/audio/ossaudio.c index e745149ca39..a4ee6ee3327 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -493,8 +493,7 @@ static void oss_fini_out (HWVoiceOut *hw) } } =20 -static int oss_init_out(HWVoiceOut *hw, struct audsettings *as, - void *drv_opaque) +static int oss_init_out(HWVoiceOut *hw, struct audsettings *as) { OSSVoiceOut *oss =3D (OSSVoiceOut *) hw; struct oss_params req, obt; @@ -625,7 +624,7 @@ static void oss_enable_out(HWVoiceOut *hw, bool enable) } } =20 -static int oss_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_op= aque) +static int oss_init_in(HWVoiceIn *hw, struct audsettings *as) { OSSVoiceIn *oss =3D (OSSVoiceIn *) hw; struct oss_params req, obt; diff --git a/audio/paaudio.c b/audio/paaudio.c index 8191b54468e..4d77f341b5f 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -518,8 +518,7 @@ fail: return NULL; } =20 -static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as, - void *drv_opaque) +static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as) { AudioMixengBackend *amb =3D hw->s; AudioPa *apa =3D AUDIO_PA(amb); @@ -570,7 +569,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, return -1; } =20 -static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_op= aque) +static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as) { AudioMixengBackend *amb =3D hw->s; AudioPa *apa =3D AUDIO_PA(amb); diff --git a/audio/pwaudio.c b/audio/pwaudio.c index ddf5f2c70f7..c1cc945e659 100644 --- a/audio/pwaudio.c +++ b/audio/pwaudio.c @@ -524,7 +524,7 @@ qpw_set_position(uint32_t channels, uint32_t position[S= PA_AUDIO_MAX_CHANNELS]) } =20 static int -qpw_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque) +qpw_init_out(HWVoiceOut *hw, struct audsettings *as) { AudioPw *c =3D AUDIO_PW(hw->s); PWVoiceOut *pw =3D (PWVoiceOut *) hw; @@ -571,7 +571,7 @@ qpw_init_out(HWVoiceOut *hw, struct audsettings *as, vo= id *drv_opaque) } =20 static int -qpw_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) +qpw_init_in(HWVoiceIn *hw, struct audsettings *as) { AudioPw *c =3D AUDIO_PW(hw->s); PWVoiceIn *pw =3D (PWVoiceIn *) hw; diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index aa3c0922199..2e9bc255a41 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -345,8 +345,7 @@ static void sdl_fini_out(HWVoiceOut *hw) sdl_close_out(sdl); } =20 -static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as, - void *drv_opaque) +static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as) { SDLVoiceOut *sdl =3D (SDLVoiceOut *)hw; SDL_AudioSpec req, obt; @@ -402,7 +401,7 @@ static void sdl_fini_in(HWVoiceIn *hw) sdl_close_in(sdl); } =20 -static int sdl_init_in(HWVoiceIn *hw, audsettings *as, void *drv_opaque) +static int sdl_init_in(HWVoiceIn *hw, audsettings *as) { SDLVoiceIn *sdl =3D (SDLVoiceIn *)hw; SDL_AudioSpec req, obt; diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c index 4c2acbcbb4b..de2ee44fa0d 100644 --- a/audio/sndioaudio.c +++ b/audio/sndioaudio.c @@ -495,7 +495,7 @@ static void sndio_enable_in(HWVoiceIn *hw, bool enable) sndio_enable(self, enable); } =20 -static int sndio_init_out(HWVoiceOut *hw, struct audsettings *as, void *op= aque) +static int sndio_init_out(HWVoiceOut *hw, struct audsettings *as) { SndioVoice *self =3D (SndioVoice *) hw; =20 @@ -508,7 +508,7 @@ static int sndio_init_out(HWVoiceOut *hw, struct audset= tings *as, void *opaque) return 0; } =20 -static int sndio_init_in(HWVoiceIn *hw, struct audsettings *as, void *opaq= ue) +static int sndio_init_in(HWVoiceIn *hw, struct audsettings *as) { SndioVoice *self =3D (SndioVoice *) hw; =20 diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index b72424055c0..248249cef61 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -108,8 +108,7 @@ static const SpiceRecordInterface record_sif =3D { =20 /* playback */ =20 -static int line_out_init(HWVoiceOut *hw, struct audsettings *as, - void *drv_opaque) +static int line_out_init(HWVoiceOut *hw, struct audsettings *as) { SpiceVoiceOut *out =3D container_of (hw, SpiceVoiceOut, hw); struct audsettings settings; @@ -225,7 +224,7 @@ static void line_out_volume(HWVoiceOut *hw, Volume *vol) =20 /* record */ =20 -static int line_in_init(HWVoiceIn *hw, struct audsettings *as, void *drv_o= paque) +static int line_in_init(HWVoiceIn *hw, struct audsettings *as) { SpiceVoiceIn *in =3D container_of (hw, SpiceVoiceIn, hw); struct audsettings settings; diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 2a7703831f3..56b3122938f 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -78,8 +78,7 @@ static void le_store (uint8_t *buf, uint32_t val, int len) } } =20 -static int wav_init_out(HWVoiceOut *hw, struct audsettings *as, - void *drv_opaque) +static int wav_init_out(HWVoiceOut *hw, struct audsettings *as) { WAVVoiceOut *wav =3D (WAVVoiceOut *) hw; int bits16 =3D 0, stereo =3D 0; diff --git a/audio/coreaudio.m b/audio/coreaudio.m index 4ab2abfc6f7..925c68e8da4 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -573,8 +573,7 @@ static OSStatus handle_voice_change( return 0; } =20 -static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as, - void *drv_opaque) +static int coreaudio_init_out(HWVoiceOut *hw, struct audsettings *as) { OSStatus status; coreaudioVoiceOut *core =3D (coreaudioVoiceOut *) hw; --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538492; cv=none; d=zohomail.com; s=zohoarc; b=VizFFSqcsRdHsfoYynQ3I5qH+qDiKrMDqHqBq9xYDbxXCEFXNDn+oDQ44dyGEQl4WGVYG5GgUrgCQXvd3LJDMA3skCCZhtVCjhDxBOgvBYHryxFNwuSBQpHG7Dk+BuoZZwu/jm/LMgh1oAVRvXjm1ODCc/BW0NxPlAw0NVLASR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538492; 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=/Qic1FdQhHa0h2JtRQyexwhZTG/kOskRr4rtiSAfENA=; b=OWD7mX+FQt5+8xTiaaolWBUCKvR/iIrSBD4nYAao/waCbAq7FvPpHurTAzxsFjDnRs9BqUI1Co15eQl9h8d8HvPeBPDnX/lqnMhc6MY0ylkrW542+XuVyG1VjaMqYSrL4Re7CQzWUAyWVlX/fOKv4edbo+abWxEqpAZlMjNyAVo= 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 1769538492684874.8158774000184; Tue, 27 Jan 2026 10:28:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknmz-00079E-Fm; Tue, 27 Jan 2026 13:27: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 1vknmG-0005oO-Pm for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:01 -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 1vknmE-0003EU-12 for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:00 -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-33-UkL2cW4lOCeUwkE9T2TTnw-1; Tue, 27 Jan 2026 13:26:52 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 659991956054; Tue, 27 Jan 2026 18:26:51 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7114319560B2; Tue, 27 Jan 2026 18:26:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538417; 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=/Qic1FdQhHa0h2JtRQyexwhZTG/kOskRr4rtiSAfENA=; b=THnDZyXPC2KzulpmLE19wUKjtEBHk1WZxC/rUArV8WM2OJfw1qkKO4tyz1kJC0kTyKOJva 9hdeRhIULAhpu+xz/1eIzMvTD+ond55a3YoW2mp/Qfe1bGCgbWMKnhZTbUdvY35MRHIu1v LC+sqylPRE7lj7teU8HxjPKxl4192WQ= X-MC-Unique: UkL2cW4lOCeUwkE9T2TTnw-1 X-Mimecast-MFC-AGG-ID: UkL2cW4lOCeUwkE9T2TTnw_1769538411 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , Akihiko Odaki , Thomas Huth , Alexandre Ratchov Subject: [PATCH 15/43] audio: remove audio_driver Date: Tue, 27 Jan 2026 22:24:42 +0400 Message-ID: <20260127182516.289834-16-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.12 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538495670154100 From: Marc-Andr=C3=A9 Lureau Move all fields from audio_driver directly into AudioMixengBackendClass, eliminating an unnecessary extra struct. Drivers now set class fields directly in class_init instead of creating a static audio_driver instance. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki --- audio/audio_int.h | 18 +++++-------- audio/audio_template.h | 58 +++++++++++++++++++---------------------- audio/alsaaudio.c | 17 +++++------- audio/audio-mixeng-be.c | 20 +++++++------- audio/dbusaudio.c | 17 +++++------- audio/dsoundaudio.c | 17 +++++------- audio/jackaudio.c | 17 +++++------- audio/noaudio.c | 28 ++++++++------------ audio/ossaudio.c | 17 +++++------- audio/paaudio.c | 17 +++++------- audio/pwaudio.c | 17 +++++------- audio/sdlaudio.c | 17 +++++------- audio/sndioaudio.c | 27 ++++++++----------- audio/spiceaudio.c | 36 +++++++++++-------------- audio/wavaudio.c | 28 ++++++++------------ audio/coreaudio.m | 28 ++++++++------------ 16 files changed, 149 insertions(+), 230 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index fb5a9dd871e..bd9c7a29e41 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -136,16 +136,6 @@ struct SWVoiceIn { QLIST_ENTRY (SWVoiceIn) entries; }; =20 -typedef struct audio_driver audio_driver; -struct audio_driver { - const char *name; - struct audio_pcm_ops *pcm_ops; - int max_voices_out; - int max_voices_in; - size_t voice_size_out; - size_t voice_size_in; -}; - struct audio_pcm_ops { int (*init_out)(HWVoiceOut *hw, audsettings *as); void (*fini_out)(HWVoiceOut *hw); @@ -229,13 +219,17 @@ struct SWVoiceCap { struct AudioMixengBackendClass { AudioBackendClass parent_class; =20 - audio_driver *driver; + const char *name; + struct audio_pcm_ops *pcm_ops; + int max_voices_out; + int max_voices_in; + size_t voice_size_out; + size_t voice_size_in; }; =20 struct AudioMixengBackend { AudioBackend parent_obj; =20 - struct audio_driver *drv; Audiodev *dev; =20 QEMUTimer *ts; diff --git a/audio/audio_template.h b/audio/audio_template.h index 6c2d2ad5dca..7187571c668 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -37,41 +37,42 @@ #endif =20 static void glue(audio_init_nb_voices_, TYPE)(AudioMixengBackend *s, - struct audio_driver *drv, in= t min_voices) + AudioMixengBackendClass *k, + int min_voices) { - int max_voices =3D glue (drv->max_voices_, TYPE); - size_t voice_size =3D glue(drv->voice_size_, TYPE); + int max_voices =3D glue(k->max_voices_, TYPE); + size_t voice_size =3D glue(k->voice_size_, TYPE); =20 - glue (s->nb_hw_voices_, TYPE) =3D glue(audio_get_pdo_, TYPE)(s->dev)->= voices; - if (glue (s->nb_hw_voices_, TYPE) > max_voices) { + glue(s->nb_hw_voices_, TYPE) =3D glue(audio_get_pdo_, TYPE)(s->dev)->v= oices; + if (glue(s->nb_hw_voices_, TYPE) > max_voices) { if (!max_voices) { #ifdef DAC - dolog ("Driver `%s' does not support " NAME "\n", drv->name); + dolog("Driver `%s' does not support " NAME "\n", k->name); #endif } else { - dolog ("Driver `%s' does not support %d " NAME " voices, max %= d\n", - drv->name, - glue (s->nb_hw_voices_, TYPE), + dolog("Driver `%s' does not support %d " NAME " voices, max %d= \n", + k->name, + glue(s->nb_hw_voices_, TYPE), max_voices); } - glue (s->nb_hw_voices_, TYPE) =3D max_voices; + glue(s->nb_hw_voices_, TYPE) =3D max_voices; } =20 - if (glue (s->nb_hw_voices_, TYPE) < min_voices) { - dolog ("Bogus number of " NAME " voices %d, setting to %d\n", - glue (s->nb_hw_voices_, TYPE), + if (glue(s->nb_hw_voices_, TYPE) < min_voices) { + dolog("Bogus number of " NAME " voices %d, setting to %d\n", + glue(s->nb_hw_voices_, TYPE), min_voices); } =20 if (audio_bug(__func__, !voice_size && max_voices)) { - dolog ("drv=3D`%s' voice_size=3D0 max_voices=3D%d\n", - drv->name, max_voices); - glue (s->nb_hw_voices_, TYPE) =3D 0; + dolog("drv=3D`%s' voice_size=3D0 max_voices=3D%d\n", + 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", - drv->name, voice_size); + k->name, voice_size); } } =20 @@ -267,29 +268,24 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMix= engBackend *s, struct audsettings *as) { HW *hw; - struct audio_driver *drv =3D s->drv; + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(s); =20 - if (!glue (s->nb_hw_voices_, TYPE)) { + if (!glue(s->nb_hw_voices_, TYPE)) { return NULL; } =20 - if (audio_bug(__func__, !drv)) { - dolog ("No host audio driver\n"); - return NULL; - } - - if (audio_bug(__func__, !drv->pcm_ops)) { - dolog ("Host audio driver without pcm_ops\n"); + if (audio_bug(__func__, !k->pcm_ops)) { + dolog("No host audio driver or missing pcm_ops\n"); return NULL; } =20 /* - * Since glue(s->nb_hw_voices_, TYPE) is !=3D 0, glue(drv->voice_size_= , TYPE) + * Since glue(s->nb_hw_voices_, TYPE) is !=3D 0, glue(k->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 =3D g_malloc0(glue(k->voice_size_, TYPE)); hw->s =3D AUDIO_MIXENG_BACKEND(object_ref(s)); - hw->pcm_ops =3D drv->pcm_ops; + hw->pcm_ops =3D k->pcm_ops; =20 QLIST_INIT (&hw->sw_head); #ifdef DAC @@ -517,8 +513,8 @@ static SW *glue(audio_mixeng_backend_open_, TYPE) ( goto fail; } =20 - if (audio_bug(__func__, !s->drv)) { - dolog ("Can not open `%s' (no host audio driver)\n", name); + if (audio_bug(__func__, !AUDIO_MIXENG_BACKEND_GET_CLASS(s)->pcm_ops)) { + dolog("Can not open `%s' (no host audio driver)\n", name); goto fail; } =20 diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 0bb2ab5c462..a49da32cc4e 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -46,7 +46,6 @@ struct AudioALSA { AudioMixengBackend parent; }; =20 -static struct audio_driver alsa_audio_driver; =20 struct pollhlp { snd_pcm_t *handle; @@ -938,15 +937,6 @@ static struct audio_pcm_ops alsa_pcm_ops =3D { .enable_in =3D alsa_enable_in, }; =20 -static struct audio_driver alsa_audio_driver =3D { - .name =3D "alsa", - .pcm_ops =3D &alsa_pcm_ops, - .max_voices_out =3D INT_MAX, - .max_voices_in =3D INT_MAX, - .voice_size_out =3D sizeof (ALSAVoiceOut), - .voice_size_in =3D sizeof (ALSAVoiceIn) -}; - static void audio_alsa_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -955,7 +945,12 @@ static void audio_alsa_class_init(ObjectClass *klass, = const void *data) audio_alsa_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_paren= t(klass)); =20 b->realize =3D audio_alsa_realize; - k->driver =3D &alsa_audio_driver; + k->name =3D "alsa"; + k->pcm_ops =3D &alsa_pcm_ops; + k->max_voices_out =3D INT_MAX; + k->max_voices_in =3D INT_MAX; + k->voice_size_out =3D sizeof(ALSAVoiceOut); + k->voice_size_in =3D sizeof(ALSAVoiceIn); } =20 static const TypeInfo audio_alsa_info =3D { diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index 8024ca6bf9f..9d16fb5e654 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -1518,21 +1518,20 @@ static bool audio_mixeng_backend_realize(AudioBacke= nd *abe, Audiodev *dev, Error **errp) { AudioMixengBackend *be =3D AUDIO_MIXENG_BACKEND(abe); - audio_driver *drv =3D AUDIO_MIXENG_BACKEND_GET_CLASS(be)->driver; + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(be); =20 be->dev =3D dev; - if (!drv->pcm_ops->get_buffer_in) { - drv->pcm_ops->get_buffer_in =3D audio_generic_get_buffer_in; - drv->pcm_ops->put_buffer_in =3D audio_generic_put_buffer_in; + if (!k->pcm_ops->get_buffer_in) { + k->pcm_ops->get_buffer_in =3D audio_generic_get_buffer_in; + k->pcm_ops->put_buffer_in =3D audio_generic_put_buffer_in; } - if (!drv->pcm_ops->get_buffer_out) { - drv->pcm_ops->get_buffer_out =3D audio_generic_get_buffer_out; - drv->pcm_ops->put_buffer_out =3D audio_generic_put_buffer_out; + if (!k->pcm_ops->get_buffer_out) { + k->pcm_ops->get_buffer_out =3D audio_generic_get_buffer_out; + k->pcm_ops->put_buffer_out =3D audio_generic_put_buffer_out; } =20 - audio_init_nb_voices_out(be, drv, 1); - audio_init_nb_voices_in(be, drv, 0); - be->drv =3D drv; + audio_init_nb_voices_out(be, k, 1); + audio_init_nb_voices_in(be, k, 0); =20 if (be->dev->timer_period <=3D 0) { be->period_ticks =3D 1; @@ -1658,7 +1657,6 @@ static void audio_mixeng_backend_finalize(Object *obj) QLIST_REMOVE(hwi, entries); } =20 - s->drv =3D NULL; if (s->dev) { qapi_free_Audiodev(s->dev); s->dev =3D NULL; diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index a69baad4aec..d78d5799952 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -61,7 +61,6 @@ struct AudioDbus { GHashTable *in_listeners; }; =20 -static struct audio_driver dbus_audio_driver; =20 typedef struct DBusVoiceOut { HWVoiceOut hw; @@ -709,15 +708,6 @@ static struct audio_pcm_ops dbus_pcm_ops =3D { .volume_in =3D dbus_volume_in, }; =20 -static struct audio_driver dbus_audio_driver =3D { - .name =3D "dbus", - .pcm_ops =3D &dbus_pcm_ops, - .max_voices_out =3D INT_MAX, - .max_voices_in =3D INT_MAX, - .voice_size_out =3D sizeof(DBusVoiceOut), - .voice_size_in =3D sizeof(DBusVoiceIn) -}; - static void audio_dbus_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -727,7 +717,12 @@ static void audio_dbus_class_init(ObjectClass *klass, = const void *data) =20 b->realize =3D audio_dbus_realize; b->set_dbus_server =3D dbus_audio_set_server; - k->driver =3D &dbus_audio_driver; + k->name =3D "dbus"; + k->pcm_ops =3D &dbus_pcm_ops; + k->max_voices_out =3D INT_MAX; + k->max_voices_in =3D INT_MAX; + k->voice_size_out =3D sizeof(DBusVoiceOut); + k->voice_size_in =3D sizeof(DBusVoiceIn); } =20 static const TypeInfo audio_dbus_info =3D { diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 4ecf2ade003..b8bc6c8c7be 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -55,7 +55,6 @@ struct AudioDsound { struct audsettings settings; }; =20 -static struct audio_driver dsound_audio_driver; =20 /* #define DEBUG_DSOUND */ =20 @@ -685,15 +684,6 @@ static struct audio_pcm_ops dsound_pcm_ops =3D { .enable_in =3D dsound_enable_in, }; =20 -static struct audio_driver dsound_audio_driver =3D { - .name =3D "dsound", - .pcm_ops =3D &dsound_pcm_ops, - .max_voices_out =3D INT_MAX, - .max_voices_in =3D 1, - .voice_size_out =3D sizeof (DSoundVoiceOut), - .voice_size_in =3D sizeof (DSoundVoiceIn) -}; - static void audio_dsound_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -702,7 +692,12 @@ static void audio_dsound_class_init(ObjectClass *klass= , const void *data) audio_dsound_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_par= ent(klass)); =20 b->realize =3D audio_dsound_realize; - k->driver =3D &dsound_audio_driver; + k->name =3D "dsound"; + k->pcm_ops =3D &dsound_pcm_ops; + k->max_voices_out =3D INT_MAX; + k->max_voices_in =3D 1; + k->voice_size_out =3D sizeof(DSoundVoiceOut); + k->voice_size_in =3D sizeof(DSoundVoiceIn); } =20 static const TypeInfo audio_dsound_info =3D { diff --git a/audio/jackaudio.c b/audio/jackaudio.c index 650ec230846..e69b313afe5 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -42,7 +42,6 @@ struct AudioJack { AudioMixengBackend parent; }; =20 -static struct audio_driver jack_driver; =20 struct QJack; =20 @@ -668,15 +667,6 @@ static struct audio_pcm_ops jack_pcm_ops =3D { .enable_in =3D qjack_enable_in }; =20 -static struct audio_driver jack_driver =3D { - .name =3D "jack", - .pcm_ops =3D &jack_pcm_ops, - .max_voices_out =3D INT_MAX, - .max_voices_in =3D INT_MAX, - .voice_size_out =3D sizeof(QJackOut), - .voice_size_in =3D sizeof(QJackIn) -}; - static void qjack_error(const char *msg) { dolog("E: %s\n", msg); @@ -691,7 +681,12 @@ static void audio_jack_class_init(ObjectClass *klass, = const void *data) { AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); =20 - k->driver =3D &jack_driver; + k->name =3D "jack"; + k->pcm_ops =3D &jack_pcm_ops; + k->max_voices_out =3D INT_MAX; + k->max_voices_in =3D INT_MAX; + k->voice_size_out =3D sizeof(QJackOut); + k->voice_size_in =3D sizeof(QJackIn); } =20 static const TypeInfo audio_jack_info =3D { diff --git a/audio/noaudio.c b/audio/noaudio.c index 5c721ed69d0..d1fba117133 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -37,15 +37,6 @@ struct AudioNone { AudioMixengBackend parent; }; =20 -static struct audio_driver no_audio_driver; - -static void audio_none_class_init(ObjectClass *klass, const void *data) -{ - AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); - - k->driver =3D &no_audio_driver; -} - typedef struct NoVoiceOut { HWVoiceOut hw; RateCtl rate; @@ -134,14 +125,17 @@ static struct audio_pcm_ops no_pcm_ops =3D { .enable_in =3D no_enable_in }; =20 -static struct audio_driver no_audio_driver =3D { - .name =3D "none", - .pcm_ops =3D &no_pcm_ops, - .max_voices_out =3D INT_MAX, - .max_voices_in =3D INT_MAX, - .voice_size_out =3D sizeof (NoVoiceOut), - .voice_size_in =3D sizeof (NoVoiceIn) -}; +static void audio_none_class_init(ObjectClass *klass, const void *data) +{ + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + k->name =3D "none"; + k->pcm_ops =3D &no_pcm_ops; + k->max_voices_out =3D INT_MAX; + k->max_voices_in =3D INT_MAX; + k->voice_size_out =3D sizeof(NoVoiceOut); + k->voice_size_in =3D sizeof(NoVoiceIn); +} =20 static const TypeInfo audio_none_info =3D { .name =3D TYPE_AUDIO_NONE, diff --git a/audio/ossaudio.c b/audio/ossaudio.c index a4ee6ee3327..15fdf54eb3e 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -46,7 +46,6 @@ struct AudioOss { AudioMixengBackend parent; }; =20 -static struct audio_driver oss_audio_driver; =20 #if defined OSS_GETVERSION && defined SNDCTL_DSP_POLICY #define USE_DSP_POLICY @@ -773,15 +772,6 @@ static struct audio_pcm_ops oss_pcm_ops =3D { .enable_in =3D oss_enable_in }; =20 -static struct audio_driver oss_audio_driver =3D { - .name =3D "oss", - .pcm_ops =3D &oss_pcm_ops, - .max_voices_out =3D INT_MAX, - .max_voices_in =3D INT_MAX, - .voice_size_out =3D sizeof (OSSVoiceOut), - .voice_size_in =3D sizeof (OSSVoiceIn) -}; - static void audio_oss_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -790,7 +780,12 @@ static void audio_oss_class_init(ObjectClass *klass, c= onst void *data) audio_oss_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_parent= (klass)); =20 b->realize =3D audio_oss_realize; - k->driver =3D &oss_audio_driver; + k->name =3D "oss"; + k->pcm_ops =3D &oss_pcm_ops; + k->max_voices_out =3D INT_MAX; + k->max_voices_in =3D INT_MAX; + k->voice_size_out =3D sizeof(OSSVoiceOut); + k->voice_size_in =3D sizeof(OSSVoiceIn); } =20 static const TypeInfo audio_oss_info =3D { diff --git a/audio/paaudio.c b/audio/paaudio.c index 4d77f341b5f..056158755c6 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -16,7 +16,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(AudioPa, AUDIO_PA) =20 static AudioBackendClass *audio_pa_parent_class; =20 -static struct audio_driver pa_audio_driver; =20 typedef struct PAConnection { char *server; @@ -931,15 +930,6 @@ static struct audio_pcm_ops qpa_pcm_ops =3D { .volume_in =3D qpa_volume_in }; =20 -static struct audio_driver pa_audio_driver =3D { - .name =3D "pa", - .pcm_ops =3D &qpa_pcm_ops, - .max_voices_out =3D INT_MAX, - .max_voices_in =3D INT_MAX, - .voice_size_out =3D sizeof (PAVoiceOut), - .voice_size_in =3D sizeof (PAVoiceIn), -}; - static void audio_pa_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -948,7 +938,12 @@ static void audio_pa_class_init(ObjectClass *klass, co= nst void *data) audio_pa_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_parent(= klass)); =20 b->realize =3D audio_pa_realize; - k->driver =3D &pa_audio_driver; + k->name =3D "pa"; + k->pcm_ops =3D &qpa_pcm_ops; + k->max_voices_out =3D INT_MAX; + k->max_voices_in =3D INT_MAX; + k->voice_size_out =3D sizeof(PAVoiceOut); + k->voice_size_in =3D sizeof(PAVoiceIn); } =20 static const TypeInfo audio_pa_info =3D { diff --git a/audio/pwaudio.c b/audio/pwaudio.c index c1cc945e659..7cadf7121bb 100644 --- a/audio/pwaudio.c +++ b/audio/pwaudio.c @@ -44,7 +44,6 @@ struct AudioPw { int last_seq, pending_seq, error; }; =20 -static struct audio_driver pw_audio_driver; =20 typedef struct pwvolume { uint32_t channels; @@ -840,15 +839,6 @@ static struct audio_pcm_ops qpw_pcm_ops =3D { .enable_in =3D qpw_enable_in }; =20 -static struct audio_driver pw_audio_driver =3D { - .name =3D "pipewire", - .pcm_ops =3D &qpw_pcm_ops, - .max_voices_out =3D INT_MAX, - .max_voices_in =3D INT_MAX, - .voice_size_out =3D sizeof(PWVoiceOut), - .voice_size_in =3D sizeof(PWVoiceIn), -}; - static void audio_pw_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -857,7 +847,12 @@ static void audio_pw_class_init(ObjectClass *klass, co= nst void *data) audio_pw_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_parent(= klass)); =20 b->realize =3D audio_pw_realize; - k->driver =3D &pw_audio_driver; + k->name =3D "pipewire"; + k->pcm_ops =3D &qpw_pcm_ops; + k->max_voices_out =3D INT_MAX; + k->max_voices_in =3D INT_MAX; + k->voice_size_out =3D sizeof(PWVoiceOut); + k->voice_size_in =3D sizeof(PWVoiceIn); } =20 static const TypeInfo audio_pw_info =3D { diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 2e9bc255a41..90867c0c11d 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -50,7 +50,6 @@ struct AudioSdl { AudioMixengBackend parent; }; =20 -static struct audio_driver sdl_audio_driver; =20 typedef struct SDLVoiceOut { HWVoiceOut hw; @@ -492,15 +491,6 @@ static struct audio_pcm_ops sdl_pcm_ops =3D { .enable_in =3D sdl_enable_in, }; =20 -static struct audio_driver sdl_audio_driver =3D { - .name =3D "sdl", - .pcm_ops =3D &sdl_pcm_ops, - .max_voices_out =3D INT_MAX, - .max_voices_in =3D INT_MAX, - .voice_size_out =3D sizeof(SDLVoiceOut), - .voice_size_in =3D sizeof(SDLVoiceIn), -}; - static void audio_sdl_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -509,7 +499,12 @@ static void audio_sdl_class_init(ObjectClass *klass, c= onst void *data) audio_sdl_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_parent= (klass)); =20 b->realize =3D audio_sdl_realize; - k->driver =3D &sdl_audio_driver; + k->name =3D "sdl"; + k->pcm_ops =3D &sdl_pcm_ops; + k->max_voices_out =3D INT_MAX; + k->max_voices_in =3D INT_MAX; + k->voice_size_out =3D sizeof(SDLVoiceOut); + k->voice_size_in =3D sizeof(SDLVoiceIn); } =20 static const TypeInfo audio_sdl_info =3D { diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c index de2ee44fa0d..8be0efbc2d6 100644 --- a/audio/sndioaudio.c +++ b/audio/sndioaudio.c @@ -32,14 +32,6 @@ struct AudioSndio { AudioMixengBackend parent; }; =20 -static struct audio_driver sndio_audio_driver; - -static void audio_sndio_class_init(ObjectClass *klass, const void *data) -{ - AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); - - k->driver =3D &sndio_audio_driver; -} =20 /* default latency in microseconds if no option is set */ #define SNDIO_LATENCY_US 50000 @@ -551,14 +543,17 @@ static struct audio_pcm_ops sndio_pcm_ops =3D { .put_buffer_in =3D sndio_put_buffer_in, }; =20 -static struct audio_driver sndio_audio_driver =3D { - .name =3D "sndio", - .pcm_ops =3D &sndio_pcm_ops, - .max_voices_out =3D INT_MAX, - .max_voices_in =3D INT_MAX, - .voice_size_out =3D sizeof(SndioVoice), - .voice_size_in =3D sizeof(SndioVoice) -}; +static void audio_sndio_class_init(ObjectClass *klass, const void *data) +{ + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + k->name =3D "sndio"; + k->pcm_ops =3D &sndio_pcm_ops; + k->max_voices_out =3D INT_MAX; + k->max_voices_in =3D INT_MAX; + k->voice_size_out =3D sizeof(SndioVoice); + k->voice_size_in =3D sizeof(SndioVoice); +} =20 static const TypeInfo audio_sndio_info =3D { .name =3D TYPE_AUDIO_SNDIO, diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 248249cef61..4f20f7f73a9 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -39,8 +39,6 @@ struct AudioSpice { AudioMixengBackend parent; }; =20 -static struct audio_driver spice_audio_driver; - static bool spice_audio_realize(AudioBackend *abe, Audiodev *dev, Error **= errp) { if (!using_spice) { @@ -52,17 +50,6 @@ static bool spice_audio_realize(AudioBackend *abe, Audio= dev *dev, Error **errp) return audio_spice_parent_class->realize(abe, dev, errp); } =20 -static void audio_spice_class_init(ObjectClass *klass, const void *data) -{ - AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); - AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); - - audio_spice_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_pare= nt(klass)); - - b->realize =3D spice_audio_realize; - k->driver =3D &spice_audio_driver; -} - #if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= =3D 3 #define LINE_OUT_SAMPLES (480 * 4) #else @@ -332,14 +319,21 @@ static struct audio_pcm_ops audio_callbacks =3D { #endif }; =20 -static struct audio_driver spice_audio_driver =3D { - .name =3D "spice", - .pcm_ops =3D &audio_callbacks, - .max_voices_out =3D 1, - .max_voices_in =3D 1, - .voice_size_out =3D sizeof (SpiceVoiceOut), - .voice_size_in =3D sizeof (SpiceVoiceIn), -}; +static void audio_spice_class_init(ObjectClass *klass, const void *data) +{ + AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + audio_spice_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_pare= nt(klass)); + + b->realize =3D spice_audio_realize; + k->name =3D "spice"; + k->pcm_ops =3D &audio_callbacks; + k->max_voices_out =3D 1; + k->max_voices_in =3D 1; + k->voice_size_out =3D sizeof(SpiceVoiceOut); + k->voice_size_in =3D sizeof(SpiceVoiceIn); +} =20 static const TypeInfo audio_spice_info =3D { .name =3D TYPE_AUDIO_SPICE, diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 56b3122938f..57a2e686785 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -37,15 +37,6 @@ struct AudioWav { AudioMixengBackend parent; }; =20 -static struct audio_driver wav_audio_driver; - -static void audio_wav_class_init(ObjectClass *klass, const void *data) -{ - AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); - - k->driver =3D &wav_audio_driver; -} - typedef struct WAVVoiceOut { HWVoiceOut hw; FILE *f; @@ -208,14 +199,17 @@ static struct audio_pcm_ops wav_pcm_ops =3D { .enable_out =3D wav_enable_out, }; =20 -static struct audio_driver wav_audio_driver =3D { - .name =3D "wav", - .pcm_ops =3D &wav_pcm_ops, - .max_voices_out =3D 1, - .max_voices_in =3D 0, - .voice_size_out =3D sizeof (WAVVoiceOut), - .voice_size_in =3D 0 -}; +static void audio_wav_class_init(ObjectClass *klass, const void *data) +{ + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + k->name =3D "wav"; + k->pcm_ops =3D &wav_pcm_ops; + k->max_voices_out =3D 1; + k->max_voices_in =3D 0; + k->voice_size_out =3D sizeof(WAVVoiceOut); + k->voice_size_in =3D 0; +} =20 static const TypeInfo audio_wav_info =3D { .name =3D TYPE_AUDIO_WAV, diff --git a/audio/coreaudio.m b/audio/coreaudio.m index 925c68e8da4..c7602dad223 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -41,15 +41,6 @@ AudioMixengBackend parent; }; =20 -static struct audio_driver coreaudio_audio_driver; - -static void audio_coreaudio_class_init(ObjectClass *klass, const void *dat= a) -{ - AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); - - k->driver =3D &coreaudio_audio_driver; -} - typedef struct coreaudioVoiceOut { HWVoiceOut hw; pthread_mutex_t buf_mutex; @@ -669,14 +660,17 @@ static void coreaudio_enable_out(HWVoiceOut *hw, bool= enable) .enable_out =3D coreaudio_enable_out }; =20 -static struct audio_driver coreaudio_audio_driver =3D { - .name =3D "coreaudio", - .pcm_ops =3D &coreaudio_pcm_ops, - .max_voices_out =3D 1, - .max_voices_in =3D 0, - .voice_size_out =3D sizeof (coreaudioVoiceOut), - .voice_size_in =3D 0 -}; +static void audio_coreaudio_class_init(ObjectClass *klass, const void *dat= a) +{ + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + k->name =3D "coreaudio"; + k->pcm_ops =3D &coreaudio_pcm_ops; + k->max_voices_out =3D 1; + k->max_voices_in =3D 0; + k->voice_size_out =3D sizeof(coreaudioVoiceOut); + k->voice_size_in =3D 0; +} =20 static const TypeInfo audio_coreaudio_info =3D { .name =3D TYPE_AUDIO_COREAUDIO, --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538585; cv=none; d=zohomail.com; s=zohoarc; b=gtZc3gMkWEpJCmZ7nouxmZiLtaoUWkz7Yahu+N2bdPNbuULlb/2p+jSC4f5/VqPe8BW/MlR80tFwekgxvtbD6RFeTqAXBHHND83ON1iOcVeC6OnyPhUx+SGAjq0hdGHnBxsJ4F/V8RLADCraTGgoWbxeqv/yO3LkgXHrUzCovrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538585; 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=G2naN/t7yMiPA2azDsOBFDTQ2YPKsRSZGHKYZX9Pggo=; b=e+FwWy4PzU0mA6qDcUGQ1nCtDK5fKzuXsNSqT9aRRpndVnILj/uolTslJgLo81j6TP23azcOoLijjNor7Ba+SWkLlQ/RTarquYecAlGRqGpMRaeXLRuMr/casNMe6kkaWpLad5rCtcry0Sog4gmDG3ps/b39Cy05WSDipbq7/qw= 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 1769538585083776.016452808613; Tue, 27 Jan 2026 10:29:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknn2-0007W8-3K; Tue, 27 Jan 2026 13:27:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vknmY-0006aT-Hs for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:20 -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 1vknmO-0003F6-UW for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:18 -0500 Received: from mx-prod-mc-05.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-235-L-q4lqAOMCq8uApAjCQ7uQ-1; Tue, 27 Jan 2026 13:27:00 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1CBB419775A3; Tue, 27 Jan 2026 18:26:59 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4DC871956095; Tue, 27 Jan 2026 18:26:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538426; 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=G2naN/t7yMiPA2azDsOBFDTQ2YPKsRSZGHKYZX9Pggo=; b=K6xEP2jhoBuXv7txTpLXP7hobC7LoVahhpzNqUqnnulUS9lxsKm09a422v+VV1H2LPQkKl GRaa/xyg1C4kF02yzlqQzJmXdDcLpbIkebFnkdj823TeV2F4fxPGku20ATn2cAFMrA90ho yntG7cZEeTgfFrSghfJKxXTdlhUG2C0= X-MC-Unique: L-q4lqAOMCq8uApAjCQ7uQ-1 X-Mimecast-MFC-AGG-ID: L-q4lqAOMCq8uApAjCQ7uQ_1769538419 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , Akihiko Odaki , Thomas Huth , Alexandre Ratchov Subject: [PATCH 16/43] audio: move pcm_ops into AudioMixengBackendClass Date: Tue, 27 Jan 2026 22:24:43 +0400 Message-ID: <20260127182516.289834-17-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.17 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538586723154100 From: Marc-Andr=C3=A9 Lureau Remove the separate audio_pcm_ops structure and move its function pointers directly into AudioMixengBackendClass. This is a cleaner QOM-style design where the PCM operations are part of the class vtable rather than a separate indirection through hw->pcm_ops. The HWVoiceOut and HWVoiceIn structures no longer need to store a pcm_ops pointer, as the operations are now accessed through the class with AUDIO_MIXENG_BACKEND_GET_CLASS(). Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki --- audio/audio_int.h | 71 +++++++++----------- audio/audio_template.h | 16 +++-- audio/alsaaudio.c | 29 ++++----- audio/audio-mixeng-be.c | 139 ++++++++++++++++++++++------------------ audio/dbusaudio.c | 33 +++++----- audio/dsoundaudio.c | 33 +++++----- audio/jackaudio.c | 29 ++++----- audio/noaudio.c | 29 ++++----- audio/ossaudio.c | 33 +++++----- audio/paaudio.c | 33 +++++----- audio/pwaudio.c | 33 +++++----- audio/sdlaudio.c | 46 +++++++------ audio/sndioaudio.c | 32 +++++---- audio/spiceaudio.c | 45 ++++++------- audio/wavaudio.c | 17 ++--- audio/coreaudio.m | 27 ++++---- 16 files changed, 308 insertions(+), 337 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index bd9c7a29e41..5334c4baad2 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -39,8 +39,6 @@ AUD_vlog(const char *cap, const char *fmt, va_list ap); void G_GNUC_PRINTF(2, 3) AUD_log(const char *cap, const char *fmt, ...); =20 -struct audio_pcm_ops; - struct audio_callback { void *opaque; audio_callback_fn fn; @@ -81,7 +79,6 @@ typedef struct HWVoiceOut { size_t samples; QLIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head; QLIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head; - struct audio_pcm_ops *pcm_ops; QLIST_ENTRY (HWVoiceOut) entries; } HWVoiceOut; =20 @@ -101,7 +98,6 @@ typedef struct HWVoiceIn { =20 size_t samples; QLIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head; - struct audio_pcm_ops *pcm_ops; QLIST_ENTRY (HWVoiceIn) entries; } HWVoiceIn; =20 @@ -136,40 +132,6 @@ struct SWVoiceIn { QLIST_ENTRY (SWVoiceIn) entries; }; =20 -struct audio_pcm_ops { - int (*init_out)(HWVoiceOut *hw, audsettings *as); - void (*fini_out)(HWVoiceOut *hw); - size_t (*write) (HWVoiceOut *hw, void *buf, size_t size); - void (*run_buffer_out)(HWVoiceOut *hw); - /* - * Get the free output buffer size. This is an upper limit. The size - * returned by function get_buffer_out may be smaller. - */ - size_t (*buffer_get_free)(HWVoiceOut *hw); - /* - * get a buffer that after later can be passed to put_buffer_out; opti= onal - * returns the buffer, and writes it's size to size (in bytes) - */ - void *(*get_buffer_out)(HWVoiceOut *hw, size_t *size); - /* - * put back the buffer returned by get_buffer_out; optional - * buf must be equal the pointer returned by get_buffer_out, - * size may be smaller - */ - size_t (*put_buffer_out)(HWVoiceOut *hw, void *buf, size_t size); - void (*enable_out)(HWVoiceOut *hw, bool enable); - void (*volume_out)(HWVoiceOut *hw, Volume *vol); - - int (*init_in) (HWVoiceIn *hw, audsettings *as); - void (*fini_in) (HWVoiceIn *hw); - size_t (*read) (HWVoiceIn *hw, void *buf, size_t size); - void (*run_buffer_in)(HWVoiceIn *hw); - void *(*get_buffer_in)(HWVoiceIn *hw, size_t *size); - void (*put_buffer_in)(HWVoiceIn *hw, void *buf, size_t size); - void (*enable_in)(HWVoiceIn *hw, bool enable); - void (*volume_in)(HWVoiceIn *hw, Volume *vol); -}; - audsettings audiodev_to_audsettings(AudiodevPerDirectionOptions *pdo); int audioformat_bytes_per_sample(AudioFormat fmt); int audio_buffer_frames(AudiodevPerDirectionOptions *pdo, @@ -220,11 +182,42 @@ struct AudioMixengBackendClass { AudioBackendClass parent_class; =20 const char *name; - struct audio_pcm_ops *pcm_ops; int max_voices_out; int max_voices_in; size_t voice_size_out; size_t voice_size_in; + + int (*init_out)(HWVoiceOut *hw, audsettings *as); + void (*fini_out)(HWVoiceOut *hw); + size_t (*write) (HWVoiceOut *hw, void *buf, size_t size); + void (*run_buffer_out)(HWVoiceOut *hw); + /* + * Get the free output buffer size. This is an upper limit. The size + * returned by function get_buffer_out may be smaller. + */ + size_t (*buffer_get_free)(HWVoiceOut *hw); + /* + * get a buffer that after later can be passed to put_buffer_out; opti= onal + * returns the buffer, and writes it's size to size (in bytes) + */ + void *(*get_buffer_out)(HWVoiceOut *hw, size_t *size); + /* + * put back the buffer returned by get_buffer_out; optional + * buf must be equal the pointer returned by get_buffer_out, + * size may be smaller + */ + size_t (*put_buffer_out)(HWVoiceOut *hw, void *buf, size_t size); + void (*enable_out)(HWVoiceOut *hw, bool enable); + void (*volume_out)(HWVoiceOut *hw, Volume *vol); + + int (*init_in) (HWVoiceIn *hw, audsettings *as); + void (*fini_in) (HWVoiceIn *hw); + size_t (*read) (HWVoiceIn *hw, void *buf, size_t size); + void (*run_buffer_in)(HWVoiceIn *hw); + void *(*get_buffer_in)(HWVoiceIn *hw, size_t *size); + void (*put_buffer_in)(HWVoiceIn *hw, void *buf, size_t size); + void (*enable_in)(HWVoiceIn *hw, bool enable); + void (*volume_in)(HWVoiceIn *hw, Volume *vol); }; =20 struct AudioMixengBackend { diff --git a/audio/audio_template.h b/audio/audio_template.h index 7187571c668..08d60422589 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -223,13 +223,14 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) { HW *hw =3D *hwp; AudioMixengBackend *s =3D hw->s; + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(s); =20 if (!hw->sw_head.lh_first) { #ifdef DAC audio_detach_capture(hw); #endif QLIST_REMOVE(hw, entries); - glue(hw->pcm_ops->fini_, TYPE) (hw); + glue(k->fini_, TYPE)(hw); glue(s->nb_hw_voices_, TYPE) +=3D 1; glue(audio_pcm_hw_free_resources_ , TYPE) (hw); object_unref(hw->s); @@ -274,8 +275,8 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMixen= gBackend *s, return NULL; } =20 - if (audio_bug(__func__, !k->pcm_ops)) { - dolog("No host audio driver or missing pcm_ops\n"); + if (audio_bug(__func__, !glue(k->init_, TYPE))) { + dolog("No host audio driver or missing init_%s\n", NAME); return NULL; } =20 @@ -285,13 +286,12 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMix= engBackend *s, */ hw =3D g_malloc0(glue(k->voice_size_, TYPE)); hw->s =3D AUDIO_MIXENG_BACKEND(object_ref(s)); - hw->pcm_ops =3D k->pcm_ops; =20 QLIST_INIT (&hw->sw_head); #ifdef DAC QLIST_INIT (&hw->cap_head); #endif - if (glue (hw->pcm_ops->init_, TYPE) (hw, as)) { + if (glue(k->init_, TYPE)(hw, as)) { goto err0; } =20 @@ -330,7 +330,7 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMixen= gBackend *s, return hw; =20 err1: - glue (hw->pcm_ops->fini_, TYPE) (hw); + glue(k->fini_, TYPE)(hw); err0: object_unref(hw->s); g_free (hw); @@ -495,6 +495,7 @@ static SW *glue(audio_mixeng_backend_open_, TYPE) ( const struct audsettings *as) { AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(be); + AudioMixengBackendClass *k; AudiodevPerDirectionOptions *pdo; =20 if (audio_bug(__func__, !be || !name || !callback_fn || !as)) { @@ -503,6 +504,7 @@ static SW *glue(audio_mixeng_backend_open_, TYPE) ( goto fail; } =20 + k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(s); pdo =3D glue(audio_get_pdo_, TYPE)(s->dev); =20 ldebug ("open %s, freq %d, nchannels %d, fmt %d\n", @@ -513,7 +515,7 @@ static SW *glue(audio_mixeng_backend_open_, TYPE) ( goto fail; } =20 - if (audio_bug(__func__, !AUDIO_MIXENG_BACKEND_GET_CLASS(s)->pcm_ops)) { + if (audio_bug(__func__, !glue(k->init_, TYPE))) { dolog("Can not open `%s' (no host audio driver)\n", name); goto fail; } diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index a49da32cc4e..d3697a148da 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -922,21 +922,6 @@ audio_alsa_realize(AudioBackend *abe, Audiodev *dev, E= rror **errp) return audio_alsa_parent_class->realize(abe, dev, errp); } =20 -static struct audio_pcm_ops alsa_pcm_ops =3D { - .init_out =3D alsa_init_out, - .fini_out =3D alsa_fini_out, - .write =3D alsa_write, - .buffer_get_free =3D alsa_buffer_get_free, - .run_buffer_out =3D audio_generic_run_buffer_out, - .enable_out =3D alsa_enable_out, - - .init_in =3D alsa_init_in, - .fini_in =3D alsa_fini_in, - .read =3D alsa_read, - .run_buffer_in =3D audio_generic_run_buffer_in, - .enable_in =3D alsa_enable_in, -}; - static void audio_alsa_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -946,11 +931,23 @@ static void audio_alsa_class_init(ObjectClass *klass,= const void *data) =20 b->realize =3D audio_alsa_realize; k->name =3D "alsa"; - k->pcm_ops =3D &alsa_pcm_ops; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(ALSAVoiceOut); k->voice_size_in =3D sizeof(ALSAVoiceIn); + + k->init_out =3D alsa_init_out; + k->fini_out =3D alsa_fini_out; + k->write =3D alsa_write; + k->buffer_get_free =3D alsa_buffer_get_free; + k->run_buffer_out =3D audio_generic_run_buffer_out; + k->enable_out =3D alsa_enable_out; + + k->init_in =3D alsa_init_in; + k->fini_in =3D alsa_fini_in; + k->read =3D alsa_read; + k->run_buffer_in =3D audio_generic_run_buffer_in; + k->enable_in =3D alsa_enable_in; } =20 static const TypeInfo audio_alsa_info =3D { diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index 9d16fb5e654..8f06afba821 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -526,7 +526,7 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *bu= f, size_t buf_len) =20 audio_pcm_sw_resample_in(sw, live, frames_out_max, &total_in, &total_o= ut); =20 - if (!hw->pcm_ops->volume_in) { + if (!AUDIO_MIXENG_BACKEND_GET_CLASS(hw->s)->volume_in) { mixeng_volume(sw->resample_buf.buffer, total_out, &sw->vol); } sw->clip(buf, sw->resample_buf.buffer, total_out); @@ -579,8 +579,10 @@ static size_t audio_pcm_hw_get_live_out (HWVoiceOut *h= w, int *nb_live) =20 static size_t audio_pcm_hw_get_free(HWVoiceOut *hw) { - return (hw->pcm_ops->buffer_get_free ? hw->pcm_ops->buffer_get_free(hw= ) : - INT_MAX) / hw->info.bytes_per_frame; + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(hw->s); + + return (k->buffer_get_free ? k->buffer_get_free(hw) : INT_MAX) / + hw->info.bytes_per_frame; } =20 static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, size_t le= n) @@ -673,7 +675,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t buf_len) 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) { + if (!AUDIO_MIXENG_BACKEND_GET_CLASS(sw->hw->s)->volume_out) { mixeng_volume(sw->resample_buf.buffer + sw->resample_buf.pos, frames_in_max - sw->resample_buf.pos, &sw->vol); } @@ -806,7 +808,7 @@ static size_t audio_mixeng_backend_write(AudioBackend *= be, SWVoiceOut *sw, if (audio_get_pdo_out(hw->s->dev)->mixing_engine) { return audio_pcm_sw_write(sw, buf, size); } else { - return hw->pcm_ops->write(hw, buf, size); + return AUDIO_MIXENG_BACKEND_GET_CLASS(hw->s)->write(hw, buf, size); } } =20 @@ -829,7 +831,7 @@ static size_t audio_mixeng_backend_read(AudioBackend *b= e, if (audio_get_pdo_in(hw->s->dev)->mixing_engine) { return audio_pcm_sw_read(sw, buf, size); } else { - return hw->pcm_ops->read(hw, buf, size); + return AUDIO_MIXENG_BACKEND_GET_CLASS(hw->s)->read(hw, buf, size); } =20 } @@ -863,12 +865,14 @@ static void audio_mixeng_backend_set_active_out(Audio= Backend *be, SWVoiceOut *sw SWVoiceCap *sc; =20 if (on) { + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(= s); + hw->pending_disable =3D 0; if (!hw->enabled) { hw->enabled =3D true; if (runstate_is_running()) { - if (hw->pcm_ops->enable_out) { - hw->pcm_ops->enable_out(hw, true); + if (k->enable_out) { + k->enable_out(hw, true); } audio_reset_timer (s); } @@ -908,14 +912,15 @@ static void audio_mixeng_backend_set_active_in(AudioB= ackend *be, SWVoiceIn *sw, hw =3D sw->hw; if (sw->active !=3D on) { AudioMixengBackend *s =3D sw->s; + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(s); SWVoiceIn *temp_sw; =20 if (on) { if (!hw->enabled) { hw->enabled =3D true; if (runstate_is_running()) { - if (hw->pcm_ops->enable_in) { - hw->pcm_ops->enable_in(hw, true); + if (k->enable_in) { + k->enable_in(hw, true); } audio_reset_timer (s); } @@ -932,8 +937,8 @@ static void audio_mixeng_backend_set_active_in(AudioBac= kend *be, SWVoiceIn *sw, =20 if (nb_active =3D=3D 1) { hw->enabled =3D false; - if (hw->pcm_ops->enable_in) { - hw->pcm_ops->enable_in(hw, false); + if (k->enable_in) { + k->enable_in(hw, false); } } } @@ -1040,12 +1045,13 @@ static void audio_capture_mix_and_clear(HWVoiceOut = *hw, size_t rpos, =20 static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, size_t live) { + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(hw->s); size_t clipped =3D 0; =20 while (live) { size_t size =3D live * hw->info.bytes_per_frame; size_t decr, proc; - void *buf =3D hw->pcm_ops->get_buffer_out(hw, &size); + void *buf =3D k->get_buffer_out(hw, &size); =20 if (size =3D=3D 0) { break; @@ -1055,8 +1061,7 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, si= ze_t live) if (buf) { audio_pcm_hw_clip_out(hw, buf, decr); } - proc =3D hw->pcm_ops->put_buffer_out(hw, buf, - decr * hw->info.bytes_per_frame= ) / + proc =3D k->put_buffer_out(hw, buf, decr * hw->info.bytes_per_fram= e) / hw->info.bytes_per_frame; =20 live -=3D proc; @@ -1068,8 +1073,8 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, si= ze_t live) } } =20 - if (hw->pcm_ops->run_buffer_out) { - hw->pcm_ops->run_buffer_out(hw); + if (k->run_buffer_out) { + k->run_buffer_out(hw); } =20 return clipped; @@ -1077,6 +1082,7 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, si= ze_t live) =20 static void audio_run_out(AudioMixengBackend *s) { + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(s); HWVoiceOut *hw =3D NULL; SWVoiceOut *sw; =20 @@ -1092,8 +1098,8 @@ static void audio_run_out(AudioMixengBackend *s) if (hw->pending_disable) { hw->enabled =3D false; hw->pending_disable =3D false; - if (hw->pcm_ops->enable_out) { - hw->pcm_ops->enable_out(hw, false); + if (k->enable_out) { + k->enable_out(hw, false); } } =20 @@ -1102,8 +1108,8 @@ static void audio_run_out(AudioMixengBackend *s) hw_free * sw->info.bytes_per_frame); } =20 - if (hw->pcm_ops->run_buffer_out) { - hw->pcm_ops->run_buffer_out(hw); + if (k->run_buffer_out) { + k->run_buffer_out(hw); } =20 continue; @@ -1146,8 +1152,8 @@ static void audio_run_out(AudioMixengBackend *s) #endif hw->enabled =3D false; hw->pending_disable =3D false; - if (hw->pcm_ops->enable_out) { - hw->pcm_ops->enable_out(hw, false); + if (k->enable_out) { + k->enable_out(hw, false); } for (sc =3D hw->cap_head.lh_first; sc; sc =3D sc->entries.le_n= ext) { sc->sw.active =3D false; @@ -1157,8 +1163,8 @@ static void audio_run_out(AudioMixengBackend *s) } =20 if (!live) { - if (hw->pcm_ops->run_buffer_out) { - hw->pcm_ops->run_buffer_out(hw); + if (k->run_buffer_out) { + k->run_buffer_out(hw); } continue; } @@ -1202,16 +1208,17 @@ static void audio_run_out(AudioMixengBackend *s) =20 static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, size_t samples) { + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(hw->s); size_t conv =3D 0; =20 - if (hw->pcm_ops->run_buffer_in) { - hw->pcm_ops->run_buffer_in(hw); + if (k->run_buffer_in) { + k->run_buffer_in(hw); } =20 while (samples) { size_t proc; size_t size =3D samples * hw->info.bytes_per_frame; - void *buf =3D hw->pcm_ops->get_buffer_in(hw, &size); + void *buf =3D k->get_buffer_in(hw, &size); =20 assert(size % hw->info.bytes_per_frame =3D=3D 0); if (size =3D=3D 0) { @@ -1222,7 +1229,7 @@ static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, size= _t samples) =20 samples -=3D proc; conv +=3D proc; - hw->pcm_ops->put_buffer_in(hw, buf, proc * hw->info.bytes_per_fram= e); + k->put_buffer_in(hw, buf, proc * hw->info.bytes_per_frame); } =20 return conv; @@ -1367,6 +1374,8 @@ void audio_run(AudioMixengBackend *s, const char *msg) =20 void audio_generic_run_buffer_in(HWVoiceIn *hw) { + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(hw->s); + if (unlikely(!hw->buf_emul)) { hw->size_emul =3D hw->samples * hw->info.bytes_per_frame; hw->buf_emul =3D g_malloc(hw->size_emul); @@ -1376,8 +1385,7 @@ void audio_generic_run_buffer_in(HWVoiceIn *hw) while (hw->pending_emul < hw->size_emul) { size_t read_len =3D MIN(hw->size_emul - hw->pos_emul, hw->size_emul - hw->pending_emul); - size_t read =3D hw->pcm_ops->read(hw, hw->buf_emul + hw->pos_emul, - read_len); + size_t read =3D k->read(hw, hw->buf_emul + hw->pos_emul, read_len); hw->pending_emul +=3D read; hw->pos_emul =3D (hw->pos_emul + read) % hw->size_emul; if (read < read_len) { @@ -1415,6 +1423,8 @@ size_t audio_generic_buffer_get_free(HWVoiceOut *hw) =20 void audio_generic_run_buffer_out(HWVoiceOut *hw) { + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(hw->s); + while (hw->pending_emul) { size_t write_len, written, start; =20 @@ -1423,7 +1433,7 @@ void audio_generic_run_buffer_out(HWVoiceOut *hw) =20 write_len =3D MIN(hw->pending_emul, hw->size_emul - start); =20 - written =3D hw->pcm_ops->write(hw, hw->buf_emul + start, write_len= ); + written =3D k->write(hw, hw->buf_emul + start, write_len); hw->pending_emul -=3D written; =20 if (written < write_len) { @@ -1458,10 +1468,11 @@ size_t audio_generic_put_buffer_out(HWVoiceOut *hw,= void *buf, size_t size) =20 size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size) { + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(hw->s); size_t total =3D 0; =20 - if (hw->pcm_ops->buffer_get_free) { - size_t free =3D hw->pcm_ops->buffer_get_free(hw); + if (k->buffer_get_free) { + size_t free =3D k->buffer_get_free(hw); =20 size =3D MIN(size, free); } @@ -1469,7 +1480,7 @@ size_t audio_generic_write(HWVoiceOut *hw, void *buf,= size_t size) while (total < size) { size_t dst_size =3D size - total; size_t copy_size, proc; - void *dst =3D hw->pcm_ops->get_buffer_out(hw, &dst_size); + void *dst =3D k->get_buffer_out(hw, &dst_size); =20 if (dst_size =3D=3D 0) { break; @@ -1479,7 +1490,7 @@ size_t audio_generic_write(HWVoiceOut *hw, void *buf,= size_t size) if (dst) { memcpy(dst, (char *)buf + total, copy_size); } - proc =3D hw->pcm_ops->put_buffer_out(hw, dst, copy_size); + proc =3D k->put_buffer_out(hw, dst, copy_size); total +=3D proc; =20 if (proc =3D=3D 0 || proc < copy_size) { @@ -1492,22 +1503,23 @@ size_t audio_generic_write(HWVoiceOut *hw, void *bu= f, size_t size) =20 size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size) { + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(hw->s); size_t total =3D 0; =20 - if (hw->pcm_ops->run_buffer_in) { - hw->pcm_ops->run_buffer_in(hw); + if (k->run_buffer_in) { + k->run_buffer_in(hw); } =20 while (total < size) { size_t src_size =3D size - total; - void *src =3D hw->pcm_ops->get_buffer_in(hw, &src_size); + void *src =3D k->get_buffer_in(hw, &src_size); =20 if (src_size =3D=3D 0) { break; } =20 memcpy((char *)buf + total, src, src_size); - hw->pcm_ops->put_buffer_in(hw, src, src_size); + k->put_buffer_in(hw, src, src_size); total +=3D src_size; } =20 @@ -1521,13 +1533,13 @@ static bool audio_mixeng_backend_realize(AudioBacke= nd *abe, AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(be); =20 be->dev =3D dev; - if (!k->pcm_ops->get_buffer_in) { - k->pcm_ops->get_buffer_in =3D audio_generic_get_buffer_in; - k->pcm_ops->put_buffer_in =3D audio_generic_put_buffer_in; + if (!k->get_buffer_in) { + k->get_buffer_in =3D audio_generic_get_buffer_in; + k->put_buffer_in =3D audio_generic_put_buffer_in; } - if (!k->pcm_ops->get_buffer_out) { - k->pcm_ops->get_buffer_out =3D audio_generic_get_buffer_out; - k->pcm_ops->put_buffer_out =3D audio_generic_put_buffer_out; + if (!k->get_buffer_out) { + k->get_buffer_out =3D audio_generic_get_buffer_out; + k->put_buffer_out =3D audio_generic_put_buffer_out; } =20 audio_init_nb_voices_out(be, k, 1); @@ -1546,18 +1558,19 @@ static void audio_vm_change_state_handler (void *op= aque, bool running, RunState state) { AudioMixengBackend *s =3D opaque; + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(s); HWVoiceOut *hwo =3D NULL; HWVoiceIn *hwi =3D NULL; =20 while ((hwo =3D audio_pcm_hw_find_any_enabled_out(s, hwo))) { - if (hwo->pcm_ops->enable_out) { - hwo->pcm_ops->enable_out(hwo, running); + if (k->enable_out) { + k->enable_out(hwo, running); } } =20 while ((hwi =3D audio_pcm_hw_find_any_enabled_in(s, hwi))) { - if (hwi->pcm_ops->enable_in) { - hwi->pcm_ops->enable_in(hwi, running); + if (k->enable_in) { + k->enable_in(hwi, running); } } audio_reset_timer (s); @@ -1627,16 +1640,17 @@ static void audio_mixeng_backend_init(Object *obj) static void audio_mixeng_backend_finalize(Object *obj) { AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(obj); + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(s); HWVoiceOut *hwo, *hwon; HWVoiceIn *hwi, *hwin; =20 QLIST_FOREACH_SAFE(hwo, &s->hw_head_out, entries, hwon) { SWVoiceCap *sc; =20 - if (hwo->enabled && hwo->pcm_ops->enable_out) { - hwo->pcm_ops->enable_out(hwo, false); + if (hwo->enabled && k->enable_out) { + k->enable_out(hwo, false); } - hwo->pcm_ops->fini_out (hwo); + k->fini_out(hwo); =20 for (sc =3D hwo->cap_head.lh_first; sc; sc =3D sc->entries.le_next= ) { CaptureVoiceOut *cap =3D sc->cap; @@ -1650,10 +1664,10 @@ static void audio_mixeng_backend_finalize(Object *o= bj) } =20 QLIST_FOREACH_SAFE(hwi, &s->hw_head_in, entries, hwin) { - if (hwi->enabled && hwi->pcm_ops->enable_in) { - hwi->pcm_ops->enable_in(hwi, false); + if (hwi->enabled && k->enable_in) { + k->enable_in(hwi, false); } - hwi->pcm_ops->fini_in (hwi); + k->fini_in(hwi); QLIST_REMOVE(hwi, entries); } =20 @@ -1694,8 +1708,6 @@ static const VMStateDescription vmstate_audio =3D { } }; =20 -static struct audio_pcm_ops capture_pcm_ops; - static CaptureVoiceOut *audio_mixeng_backend_add_capture( AudioBackend *be, struct audsettings *as, @@ -1736,7 +1748,6 @@ static CaptureVoiceOut *audio_mixeng_backend_add_capt= ure( =20 hw =3D &cap->hw; hw->s =3D s; - hw->pcm_ops =3D &capture_pcm_ops; QLIST_INIT (&hw->sw_head); QLIST_INIT (&cap->cb_head); =20 @@ -1817,14 +1828,15 @@ static void audio_mixeng_backend_set_volume_out(Aud= ioBackend *be, SWVoiceOut *sw { if (sw) { HWVoiceOut *hw =3D sw->hw; + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(hw->= s); =20 sw->vol.mute =3D vol->mute; sw->vol.l =3D nominal_volume.l * vol->vol[0] / 255; sw->vol.r =3D nominal_volume.l * vol->vol[vol->channels > 1 ? 1 : = 0] / 255; =20 - if (hw->pcm_ops->volume_out) { - hw->pcm_ops->volume_out(hw, vol); + if (k->volume_out) { + k->volume_out(hw, vol); } } } @@ -1834,14 +1846,15 @@ static void audio_mixeng_backend_set_volume_in(Audi= oBackend *be, SWVoiceIn *sw, { if (sw) { HWVoiceIn *hw =3D sw->hw; + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(hw->= s); =20 sw->vol.mute =3D vol->mute; sw->vol.l =3D nominal_volume.l * vol->vol[0] / 255; sw->vol.r =3D nominal_volume.r * vol->vol[vol->channels > 1 ? 1 : = 0] / 255; =20 - if (hw->pcm_ops->volume_in) { - hw->pcm_ops->volume_in(hw, vol); + if (k->volume_in) { + k->volume_in(hw, vol); } } } diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index d78d5799952..9d5331b8c47 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -691,23 +691,6 @@ dbus_audio_set_server(AudioBackend *s, return true; } =20 -static struct audio_pcm_ops dbus_pcm_ops =3D { - .init_out =3D dbus_init_out, - .fini_out =3D dbus_fini_out, - .write =3D audio_generic_write, - .get_buffer_out =3D dbus_get_buffer_out, - .put_buffer_out =3D dbus_put_buffer_out, - .enable_out =3D dbus_enable_out, - .volume_out =3D dbus_volume_out, - - .init_in =3D dbus_init_in, - .fini_in =3D dbus_fini_in, - .read =3D dbus_read, - .run_buffer_in =3D audio_generic_run_buffer_in, - .enable_in =3D dbus_enable_in, - .volume_in =3D dbus_volume_in, -}; - static void audio_dbus_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -718,11 +701,25 @@ static void audio_dbus_class_init(ObjectClass *klass,= const void *data) b->realize =3D audio_dbus_realize; b->set_dbus_server =3D dbus_audio_set_server; k->name =3D "dbus"; - k->pcm_ops =3D &dbus_pcm_ops; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(DBusVoiceOut); k->voice_size_in =3D sizeof(DBusVoiceIn); + + k->init_out =3D dbus_init_out; + k->fini_out =3D dbus_fini_out; + k->write =3D audio_generic_write; + k->get_buffer_out =3D dbus_get_buffer_out; + k->put_buffer_out =3D dbus_put_buffer_out; + k->enable_out =3D dbus_enable_out; + k->volume_out =3D dbus_volume_out; + + k->init_in =3D dbus_init_in; + k->fini_in =3D dbus_fini_in; + k->read =3D dbus_read; + k->run_buffer_in =3D audio_generic_run_buffer_in; + k->enable_in =3D dbus_enable_in; + k->volume_in =3D dbus_volume_in; } =20 static const TypeInfo audio_dbus_info =3D { diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index b8bc6c8c7be..afd901518cc 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -667,23 +667,6 @@ audio_dsound_realize(AudioBackend *abe, Audiodev *dev,= Error **errp) return true; } =20 -static struct audio_pcm_ops dsound_pcm_ops =3D { - .init_out =3D dsound_init_out, - .fini_out =3D dsound_fini_out, - .write =3D audio_generic_write, - .buffer_get_free =3D dsound_buffer_get_free, - .get_buffer_out =3D dsound_get_buffer_out, - .put_buffer_out =3D dsound_put_buffer_out, - .enable_out =3D dsound_enable_out, - - .init_in =3D dsound_init_in, - .fini_in =3D dsound_fini_in, - .read =3D audio_generic_read, - .get_buffer_in =3D dsound_get_buffer_in, - .put_buffer_in =3D dsound_put_buffer_in, - .enable_in =3D dsound_enable_in, -}; - static void audio_dsound_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -693,11 +676,25 @@ static void audio_dsound_class_init(ObjectClass *klas= s, const void *data) =20 b->realize =3D audio_dsound_realize; k->name =3D "dsound"; - k->pcm_ops =3D &dsound_pcm_ops; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D 1; k->voice_size_out =3D sizeof(DSoundVoiceOut); k->voice_size_in =3D sizeof(DSoundVoiceIn); + + k->init_out =3D dsound_init_out; + k->fini_out =3D dsound_fini_out; + k->write =3D audio_generic_write; + k->buffer_get_free =3D dsound_buffer_get_free; + k->get_buffer_out =3D dsound_get_buffer_out; + k->put_buffer_out =3D dsound_put_buffer_out; + k->enable_out =3D dsound_enable_out; + + k->init_in =3D dsound_init_in; + k->fini_in =3D dsound_fini_in; + k->read =3D audio_generic_read; + k->get_buffer_in =3D dsound_get_buffer_in; + k->put_buffer_in =3D dsound_put_buffer_in; + k->enable_in =3D dsound_enable_in; } =20 static const TypeInfo audio_dsound_info =3D { diff --git a/audio/jackaudio.c b/audio/jackaudio.c index e69b313afe5..681eb17df55 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -652,21 +652,6 @@ static int qjack_thread_creator(jack_native_thread_t *= thread, } #endif =20 -static struct audio_pcm_ops jack_pcm_ops =3D { - .init_out =3D qjack_init_out, - .fini_out =3D qjack_fini_out, - .write =3D qjack_write, - .buffer_get_free =3D audio_generic_buffer_get_free, - .run_buffer_out =3D audio_generic_run_buffer_out, - .enable_out =3D qjack_enable_out, - - .init_in =3D qjack_init_in, - .fini_in =3D qjack_fini_in, - .read =3D qjack_read, - .run_buffer_in =3D audio_generic_run_buffer_in, - .enable_in =3D qjack_enable_in -}; - static void qjack_error(const char *msg) { dolog("E: %s\n", msg); @@ -682,11 +667,23 @@ static void audio_jack_class_init(ObjectClass *klass,= const void *data) AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); =20 k->name =3D "jack"; - k->pcm_ops =3D &jack_pcm_ops; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(QJackOut); k->voice_size_in =3D sizeof(QJackIn); + + k->init_out =3D qjack_init_out; + k->fini_out =3D qjack_fini_out; + k->write =3D qjack_write; + k->buffer_get_free =3D audio_generic_buffer_get_free; + k->run_buffer_out =3D audio_generic_run_buffer_out; + k->enable_out =3D qjack_enable_out; + + k->init_in =3D qjack_init_in; + k->fini_in =3D qjack_fini_in; + k->read =3D qjack_read; + k->run_buffer_in =3D audio_generic_run_buffer_in; + k->enable_in =3D qjack_enable_in; } =20 static const TypeInfo audio_jack_info =3D { diff --git a/audio/noaudio.c b/audio/noaudio.c index d1fba117133..2f4c3a77457 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -110,31 +110,28 @@ static void no_enable_in(HWVoiceIn *hw, bool enable) } } =20 -static struct audio_pcm_ops no_pcm_ops =3D { - .init_out =3D no_init_out, - .fini_out =3D no_fini_out, - .write =3D no_write, - .buffer_get_free =3D audio_generic_buffer_get_free, - .run_buffer_out =3D audio_generic_run_buffer_out, - .enable_out =3D no_enable_out, - - .init_in =3D no_init_in, - .fini_in =3D no_fini_in, - .read =3D no_read, - .run_buffer_in =3D audio_generic_run_buffer_in, - .enable_in =3D no_enable_in -}; - static void audio_none_class_init(ObjectClass *klass, const void *data) { AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); =20 k->name =3D "none"; - k->pcm_ops =3D &no_pcm_ops; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(NoVoiceOut); k->voice_size_in =3D sizeof(NoVoiceIn); + + k->init_out =3D no_init_out; + k->fini_out =3D no_fini_out; + k->write =3D no_write; + k->buffer_get_free =3D audio_generic_buffer_get_free; + k->run_buffer_out =3D audio_generic_run_buffer_out; + k->enable_out =3D no_enable_out; + + k->init_in =3D no_init_in; + k->fini_in =3D no_fini_in; + k->read =3D no_read; + k->run_buffer_in =3D audio_generic_run_buffer_in; + k->enable_in =3D no_enable_in; } =20 static const TypeInfo audio_none_info =3D { diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 15fdf54eb3e..95b7963ed0c 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -755,23 +755,6 @@ audio_oss_realize(AudioBackend *abe, Audiodev *dev, Er= ror **errp) return audio_oss_parent_class->realize(abe, dev, errp); } =20 -static struct audio_pcm_ops oss_pcm_ops =3D { - .init_out =3D oss_init_out, - .fini_out =3D oss_fini_out, - .write =3D oss_write, - .buffer_get_free =3D oss_buffer_get_free, - .run_buffer_out =3D oss_run_buffer_out, - .get_buffer_out =3D oss_get_buffer_out, - .put_buffer_out =3D oss_put_buffer_out, - .enable_out =3D oss_enable_out, - - .init_in =3D oss_init_in, - .fini_in =3D oss_fini_in, - .read =3D oss_read, - .run_buffer_in =3D audio_generic_run_buffer_in, - .enable_in =3D oss_enable_in -}; - static void audio_oss_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -781,11 +764,25 @@ static void audio_oss_class_init(ObjectClass *klass, = const void *data) =20 b->realize =3D audio_oss_realize; k->name =3D "oss"; - k->pcm_ops =3D &oss_pcm_ops; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(OSSVoiceOut); k->voice_size_in =3D sizeof(OSSVoiceIn); + + k->init_out =3D oss_init_out; + k->fini_out =3D oss_fini_out; + k->write =3D oss_write; + k->buffer_get_free =3D oss_buffer_get_free; + k->run_buffer_out =3D oss_run_buffer_out; + k->get_buffer_out =3D oss_get_buffer_out; + k->put_buffer_out =3D oss_put_buffer_out; + k->enable_out =3D oss_enable_out; + + k->init_in =3D oss_init_in; + k->fini_in =3D oss_fini_in; + k->read =3D oss_read; + k->run_buffer_in =3D audio_generic_run_buffer_in; + k->enable_in =3D oss_enable_in; } =20 static const TypeInfo audio_oss_info =3D { diff --git a/audio/paaudio.c b/audio/paaudio.c index 056158755c6..e98b4a33b68 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -913,23 +913,6 @@ static void audio_pa_finalize(Object *obj) } } =20 -static struct audio_pcm_ops qpa_pcm_ops =3D { - .init_out =3D qpa_init_out, - .fini_out =3D qpa_fini_out, - .write =3D qpa_write, - .buffer_get_free =3D qpa_buffer_get_free, - .get_buffer_out =3D qpa_get_buffer_out, - .put_buffer_out =3D qpa_put_buffer_out, - .volume_out =3D qpa_volume_out, - - .init_in =3D qpa_init_in, - .fini_in =3D qpa_fini_in, - .read =3D qpa_read, - .get_buffer_in =3D qpa_get_buffer_in, - .put_buffer_in =3D qpa_put_buffer_in, - .volume_in =3D qpa_volume_in -}; - static void audio_pa_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -939,11 +922,25 @@ static void audio_pa_class_init(ObjectClass *klass, c= onst void *data) =20 b->realize =3D audio_pa_realize; k->name =3D "pa"; - k->pcm_ops =3D &qpa_pcm_ops; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(PAVoiceOut); k->voice_size_in =3D sizeof(PAVoiceIn); + + k->init_out =3D qpa_init_out; + k->fini_out =3D qpa_fini_out; + k->write =3D qpa_write; + k->buffer_get_free =3D qpa_buffer_get_free; + k->get_buffer_out =3D qpa_get_buffer_out; + k->put_buffer_out =3D qpa_put_buffer_out; + k->volume_out =3D qpa_volume_out; + + k->init_in =3D qpa_init_in; + k->fini_in =3D qpa_fini_in; + k->read =3D qpa_read; + k->get_buffer_in =3D qpa_get_buffer_in; + k->put_buffer_in =3D qpa_put_buffer_in; + k->volume_in =3D qpa_volume_in; } =20 static const TypeInfo audio_pa_info =3D { diff --git a/audio/pwaudio.c b/audio/pwaudio.c index 7cadf7121bb..39b2b8f0a0d 100644 --- a/audio/pwaudio.c +++ b/audio/pwaudio.c @@ -822,23 +822,6 @@ audio_pw_finalize(Object *obj) g_clear_pointer(&pw->thread_loop, pw_thread_loop_destroy); } =20 -static struct audio_pcm_ops qpw_pcm_ops =3D { - .init_out =3D qpw_init_out, - .fini_out =3D qpw_fini_out, - .write =3D qpw_write, - .buffer_get_free =3D qpw_buffer_get_free, - .run_buffer_out =3D audio_generic_run_buffer_out, - .enable_out =3D qpw_enable_out, - .volume_out =3D qpw_volume_out, - .volume_in =3D qpw_volume_in, - - .init_in =3D qpw_init_in, - .fini_in =3D qpw_fini_in, - .read =3D qpw_read, - .run_buffer_in =3D audio_generic_run_buffer_in, - .enable_in =3D qpw_enable_in -}; - static void audio_pw_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -848,11 +831,25 @@ static void audio_pw_class_init(ObjectClass *klass, c= onst void *data) =20 b->realize =3D audio_pw_realize; k->name =3D "pipewire"; - k->pcm_ops =3D &qpw_pcm_ops; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(PWVoiceOut); k->voice_size_in =3D sizeof(PWVoiceIn); + + k->init_out =3D qpw_init_out; + k->fini_out =3D qpw_fini_out; + k->write =3D qpw_write; + k->buffer_get_free =3D qpw_buffer_get_free; + k->run_buffer_out =3D audio_generic_run_buffer_out; + k->enable_out =3D qpw_enable_out; + k->volume_out =3D qpw_volume_out; + + k->init_in =3D qpw_init_in; + k->fini_in =3D qpw_fini_in; + k->read =3D qpw_read; + k->run_buffer_in =3D audio_generic_run_buffer_in; + k->enable_in =3D qpw_enable_in; + k->volume_in =3D qpw_volume_in; } =20 static const TypeInfo audio_pw_info =3D { diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 90867c0c11d..4fb9abd66c3 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -468,29 +468,6 @@ static void audio_sdl_finalize(Object *obj) SDL_QuitSubSystem(SDL_INIT_AUDIO); } =20 -static struct audio_pcm_ops sdl_pcm_ops =3D { - .init_out =3D sdl_init_out, - .fini_out =3D sdl_fini_out, - /* wrapper for audio_generic_write */ - .write =3D sdl_write, - /* wrapper for audio_generic_buffer_get_free */ - .buffer_get_free =3D sdl_buffer_get_free, - /* wrapper for audio_generic_get_buffer_out */ - .get_buffer_out =3D sdl_get_buffer_out, - /* wrapper for audio_generic_put_buffer_out */ - .put_buffer_out =3D sdl_put_buffer_out, - .enable_out =3D sdl_enable_out, - .init_in =3D sdl_init_in, - .fini_in =3D sdl_fini_in, - /* wrapper for audio_generic_read */ - .read =3D sdl_read, - /* wrapper for audio_generic_get_buffer_in */ - .get_buffer_in =3D sdl_get_buffer_in, - /* wrapper for audio_generic_put_buffer_in */ - .put_buffer_in =3D sdl_put_buffer_in, - .enable_in =3D sdl_enable_in, -}; - static void audio_sdl_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -500,11 +477,32 @@ static void audio_sdl_class_init(ObjectClass *klass, = const void *data) =20 b->realize =3D audio_sdl_realize; k->name =3D "sdl"; - k->pcm_ops =3D &sdl_pcm_ops; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(SDLVoiceOut); k->voice_size_in =3D sizeof(SDLVoiceIn); + + k->init_out =3D sdl_init_out; + k->fini_out =3D sdl_fini_out; + /* wrapper for audio_generic_write */ + k->write =3D sdl_write; + /* wrapper for audio_generic_buffer_get_free */ + k->buffer_get_free =3D sdl_buffer_get_free; + /* wrapper for audio_generic_get_buffer_out */ + k->get_buffer_out =3D sdl_get_buffer_out; + /* wrapper for audio_generic_put_buffer_out */ + k->put_buffer_out =3D sdl_put_buffer_out; + k->enable_out =3D sdl_enable_out; + + k->init_in =3D sdl_init_in; + k->fini_in =3D sdl_fini_in; + /* wrapper for audio_generic_read */ + k->read =3D sdl_read; + /* wrapper for audio_generic_get_buffer_in */ + k->get_buffer_in =3D sdl_get_buffer_in; + /* wrapper for audio_generic_put_buffer_in */ + k->put_buffer_in =3D sdl_put_buffer_in; + k->enable_in =3D sdl_enable_in; } =20 static const TypeInfo audio_sdl_info =3D { diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c index 8be0efbc2d6..bc62f670a33 100644 --- a/audio/sndioaudio.c +++ b/audio/sndioaudio.c @@ -527,32 +527,30 @@ static void sndio_fini_in(HWVoiceIn *hw) sndio_fini(self); } =20 -static struct audio_pcm_ops sndio_pcm_ops =3D { - .init_out =3D sndio_init_out, - .fini_out =3D sndio_fini_out, - .enable_out =3D sndio_enable_out, - .write =3D audio_generic_write, - .buffer_get_free =3D sndio_buffer_get_free, - .get_buffer_out =3D sndio_get_buffer_out, - .put_buffer_out =3D sndio_put_buffer_out, - .init_in =3D sndio_init_in, - .fini_in =3D sndio_fini_in, - .read =3D audio_generic_read, - .enable_in =3D sndio_enable_in, - .get_buffer_in =3D sndio_get_buffer_in, - .put_buffer_in =3D sndio_put_buffer_in, -}; - static void audio_sndio_class_init(ObjectClass *klass, const void *data) { AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); =20 k->name =3D "sndio"; - k->pcm_ops =3D &sndio_pcm_ops; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(SndioVoice); k->voice_size_in =3D sizeof(SndioVoice); + + k->init_out =3D sndio_init_out; + k->fini_out =3D sndio_fini_out; + k->write =3D audio_generic_write; + k->buffer_get_free =3D sndio_buffer_get_free; + k->get_buffer_out =3D sndio_get_buffer_out; + k->put_buffer_out =3D sndio_put_buffer_out; + k->enable_out =3D sndio_enable_out; + + k->init_in =3D sndio_init_in; + k->fini_in =3D sndio_fini_in; + k->read =3D audio_generic_read; + k->get_buffer_in =3D sndio_get_buffer_in; + k->put_buffer_in =3D sndio_put_buffer_in; + k->enable_in =3D sndio_enable_in; } =20 static const TypeInfo audio_sndio_info =3D { diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 4f20f7f73a9..fa1cb04dbf7 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -296,29 +296,6 @@ static void line_in_volume(HWVoiceIn *hw, Volume *vol) } #endif =20 -static struct audio_pcm_ops audio_callbacks =3D { - .init_out =3D line_out_init, - .fini_out =3D line_out_fini, - .write =3D audio_generic_write, - .buffer_get_free =3D line_out_get_free, - .get_buffer_out =3D line_out_get_buffer, - .put_buffer_out =3D line_out_put_buffer, - .enable_out =3D line_out_enable, -#if (SPICE_INTERFACE_PLAYBACK_MAJOR >=3D 1) && \ - (SPICE_INTERFACE_PLAYBACK_MINOR >=3D 2) - .volume_out =3D line_out_volume, -#endif - - .init_in =3D line_in_init, - .fini_in =3D line_in_fini, - .read =3D line_in_read, - .run_buffer_in =3D audio_generic_run_buffer_in, - .enable_in =3D line_in_enable, -#if ((SPICE_INTERFACE_RECORD_MAJOR >=3D 2) && (SPICE_INTERFACE_RECORD_MINO= R >=3D 2)) - .volume_in =3D line_in_volume, -#endif -}; - static void audio_spice_class_init(ObjectClass *klass, const void *data) { AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); @@ -328,11 +305,31 @@ static void audio_spice_class_init(ObjectClass *klass= , const void *data) =20 b->realize =3D spice_audio_realize; k->name =3D "spice"; - k->pcm_ops =3D &audio_callbacks; k->max_voices_out =3D 1; k->max_voices_in =3D 1; k->voice_size_out =3D sizeof(SpiceVoiceOut); k->voice_size_in =3D sizeof(SpiceVoiceIn); + + k->init_out =3D line_out_init; + k->fini_out =3D line_out_fini; + k->write =3D audio_generic_write; + k->buffer_get_free =3D line_out_get_free; + k->get_buffer_out =3D line_out_get_buffer; + k->put_buffer_out =3D line_out_put_buffer; + k->enable_out =3D line_out_enable; +#if (SPICE_INTERFACE_PLAYBACK_MAJOR >=3D 1) && \ + (SPICE_INTERFACE_PLAYBACK_MINOR >=3D 2) + k->volume_out =3D line_out_volume; +#endif + + k->init_in =3D line_in_init; + k->fini_in =3D line_in_fini; + k->read =3D line_in_read; + k->run_buffer_in =3D audio_generic_run_buffer_in; + k->enable_in =3D line_in_enable; +#if ((SPICE_INTERFACE_RECORD_MAJOR >=3D 2) && (SPICE_INTERFACE_RECORD_MINO= R >=3D 2)) + k->volume_in =3D line_in_volume; +#endif } =20 static const TypeInfo audio_spice_info =3D { diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 57a2e686785..090f3f4dc60 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -190,25 +190,22 @@ static void wav_enable_out(HWVoiceOut *hw, bool enabl= e) } } =20 -static struct audio_pcm_ops wav_pcm_ops =3D { - .init_out =3D wav_init_out, - .fini_out =3D wav_fini_out, - .write =3D wav_write_out, - .buffer_get_free =3D audio_generic_buffer_get_free, - .run_buffer_out =3D audio_generic_run_buffer_out, - .enable_out =3D wav_enable_out, -}; - static void audio_wav_class_init(ObjectClass *klass, const void *data) { AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); =20 k->name =3D "wav"; - k->pcm_ops =3D &wav_pcm_ops; k->max_voices_out =3D 1; k->max_voices_in =3D 0; k->voice_size_out =3D sizeof(WAVVoiceOut); k->voice_size_in =3D 0; + + k->init_out =3D wav_init_out; + k->fini_out =3D wav_fini_out; + k->write =3D wav_write_out; + k->buffer_get_free =3D audio_generic_buffer_get_free; + k->run_buffer_out =3D audio_generic_run_buffer_out; + k->enable_out =3D wav_enable_out; } =20 static const TypeInfo audio_wav_info =3D { diff --git a/audio/coreaudio.m b/audio/coreaudio.m index c7602dad223..af614144bd1 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -646,30 +646,27 @@ static void coreaudio_enable_out(HWVoiceOut *hw, bool= enable) update_device_playback_state(core); } =20 -static struct audio_pcm_ops coreaudio_pcm_ops =3D { - .init_out =3D coreaudio_init_out, - .fini_out =3D coreaudio_fini_out, - /* wrapper for audio_generic_write */ - .write =3D coreaudio_write, - /* wrapper for audio_generic_buffer_get_free */ - .buffer_get_free =3D coreaudio_buffer_get_free, - /* wrapper for audio_generic_get_buffer_out */ - .get_buffer_out =3D coreaudio_get_buffer_out, - /* wrapper for audio_generic_put_buffer_out */ - .put_buffer_out =3D coreaudio_put_buffer_out, - .enable_out =3D coreaudio_enable_out -}; - static void audio_coreaudio_class_init(ObjectClass *klass, const void *dat= a) { AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); =20 k->name =3D "coreaudio"; - k->pcm_ops =3D &coreaudio_pcm_ops; k->max_voices_out =3D 1; k->max_voices_in =3D 0; k->voice_size_out =3D sizeof(coreaudioVoiceOut); k->voice_size_in =3D 0; + + k->init_out =3D coreaudio_init_out; + k->fini_out =3D coreaudio_fini_out; + /* wrapper for audio_generic_write */ + k->write =3D coreaudio_write; + /* wrapper for audio_generic_buffer_get_free */ + k->buffer_get_free =3D coreaudio_buffer_get_free; + /* wrapper for audio_generic_get_buffer_out */ + k->get_buffer_out =3D coreaudio_get_buffer_out; + /* wrapper for audio_generic_put_buffer_out */ + k->put_buffer_out =3D coreaudio_put_buffer_out; + k->enable_out =3D coreaudio_enable_out; } =20 static const TypeInfo audio_coreaudio_info =3D { --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538597; cv=none; d=zohomail.com; s=zohoarc; b=GL46jybU/TB7dluvV4T2eJNnc/L3LS5CwVep4n9Ayl9KOB3Hfo80OhtdyvM4IQU1/X3Yqkw4c6BPraYOpdbKkTm2mvLaviSLbyTqXspS2LuyU32oamO3bMfPyeMdJ/AE6bEEMFYAedcSDEEOksKmz5h3bZ5xDDyk+xRWLteaxdo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538597; 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=7ZdYKmNLoEsJBbqPpo6MYiCezszAtK3pqCFqD6svpNo=; b=T5xoueN4XXAYb4Prr451KABoCrdyR+po8o2Qg3QIoLGSxb1f1H48oHtkx5ejUQXTlzNOEn7JemU/erkEWIWVRWRGzDIUT1tjdMw6WpK2qCtB2b8oZO2izE6Kb7G8uoT9BLHDpIe7OT28DsBdGXhgjGweVAksEJK+XEoRGM7zSDo= 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 1769538597717790.6110992157382; Tue, 27 Jan 2026 10:29:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknnT-0008VA-7M; Tue, 27 Jan 2026 13:28: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 1vknmV-0006ZW-SE for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:20 -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 1vknmU-0003FC-7F for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:15 -0500 Received: from mx-prod-mc-03.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-319-MVcSKD4YPSavVBlyEmkXGw-1; Tue, 27 Jan 2026 13:27:05 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E31211955DB6; Tue, 27 Jan 2026 18:27:04 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 71C5F30001A2; Tue, 27 Jan 2026 18:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538427; 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=7ZdYKmNLoEsJBbqPpo6MYiCezszAtK3pqCFqD6svpNo=; b=i59OirPnjwmVSkDzOVr2A38G0A8jYwTUEhSHQa1vnN4kpnzXgG+ZbilUR2/SVa2K/lyvsm 8/R4jghOHAHjZeUO0XOBuxQxbuf8fVfQuzEnlBDJL0eE/+ze+kncQd6w7PPK7KI3/vf/LZ GvYSGXUO8RLu+s9lY0BYEs5Y58WLmdc= X-MC-Unique: MVcSKD4YPSavVBlyEmkXGw-1 X-Mimecast-MFC-AGG-ID: MVcSKD4YPSavVBlyEmkXGw_1769538425 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 17/43] audio: constify some add_capture() arguments Date: Tue, 27 Jan 2026 22:24:44 +0400 Message-ID: <20260127182516.289834-18-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.4.1 on 10.30.177.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+importer=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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538598786154100 From: Marc-Andr=C3=A9 Lureau --- include/qemu/audio-capture.h | 4 ++-- include/qemu/audio.h | 4 ++-- audio/audio-be.c | 4 ++-- audio/audio-mixeng-be.c | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/qemu/audio-capture.h b/include/qemu/audio-capture.h index d7998232243..f1319c90020 100644 --- a/include/qemu/audio-capture.h +++ b/include/qemu/audio-capture.h @@ -21,8 +21,8 @@ typedef struct CaptureState { =20 CaptureVoiceOut *audio_be_add_capture( AudioBackend *be, - struct audsettings *as, - struct audio_capture_ops *ops, + const struct audsettings *as, + const struct audio_capture_ops *ops, void *opaque); =20 void audio_be_del_capture( diff --git a/include/qemu/audio.h b/include/qemu/audio.h index dfe247ab8c4..b6b6ee9b560 100644 --- a/include/qemu/audio.h +++ b/include/qemu/audio.h @@ -96,8 +96,8 @@ typedef struct AudioBackendClass { size_t (*read)(AudioBackend *be, SWVoiceIn *sw, void *buf, size_t size= ); int (*get_buffer_size_out)(AudioBackend *be, SWVoiceOut *sw); CaptureVoiceOut *(*add_capture)(AudioBackend *be, - struct audsettings *as, - struct audio_capture_ops *ops, + const struct audsettings *as, + const struct audio_capture_ops *ops, void *cb_opaque); void (*del_capture)(AudioBackend *be, CaptureVoiceOut *cap, void *cb_o= paque); =20 diff --git a/audio/audio-be.c b/audio/audio-be.c index 3150a57dc8a..725c860a194 100644 --- a/audio/audio-be.c +++ b/audio/audio-be.c @@ -182,8 +182,8 @@ void audio_be_set_volume_in(AudioBackend *be, SWVoiceIn= *sw, Volume *vol) =20 CaptureVoiceOut *audio_be_add_capture( AudioBackend *be, - struct audsettings *as, - struct audio_capture_ops *ops, + const struct audsettings *as, + const struct audio_capture_ops *ops, void *cb_opaque) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index 8f06afba821..a0e542754e5 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -314,7 +314,7 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *i= nfo, void *buf, int len) * Capture */ static CaptureVoiceOut *audio_pcm_capture_find_specific(AudioMixengBackend= *s, - struct audsettings= *as) + const struct audse= ttings *as) { CaptureVoiceOut *cap; =20 @@ -1585,8 +1585,8 @@ static const char *audio_mixeng_backend_get_id(AudioB= ackend *be) =20 static CaptureVoiceOut *audio_mixeng_backend_add_capture( AudioBackend *be, - struct audsettings *as, - struct audio_capture_ops *ops, + const struct audsettings *as, + const struct audio_capture_ops *ops, void *cb_opaque); =20 static void audio_mixeng_backend_del_capture( @@ -1710,8 +1710,8 @@ static const VMStateDescription vmstate_audio =3D { =20 static CaptureVoiceOut *audio_mixeng_backend_add_capture( AudioBackend *be, - struct audsettings *as, - struct audio_capture_ops *ops, + const struct audsettings *as, + const struct audio_capture_ops *ops, void *cb_opaque) { AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(be); --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538738; cv=none; d=zohomail.com; s=zohoarc; b=KkQcDQtKEzuopxKGXhJ1S65Unr+He88f3jaaaQo5MmyXS36NO+5rnZkx1Cr5KNpTHVy6hp8x/SOK43VGS2yfPuk3yXr8OLoQNeLSnlgZ2uHBB0xHgPHgFOja8q5zDyqk+u3gU3xhNcyIhrXr5xeEqzUuMxlb/TMFPG2wby7oZqA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538738; 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=5gZWS0P3L7mvQlWjaqydgsTsf5WMySyE9Qsec9MyuTc=; b=dMwOzvAcYUXzL15hZ8sj06NmXF/rLPEn75nZJjmF4F8MTiHaehR1E2HtXDj8skEBE3qOGHfn7UUgWp19g2+gNZTBcFpa+3HF64F8ncKWhx6jhmzGJXTriQadMeS6aZ7+PNKgIl3ZhwN4wkCuzGM2cpbOHR/znzH+fCQgHWiuLY0= 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 1769538738969252.54483620640076; Tue, 27 Jan 2026 10:32:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknnV-0000Jj-I9; Tue, 27 Jan 2026 13:28:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vknma-0006dj-KR for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:26 -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 1vknmY-0003G6-2X for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:20 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-247-uiUVrsM-OQ2i71s-EwUp2w-1; Tue, 27 Jan 2026 13:27:13 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A05881800372; Tue, 27 Jan 2026 18:27:10 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 11F5E19560B2; Tue, 27 Jan 2026 18:27:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538436; 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=5gZWS0P3L7mvQlWjaqydgsTsf5WMySyE9Qsec9MyuTc=; b=elnsSYosJBtMvih1cFnXk21pexceL0tZngb7eHzpDCUzWy05QO84T5mG5lr48PdVqN6DF5 QKM7edx71vjcU7R4KaW9fhvjDvigcT9g65e4ZaO4y2y8ZBOsdJWrvlly688EUhEgWwtc0C ilo87XbKqgpX6B6AEn/NRTbBQi5ZOYw= X-MC-Unique: uiUVrsM-OQ2i71s-EwUp2w-1 X-Mimecast-MFC-AGG-ID: uiUVrsM-OQ2i71s-EwUp2w_1769538432 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck Subject: [PATCH 18/43] audio/alsa: replace custom logging with error_report and trace events Date: Tue, 27 Jan 2026 22:24:45 +0400 Message-ID: <20260127182516.289834-19-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.12 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538740924154100 From: Marc-Andr=C3=A9 Lureau The ALSA audio backend uses its own logging infrastructure (AUD_log, AUD_vlog, dolog, ldebug) and a custom alsa_dump_info() debug helper. This approach is inconsistent with the rest of QEMU and makes the output harder to filter and configure. Replace the custom logging with standard QEMU error reporting: - Use error_report() / error_printf() for errors - Use warn_report() for non-fatal warnings (invalid formats, rejected parameters, unexpected states) - Convert ldebug() calls and alsa_dump_info() to trace events Remove DEBUG_ALSA and AUDIO_CAP macros which are no longer needed. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/alsaaudio.c | 169 ++++++++++++++++++--------------------------- audio/trace-events | 5 ++ 2 files changed, 72 insertions(+), 102 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index d3697a148da..3058af58e0b 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -26,17 +26,15 @@ #include #include "qemu/main-loop.h" #include "qemu/module.h" +#include "qemu/error-report.h" #include "qemu/audio.h" #include "qom/object.h" #include "trace.h" =20 #pragma GCC diagnostic ignored "-Waddress" =20 -#define AUDIO_CAP "alsa" #include "audio_int.h" =20 -#define DEBUG_ALSA 0 - #define TYPE_AUDIO_ALSA "audio-alsa" OBJECT_DECLARE_SIMPLE_TYPE(AudioALSA, AUDIO_ALSA) =20 @@ -81,33 +79,29 @@ struct alsa_params_obt { snd_pcm_uframes_t samples; }; =20 -static void G_GNUC_PRINTF (2, 3) alsa_logerr (int err, const char *fmt, ..= .) +static void G_GNUC_PRINTF(2, 3) alsa_logerr(int err, const char *fmt, ...) { va_list ap; =20 - va_start (ap, fmt); - AUD_vlog (AUDIO_CAP, fmt, ap); - va_end (ap); - - AUD_log (AUDIO_CAP, "Reason: %s\n", snd_strerror (err)); + error_printf("alsa: "); + va_start(ap, fmt); + error_vprintf(fmt, ap); + va_end(ap); + error_printf(" Reason: %s", snd_strerror(err)); + error_printf("\n"); } =20 -static void G_GNUC_PRINTF (3, 4) alsa_logerr2 ( - int err, - const char *typ, - const char *fmt, - ... - ) +static void G_GNUC_PRINTF(3, 4) alsa_logerr2(int err, const char *typ, + const char *fmt, ...) { va_list ap; =20 - AUD_log (AUDIO_CAP, "Could not initialize %s\n", typ); - - va_start (ap, fmt); - AUD_vlog (AUDIO_CAP, fmt, ap); - va_end (ap); - - AUD_log (AUDIO_CAP, "Reason: %s\n", snd_strerror (err)); + error_printf("alsa: Could not initialize %s:", typ); + va_start(ap, fmt); + error_vprintf(fmt, ap); + va_end(ap); + error_printf(" Reason: %s", snd_strerror(err)); + error_printf("\n"); } =20 static void alsa_fini_poll (struct pollhlp *hlp) @@ -130,7 +124,7 @@ static void alsa_anal_close1 (snd_pcm_t **handlep) { int err =3D snd_pcm_close (*handlep); if (err) { - alsa_logerr (err, "Failed to close PCM handle %p\n", *handlep); + alsa_logerr(err, "Failed to close PCM handle %p", *handlep); } *handlep =3D NULL; } @@ -145,7 +139,7 @@ static int alsa_recover (snd_pcm_t *handle) { int err =3D snd_pcm_prepare (handle); if (err < 0) { - alsa_logerr (err, "Failed to prepare handle %p\n", handle); + alsa_logerr(err, "Failed to prepare handle %p", handle); return -1; } return 0; @@ -155,7 +149,7 @@ static int alsa_resume (snd_pcm_t *handle) { int err =3D snd_pcm_resume (handle); if (err < 0) { - alsa_logerr (err, "Failed to resume handle %p\n", handle); + alsa_logerr(err, "Failed to resume handle %p", handle); return -1; } return 0; @@ -170,7 +164,7 @@ static void alsa_poll_handler (void *opaque) =20 count =3D poll (hlp->pfds, hlp->count, 0); if (count < 0) { - dolog ("alsa_poll_handler: poll %s\n", strerror (errno)); + warn_report("alsa_poll_handler: poll %s", strerror(errno)); return; } =20 @@ -183,7 +177,7 @@ static void alsa_poll_handler (void *opaque) err =3D snd_pcm_poll_descriptors_revents (hlp->handle, hlp->pfds, hlp->count, &revents); if (err < 0) { - alsa_logerr (err, "snd_pcm_poll_descriptors_revents"); + alsa_logerr(err, "snd_pcm_poll_descriptors_revents"); return; } =20 @@ -215,7 +209,7 @@ static void alsa_poll_handler (void *opaque) break; =20 default: - dolog ("Unexpected state %d\n", state); + warn_report("alsa: Unexpected state %d", state); } } =20 @@ -226,8 +220,8 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct = pollhlp *hlp, int mask) =20 count =3D snd_pcm_poll_descriptors_count (handle); if (count <=3D 0) { - dolog ("Could not initialize poll mode\n" - "Invalid number of poll descriptors %d\n", count); + warn_report("alsa: Could not initialize poll mode: " + "Invalid number of poll descriptors %d", count); return -1; } =20 @@ -235,8 +229,7 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct = pollhlp *hlp, int mask) =20 err =3D snd_pcm_poll_descriptors (handle, pfds, count); if (err < 0) { - alsa_logerr (err, "Could not initialize poll mode\n" - "Could not obtain poll descriptors\n"); + alsa_logerr(err, "Could not initialize poll mode: Could not obtain= poll descriptors"); g_free (pfds); return -1; } @@ -298,10 +291,7 @@ static snd_pcm_format_t aud_to_alsafmt(AudioFormat fmt= , bool big_endian) return big_endian ? SND_PCM_FORMAT_FLOAT_BE : SND_PCM_FORMAT_FLOAT= _LE; =20 default: - dolog ("Internal logic error: Bad audio format %d\n", fmt); -#ifdef DEBUG_AUDIO - abort (); -#endif + warn_report("alsa: Internal logic error: Bad audio format %d", fmt= ); return SND_PCM_FORMAT_U8; } } @@ -371,29 +361,13 @@ static int alsa_to_audfmt (snd_pcm_format_t alsafmt, = AudioFormat *fmt, break; =20 default: - dolog ("Unrecognized audio format %d\n", alsafmt); + warn_report("alsa: Unrecognized audio format %d", alsafmt); return -1; } =20 return 0; } =20 -static void alsa_dump_info (struct alsa_params_req *req, - struct alsa_params_obt *obt, - snd_pcm_format_t obtfmt, - AudiodevAlsaPerDirectionOptions *apdo) -{ - dolog("parameter | requested value | obtained value\n"); - dolog("format | %10d | %10d\n", req->fmt, obtfmt); - dolog("channels | %10d | %10d\n", - req->nchannels, obt->nchannels); - dolog("frequency | %10d | %10d\n", req->freq, obt->freq); - dolog("=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D\n"); - dolog("requested: buffer len %" PRId32 " period len %" PRId32 "\n", - apdo->buffer_length, apdo->period_length); - dolog("obtained: samples %ld\n", obt->samples); -} - static void alsa_set_threshold (snd_pcm_t *handle, snd_pcm_uframes_t thres= hold) { int err; @@ -403,23 +377,22 @@ static void alsa_set_threshold (snd_pcm_t *handle, sn= d_pcm_uframes_t threshold) =20 err =3D snd_pcm_sw_params_current (handle, sw_params); if (err < 0) { - dolog ("Could not fully initialize DAC\n"); - alsa_logerr (err, "Failed to get current software parameters\n"); + error_report("alsa: Could not fully initialize DAC"); + alsa_logerr(err, "Failed to get current software parameters"); return; } =20 err =3D snd_pcm_sw_params_set_start_threshold (handle, sw_params, thre= shold); if (err < 0) { - dolog ("Could not fully initialize DAC\n"); - alsa_logerr (err, "Failed to set software threshold to %ld\n", - threshold); + error_report("alsa: Could not fully initialize DAC"); + alsa_logerr(err, "Failed to set software threshold to %ld", thresh= old); return; } =20 err =3D snd_pcm_sw_params (handle, sw_params); if (err < 0) { - dolog ("Could not fully initialize DAC\n"); - alsa_logerr (err, "Failed to set software parameters\n"); + error_report("alsa: Could not fully initialize DAC"); + alsa_logerr(err, "Failed to set software parameters"); return; } } @@ -451,13 +424,13 @@ static int alsa_open(bool in, struct alsa_params_req = *req, SND_PCM_NONBLOCK ); if (err < 0) { - alsa_logerr2 (err, typ, "Failed to open `%s':\n", pcm_name); + alsa_logerr2(err, typ, "Failed to open `%s'", pcm_name); return -1; } =20 err =3D snd_pcm_hw_params_any (handle, hw_params); if (err < 0) { - alsa_logerr2 (err, typ, "Failed to initialize hardware parameters\= n"); + alsa_logerr2(err, typ, "Failed to initialize hardware parameters"); goto err; } =20 @@ -467,18 +440,18 @@ static int alsa_open(bool in, struct alsa_params_req = *req, SND_PCM_ACCESS_RW_INTERLEAVED ); if (err < 0) { - alsa_logerr2 (err, typ, "Failed to set access type\n"); + alsa_logerr2(err, typ, "Failed to set access type"); goto err; } =20 err =3D snd_pcm_hw_params_set_format (handle, hw_params, req->fmt); if (err < 0) { - alsa_logerr2 (err, typ, "Failed to set format %d\n", req->fmt); + alsa_logerr2(err, typ, "Failed to set format %d", req->fmt); } =20 err =3D snd_pcm_hw_params_set_rate_near (handle, hw_params, &freq, 0); if (err < 0) { - alsa_logerr2 (err, typ, "Failed to set frequency %d\n", req->freq); + alsa_logerr2(err, typ, "Failed to set frequency %d", req->freq); goto err; } =20 @@ -488,8 +461,7 @@ static int alsa_open(bool in, struct alsa_params_req *r= eq, &nchannels ); if (err < 0) { - alsa_logerr2 (err, typ, "Failed to set number of channels %d\n", - req->nchannels); + alsa_logerr2(err, typ, "Failed to set number of channels %d", req-= >nchannels); goto err; } =20 @@ -501,14 +473,14 @@ static int alsa_open(bool in, struct alsa_params_req = *req, handle, hw_params, &btime, &dir); =20 if (err < 0) { - alsa_logerr2(err, typ, "Failed to set buffer time to %" PRId32= "\n", + alsa_logerr2(err, typ, "Failed to set buffer time to %" PRId32, apdo->buffer_length); goto err; } =20 if (apdo->has_buffer_length && btime !=3D apdo->buffer_length) { - dolog("Requested buffer time %" PRId32 - " was rejected, using %u\n", apdo->buffer_length, btime); + warn_report("alsa: Requested buffer time %" PRId32 " was rejec= ted, using %u", + apdo->buffer_length, btime); } } =20 @@ -520,43 +492,43 @@ static int alsa_open(bool in, struct alsa_params_req = *req, &dir); =20 if (err < 0) { - alsa_logerr2(err, typ, "Failed to set period time to %" PRId32= "\n", + alsa_logerr2(err, typ, "Failed to set period time to %" PRId32, apdo->period_length); goto err; } =20 if (apdo->has_period_length && ptime !=3D apdo->period_length) { - dolog("Requested period time %" PRId32 " was rejected, using %= d\n", - apdo->period_length, ptime); + warn_report("alsa: Requested period time %" PRId32 " was rejec= ted, using %d", + apdo->period_length, ptime); } } =20 err =3D snd_pcm_hw_params (handle, hw_params); if (err < 0) { - alsa_logerr2 (err, typ, "Failed to apply audio parameters\n"); + alsa_logerr2(err, typ, "Failed to apply audio parameters"); goto err; } =20 err =3D snd_pcm_hw_params_get_buffer_size (hw_params, &obt_buffer_size= ); if (err < 0) { - alsa_logerr2 (err, typ, "Failed to get buffer size\n"); + alsa_logerr2(err, typ, "Failed to get buffer size"); goto err; } =20 err =3D snd_pcm_hw_params_get_format (hw_params, &obtfmt); if (err < 0) { - alsa_logerr2 (err, typ, "Failed to get format\n"); + alsa_logerr2(err, typ, "Failed to get format"); goto err; } =20 if (alsa_to_audfmt (obtfmt, &obt->fmt, &obt->endianness)) { - dolog ("Invalid format was returned %d\n", obtfmt); + error_report("alsa: Invalid format was returned %d", obtfmt); goto err; } =20 err =3D snd_pcm_prepare (handle); if (err < 0) { - alsa_logerr2 (err, typ, "Could not prepare handle %p\n", handle); + alsa_logerr2(err, typ, "Could not prepare handle %p", handle); goto err; } =20 @@ -574,11 +546,9 @@ static int alsa_open(bool in, struct alsa_params_req *= req, =20 *handlep =3D handle; =20 - if (DEBUG_ALSA || obtfmt !=3D req->fmt || - obt->nchannels !=3D req->nchannels || obt->freq !=3D req->freq) { - dolog ("Audio parameters for %s\n", typ); - alsa_dump_info(req, obt, obtfmt, apdo); - } + trace_alsa_info_params(req->fmt, obtfmt, req->nchannels, obt->nchannel= s, + req->freq, obt->freq); + trace_alsa_info_samples(apdo->buffer_length, apdo->period_length, obt-= >samples); =20 return 0; =20 @@ -601,8 +571,7 @@ static size_t alsa_buffer_get_free(HWVoiceOut *hw) } } if (avail < 0) { - alsa_logerr(avail, - "Could not obtain number of available frames\n"); + alsa_logerr(avail, "Could not obtain number of available frame= s"); avail =3D 0; } } @@ -643,8 +612,7 @@ static size_t alsa_write(HWVoiceOut *hw, void *buf, siz= e_t len) =20 case -EPIPE: if (alsa_recover(alsa->handle)) { - alsa_logerr(written, "Failed to write %zu frames\n", - len_frames); + alsa_logerr(written, "Failed to write %zu frames", len= _frames); return pos; } trace_alsa_xrun_out(); @@ -656,8 +624,7 @@ static size_t alsa_write(HWVoiceOut *hw, void *buf, siz= e_t len) * recovery */ if (alsa_resume(alsa->handle)) { - alsa_logerr(written, "Failed to write %zu frames\n", - len_frames); + alsa_logerr(written, "Failed to write %zu frames", len= _frames); return pos; } trace_alsa_resume_out(); @@ -667,8 +634,7 @@ static size_t alsa_write(HWVoiceOut *hw, void *buf, siz= e_t len) return pos; =20 default: - alsa_logerr(written, "Failed to write %zu frames from %p\n= ", - len, src); + alsa_logerr(written, "Failed to write %zu frames from %p",= len_frames, src); return pos; } } @@ -687,7 +653,7 @@ static void alsa_fini_out (HWVoiceOut *hw) { ALSAVoiceOut *alsa =3D (ALSAVoiceOut *) hw; =20 - ldebug ("alsa_fini\n"); + trace_alsa_fini_out(); alsa_anal_close (&alsa->handle, &alsa->pollhlp); } =20 @@ -732,19 +698,19 @@ static int alsa_voice_ctl (snd_pcm_t *handle, const c= har *typ, int ctl) if (ctl =3D=3D VOICE_CTL_PAUSE) { err =3D snd_pcm_drop (handle); if (err < 0) { - alsa_logerr (err, "Could not stop %s\n", typ); + alsa_logerr(err, "Could not stop %s", typ); return -1; } } else { err =3D snd_pcm_prepare (handle); if (err < 0) { - alsa_logerr (err, "Could not prepare handle for %s\n", typ); + alsa_logerr(err, "Could not prepare handle for %s", typ); return -1; } if (ctl =3D=3D VOICE_CTL_START) { err =3D snd_pcm_start(handle); if (err < 0) { - alsa_logerr (err, "Could not start handle for %s\n", typ); + alsa_logerr(err, "Could not start handle for %s", typ); return -1; } } @@ -758,17 +724,17 @@ static void alsa_enable_out(HWVoiceOut *hw, bool enab= le) ALSAVoiceOut *alsa =3D (ALSAVoiceOut *) hw; AudiodevAlsaPerDirectionOptions *apdo =3D hw->s->dev->u.alsa.out; =20 + trace_alsa_enable_out(enable); + if (enable) { bool poll_mode =3D apdo->try_poll; =20 - ldebug("enabling voice\n"); if (poll_mode && alsa_poll_out(hw)) { poll_mode =3D 0; } hw->poll_mode =3D poll_mode; alsa_voice_ctl(alsa->handle, "playback", VOICE_CTL_PREPARE); } else { - ldebug("disabling voice\n"); if (hw->poll_mode) { hw->poll_mode =3D 0; alsa_fini_poll(&alsa->pollhlp); @@ -834,7 +800,7 @@ static size_t alsa_read(HWVoiceIn *hw, void *buf, size_= t len) =20 case -EPIPE: if (alsa_recover(alsa->handle)) { - alsa_logerr(nread, "Failed to read %zu frames\n", len); + alsa_logerr(nread, "Failed to read %zu frames", len); return pos; } trace_alsa_xrun_in(); @@ -844,8 +810,7 @@ static size_t alsa_read(HWVoiceIn *hw, void *buf, size_= t len) return pos; =20 default: - alsa_logerr(nread, "Failed to read %zu frames to %p\n", - len, dst); + alsa_logerr(nread, "Failed to read %zu frames to %p", len,= dst); return pos; } } @@ -862,10 +827,11 @@ static void alsa_enable_in(HWVoiceIn *hw, bool enable) ALSAVoiceIn *alsa =3D (ALSAVoiceIn *) hw; AudiodevAlsaPerDirectionOptions *apdo =3D hw->s->dev->u.alsa.in; =20 + trace_alsa_enable_in(enable); + if (enable) { bool poll_mode =3D apdo->try_poll; =20 - ldebug("enabling voice\n"); if (poll_mode && alsa_poll_in(hw)) { poll_mode =3D 0; } @@ -873,7 +839,6 @@ static void alsa_enable_in(HWVoiceIn *hw, bool enable) =20 alsa_voice_ctl(alsa->handle, "capture", VOICE_CTL_START); } else { - ldebug ("disabling voice\n"); if (hw->poll_mode) { hw->poll_mode =3D 0; alsa_fini_poll(&alsa->pollhlp); diff --git a/audio/trace-events b/audio/trace-events index f7f639d9605..737e3e60694 100644 --- a/audio/trace-events +++ b/audio/trace-events @@ -9,6 +9,11 @@ alsa_read_zero(long len) "Failed to read %ld frames (read = zero)" alsa_xrun_out(void) "Recovering from playback xrun" alsa_xrun_in(void) "Recovering from capture xrun" alsa_resume_out(void) "Resuming suspended output stream" +alsa_info_params(int req_fmt, int obt_fmt, int req_channels, int obt_chann= els, int req_freq, int obt_freq) "format %d->%d, channels %d->%d, frequency= %d->%d" +alsa_info_samples(int buffer_length, int period_length, long samples) "req= uested: buffer len %d, period len %d; obtained: %ld samples" +alsa_fini_out(void) "" +alsa_enable_out(bool enable) "enable=3D%d" +alsa_enable_in(bool enable) "enable=3D%d" =20 # ossaudio.c oss_version(int version) "OSS version =3D 0x%x" --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538659; cv=none; d=zohomail.com; s=zohoarc; b=mLgRfyFtWwzeFrKvKECEKF/2Y0XVDb7sRlghtYr4uF12amZL8k0p8vu9mztQLdW8MKdD1tiX6z21iRh43VRg9OB/u9ru7fWq/sJpnE5Lb3Thss5dyZhKEA5iP+2/HKKxbA8p8+MkSbtNud6yH4vLwK2IWHm0wAchUZUQjDrbwbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538659; 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=52OdNpdwwZ/rPIzESn/Hb+mrzd9AWUtPqG8Ws/yqOBY=; b=DVHY7jXfLlbweaG5HXlug03awO3tbJ9fNFVOXFWpWYXmMSoYpcY4u+9Y1iHGSS/OkUMhkcV+IUUlDxsvy7x8IlwKjAjETYyjY2SFF0UaLZ0+cdtoJhOK9UAfDUFV8bV98gdsKm43c/x8E69iSM4Go2QLvFHRNQ9krt9JVcPnH+4= 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 1769538659453915.1079979376659; Tue, 27 Jan 2026 10:30:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknnS-0008SE-EU; Tue, 27 Jan 2026 13:28:14 -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 1vknmg-0006jF-Tr for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27: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 1vknme-0003GU-SI for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:26 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-dhYoyCR2ONWyhTpYkT981w-1; Tue, 27 Jan 2026 13:27:17 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4327A18005AE; Tue, 27 Jan 2026 18:27:16 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D96F519560B2; Tue, 27 Jan 2026 18:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538443; 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=52OdNpdwwZ/rPIzESn/Hb+mrzd9AWUtPqG8Ws/yqOBY=; b=HRDUr6klLGTLtcn5aMzuttwYU23Oa0ue681dbO97Uscaf5otadEAbuk6wYr0kq64Gi3ZIy pOtzrG/7uYhyJDpLxyKgg8HP4dlUeVyVzO6YZ/+97Z1MIcNIRcxWaHOBizKdj47XI5NJDf o22d3IebRFMGyZmvdygTwNJ+6U1Gkt0= X-MC-Unique: dhYoyCR2ONWyhTpYkT981w-1 X-Mimecast-MFC-AGG-ID: dhYoyCR2ONWyhTpYkT981w_1769538436 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , Akihiko Odaki Subject: [PATCH 19/43] audio/coreaudio: replace custom logging with error_report Date: Tue, 27 Jan 2026 22:24:46 +0400 Message-ID: <20260127182516.289834-20-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.12 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538660484158500 From: Marc-Andr=C3=A9 Lureau The CoreAudio backend uses its own logging infrastructure (AUD_log, AUD_vlog, dolog) and the AUDIO_CAP macro. This approach is inconsistent with the rest of QEMU and makes the output harder to filter and configure. Replace the custom logging with standard QEMU error reporting: - Use error_report() / error_printf() for errors - Use warn_report() for non-fatal warnings (buffer frame size adjustments) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki --- audio/coreaudio.m | 124 ++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 64 deletions(-) diff --git a/audio/coreaudio.m b/audio/coreaudio.m index af614144bd1..40d7986b1d7 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -28,10 +28,9 @@ =20 #include "qemu/main-loop.h" #include "qemu/module.h" +#include "qemu/error-report.h" #include "qemu/audio.h" #include "qom/object.h" - -#define AUDIO_CAP "coreaudio" #include "audio_int.h" =20 #define TYPE_AUDIO_COREAUDIO "audio-coreaudio" @@ -157,7 +156,7 @@ static OSStatus coreaudio_get_isrunning(AudioDeviceID i= d, UInt32 *result) result); } =20 -static void coreaudio_logstatus (OSStatus status) +static void coreaudio_logstatus(OSStatus status) { const char *str =3D "BUG"; =20 @@ -207,70 +206,64 @@ static void coreaudio_logstatus (OSStatus status) break; =20 default: - AUD_log (AUDIO_CAP, "Reason: status code %" PRId32 "\n", (int32_t)= status); + error_printf(" Reason: status code %" PRId32, (int32_t)status); return; } =20 - AUD_log (AUDIO_CAP, "Reason: %s\n", str); + error_printf(" Reason: %s", str); } =20 -static void G_GNUC_PRINTF (2, 3) coreaudio_logerr ( - OSStatus status, - const char *fmt, - ... - ) +static void G_GNUC_PRINTF(2, 3) coreaudio_logerr(OSStatus status, + const char *fmt, ...) { va_list ap; =20 - va_start (ap, fmt); - AUD_log (AUDIO_CAP, fmt, ap); - va_end (ap); - - coreaudio_logstatus (status); + error_printf("coreaudio: "); + va_start(ap, fmt); + error_vprintf(fmt, ap); + va_end(ap); + coreaudio_logstatus(status); + error_printf("\n"); } =20 -static void G_GNUC_PRINTF (3, 4) coreaudio_logerr2 ( - OSStatus status, - const char *typ, - const char *fmt, - ... - ) +static void G_GNUC_PRINTF(3, 4) coreaudio_logerr2(OSStatus status, + const char *typ, + const char *fmt, ...) { va_list ap; =20 - AUD_log (AUDIO_CAP, "Could not initialize %s\n", typ); - - va_start (ap, fmt); - AUD_vlog (AUDIO_CAP, fmt, ap); - va_end (ap); - - coreaudio_logstatus (status); + error_printf("coreaudio: Could not initialize %s: ", typ); + va_start(ap, fmt); + error_vprintf(fmt, ap); + va_end(ap); + coreaudio_logstatus(status); + error_printf("\n"); } =20 #define coreaudio_playback_logerr(status, ...) \ coreaudio_logerr2(status, "playback", __VA_ARGS__) =20 -static int coreaudio_buf_lock (coreaudioVoiceOut *core, const char *fn_nam= e) +static int coreaudio_buf_lock(coreaudioVoiceOut *core, const char *fn_name) { int err; =20 - err =3D pthread_mutex_lock (&core->buf_mutex); + err =3D pthread_mutex_lock(&core->buf_mutex); if (err) { - dolog ("Could not lock voice for %s\nReason: %s\n", - fn_name, strerror (err)); + error_report("coreaudio: Could not lock voice for %s: %s", + fn_name, strerror(err)); return -1; } return 0; } =20 -static int coreaudio_buf_unlock (coreaudioVoiceOut *core, const char *fn_n= ame) +static int coreaudio_buf_unlock(coreaudioVoiceOut *core, const char *fn_na= me) { int err; =20 - err =3D pthread_mutex_unlock (&core->buf_mutex); + err =3D pthread_mutex_unlock(&core->buf_mutex); if (err) { - dolog ("Could not unlock voice for %s\nReason: %s\n", - fn_name, strerror (err)); + error_report("coreaudio: Could not unlock voice for %s: %s", + fn_name, strerror(err)); return -1; } return 0; @@ -378,12 +371,13 @@ static OSStatus init_out_device(coreaudioVoiceOut *co= re) =20 status =3D coreaudio_get_voice(&core->outputDeviceID); if (status !=3D kAudioHardwareNoError) { - coreaudio_playback_logerr (status, - "Could not get default output Device\n"= ); + coreaudio_playback_logerr(status, + "Could not get default output device"); return status; } if (core->outputDeviceID =3D=3D kAudioDeviceUnknown) { - dolog ("Could not initialize playback - Unknown Audiodevice\n"); + error_report("coreaudio: Could not initialize playback: " + "Unknown audio device"); return status; } =20 @@ -394,17 +388,19 @@ static OSStatus init_out_device(coreaudioVoiceOut *co= re) return 0; } if (status !=3D kAudioHardwareNoError) { - coreaudio_playback_logerr (status, - "Could not get device buffer frame ran= ge\n"); + coreaudio_playback_logerr(status, + "Could not get device buffer frame range= "); return status; } =20 if (frameRange.mMinimum > core->frameSizeSetting) { core->audioDevicePropertyBufferFrameSize =3D (UInt32) frameRange.m= Minimum; - dolog ("warning: Upsizing Buffer Frames to %f\n", frameRange.mMini= mum); + warn_report("coreaudio: Upsizing buffer frames to %f", + frameRange.mMinimum); } else if (frameRange.mMaximum < core->frameSizeSetting) { core->audioDevicePropertyBufferFrameSize =3D (UInt32) frameRange.m= Maximum; - dolog ("warning: Downsizing Buffer Frames to %f\n", frameRange.mMa= ximum); + warn_report("coreaudio: Downsizing buffer frames to %f", + frameRange.mMaximum); } else { core->audioDevicePropertyBufferFrameSize =3D core->frameSizeSettin= g; } @@ -416,9 +412,9 @@ static OSStatus init_out_device(coreaudioVoiceOut *core) return 0; } if (status !=3D kAudioHardwareNoError) { - coreaudio_playback_logerr (status, - "Could not set device buffer frame siz= e %" PRIu32 "\n", - (uint32_t)core->audioDevicePropertyBuf= ferFrameSize); + coreaudio_playback_logerr(status, + "Could not set device buffer frame size = %" PRIu32, + (uint32_t)core->audioDevicePropertyBuffe= rFrameSize); return status; } =20 @@ -429,8 +425,8 @@ static OSStatus init_out_device(coreaudioVoiceOut *core) return 0; } if (status !=3D kAudioHardwareNoError) { - coreaudio_playback_logerr (status, - "Could not get device buffer frame siz= e\n"); + coreaudio_playback_logerr(status, + "Could not get device buffer frame size"= ); return status; } core->hw.samples =3D core->bufferCount * core->audioDevicePropertyBuff= erFrameSize; @@ -442,9 +438,9 @@ static OSStatus init_out_device(coreaudioVoiceOut *core) return 0; } if (status !=3D kAudioHardwareNoError) { - coreaudio_playback_logerr (status, - "Could not set samplerate %lf\n", - streamBasicDescription.mSampleRate); + coreaudio_playback_logerr(status, + "Could not set samplerate %lf", + streamBasicDescription.mSampleRate); core->outputDeviceID =3D kAudioDeviceUnknown; return status; } @@ -468,7 +464,7 @@ static OSStatus init_out_device(coreaudioVoiceOut *core) return 0; } if (status !=3D kAudioHardwareNoError || core->ioprocid =3D=3D NULL) { - coreaudio_playback_logerr (status, "Could not set IOProc\n"); + coreaudio_playback_logerr(status, "Could not set IOProc"); core->outputDeviceID =3D kAudioDeviceUnknown; return status; } @@ -486,13 +482,13 @@ static void fini_out_device(coreaudioVoiceOut *core) if (status !=3D kAudioHardwareBadObjectError) { if (status !=3D kAudioHardwareNoError) { coreaudio_logerr(status, - "Could not determine whether Device is playin= g\n"); + "Could not determine whether device is playin= g"); } =20 if (isrunning) { status =3D AudioDeviceStop(core->outputDeviceID, core->ioproci= d); if (status !=3D kAudioHardwareBadDeviceError && status !=3D kA= udioHardwareNoError) { - coreaudio_logerr(status, "Could not stop playback\n"); + coreaudio_logerr(status, "Could not stop playback"); } } } @@ -501,7 +497,7 @@ static void fini_out_device(coreaudioVoiceOut *core) status =3D AudioDeviceDestroyIOProcID(core->outputDeviceID, core->ioprocid); if (status !=3D kAudioHardwareBadDeviceError && status !=3D kAudioHard= wareNoError) { - coreaudio_logerr(status, "Could not remove IOProc\n"); + coreaudio_logerr(status, "Could not remove IOProc"); } core->outputDeviceID =3D kAudioDeviceUnknown; } @@ -515,7 +511,7 @@ static void update_device_playback_state(coreaudioVoice= Out *core) if (status !=3D kAudioHardwareNoError) { if (status !=3D kAudioHardwareBadObjectError) { coreaudio_logerr(status, - "Could not determine whether Device is playin= g\n"); + "Could not determine whether device is playin= g"); } =20 return; @@ -526,7 +522,7 @@ static void update_device_playback_state(coreaudioVoice= Out *core) if (!isrunning) { status =3D AudioDeviceStart(core->outputDeviceID, core->ioproc= id); if (status !=3D kAudioHardwareBadDeviceError && status !=3D kA= udioHardwareNoError) { - coreaudio_logerr (status, "Could not resume playback\n"); + coreaudio_logerr(status, "Could not resume playback"); } } } else { @@ -535,7 +531,7 @@ static void update_device_playback_state(coreaudioVoice= Out *core) status =3D AudioDeviceStop(core->outputDeviceID, core->ioprocid); if (status !=3D kAudioHardwareBadDeviceError && status !=3D kA= udioHardwareNoError) { - coreaudio_logerr(status, "Could not pause playback\n"); + coreaudio_logerr(status, "Could not pause playback"); } } } @@ -576,7 +572,7 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct au= dsettings *as) /* create mutex */ err =3D pthread_mutex_init(&core->buf_mutex, NULL); if (err) { - dolog("Could not create mutex\nReason: %s\n", strerror (err)); + error_report("coreaudio: Could not create mutex: %s", strerror(err= )); return -1; } =20 @@ -594,8 +590,8 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct au= dsettings *as) &voice_addr, handle_voice_chan= ge, core); if (status !=3D kAudioHardwareNoError) { - coreaudio_playback_logerr (status, - "Could not listen to voice property cha= nge\n"); + coreaudio_playback_logerr(status, + "Could not listen to voice property chan= ge"); return -1; } =20 @@ -606,7 +602,7 @@ static int coreaudio_init_out(HWVoiceOut *hw, struct au= dsettings *as) core); if (status !=3D kAudioHardwareNoError) { coreaudio_playback_logerr(status, - "Could not remove voice property cha= nge listener\n"); + "Could not remove voice property cha= nge listener"); } =20 return -1; @@ -626,7 +622,7 @@ static void coreaudio_fini_out (HWVoiceOut *hw) handle_voice_change, core); if (status !=3D kAudioHardwareNoError) { - coreaudio_logerr(status, "Could not remove voice property change l= istener\n"); + coreaudio_logerr(status, "Could not remove voice property change l= istener"); } =20 fini_out_device(core); @@ -634,7 +630,7 @@ static void coreaudio_fini_out (HWVoiceOut *hw) /* destroy mutex */ err =3D pthread_mutex_destroy(&core->buf_mutex); if (err) { - dolog("Could not destroy mutex\nReason: %s\n", strerror (err)); + error_report("coreaudio: Could not destroy mutex: %s", strerror(er= r)); } } =20 --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538611; cv=none; d=zohomail.com; s=zohoarc; b=Ltv34wkb+qho8wnZPT3R/Qw4MmI6ZuTN3s5BoTkGR+BNI260p8A7ank540jo9+nlzgY2nJKAqBqx3vUiLWO30FjfdIytrBbM8wBzOOa9I2QnqvqXlvy7yS9Q5Zj0IV2yF8xLw10LvflamKawho64oZ8e3IGdX57dIp+8GBfEsUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538611; 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=/QvH9AddxhOejOpg3DVvYmoSf2Li1vTGLcDdkO/i7R4=; b=MALvY52JzmCyJRwnl5yh4DrohqhG+pxAcJYBZ8DzCrIMVLGBSF1UvEySsZ0FxS/IMxOmzAhhBt0UvEivbj6a2Xnts6B0nJX9MXR6jY2m5006Z6PKupI4+MrUk9xvlZ4EuVtYmg48dWb577vpzA8RiiVP5+Z3p8qT0BWomcD35EQ= 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 1769538611425265.090495293549; Tue, 27 Jan 2026 10:30:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknnf-0001OM-4C; Tue, 27 Jan 2026 13:28:29 -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 1vknmg-0006j8-AB for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27: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 1vknme-0003Ga-S5 for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:26 -0500 Received: from mx-prod-mc-05.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-318-5VDuW_JHNQiivTuPmhNvfQ-1; Tue, 27 Jan 2026 13:27:22 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 83BDB1956096; Tue, 27 Jan 2026 18:27:21 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3925D18004D8; Tue, 27 Jan 2026 18:27:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538443; 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=/QvH9AddxhOejOpg3DVvYmoSf2Li1vTGLcDdkO/i7R4=; b=cuIJ3pMnYUmSJugytwAs5fWPBcKsdDvbp2E5zzc9/B86fX+oib++V0hfW9XepZlMXxb2fP ChwtMltCWX6iUqNaBigSJRa/IhxD9Ktw9mWHcs2d/Vyo8lrmalb2MTjUg0cXy/ncGVmiu5 d205IHcUBA7d/m5qC+XQfmqHZKoBNGs= X-MC-Unique: 5VDuW_JHNQiivTuPmhNvfQ-1 X-Mimecast-MFC-AGG-ID: 5VDuW_JHNQiivTuPmhNvfQ_1769538441 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 20/43] audio/dbus: remove unused AUDIO_CAP macro Date: Tue, 27 Jan 2026 22:24:47 +0400 Message-ID: <20260127182516.289834-21-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538612063158500 From: Marc-Andr=C3=A9 Lureau The DBus audio backend already uses error_report() for error logging. Remove the unused AUDIO_CAP macro which was left over from the old logging infrastructure. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/dbusaudio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index 9d5331b8c47..e284542b2dd 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -36,7 +36,6 @@ #include "ui/dbus-display.h" #include "ui/dbus-display1.h" =20 -#define AUDIO_CAP "dbus" #include "qemu/audio.h" #include "audio_int.h" #include "trace.h" --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538590; cv=none; d=zohomail.com; s=zohoarc; b=lOz/AMHa0zHc1vU10PFRhSDepXYs3xBom/mxV9hM/TtzjZOogaeLpyvKJ3Ze2rfYUZsoeoBKZ3CNNYOclvsCT0ZJ0gvbcZMgWwkee+ItuH6s3pvufEu54t2rqzLK5BXONz4h23GaA3MAoZmbgnLeV4tdKyzlxngzjZrtWNTZUXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538590; 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=cncirRWqxnV/aMGqhBJFl/3SjgKGGKTbkjCS1elG0+s=; b=ETpqkuxtFCmaL01wyn2meTTay2ZXq3Vl9UwuINnKA5atSYPg9cwEYAlrVeVna1Q4/fonNWVGPk358SXK11Xsc2GYy2faEzFu+kAHmQSKs7iOLW1uGrXV1kY+Sdow9wEC/I6Z9/WKvo3QHU0Ev3LVzAJxLNrs6a+Qr7nK3TWnUlQ= 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 1769538590075773.1396063170846; Tue, 27 Jan 2026 10:29:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknmz-00078s-Eg; Tue, 27 Jan 2026 13:27: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 1vknmp-0006th-CR for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:39 -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 1vknmm-0003HO-P1 for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27: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-602-KHjrDHeEOVGjdOJToXHDng-1; Tue, 27 Jan 2026 13:27:28 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 8CE4E1944EBB; Tue, 27 Jan 2026 18:27:27 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DF093195419A; Tue, 27 Jan 2026 18:27:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538451; 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=cncirRWqxnV/aMGqhBJFl/3SjgKGGKTbkjCS1elG0+s=; b=ENl16soivC/O19m8Ykp+1xhLedlvOBC2R+8dAcA3GaFJf4l4tIeEXeyG/hxO+5o6rZQ4sG uXOII4V8vGFEm15tZob1R+BhhKLyxhaNPnrGriW/fz/1xtpsUk3VkULaJSozWneea8JJ6h 3YTrmdQXbpDcZQPx+7ZjCdfJjSjY9qo= X-MC-Unique: KHjrDHeEOVGjdOJToXHDng-1 X-Mimecast-MFC-AGG-ID: KHjrDHeEOVGjdOJToXHDng_1769538447 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 21/43] audio/dsound: replace custom logging with error_report & trace Date: Tue, 27 Jan 2026 22:24:48 +0400 Message-ID: <20260127182516.289834-22-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.17 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538592522154100 From: Marc-Andr=C3=A9 Lureau The DirectSound audio backend uses its own logging infrastructure (AUD_log, AUD_vlog, dolog) and the AUDIO_CAP macro. This approach is inconsistent with the rest of QEMU and makes the output harder to filter and configure. Replace the custom logging with standard QEMU error reporting. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/dsound_template.h | 72 ++++++++++----------- audio/audio_win_int.c | 31 +++++----- audio/dsoundaudio.c | 134 ++++++++++++++++------------------------ audio/trace-events | 5 ++ 4 files changed, 108 insertions(+), 134 deletions(-) diff --git a/audio/dsound_template.h b/audio/dsound_template.h index 022a7307c99..af4019bcb34 100644 --- a/audio/dsound_template.h +++ b/audio/dsound_template.h @@ -53,9 +53,9 @@ static int glue (dsound_unlock_, TYPE) ( { HRESULT hr; =20 - hr =3D glue (IFACE, _Unlock) (buf, p1, blen1, p2, blen2); - if (FAILED (hr)) { - dsound_logerr (hr, "Could not unlock " NAME "\n"); + hr =3D glue(IFACE, _Unlock)(buf, p1, blen1, p2, blen2); + if (FAILED(hr)) { + dsound_logerr(hr, "Could not unlock " NAME); return -1; } =20 @@ -85,35 +85,35 @@ static int glue (dsound_lock_, TYPE) ( #endif hr =3D glue(IFACE, _Lock)(buf, pos, len, p1p, blen1p, p2p, blen2p, fla= g); =20 - if (FAILED (hr)) { + if (FAILED(hr)) { #ifndef DSBTYPE_IN if (hr =3D=3D DSERR_BUFFERLOST) { - if (glue (dsound_restore_, TYPE) (buf, s)) { - dsound_logerr (hr, "Could not lock " NAME "\n"); + if (glue(dsound_restore_, TYPE)(buf, s)) { + dsound_logerr(hr, "Could not lock " NAME); } goto fail; } #endif - dsound_logerr (hr, "Could not lock " NAME "\n"); + dsound_logerr(hr, "Could not lock " NAME); goto fail; } =20 if ((p1p && *p1p && (*blen1p % info->bytes_per_frame)) || (p2p && *p2p && (*blen2p % info->bytes_per_frame))) { - dolog("DirectSound returned misaligned buffer %ld %ld\n", - *blen1p, *blen2p); + error_report("dsound: returned misaligned buffer %ld %ld", + *blen1p, *blen2p); glue(dsound_unlock_, TYPE)(buf, *p1p, p2p ? *p2p : NULL, *blen1p, blen2p ? *blen2p : 0); goto fail; } =20 if (p1p && !*p1p && *blen1p) { - dolog("warning: !p1 && blen1=3D%ld\n", *blen1p); + warn_report("dsound: !p1 && blen1=3D%ld", *blen1p); *blen1p =3D 0; } =20 if (p2p && !*p2p && *blen2p) { - dolog("warning: !p2 && blen2=3D%ld\n", *blen2p); + warn_report("dsound: !p2 && blen2=3D%ld", *blen2p); *blen2p =3D 0; } =20 @@ -143,14 +143,14 @@ static void dsound_fini_out (HWVoiceOut *hw) #endif =20 if (ds->FIELD) { - hr =3D glue (IFACE, _Stop) (ds->FIELD); - if (FAILED (hr)) { - dsound_logerr (hr, "Could not stop " NAME "\n"); + hr =3D glue(IFACE, _Stop)(ds->FIELD); + if (FAILED(hr)) { + dsound_logerr(hr, "Could not stop " NAME); } =20 - hr =3D glue (IFACE, _Release) (ds->FIELD); - if (FAILED (hr)) { - dsound_logerr (hr, "Could not release " NAME "\n"); + hr =3D glue(IFACE, _Release)(ds->FIELD); + if (FAILED(hr)) { + dsound_logerr(hr, "Could not release " NAME); } ds->FIELD =3D NULL; } @@ -182,7 +182,8 @@ static int dsound_init_out(HWVoiceOut *hw, struct audse= ttings *as) #endif =20 if (!s->FIELD2) { - dolog ("Attempt to initialize voice without " NAME2 " object\n"); + error_report("dsound: Attempt to initialize voice without " + NAME2 " object"); return -1; } =20 @@ -212,28 +213,28 @@ static int dsound_init_out(HWVoiceOut *hw, struct aud= settings *as) ); #endif =20 - if (FAILED (hr)) { - dsound_logerr2 (hr, typ, "Could not create " NAME "\n"); + if (FAILED(hr)) { + dsound_logerr2(hr, typ, "Could not create " NAME); return -1; } =20 - hr =3D glue (IFACE, _GetFormat) (ds->FIELD, &wfx, sizeof (wfx), NULL); - if (FAILED (hr)) { - dsound_logerr2 (hr, typ, "Could not get " NAME " format\n"); + hr =3D glue(IFACE, _GetFormat)(ds->FIELD, &wfx, sizeof(wfx), NULL); + if (FAILED(hr)) { + dsound_logerr2(hr, typ, "Could not get " NAME " format"); goto fail0; } =20 -#ifdef DEBUG_DSOUND - dolog (NAME "\n"); - print_wave_format (&wfx); -#endif + trace_dsound_wave_format( + wfx.wFormatTag, wfx.nChannels, + wfx.nSamplesPerSec, wfx.nAvgBytesPerSec, + wfx.nBlockAlign, wfx.wBitsPerSample, wfx.cbSize); =20 memset (&bc, 0, sizeof (bc)); bc.dwSize =3D sizeof (bc); =20 - hr =3D glue (IFACE, _GetCaps) (ds->FIELD, &bc); - if (FAILED (hr)) { - dsound_logerr2 (hr, typ, "Could not get " NAME " format\n"); + hr =3D glue(IFACE, _GetCaps)(ds->FIELD, &bc); + if (FAILED(hr)) { + dsound_logerr2(hr, typ, "Could not get " NAME " caps"); goto fail0; } =20 @@ -247,18 +248,13 @@ static int dsound_init_out(HWVoiceOut *hw, struct aud= settings *as) audio_pcm_init_info (&hw->info, &obt_as); =20 if (bc.dwBufferBytes % hw->info.bytes_per_frame) { - dolog ( - "GetCaps returned misaligned buffer size %ld, alignment %d\n", - bc.dwBufferBytes, hw->info.bytes_per_frame - ); + warn_report("dsound: GetCaps returned misaligned buffer size %ld, " + "alignment %d", bc.dwBufferBytes, hw->info.bytes_per_f= rame); } hw->size_emul =3D bc.dwBufferBytes; hw->samples =3D bc.dwBufferBytes / hw->info.bytes_per_frame; =20 -#ifdef DEBUG_DSOUND - dolog ("caps %ld, desc %ld\n", - bc.dwBufferBytes, bd.dwBufferBytes); -#endif + trace_dsound_buffer_bytes(bc.dwBufferBytes, bd.dwBufferBytes); return 0; =20 fail0: diff --git a/audio/audio_win_int.c b/audio/audio_win_int.c index 44a8ff24a6f..ecd599c87de 100644 --- a/audio/audio_win_int.c +++ b/audio/audio_win_int.c @@ -2,12 +2,12 @@ =20 #include "qemu/osdep.h" =20 -#define AUDIO_CAP "win-int" #include #include #include =20 #include "qemu/audio.h" +#include "qemu/error-report.h" #include "audio_int.h" #include "audio_win_int.h" =20 @@ -53,7 +53,7 @@ int waveformat_from_audio_settings (WAVEFORMATEX *wfx, break; =20 default: - dolog("Internal logic error: Bad audio format %d\n", as->fmt); + error_report("dsound: Internal logic error: Bad audio format %d", = as->fmt); return -1; } =20 @@ -64,7 +64,7 @@ int waveformat_to_audio_settings (WAVEFORMATEX *wfx, struct audsettings *as) { if (!wfx->nSamplesPerSec) { - dolog ("Invalid wave format, frequency is zero\n"); + error_report("dsound: Invalid wave format, frequency is zero"); return -1; } as->freq =3D wfx->nSamplesPerSec; @@ -79,10 +79,9 @@ int waveformat_to_audio_settings (WAVEFORMATEX *wfx, break; =20 default: - dolog ( - "Invalid wave format, number of channels is not 1 or 2, but %d= \n", - wfx->nChannels - ); + error_report("dsound: Invalid wave format, " + "number of channels is not 1 or 2, but %d", + wfx->nChannels); return -1; } =20 @@ -101,9 +100,9 @@ int waveformat_to_audio_settings (WAVEFORMATEX *wfx, break; =20 default: - dolog("Invalid PCM wave format, bits per sample is not " - "8, 16 or 32, but %d\n", - wfx->wBitsPerSample); + error_report("dsound: Invalid PCM wave format, bits per sample= is not " + "8, 16 or 32, but %d", + wfx->wBitsPerSample); return -1; } } else if (wfx->wFormatTag =3D=3D WAVE_FORMAT_IEEE_FLOAT) { @@ -113,15 +112,15 @@ int waveformat_to_audio_settings (WAVEFORMATEX *wfx, break; =20 default: - dolog("Invalid IEEE_FLOAT wave format, bits per sample is not " - "32, but %d\n", - wfx->wBitsPerSample); + error_report("dsound: Invalid IEEE_FLOAT wave format, " + "bits per sample is not 32, but %d", + wfx->wBitsPerSample); return -1; } } else { - dolog("Invalid wave format, tag is not PCM and not IEEE_FLOAT, " - "but %d\n", - wfx->wFormatTag); + error_report("dsound: Invalid wave format, " + "tag is not PCM and not IEEE_FLOAT, but %d", + wfx->wFormatTag); return -1; } =20 diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index afd901518cc..2f17ab49730 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -28,8 +28,7 @@ =20 #include "qemu/osdep.h" #include "qemu/audio.h" - -#define AUDIO_CAP "dsound" +#include "qemu/error-report.h" #include "audio_int.h" #include "qemu/module.h" #include "qapi/error.h" @@ -40,6 +39,7 @@ #include #include =20 +#include "trace.h" #include "audio_win_int.h" =20 #define TYPE_AUDIO_DSOUND "audio-dsound" @@ -55,9 +55,6 @@ struct AudioDsound { struct audsettings settings; }; =20 - -/* #define DEBUG_DSOUND */ - typedef struct { HWVoiceOut hw; LPDIRECTSOUNDBUFFER dsound_buffer; @@ -214,56 +211,37 @@ static void dsound_log_hresult(HRESULT hr) const char *str =3D dserror(hr); =20 if (str) { - AUD_log (AUDIO_CAP, "Reason: %s\n", str); + error_printf(" Reason: %s", str); } else { - AUD_log (AUDIO_CAP, "Reason: Unknown (HRESULT: 0x%lx)\n", hr); + error_printf(" Reason: Unknown (HRESULT: 0x%lx)", hr); } } =20 -static void G_GNUC_PRINTF (2, 3) dsound_logerr ( - HRESULT hr, - const char *fmt, - ... - ) +static void G_GNUC_PRINTF(2, 3) dsound_logerr(HRESULT hr, const char *fmt,= ...) { va_list ap; =20 - va_start (ap, fmt); - AUD_vlog (AUDIO_CAP, fmt, ap); - va_end (ap); - - dsound_log_hresult (hr); + error_printf("dsound: "); + va_start(ap, fmt); + error_vprintf(fmt, ap); + va_end(ap); + dsound_log_hresult(hr); + error_printf("\n"); } =20 -static void G_GNUC_PRINTF (3, 4) dsound_logerr2 ( - HRESULT hr, - const char *typ, - const char *fmt, - ... - ) +static void G_GNUC_PRINTF(3, 4) dsound_logerr2(HRESULT hr, const char *typ, + const char *fmt, ...) { va_list ap; =20 - AUD_log (AUDIO_CAP, "Could not initialize %s\n", typ); - va_start (ap, fmt); - AUD_vlog (AUDIO_CAP, fmt, ap); - va_end (ap); - - dsound_log_hresult (hr); + error_printf("dsound: Could not initialize %s: ", typ); + va_start(ap, fmt); + error_vprintf(fmt, ap); + va_end(ap); + dsound_log_hresult(hr); + error_printf("\n"); } =20 -#ifdef DEBUG_DSOUND -static void print_wave_format (WAVEFORMATEX *wfx) -{ - dolog ("tag =3D %d\n", wfx->wFormatTag); - dolog ("nChannels =3D %d\n", wfx->nChannels); - dolog ("nSamplesPerSec =3D %ld\n", wfx->nSamplesPerSec); - dolog ("nAvgBytesPerSec =3D %ld\n", wfx->nAvgBytesPerSec); - dolog ("nBlockAlign =3D %d\n", wfx->nBlockAlign); - dolog ("wBitsPerSample =3D %d\n", wfx->wBitsPerSample); - dolog ("cbSize =3D %d\n", wfx->cbSize); -} -#endif =20 static int dsound_restore_out (LPDIRECTSOUNDBUFFER dsb, AudioDsound *s) { @@ -272,7 +250,7 @@ static int dsound_restore_out (LPDIRECTSOUNDBUFFER dsb,= AudioDsound *s) hr =3D IDirectSoundBuffer_Restore (dsb); =20 if (hr !=3D DS_OK) { - dsound_logerr (hr, "Could not restore playback buffer\n"); + dsound_logerr(hr, "Could not restore playback buffer"); return -1; } return 0; @@ -290,7 +268,7 @@ static int dsound_get_status_out (LPDIRECTSOUNDBUFFER d= sb, DWORD *statusp, =20 hr =3D IDirectSoundBuffer_GetStatus (dsb, statusp); if (FAILED (hr)) { - dsound_logerr (hr, "Could not get playback buffer status\n"); + dsound_logerr(hr, "Could not get playback buffer status"); return -1; } =20 @@ -309,7 +287,7 @@ static int dsound_get_status_in (LPDIRECTSOUNDCAPTUREBU= FFER dscb, =20 hr =3D IDirectSoundCaptureBuffer_GetStatus (dscb, statusp); if (FAILED (hr)) { - dsound_logerr (hr, "Could not get capture buffer status\n"); + dsound_logerr(hr, "Could not get capture buffer status"); return -1; } =20 @@ -340,11 +318,7 @@ static void dsound_clear_sample (HWVoiceOut *hw, LPDIR= ECTSOUNDBUFFER dsb, len1 =3D blen1 / hw->info.bytes_per_frame; len2 =3D blen2 / hw->info.bytes_per_frame; =20 -#ifdef DEBUG_DSOUND - dolog ("clear %p,%ld,%ld %p,%ld,%ld\n", - p1, blen1, len1, - p2, blen2, len2); -#endif + trace_dsound_clear_sample(p1, blen1, len1, p2, blen2, len2); =20 if (p1 && len1) { audio_pcm_info_clear_buf (&hw->info, p1, len1); @@ -366,40 +340,40 @@ static void dsound_enable_out(HWVoiceOut *hw, bool en= able) LPDIRECTSOUNDBUFFER dsb =3D ds->dsound_buffer; =20 if (!dsb) { - dolog ("Attempt to control voice without a buffer\n"); + error_report("dsound: Attempt to control voice without a buffer"); return; } =20 if (enable) { - if (dsound_get_status_out (dsb, &status, s)) { + if (dsound_get_status_out(dsb, &status, s)) { return; } =20 if (status & DSBSTATUS_PLAYING) { - dolog ("warning: Voice is already playing\n"); + warn_report("dsound: Voice is already playing"); return; } =20 - dsound_clear_sample (hw, dsb, s); + dsound_clear_sample(hw, dsb, s); =20 - hr =3D IDirectSoundBuffer_Play (dsb, 0, 0, DSBPLAY_LOOPING); - if (FAILED (hr)) { - dsound_logerr (hr, "Could not start playing buffer\n"); + hr =3D IDirectSoundBuffer_Play(dsb, 0, 0, DSBPLAY_LOOPING); + if (FAILED(hr)) { + dsound_logerr(hr, "Could not start playing buffer"); return; } } else { - if (dsound_get_status_out (dsb, &status, s)) { + if (dsound_get_status_out(dsb, &status, s)) { return; } =20 if (status & DSBSTATUS_PLAYING) { - hr =3D IDirectSoundBuffer_Stop (dsb); - if (FAILED (hr)) { - dsound_logerr (hr, "Could not stop playing buffer\n"); + hr =3D IDirectSoundBuffer_Stop(dsb); + if (FAILED(hr)) { + dsound_logerr(hr, "Could not stop playing buffer"); return; } } else { - dolog ("warning: Voice is not playing\n"); + warn_report("dsound: Voice is not playing"); } } } @@ -414,7 +388,7 @@ static size_t dsound_buffer_get_free(HWVoiceOut *hw) hr =3D IDirectSoundBuffer_GetCurrentPosition( dsb, &ppos, ds->first_time ? &wpos : NULL); if (FAILED(hr)) { - dsound_logerr(hr, "Could not get playback buffer position\n"); + dsound_logerr(hr, "Could not get playback buffer position"); return 0; } =20 @@ -441,7 +415,7 @@ static void *dsound_get_buffer_out(HWVoiceOut *hw, size= _t *size) err =3D dsound_lock_out(dsb, &hw->info, hw->pos_emul, req_size, &ret, = NULL, &act_size, NULL, false, AUDIO_DSOUND(hw->s)); if (err) { - dolog("Failed to lock buffer\n"); + error_report("dsound: Failed to lock buffer"); *size =3D 0; return NULL; } @@ -457,7 +431,7 @@ static size_t dsound_put_buffer_out(HWVoiceOut *hw, voi= d *buf, size_t len) int err =3D dsound_unlock_out(dsb, buf, NULL, len, 0); =20 if (err) { - dolog("Failed to unlock buffer!!\n"); + error_report("dsound: Failed to unlock buffer"); return 0; } hw->pos_emul =3D (hw->pos_emul + len) % hw->size_emul; @@ -473,40 +447,40 @@ static void dsound_enable_in(HWVoiceIn *hw, bool enab= le) LPDIRECTSOUNDCAPTUREBUFFER dscb =3D ds->dsound_capture_buffer; =20 if (!dscb) { - dolog ("Attempt to control capture voice without a buffer\n"); + error_report("dsound: Attempt to control capture voice without a b= uffer"); return; } =20 if (enable) { - if (dsound_get_status_in (dscb, &status)) { + if (dsound_get_status_in(dscb, &status)) { return; } =20 if (status & DSCBSTATUS_CAPTURING) { - dolog ("warning: Voice is already capturing\n"); + warn_report("dsound: Voice is already capturing"); return; } =20 /* clear ?? */ =20 - hr =3D IDirectSoundCaptureBuffer_Start (dscb, DSCBSTART_LOOPING); - if (FAILED (hr)) { - dsound_logerr (hr, "Could not start capturing\n"); + hr =3D IDirectSoundCaptureBuffer_Start(dscb, DSCBSTART_LOOPING); + if (FAILED(hr)) { + dsound_logerr(hr, "Could not start capturing"); return; } } else { - if (dsound_get_status_in (dscb, &status)) { + if (dsound_get_status_in(dscb, &status)) { return; } =20 if (status & DSCBSTATUS_CAPTURING) { - hr =3D IDirectSoundCaptureBuffer_Stop (dscb); - if (FAILED (hr)) { - dsound_logerr (hr, "Could not stop capturing\n"); + hr =3D IDirectSoundCaptureBuffer_Stop(dscb); + if (FAILED(hr)) { + dsound_logerr(hr, "Could not stop capturing"); return; } } else { - dolog ("warning: Voice is not capturing\n"); + warn_report("dsound: Voice is not capturing"); } } } @@ -523,7 +497,7 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t= *size) =20 hr =3D IDirectSoundCaptureBuffer_GetCurrentPosition(dscb, NULL, &rpos); if (FAILED(hr)) { - dsound_logerr(hr, "Could not get capture buffer position\n"); + dsound_logerr(hr, "Could not get capture buffer position"); *size =3D 0; return NULL; } @@ -544,7 +518,7 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t= *size) err =3D dsound_lock_in(dscb, &hw->info, hw->pos_emul, req_size, &ret, = NULL, &act_size, NULL, false, AUDIO_DSOUND(hw->s)); if (err) { - dolog("Failed to lock buffer\n"); + error_report("dsound: Failed to lock buffer"); *size =3D 0; return NULL; } @@ -560,7 +534,7 @@ static void dsound_put_buffer_in(HWVoiceIn *hw, void *b= uf, size_t len) int err =3D dsound_unlock_in(dscb, buf, NULL, len, 0); =20 if (err) { - dolog("Failed to unlock buffer!!\n"); + error_report("dsound: Failed to unlock buffer"); return; } hw->pos_emul =3D (hw->pos_emul + len) % hw->size_emul; @@ -577,7 +551,7 @@ static void audio_dsound_finalize(Object *obj) =20 hr =3D IDirectSound_Release (s->dsound); if (FAILED (hr)) { - dsound_logerr (hr, "Could not release DirectSound\n"); + dsound_logerr(hr, "Could not release DirectSound"); } s->dsound =3D NULL; =20 @@ -587,7 +561,7 @@ static void audio_dsound_finalize(Object *obj) =20 hr =3D IDirectSoundCapture_Release (s->dsound_capture); if (FAILED (hr)) { - dsound_logerr (hr, "Could not release DirectSoundCapture\n"); + dsound_logerr(hr, "Could not release DirectSoundCapture"); } s->dsound_capture =3D NULL; } diff --git a/audio/trace-events b/audio/trace-events index 737e3e60694..b2f29666700 100644 --- a/audio/trace-events +++ b/audio/trace-events @@ -23,6 +23,11 @@ dbus_audio_register(const char *s, const char *dir) "sen= der =3D %s, dir =3D %s" dbus_audio_put_buffer_out(size_t pos, size_t size) "buf_pos =3D %zu, buf_s= ize =3D %zu" dbus_audio_read(size_t len) "len =3D %zu" =20 +# dsoundaudio.c +dsound_clear_sample(void *p1, uint32_t blen1, uint32_t len1, void *p2, uin= t32_t blen2, uint32_t len2) "p1=3D%p, blen1=3D%u, len1=3D%u, p2=3D%p, blen2= =3D%u, len2=3D%u" +dsound_wave_format(uint16_t wFormatTag, uint16_t nChannels, uint32_t nSamp= lesPerSec, uint32_t nAvgBytesPerSec, uint16_t nBlockAlign, uint16_t wBitsPe= rSample, uint16_t cbSize) "wFormatTag=3D%u, nChannels=3D%u, nSamplesPerSec= =3D%u, nAvgBytesPerSec=3D%u, nBlockAlign=3D%u, wBitsPerSample=3D%u, cbSize= =3D%u" +dsound_buffer_bytes(uint32_t caps_bytes, uint32_t desc_bytes) "caps_bytes= =3D%u, desc_bytes=3D%u" + # pwaudio.c pw_state_changed(int nodeid, const char *s) "node id: %d stream state: %s" pw_read(int32_t avail, uint32_t index, size_t len) "avail=3D%d index=3D%u = len=3D%zu" --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538813; cv=none; d=zohomail.com; s=zohoarc; b=RiIUZIlE1yXI45o0RojItlGEHkAW1BZ62kB1GKuIVLk1t+AwR5ToamtfXPE6mGcaDSu01BpWdE1hw4sIIXU195s4PLwevCUSgqu0YREwQd3TQ+IWU2c6ce5WX+P3kjsUxZNuN9VOFjPGtWCuDJxN9Ur7QAtXsQJ33dlLULYS2/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538813; 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=TTOiWR2hBbeuZK34GY/zWvM26KogxZDm7LMUKKV+/Is=; b=Z6ujQuCTT9YoTHHc9qf614bBGZFIFIQyjfHJXjO1alTrn5Iw1Us4nbtm4JHXpl7ZjwwsPnBackgSYTFZU7ojGyH8d9vbotIAjBwDiI9ZGapcYCgkv44JhW31LA1KSh6iEmvY7ykWN+HlBPJ93Sqh6rAvlxNFAxiP1O3Csp/D+8o= 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 1769538813277113.86146743003485; Tue, 27 Jan 2026 10:33:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknnS-0008UJ-RM; Tue, 27 Jan 2026 13:28:14 -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 1vknmt-0006vO-Ng for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:41 -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 1vknms-0003Hp-3f for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:39 -0500 Received: from mx-prod-mc-05.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-303-1Mba4zLAOXuTeCB1w3fpFQ-1; Tue, 27 Jan 2026 13:27:34 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 249BF19775AD; Tue, 27 Jan 2026 18:27:33 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D44DD18007D2; Tue, 27 Jan 2026 18:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538457; 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=TTOiWR2hBbeuZK34GY/zWvM26KogxZDm7LMUKKV+/Is=; b=biXSfJn3RZFGVIErfvRZnChZXfZKuzB0K8t84di6G4qRRGfS2KucA1j2HzoUiVP85/Lo36 CsuBbPJ1Pgl6yAKhjpPvEvxyu54nUkNUFKPus2rMVqt7GMb2ibjRoAN2ypyI6nJnOWYaJa NZqqjeTGnLGkN4t+UiymsXXfslHyUr8= X-MC-Unique: 1Mba4zLAOXuTeCB1w3fpFQ-1 X-Mimecast-MFC-AGG-ID: 1Mba4zLAOXuTeCB1w3fpFQ_1769538453 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck Subject: [PATCH 22/43] audio/jack: replace custom logging with report & trace Date: Tue, 27 Jan 2026 22:24:49 +0400 Message-ID: <20260127182516.289834-23-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538815862154100 From: Marc-Andr=C3=A9 Lureau Replace the custom audio logging infrastructure with standard QEMU error reporting and tracing. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/jackaudio.c | 29 +++++++++++++---------------- audio/trace-events | 9 +++++++++ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/audio/jackaudio.c b/audio/jackaudio.c index 681eb17df55..547672f6d36 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -26,11 +26,11 @@ #include "qemu/module.h" #include "qemu/atomic.h" #include "qemu/main-loop.h" +#include "qemu/error-report.h" #include "qemu/audio.h" #include "qom/object.h" - -#define AUDIO_CAP "jack" #include "audio_int.h" +#include "trace.h" =20 #include #include @@ -343,7 +343,7 @@ static void qjack_client_recover(QJackClient *c) =20 /* if enabled then attempt to recover */ if (c->enabled) { - dolog("attempting to reconnect to server\n"); + trace_jack_client_recover(); qjack_client_init(c); } } @@ -399,10 +399,10 @@ static void qjack_client_connect_ports(QJackClient *c) } =20 if (c->out) { - dolog("connect %s -> %s\n", p, ports[i]); + trace_jack_connect(p, ports[i]); jack_connect(c->client, p, ports[i]); } else { - dolog("connect %s -> %s\n", ports[i], p); + trace_jack_connect(ports[i], p); jack_connect(c->client, ports[i], p); } } @@ -441,9 +441,9 @@ static int qjack_client_init(QJackClient *c) c->opt->server_name); =20 if (c->client =3D=3D NULL) { - dolog("jack_client_open failed: status =3D 0x%2.0x\n", status); + error_report("jack: jack_client_open failed: status =3D 0x%2.0x", = status); if (status & JackServerFailed) { - dolog("unable to connect to JACK server\n"); + error_report("jack: unable to connect to JACK server"); } return -1; } @@ -451,12 +451,11 @@ static int qjack_client_init(QJackClient *c) c->freq =3D jack_get_sample_rate(c->client); =20 if (status & JackServerStarted) { - dolog("JACK server started\n"); + trace_jack_server_started(); } =20 if (status & JackNameNotUnique) { - dolog("JACK unique name assigned %s\n", - jack_get_client_name(c->client)); + trace_jack_unique_name(jack_get_client_name(c->client)); } =20 /* Allocate working buffer for process callback */ @@ -536,8 +535,7 @@ static int qjack_init_out(HWVoiceOut *hw, struct audset= tings *as) }; audio_pcm_init_info(&hw->info, &os); =20 - dolog("JACK output configured for %dHz (%d samples)\n", - jo->c.freq, jo->c.buffersize); + trace_jack_out_init(jo->c.freq, jo->c.buffersize); =20 return 0; } @@ -572,8 +570,7 @@ static int qjack_init_in(HWVoiceIn *hw, struct audsetti= ngs *as) }; audio_pcm_init_info(&hw->info, &is); =20 - dolog("JACK input configured for %dHz (%d samples)\n", - ji->c.freq, ji->c.buffersize); + trace_jack_in_init(ji->c.freq, ji->c.buffersize); =20 return 0; } @@ -654,12 +651,12 @@ static int qjack_thread_creator(jack_native_thread_t = *thread, =20 static void qjack_error(const char *msg) { - dolog("E: %s\n", msg); + error_report("jack: %s", msg); } =20 static void qjack_info(const char *msg) { - dolog("I: %s\n", msg); + trace_jack_info(msg); } =20 static void audio_jack_class_init(ObjectClass *klass, const void *data) diff --git a/audio/trace-events b/audio/trace-events index b2f29666700..79744456cec 100644 --- a/audio/trace-events +++ b/audio/trace-events @@ -28,6 +28,15 @@ dsound_clear_sample(void *p1, uint32_t blen1, uint32_t l= en1, void *p2, uint32_t dsound_wave_format(uint16_t wFormatTag, uint16_t nChannels, uint32_t nSamp= lesPerSec, uint32_t nAvgBytesPerSec, uint16_t nBlockAlign, uint16_t wBitsPe= rSample, uint16_t cbSize) "wFormatTag=3D%u, nChannels=3D%u, nSamplesPerSec= =3D%u, nAvgBytesPerSec=3D%u, nBlockAlign=3D%u, wBitsPerSample=3D%u, cbSize= =3D%u" dsound_buffer_bytes(uint32_t caps_bytes, uint32_t desc_bytes) "caps_bytes= =3D%u, desc_bytes=3D%u" =20 +# jackaudio.c +jack_client_recover(void) "attempting to reconnect to server" +jack_connect(const char *src, const char *dst) "connect %s -> %s" +jack_server_started(void) "server started" +jack_unique_name(const char *name) "unique name assigned %s" +jack_out_init(uint32_t freq, int buffersize) "output configured for %uHz (= %d samples)" +jack_in_init(uint32_t freq, int buffersize) "input configured for %uHz (%d= samples)" +jack_info(const char *msg) "%s" + # pwaudio.c pw_state_changed(int nodeid, const char *s) "node id: %d stream state: %s" pw_read(int32_t avail, uint32_t index, size_t len) "avail=3D%d index=3D%u = len=3D%zu" --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538595; cv=none; d=zohomail.com; s=zohoarc; b=FRrJ3TzXvtxBb6ibFkVBaHjNr7S8O/QrHE/EHbhqY97yZV9XuhcTabASuYZOD9zOcB2zo/KM0XrYH9SMcwT+SyzAUD3ERS45UfeW5EnSrzr2XLYf8pkwWmddv2K7zoXj7HFqmObye2hyViFeSSMJq6AXUWHyeKKrjCrYAFhdhd8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538595; 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=l8t45HKZtfHB+jE00A0eYVXn2BK7Fbmf77WrRFpYUCg=; b=kg+LPla/VYvBtPN0IBE5T1lwiMyyPQWciKV3sJMoHUhF0XNaFnC0xV6f/SDJ8ei1BNmNaYa2tx4e7clL7j4IT0EuswVJlIztit0dLTYmpLSlvBZdOHy9/dyqLqluzGSiDAMIcB8CUKjS7BPEJ3t+83IAQoQjnAwqVZe0IzcpL3A= 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 1769538594999131.04214268386954; Tue, 27 Jan 2026 10:29:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknnU-0000Fz-T7; Tue, 27 Jan 2026 13:28: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 1vknmz-00078n-0I for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:45 -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 1vknmx-0003IX-LH for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:44 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-444-yu9a40u-P2m_Tq_a6HpLkg-1; Tue, 27 Jan 2026 13:27:39 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B662B18005B0; Tue, 27 Jan 2026 18:27:38 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6BA2219560B2; Tue, 27 Jan 2026 18:27:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538462; 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=l8t45HKZtfHB+jE00A0eYVXn2BK7Fbmf77WrRFpYUCg=; b=bmJbrT6q0D8z9lvbNq4XVLmUT3wpQ/SxkXjKn9dgA0eTwz29MC6cCvgm8katOF7ggMRJi8 X9yf6gWEppyaRD1fKOwovH3ENerpqAQSjGlsiQjpYjK59Hf2BLK8BpNLTAMxOJyfrJ5qH+ FOwfSu/CobqNUHKfciqBmILdCG6bGAs= X-MC-Unique: yu9a40u-P2m_Tq_a6HpLkg-1 X-Mimecast-MFC-AGG-ID: yu9a40u-P2m_Tq_a6HpLkg_1769538458 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 23/43] audio/noaudio: remove unused AUDIO_CAP macro Date: Tue, 27 Jan 2026 22:24:50 +0400 Message-ID: <20260127182516.289834-24-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.12 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538596409154100 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/noaudio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/audio/noaudio.c b/audio/noaudio.c index 2f4c3a77457..20208c71069 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -27,7 +27,6 @@ #include "qemu/audio.h" #include "qom/object.h" =20 -#define AUDIO_CAP "noaudio" #include "audio_int.h" =20 #define TYPE_AUDIO_NONE "audio-none" --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538668; cv=none; d=zohomail.com; s=zohoarc; b=Mmy63FlJdUkojEPSNxRdD4T/5z+b/OPYSrDGGF/X9fvp1CKuRF0SLYb3+mb8x6USXgWwBBDWC25sze1Evh4mZ5pMX8OfffJgKt99zFlAOMhn0vc739vfJnPEUmjUX3bQSbFFLY8emqSEvbbdfsrrrctQL9M1Z6VGJeecVEa1x5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538668; 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=tdqFkR++Mx8sP/ibIVMErSUZQuFIsPXgRhBYzMQnBnE=; b=jCItvS8e5COQdsv5+076aBqUQYpSdifLBeIv6fpqo+I17MZx1CY8sVG5V51u6o//dRXD98Ho3s9gVmCIamCiJU8/Fx8WgwpLV/MyxzwPGiTX7evEEbNKY3Uq9LJ7DtRXhapYs565yeXGQTlx92hXZ7tpyh80OxsxqolrIAYWMZM= 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 1769538668003321.29551584215517; Tue, 27 Jan 2026 10:31:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknor-00023t-Cy; Tue, 27 Jan 2026 13:29:42 -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 1vknn4-0007sy-Ls for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27: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 1vknn2-0003J1-8I for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:50 -0500 Received: from mx-prod-mc-03.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-321-2YbPT5gZOaWq3CZb4x6RVA-1; Tue, 27 Jan 2026 13:27:46 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 011411955D84; Tue, 27 Jan 2026 18:27:45 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4FE181956095; Tue, 27 Jan 2026 18:27:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538467; 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=tdqFkR++Mx8sP/ibIVMErSUZQuFIsPXgRhBYzMQnBnE=; b=LIAFYOS04hWv7Kl+kdIsaUPitjVSg5kjKPxEwjpqIWvMdsBXRj66953ipTBb1c1YgNkmvm RkQf6DKr7wgzJxNnFCzdkadKPTjqFL1jk8KBFO6F4KiOSy8DM9aBG+BxfrjDuk+ib3GnzZ GIvnSKv15vYV/B4RoSeI75bDAzrZGW8= X-MC-Unique: 2YbPT5gZOaWq3CZb4x6RVA-1 X-Mimecast-MFC-AGG-ID: 2YbPT5gZOaWq3CZb4x6RVA_1769538465 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 24/43] audio/oss: replace custom logging with report & trace Date: Tue, 27 Jan 2026 22:24:51 +0400 Message-ID: <20260127182516.289834-25-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.17 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538669879154100 From: Marc-Andr=C3=A9 Lureau Replace the custom audio logging infrastructure with standard QEMU error reporting and tracing. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/ossaudio.c | 176 ++++++++++++++++++++------------------------- audio/trace-events | 5 ++ 2 files changed, 81 insertions(+), 100 deletions(-) diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 95b7963ed0c..8388f81343b 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -31,11 +31,10 @@ #include "qemu/host-utils.h" #include "qapi/error.h" #include "qemu/audio.h" +#include "qemu/error-report.h" #include "qom/object.h" -#include "trace.h" - -#define AUDIO_CAP "oss" #include "audio_int.h" +#include "trace.h" =20 #define TYPE_AUDIO_OSS "audio-oss" OBJECT_DECLARE_SIMPLE_TYPE(AudioOss, AUDIO_OSS) @@ -76,43 +75,40 @@ struct oss_params { int fragsize; }; =20 -static void G_GNUC_PRINTF (2, 3) oss_logerr (int err, const char *fmt, ...) +static void G_GNUC_PRINTF(2, 3) oss_logerr(int err, const char *fmt, ...) { va_list ap; =20 - va_start (ap, fmt); - AUD_vlog (AUDIO_CAP, fmt, ap); - va_end (ap); + error_printf("oss: "); + va_start(ap, fmt); + error_vprintf(fmt, ap); + va_end(ap); =20 - AUD_log (AUDIO_CAP, "Reason: %s\n", strerror (err)); + error_printf(" Reason: %s\n", strerror(err)); } =20 -static void G_GNUC_PRINTF (3, 4) oss_logerr2 ( - int err, - const char *typ, - const char *fmt, - ... - ) +static void G_GNUC_PRINTF(3, 4) oss_logerr2(int err, const char *typ, + const char *fmt, ...) { va_list ap; =20 - AUD_log (AUDIO_CAP, "Could not initialize %s\n", typ); + error_printf("oss: Could not initialize %s: ", typ); =20 - va_start (ap, fmt); - AUD_vlog (AUDIO_CAP, fmt, ap); - va_end (ap); + va_start(ap, fmt); + error_vprintf(fmt, ap); + va_end(ap); =20 - AUD_log (AUDIO_CAP, "Reason: %s\n", strerror (err)); + error_printf(" Reason: %s\n", strerror(err)); } =20 -static void oss_anal_close (int *fdp) +static void oss_anal_close(int *fdp) { int err; =20 - qemu_set_fd_handler (*fdp, NULL, NULL, NULL); - err =3D close (*fdp); + qemu_set_fd_handler(*fdp, NULL, NULL, NULL); + err =3D close(*fdp); if (err) { - oss_logerr (errno, "Failed to close file(fd=3D%d)\n", *fdp); + oss_logerr(errno, "Failed to close file(fd=3D%d)", *fdp); } *fdp =3D -1; } @@ -159,10 +155,7 @@ static int aud_to_ossfmt(AudioFormat fmt, bool big_end= ian) return big_endian ? AFMT_U16_BE : AFMT_U16_LE; =20 default: - dolog ("Internal logic error: Bad audio format %d\n", fmt); -#ifdef DEBUG_AUDIO - abort (); -#endif + error_report("oss: Internal logic error: Bad audio format %d", fmt= ); return AFMT_U8; } } @@ -201,27 +194,13 @@ static int oss_to_audfmt (int ossfmt, AudioFormat *fm= t, int *endianness) break; =20 default: - dolog ("Unrecognized audio format %d\n", ossfmt); + error_report("oss: Unrecognized audio format %d", ossfmt); return -1; } =20 return 0; } =20 -#if defined DEBUG_MISMATCHES || defined DEBUG -static void oss_dump_info (struct oss_params *req, struct oss_params *obt) -{ - dolog ("parameter | requested value | obtained value\n"); - dolog ("format | %10d | %10d\n", req->fmt, obt->fmt); - dolog ("channels | %10d | %10d\n", - req->nchannels, obt->nchannels); - dolog ("frequency | %10d | %10d\n", req->freq, obt->freq); - dolog ("nfrags | %10d | %10d\n", req->nfrags, obt->nfrags); - dolog ("fragsize | %10d | %10d\n", - req->fragsize, obt->fragsize); -} -#endif - #ifdef USE_DSP_POLICY static int oss_get_version (int fd, int *version, const char *typ) { @@ -240,7 +219,7 @@ static int oss_get_version (int fd, int *version, const= char *typ) return 0; } #endif - oss_logerr2 (errno, typ, "Failed to get OSS version\n"); + oss_logerr2(errno, typ, "Failed to get OSS version"); return -1; } return 0; @@ -269,7 +248,7 @@ static int oss_open(int in, struct oss_params *req, aud= settings *as, =20 fd =3D open (dspname, oflags | O_NONBLOCK); if (-1 =3D=3D fd) { - oss_logerr2 (errno, typ, "Failed to open `%s'\n", dspname); + oss_logerr2(errno, typ, "Failed to open '%s'", dspname); return -1; } =20 @@ -281,23 +260,23 @@ static int oss_open(int in, struct oss_params *req, a= udsettings *as, qapi_AudiodevOssPerDirectionOptions_base(opdo), as, 23220); =20 if (ioctl (fd, SNDCTL_DSP_SAMPLESIZE, &fmt)) { - oss_logerr2 (errno, typ, "Failed to set sample size %d\n", req->fm= t); + oss_logerr2(errno, typ, "Failed to set sample size %d", req->fmt); goto err; } =20 if (ioctl (fd, SNDCTL_DSP_CHANNELS, &nchannels)) { - oss_logerr2 (errno, typ, "Failed to set number of channels %d\n", - req->nchannels); + oss_logerr2(errno, typ, "Failed to set number of channels %d", + req->nchannels); goto err; } =20 if (ioctl (fd, SNDCTL_DSP_SPEED, &freq)) { - oss_logerr2 (errno, typ, "Failed to set frequency %d\n", req->freq= ); + oss_logerr2(errno, typ, "Failed to set frequency %d", req->freq); goto err; } =20 if (ioctl (fd, SNDCTL_DSP_NONBLOCK, NULL)) { - oss_logerr2 (errno, typ, "Failed to set non-blocking mode\n"); + oss_logerr2(errno, typ, "Failed to set non-blocking mode"); goto err; } =20 @@ -311,9 +290,9 @@ static int oss_open(int in, struct oss_params *req, aud= settings *as, if (version >=3D 0x040000) { int policy2 =3D policy; if (ioctl(fd, SNDCTL_DSP_POLICY, &policy2)) { - oss_logerr2 (errno, typ, - "Failed to set timing policy to %d\n", - policy); + oss_logerr2(errno, typ, + "Failed to set timing policy to %d", + policy); goto err; } setfragment =3D 0; @@ -325,20 +304,20 @@ static int oss_open(int in, struct oss_params *req, a= udsettings *as, if (setfragment) { int mmmmssss =3D (req->nfrags << 16) | ctz32 (req->fragsize); if (ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &mmmmssss)) { - oss_logerr2 (errno, typ, "Failed to set buffer length (%d, %d)= \n", - req->nfrags, req->fragsize); + oss_logerr2(errno, typ, "Failed to set buffer length (%d, %d)", + req->nfrags, req->fragsize); goto err; } } =20 if (ioctl (fd, in ? SNDCTL_DSP_GETISPACE : SNDCTL_DSP_GETOSPACE, &abin= fo)) { - oss_logerr2 (errno, typ, "Failed to get buffer length\n"); + oss_logerr2(errno, typ, "Failed to get buffer length"); goto err; } =20 if (!abinfo.fragstotal || !abinfo.fragsize) { - AUD_log (AUDIO_CAP, "Returned bogus buffer information(%d, %d) for= %s\n", - abinfo.fragstotal, abinfo.fragsize, typ); + error_report("oss: Returned bogus buffer information(%d, %d) for %= s", + abinfo.fragstotal, abinfo.fragsize, typ); goto err; } =20 @@ -349,20 +328,13 @@ static int oss_open(int in, struct oss_params *req, a= udsettings *as, obt->fragsize =3D abinfo.fragsize; *pfd =3D fd; =20 -#ifdef DEBUG_MISMATCHES - if ((req->fmt !=3D obt->fmt) || - (req->nchannels !=3D obt->nchannels) || - (req->freq !=3D obt->freq) || - (req->fragsize !=3D obt->fragsize) || - (req->nfrags !=3D obt->nfrags)) { - dolog ("Audio parameters mismatch\n"); - oss_dump_info (req, obt); - } -#endif + trace_oss_out_params( + req->fmt, obt->fmt, + req->nchannels, obt->nchannels, + req->freq, obt->freq, + req->nfrags, obt->nfrags, + req->fragsize, obt->fragsize); =20 -#ifdef DEBUG - oss_dump_info (req, obt); -#endif return 0; =20 err: @@ -378,7 +350,7 @@ static size_t oss_get_available_bytes(OSSVoiceOut *oss) =20 err =3D ioctl(oss->fd, SNDCTL_DSP_GETOPTR, &cntinfo); if (err < 0) { - oss_logerr(errno, "SNDCTL_DSP_GETOPTR failed\n"); + oss_logerr(errno, "SNDCTL_DSP_GETOPTR failed"); return 0; } =20 @@ -459,8 +431,7 @@ static size_t oss_write(HWVoiceOut *hw, void *buf, size= _t len) bytes_written =3D write(oss->fd, pcm, len); if (bytes_written < 0) { if (errno !=3D EAGAIN) { - oss_logerr(errno, "failed to write %zu bytes\n", - len); + oss_logerr(errno, "failed to write %zu bytes", len); } return pos; } @@ -474,18 +445,18 @@ static size_t oss_write(HWVoiceOut *hw, void *buf, si= ze_t len) return pos; } =20 -static void oss_fini_out (HWVoiceOut *hw) +static void oss_fini_out(HWVoiceOut *hw) { int err; - OSSVoiceOut *oss =3D (OSSVoiceOut *) hw; + OSSVoiceOut *oss =3D (OSSVoiceOut *)hw; =20 - ldebug ("oss_fini\n"); - oss_anal_close (&oss->fd); + trace_oss_fini_out(); + oss_anal_close(&oss->fd); =20 if (oss->mmapped && hw->buf_emul) { err =3D munmap(hw->buf_emul, hw->size_emul); if (err) { - oss_logerr(errno, "Failed to unmap buffer %p, size %zu\n", + oss_logerr(errno, "Failed to unmap buffer %p, size %zu", hw->buf_emul, hw->size_emul); } hw->buf_emul =3D NULL; @@ -526,8 +497,8 @@ static int oss_init_out(HWVoiceOut *hw, struct audsetti= ngs *as) oss->fragsize =3D obt.fragsize; =20 if (obt.nfrags * obt.fragsize % hw->info.bytes_per_frame) { - dolog ("warning: Misaligned DAC buffer, size %d, alignment %d\n", - obt.nfrags * obt.fragsize, hw->info.bytes_per_frame); + warn_report("oss: Misaligned DAC buffer, size %d, alignment %d", + obt.nfrags * obt.fragsize, hw->info.bytes_per_frame); } =20 hw->samples =3D (obt.nfrags * obt.fragsize) / hw->info.bytes_per_frame; @@ -544,20 +515,16 @@ static int oss_init_out(HWVoiceOut *hw, struct audset= tings *as) 0 ); if (hw->buf_emul =3D=3D MAP_FAILED) { - oss_logerr(errno, "Failed to map %zu bytes of DAC\n", - hw->size_emul); + oss_logerr(errno, "Failed to map %zu bytes of DAC", hw->size_e= mul); hw->buf_emul =3D NULL; } else { int trig =3D 0; if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { - oss_logerr (errno, "SNDCTL_DSP_SETTRIGGER 0 failed\n"); + oss_logerr(errno, "SNDCTL_DSP_SETTRIGGER 0 failed"); } else { trig =3D PCM_ENABLE_OUTPUT; - if (ioctl (fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { - oss_logerr ( - errno, - "SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n" - ); + if (ioctl(fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { + oss_logerr(errno, "SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OU= TPUT failed"); } else { oss->mmapped =3D 1; } @@ -566,7 +533,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsetti= ngs *as) if (!oss->mmapped) { err =3D munmap(hw->buf_emul, hw->size_emul); if (err) { - oss_logerr(errno, "Failed to unmap buffer %p size %zu\= n", + oss_logerr(errno, "Failed to unmap buffer %p size %zu", hw->buf_emul, hw->size_emul); } hw->buf_emul =3D NULL; @@ -582,13 +549,14 @@ static int oss_init_out(HWVoiceOut *hw, struct audset= tings *as) static void oss_enable_out(HWVoiceOut *hw, bool enable) { int trig; - OSSVoiceOut *oss =3D (OSSVoiceOut *) hw; + OSSVoiceOut *oss =3D (OSSVoiceOut *)hw; AudiodevOssPerDirectionOptions *opdo =3D oss->dev->u.oss.out; =20 + trace_oss_enable_out(enable); + if (enable) { hw->poll_mode =3D opdo->try_poll; =20 - ldebug("enabling voice\n"); if (hw->poll_mode) { oss_poll_out(hw); } @@ -601,12 +569,12 @@ static void oss_enable_out(HWVoiceOut *hw, bool enabl= e) trig =3D PCM_ENABLE_OUTPUT; if (ioctl(oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { oss_logerr(errno, - "SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed\n"); + "SNDCTL_DSP_SETTRIGGER PCM_ENABLE_OUTPUT failed"); return; } } else { if (hw->poll_mode) { - qemu_set_fd_handler (oss->fd, NULL, NULL, NULL); + qemu_set_fd_handler(oss->fd, NULL, NULL, NULL); hw->poll_mode =3D 0; } =20 @@ -614,10 +582,9 @@ static void oss_enable_out(HWVoiceOut *hw, bool enable) return; } =20 - ldebug ("disabling voice\n"); trig =3D 0; - if (ioctl (oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { - oss_logerr (errno, "SNDCTL_DSP_SETTRIGGER 0 failed\n"); + if (ioctl(oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { + oss_logerr(errno, "SNDCTL_DSP_SETTRIGGER 0 failed"); return; } } @@ -654,9 +621,16 @@ static int oss_init_in(HWVoiceIn *hw, struct audsettin= gs *as) oss->nfrags =3D obt.nfrags; oss->fragsize =3D obt.fragsize; =20 + trace_oss_in_params( + req.fmt, obt.fmt, + req.nchannels, obt.nchannels, + req.freq, obt.freq, + req.nfrags, obt.nfrags, + req.fragsize, obt.fragsize); + if (obt.nfrags * obt.fragsize % hw->info.bytes_per_frame) { - dolog ("warning: Misaligned ADC buffer, size %d, alignment %d\n", - obt.nfrags * obt.fragsize, hw->info.bytes_per_frame); + warn_report("oss: Misaligned ADC buffer, size %d, alignment %d", + obt.nfrags * obt.fragsize, hw->info.bytes_per_frame); } =20 hw->samples =3D (obt.nfrags * obt.fragsize) / hw->info.bytes_per_frame; @@ -690,7 +664,7 @@ static size_t oss_read(HWVoiceIn *hw, void *buf, size_t= len) case EAGAIN: break; default: - oss_logerr(errno, "Failed to read %zu bytes of audio (to %= p)\n", + oss_logerr(errno, "Failed to read %zu bytes of audio (to %= p)", len, dst); break; } @@ -706,9 +680,11 @@ static size_t oss_read(HWVoiceIn *hw, void *buf, size_= t len) =20 static void oss_enable_in(HWVoiceIn *hw, bool enable) { - OSSVoiceIn *oss =3D (OSSVoiceIn *) hw; + OSSVoiceIn *oss =3D (OSSVoiceIn *)hw; AudiodevOssPerDirectionOptions *opdo =3D oss->dev->u.oss.out; =20 + trace_oss_enable_in(enable); + if (enable) { hw->poll_mode =3D opdo->try_poll; =20 diff --git a/audio/trace-events b/audio/trace-events index 79744456cec..f33be2dd8e3 100644 --- a/audio/trace-events +++ b/audio/trace-events @@ -17,6 +17,11 @@ alsa_enable_in(bool enable) "enable=3D%d" =20 # ossaudio.c oss_version(int version) "OSS version =3D 0x%x" +oss_out_params(int req_fmt, int obt_fmt, int req_channels, int obt_channel= s, int req_freq, int obt_freq, int req_nfrags, int obt_nfrags, int req_frag= size, int obt_fragsize) "fmt=3D%d->%d, channels %d->%d, freq=3D%d->%d, nfra= gs=3D%d->%d, fragsize=3D%d->%d" +oss_in_params(int req_fmt, int obt_fmt, int req_channels, int obt_channels= , int req_freq, int obt_freq, int req_nfrags, int obt_nfrags, int req_frags= ize, int obt_fragsize) "fmt=3D%d->%d, channels %d->%d, freq=3D%d->%d, nfrag= s=3D%d->%d, fragsize=3D%d->%d" +oss_fini_out(void) "" +oss_enable_out(bool enable) "enable=3D%d" +oss_enable_in(bool enable) "enable=3D%d" =20 # dbusaudio.c dbus_audio_register(const char *s, const char *dir) "sender =3D %s, dir = =3D %s" --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769539075; cv=none; d=zohomail.com; s=zohoarc; b=k0DqfOXRRM6kP9TAskTV6hB3S6J4d9aC9xr7nMqEyNwiCbioe43vv5CC1ZIBXhaEJHJ6dNYBXftWu86O1a9ZDAfrwuKiL2TmYOx3FgH8p4EnaUfibJ12LTRqaWWtzmespRk+ZQcrqsXDEmfNzwrn/0bvixBaYqM8W2+UTArRgog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769539075; 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=yp36FhVc4LAhpZW/GULuuQuOYaoHS/c71saP9NS+qrk=; b=ASKcc2hPDa4rx2shWSWXUZwawNtz6pfj3SBCDxfrnoL2weyq5XXIbxVj2PxLMAiM8dC7/HGuD37iYScsEkvHMepMG6xlD8PVFoMnFmFnqZlMXa+E0js2XzkCCa3p3LUde/byZf3iMvKwHmXFKGbDsm8GsPJTKKuJLv8rTOjvPQM= 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 1769539075797556.3502984090991; Tue, 27 Jan 2026 10:37:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknpI-0005SI-Sy; Tue, 27 Jan 2026 13:30: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 1vknnA-000863-II for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28: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 1vknn8-0003JR-Er for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:27:56 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-130-AZuyVIs4MoOwggkdcFWIsQ-1; Tue, 27 Jan 2026 13:27:51 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0477F18005BC; Tue, 27 Jan 2026 18:27:50 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0A07E1956095; Tue, 27 Jan 2026 18:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538472; 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=yp36FhVc4LAhpZW/GULuuQuOYaoHS/c71saP9NS+qrk=; b=Sw7EFm2/qqIRgMXhhiEuHhtE869fAMsKT1h2zisr/ZlTZM0s/3IqD9XWMTAK4Oq+XvR0vU fdICbB9Eu6ehZw6lxudF8OhaBvBNTHxUUJ3KuMipCaojbPFcGJPEHXLi+ZxHaab20Vz4GC fG60TdbVW1kDOVLziuhSxlkYpo6OZ2o= X-MC-Unique: AZuyVIs4MoOwggkdcFWIsQ-1 X-Mimecast-MFC-AGG-ID: AZuyVIs4MoOwggkdcFWIsQ_1769538470 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 25/43] audio/pa: replace custom logging with report & trace Date: Tue, 27 Jan 2026 22:24:52 +0400 Message-ID: <20260127182516.289834-26-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.17 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769539077673158500 From: Marc-Andr=C3=A9 Lureau Replace the custom audio logging infrastructure with standard QEMU error reporting and tracing. qpa_conn_init() is called during audio_pa_realize() and already reports an error through Error *. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/paaudio.c | 77 ++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index e98b4a33b68..bc6a8fa67b3 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -3,14 +3,13 @@ #include "qemu/osdep.h" #include "qemu/module.h" #include "qemu/audio.h" +#include "qemu/error-report.h" #include "qapi/error.h" #include "qom/object.h" +#include "audio_int.h" =20 #include =20 -#define AUDIO_CAP "pulseaudio" -#include "audio_int.h" - #define TYPE_AUDIO_PA "audio-pa" OBJECT_DECLARE_SIMPLE_TYPE(AudioPa, AUDIO_PA) =20 @@ -51,15 +50,16 @@ typedef struct { =20 static void qpa_conn_fini(PAConnection *c); =20 -static void G_GNUC_PRINTF (2, 3) qpa_logerr (int err, const char *fmt, ...) +static void G_GNUC_PRINTF(2, 3) qpa_logerr(int err, const char *fmt, ...) { va_list ap; =20 - va_start (ap, fmt); - AUD_vlog (AUDIO_CAP, fmt, ap); - va_end (ap); + error_printf("pulseaudio: "); + va_start(ap, fmt); + error_vprintf(fmt, ap); + va_end(ap); =20 - AUD_log (AUDIO_CAP, "Reason: %s\n", pa_strerror (err)); + error_printf(" Reason: %s\n", pa_strerror(err)); } =20 #ifndef PA_CONTEXT_IS_GOOD @@ -113,12 +113,12 @@ static void *qpa_get_buffer_in(HWVoiceIn *hw, size_t = *size) pa_threaded_mainloop_lock(c->mainloop); =20 CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail, - "pa_threaded_mainloop_lock failed\n"); + "pa_threaded_mainloop_lock failed"); =20 if (!p->read_length) { r =3D pa_stream_peek(p->stream, &p->read_data, &p->read_length); CHECK_SUCCESS_GOTO(c, r =3D=3D 0, unlock_and_fail, - "pa_stream_peek failed\n"); + "pa_stream_peek failed"); } =20 *size =3D MIN(p->read_length, *size); @@ -141,7 +141,7 @@ static void qpa_put_buffer_in(HWVoiceIn *hw, void *buf,= size_t size) pa_threaded_mainloop_lock(c->mainloop); =20 CHECK_DEAD_GOTO(c, p->stream, unlock, - "pa_threaded_mainloop_lock failed\n"); + "pa_threaded_mainloop_lock failed"); =20 assert(buf =3D=3D p->read_data && size <=3D p->read_length); =20 @@ -150,7 +150,7 @@ static void qpa_put_buffer_in(HWVoiceIn *hw, void *buf,= size_t size) =20 if (size && !p->read_length) { r =3D pa_stream_drop(p->stream); - CHECK_SUCCESS_GOTO(c, r =3D=3D 0, unlock, "pa_stream_drop failed\n= "); + CHECK_SUCCESS_GOTO(c, r =3D=3D 0, unlock, "pa_stream_drop failed"); } =20 unlock: @@ -166,7 +166,7 @@ static size_t qpa_read(HWVoiceIn *hw, void *data, size_= t length) pa_threaded_mainloop_lock(c->mainloop); =20 CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail, - "pa_threaded_mainloop_lock failed\n"); + "pa_threaded_mainloop_lock failed"); if (pa_stream_get_state(p->stream) !=3D PA_STREAM_READY) { /* wait for stream to become ready */ goto unlock; @@ -179,7 +179,7 @@ static size_t qpa_read(HWVoiceIn *hw, void *data, size_= t length) if (!p->read_length) { r =3D pa_stream_peek(p->stream, &p->read_data, &p->read_length= ); CHECK_SUCCESS_GOTO(c, r =3D=3D 0, unlock_and_fail, - "pa_stream_peek failed\n"); + "pa_stream_peek failed"); if (!p->read_length) { /* buffer is empty */ break; @@ -196,7 +196,7 @@ static size_t qpa_read(HWVoiceIn *hw, void *data, size_= t length) if (!p->read_length) { r =3D pa_stream_drop(p->stream); CHECK_SUCCESS_GOTO(c, r =3D=3D 0, unlock_and_fail, - "pa_stream_drop failed\n"); + "pa_stream_drop failed"); } } =20 @@ -218,7 +218,7 @@ static size_t qpa_buffer_get_free(HWVoiceOut *hw) pa_threaded_mainloop_lock(c->mainloop); =20 CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail, - "pa_threaded_mainloop_lock failed\n"); + "pa_threaded_mainloop_lock failed"); if (pa_stream_get_state(p->stream) !=3D PA_STREAM_READY) { /* wait for stream to become ready */ l =3D 0; @@ -227,7 +227,7 @@ static size_t qpa_buffer_get_free(HWVoiceOut *hw) =20 l =3D pa_stream_writable_size(p->stream); CHECK_SUCCESS_GOTO(c, l !=3D (size_t) -1, unlock_and_fail, - "pa_stream_writable_size failed\n"); + "pa_stream_writable_size failed"); =20 unlock: pa_threaded_mainloop_unlock(c->mainloop); @@ -248,12 +248,12 @@ static void *qpa_get_buffer_out(HWVoiceOut *hw, size_= t *size) pa_threaded_mainloop_lock(c->mainloop); =20 CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail, - "pa_threaded_mainloop_lock failed\n"); + "pa_threaded_mainloop_lock failed"); =20 *size =3D -1; r =3D pa_stream_begin_write(p->stream, &ret, size); CHECK_SUCCESS_GOTO(c, r >=3D 0, unlock_and_fail, - "pa_stream_begin_write failed\n"); + "pa_stream_begin_write failed"); =20 pa_threaded_mainloop_unlock(c->mainloop); return ret; @@ -273,10 +273,10 @@ static size_t qpa_put_buffer_out(HWVoiceOut *hw, void= *data, size_t length) pa_threaded_mainloop_lock(c->mainloop); =20 CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail, - "pa_threaded_mainloop_lock failed\n"); + "pa_threaded_mainloop_lock failed"); =20 r =3D pa_stream_write(p->stream, data, length, NULL, 0LL, PA_SEEK_RELA= TIVE); - CHECK_SUCCESS_GOTO(c, r >=3D 0, unlock_and_fail, "pa_stream_write fail= ed\n"); + CHECK_SUCCESS_GOTO(c, r >=3D 0, unlock_and_fail, "pa_stream_write fail= ed"); =20 pa_threaded_mainloop_unlock(c->mainloop); return length; @@ -296,7 +296,7 @@ static size_t qpa_write(HWVoiceOut *hw, void *data, siz= e_t length) pa_threaded_mainloop_lock(c->mainloop); =20 CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail, - "pa_threaded_mainloop_lock failed\n"); + "pa_threaded_mainloop_lock failed"); if (pa_stream_get_state(p->stream) !=3D PA_STREAM_READY) { /* wait for stream to become ready */ l =3D 0; @@ -306,14 +306,14 @@ static size_t qpa_write(HWVoiceOut *hw, void *data, s= ize_t length) l =3D pa_stream_writable_size(p->stream); =20 CHECK_SUCCESS_GOTO(c, l !=3D (size_t) -1, unlock_and_fail, - "pa_stream_writable_size failed\n"); + "pa_stream_writable_size failed"); =20 if (l > length) { l =3D length; } =20 r =3D pa_stream_write(p->stream, data, l, NULL, 0LL, PA_SEEK_RELATIVE); - CHECK_SUCCESS_GOTO(c, r >=3D 0, unlock_and_fail, "pa_stream_write fail= ed\n"); + CHECK_SUCCESS_GOTO(c, r >=3D 0, unlock_and_fail, "pa_stream_write fail= ed"); =20 unlock: pa_threaded_mainloop_unlock(c->mainloop); @@ -345,7 +345,7 @@ static pa_sample_format_t audfmt_to_pa(AudioFormat afmt= , bool big_endian) format =3D big_endian ? PA_SAMPLE_FLOAT32BE : PA_SAMPLE_FLOAT32LE; break; default: - dolog ("Internal logic error: Bad audio format %d\n", afmt); + error_report("pulseaudio: Internal logic error: Bad audio format %= d", afmt); format =3D PA_SAMPLE_U8; break; } @@ -376,12 +376,12 @@ static AudioFormat pa_to_audfmt (pa_sample_format_t f= mt, int *endianness) *endianness =3D 0; return AUDIO_FORMAT_F32; default: - dolog ("Internal logic error: Bad pa_sample_format %d\n", fmt); + error_report("pulseaudio: Internal logic error: Bad pa_sample_form= at %d", fmt); return AUDIO_FORMAT_U8; } } =20 -static void context_state_cb (pa_context *c, void *userdata) +static void context_state_cb(pa_context *c, void *userdata) { PAConnection *conn =3D userdata; =20 @@ -473,7 +473,7 @@ static pa_stream *qpa_simple_new ( break; =20 default: - dolog("Internal error: unsupported channel count %d\n", ss->channe= ls); + error_report("pulseaudio: unsupported channel count %d", ss->chann= els); goto fail; } =20 @@ -553,7 +553,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as) &error ); if (!pa->stream) { - qpa_logerr (error, "pa_simple_new for playback failed\n"); + qpa_logerr(error, "pa_simple_new for playback failed"); goto fail1; } =20 @@ -604,7 +604,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as) &error ); if (!pa->stream) { - qpa_logerr (error, "pa_simple_new for capture failed\n"); + qpa_logerr(error, "pa_simple_new for capture failed"); goto fail1; } =20 @@ -633,7 +633,7 @@ static void qpa_simple_disconnect(PAConnection *c, pa_s= tream *stream) =20 err =3D pa_stream_disconnect(stream); if (err !=3D 0) { - dolog("Failed to disconnect! err=3D%d\n", err); + error_report("pulseaudio: Failed to disconnect! err=3D%d", err); } pa_stream_unref(stream); } @@ -664,7 +664,7 @@ static void qpa_fini_in (HWVoiceIn *hw) int r =3D pa_stream_drop(pa->stream); if (r) { qpa_logerr(pa_context_errno(c->context), - "pa_stream_drop failed\n"); + "pa_stream_drop failed"); } pa->read_length =3D 0; } @@ -698,7 +698,7 @@ static void qpa_volume_out(HWVoiceOut *hw, Volume *vol) &v, NULL, NULL); if (!op) { qpa_logerr(pa_context_errno(c->context), - "set_sink_input_volume() failed\n"); + "set_sink_input_volume() failed"); } else { pa_operation_unref(op); } @@ -708,7 +708,7 @@ static void qpa_volume_out(HWVoiceOut *hw, Volume *vol) vol->mute, NULL, NULL); if (!op) { qpa_logerr(pa_context_errno(c->context), - "set_sink_input_mute() failed\n"); + "set_sink_input_mute() failed"); } else { pa_operation_unref(op); } @@ -740,7 +740,7 @@ static void qpa_volume_in(HWVoiceIn *hw, Volume *vol) &v, NULL, NULL); if (!op) { qpa_logerr(pa_context_errno(c->context), - "set_source_output_volume() failed\n"); + "set_source_output_volume() failed"); } else { pa_operation_unref(op); } @@ -750,7 +750,7 @@ static void qpa_volume_in(HWVoiceIn *hw, Volume *vol) vol->mute, NULL, NULL); if (!op) { qpa_logerr(pa_context_errno(c->context), - "set_source_output_mute() failed\n"); + "set_source_output_mute() failed"); } else { pa_operation_unref(op); } @@ -788,7 +788,7 @@ static void *qpa_conn_init(const char *server) =20 if (pa_context_connect(c->context, server, 0, NULL) < 0) { qpa_logerr(pa_context_errno(c->context), - "pa_context_connect() failed\n"); + "pa_context_connect() failed"); goto fail; } =20 @@ -809,7 +809,7 @@ static void *qpa_conn_init(const char *server) =20 if (!PA_CONTEXT_IS_GOOD(state)) { qpa_logerr(pa_context_errno(c->context), - "Wrong context state\n"); + "Wrong context state"); goto unlock_and_fail; } =20 @@ -823,7 +823,6 @@ static void *qpa_conn_init(const char *server) unlock_and_fail: pa_threaded_mainloop_unlock(c->mainloop); fail: - AUD_log (AUDIO_CAP, "Failed to initialize PA context"); qpa_conn_fini(c); return NULL; } --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538735; cv=none; d=zohomail.com; s=zohoarc; b=LxgVF7hT/5PKn6R0madEUgJkI7O7fzhiBGSwKP0V4W2AFX0o5qQqMkGksY+cNSfYdTbqyACJTpA+1vk/zKlSfgQm4z55nztK/vpyitd1w5y2Vs9sK9eyInJ2U0+pMWktN74Al4Zk1LMwMFqlm0xS66CmChWAhxoCrf4iNDXzsJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538735; 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=kb0XUX8Hbw1CeUAvB+XxD3OCphYLf6Qpo+MzOpEtu6c=; b=A30UqO54QjG//oCvS9eTMPr0X5HdLvhiekHbqB04bFydTmN12hdIR+1qCqXaWyB0qEjpaW4lL3mqbmROi/Btf2TYVa5AwtEIxPa31/sP1yYywvdSmjhIxTXGsWYNrM9/5+ggHg4c59TaXUgYhmbRlGDjNgSV63WgO5ur32NoUH0= 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 1769538735500121.77927917327258; Tue, 27 Jan 2026 10:32:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknow-0002Sr-4K; Tue, 27 Jan 2026 13:29:46 -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 1vknnI-0008AT-5v for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:07 -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 1vknnF-0003KX-BA for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:02 -0500 Received: from mx-prod-mc-05.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-577-uHd0GKlmPEe_vP8CexXLpA-1; Tue, 27 Jan 2026 13:27:56 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BE9E11955F2C; Tue, 27 Jan 2026 18:27:55 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4E79319560B4; Tue, 27 Jan 2026 18:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538480; 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=kb0XUX8Hbw1CeUAvB+XxD3OCphYLf6Qpo+MzOpEtu6c=; b=YZslk9ZJgPsx/UI5qyENFFQQ2qXft1a805OgpVynmxe6rI1LtofDPvp89C/d7cEMBCffQ4 K7oAcGO6GxxyREoOgOSK7J2duZJ37i3lub2j2+9DK+sc70CqbNwYQRmE2AWeJdPn9aMOMW I7U8b/SBi1aLqMgmBm1/fjwlTODCQEY= X-MC-Unique: uHd0GKlmPEe_vP8CexXLpA-1 X-Mimecast-MFC-AGG-ID: uHd0GKlmPEe_vP8CexXLpA_1769538475 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 26/43] audio/pw: replace custom logging with error_report Date: Tue, 27 Jan 2026 22:24:53 +0400 Message-ID: <20260127182516.289834-27-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.12 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538736890158500 From: Marc-Andr=C3=A9 Lureau Replace the custom audio logging infrastructure (dolog macro) with standard QEMU error reporting (error_report). Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/pwaudio.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/audio/pwaudio.c b/audio/pwaudio.c index 39b2b8f0a0d..c30738c16ef 100644 --- a/audio/pwaudio.c +++ b/audio/pwaudio.c @@ -20,14 +20,13 @@ #include =20 #include + +#include "audio_int.h" #include "trace.h" =20 -#define AUDIO_CAP "pipewire" #define RINGBUFFER_SIZE (1u << 22) #define RINGBUFFER_MASK (RINGBUFFER_SIZE - 1) =20 -#include "audio_int.h" - #define TYPE_AUDIO_PW "audio-pipewire" OBJECT_DECLARE_SIMPLE_TYPE(AudioPw, AUDIO_PW) =20 @@ -358,7 +357,7 @@ audfmt_to_pw(AudioFormat fmt, bool big_endian) format =3D big_endian ? SPA_AUDIO_FORMAT_F32_BE : SPA_AUDIO_FORMAT= _F32_LE; break; default: - dolog("Internal logic error: Bad audio format %d\n", fmt); + error_report("pipewire: internal logic error: bad audio format %d"= , fmt); format =3D SPA_AUDIO_FORMAT_U8; break; } @@ -418,7 +417,7 @@ pw_to_audfmt(enum spa_audio_format fmt, int *endianness, return AUDIO_FORMAT_F32; default: *sample_size =3D 1; - dolog("Internal logic error: Bad spa_audio_format %d\n", fmt); + error_report("pipewire: internal logic error: bad spa_audio_format= %d", fmt); return AUDIO_FORMAT_U8; } } @@ -518,7 +517,7 @@ qpw_set_position(uint32_t channels, uint32_t position[S= PA_AUDIO_MAX_CHANNELS]) position[0] =3D SPA_AUDIO_CHANNEL_MONO; break; default: - dolog("Internal error: unsupported channel count %d\n", channels); + error_report("pipewire: unsupported channel count %d", channels); } } =20 --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538620; cv=none; d=zohomail.com; s=zohoarc; b=JRw+47D6jLved/cZL+466Y1vI7R69JzjwaK2AXks3iPbRQxIGjASdbhprthFakhrVFkyk+sc11qJmwgw48YEguhWKdrTwXLMIyy5JVllo2tewp98/Dnt6JnnfKz7IAyaj/fCt6vbtFJpEkVoFPS/aEQ7DlL3Xip49CagvTOM0Q4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538620; 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=MqaEB3FeX5ZXTlaeRJLZyser7EAzSZP84ZhcqgvQ8JA=; b=bDD1AQOS7TCHpDsWOA4Sr5VUy+AimB/wwIShMEVZvFGwGkBn8TYhCgf6tIFSeISxx+XBYvSXfbY1TLQeR8vTnEVw/s9DCXV+jbrYSDJM0UKNbHCC5OfDd+w9mn3s0rqElyAakxqYbgxr7k0Lcb8bWTPYQ8cjouBGu2fEkRYdJok= 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 1769538620557543.5887579370474; Tue, 27 Jan 2026 10:30:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknnX-0000nv-Ur; Tue, 27 Jan 2026 13:28: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 1vknnK-0008Bc-CD for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:08 -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 1vknnI-0003L2-Li for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:06 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-679-j3nX336BP7mU4jyQ1gbbaQ-1; Tue, 27 Jan 2026 13:28:02 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5770D1800357; Tue, 27 Jan 2026 18:28:01 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 536851958DC0; Tue, 27 Jan 2026 18:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538484; 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=MqaEB3FeX5ZXTlaeRJLZyser7EAzSZP84ZhcqgvQ8JA=; b=ZihHLsOGR7R4++/a2pa/IwFVJ4ClI53UJMwMjUuUeYH79JU6Nzy0O+akOwFTmuePQpbgkO lsYcKsaeVmVci2qN966nQYZmmd5Cjj+Hk7G30KnRpmWoLFP3vvaCknzXgq5Bxszwu23vIw QqYl7zNt5G6l1pjVPjTzCWgnHhuzcQQ= X-MC-Unique: j3nX336BP7mU4jyQ1gbbaQ-1 X-Mimecast-MFC-AGG-ID: j3nX336BP7mU4jyQ1gbbaQ_1769538481 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 27/43] audio/sdl: replace custom logging with error_report Date: Tue, 27 Jan 2026 22:24:54 +0400 Message-ID: <20260127182516.289834-28-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.12 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538622117158500 From: Marc-Andr=C3=A9 Lureau Replace the custom audio logging infrastructure (dolog macro and AUD_log/AUD_vlog) with standard QEMU error reporting (error_report, error_printf, error_vprintf). Note that we also dropped the abort() call in DEBUG_AUDIO, as it is not usually compiled with, doesn't help much, and can easily be added back when doing development as needed. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/sdlaudio.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 4fb9abd66c3..bb667ef9525 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -26,6 +26,7 @@ #include #include #include "qemu/module.h" +#include "qemu/error-report.h" #include "qapi/error.h" #include "qemu/audio.h" #include "qom/object.h" @@ -38,7 +39,6 @@ #endif #endif =20 -#define AUDIO_CAP "sdl" #include "audio_int.h" =20 #define TYPE_AUDIO_SDL "audio-sdl" @@ -67,15 +67,15 @@ typedef struct SDLVoiceIn { SDL_AudioDeviceID devid; } SDLVoiceIn; =20 -static void G_GNUC_PRINTF (1, 2) sdl_logerr (const char *fmt, ...) +static void G_GNUC_PRINTF (1, 2) sdl_logerr(const char *fmt, ...) { va_list ap; =20 - va_start (ap, fmt); - AUD_vlog (AUDIO_CAP, fmt, ap); - va_end (ap); + va_start(ap, fmt); + error_vprintf(fmt, ap); + va_end(ap); =20 - AUD_log (AUDIO_CAP, "Reason: %s\n", SDL_GetError ()); + error_printf("Reason: %s\n", SDL_GetError()); } =20 static int aud_to_sdlfmt (AudioFormat fmt) @@ -102,10 +102,7 @@ static int aud_to_sdlfmt (AudioFormat fmt) return AUDIO_F32LSB; =20 default: - dolog ("Internal logic error: Bad audio format %d\n", fmt); -#ifdef DEBUG_AUDIO - abort (); -#endif + error_report("sdl: internal logic error: bad audio format %d", fmt= ); return AUDIO_U8; } } @@ -164,7 +161,7 @@ static int sdl_to_audfmt(int sdlfmt, AudioFormat *fmt, = int *endianness) break; =20 default: - dolog ("Unrecognized SDL audio format %d\n", sdlfmt); + error_report("sdl: unrecognized audio format %d", sdlfmt); return -1; } =20 @@ -182,12 +179,12 @@ static SDL_AudioDeviceID sdl_open(SDL_AudioSpec *req,= SDL_AudioSpec *obt, /* Make sure potential threads created by SDL don't hog signals. */ err =3D sigfillset (&new); if (err) { - dolog ("sdl_open: sigfillset failed: %s\n", strerror (errno)); + error_report("sdl: sigfillset failed: %s", strerror (errno)); return 0; } err =3D pthread_sigmask (SIG_BLOCK, &new, &old); if (err) { - dolog ("sdl_open: pthread_sigmask failed: %s\n", strerror (err)); + error_report("sdl: pthread_sigmask failed: %s", strerror (err)); return 0; } #endif @@ -201,8 +198,8 @@ static SDL_AudioDeviceID sdl_open(SDL_AudioSpec *req, S= DL_AudioSpec *obt, #ifndef _WIN32 err =3D pthread_sigmask (SIG_SETMASK, &old, NULL); if (err) { - dolog ("sdl_open: pthread_sigmask (restore) failed: %s\n", - strerror (errno)); + error_report("sdl: pthread_sigmask (restore) failed: %s", + strerror (errno)); /* We have failed to restore original signal mask, all bets are of= f, so exit the process */ exit (EXIT_FAILURE); @@ -233,8 +230,6 @@ static void sdl_callback_out(void *opaque, Uint8 *buf, = int len) =20 if (!sdl->exit) { =20 - /* dolog("callback_out: len=3D%d avail=3D%zu\n", len, hw->pending_= emul); */ - while (hw->pending_emul && len) { size_t write_len, start; =20 @@ -283,8 +278,6 @@ static void sdl_callback_in(void *opaque, Uint8 *buf, i= nt len) return; } =20 - /* dolog("callback_in: len=3D%d pending=3D%zu\n", len, hw->pending_emu= l); */ - while (hw->pending_emul < hw->size_emul && len) { size_t read_len =3D MIN(len, MIN(hw->size_emul - hw->pos_emul, hw->size_emul - hw->pending_emul)); --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538958; cv=none; d=zohomail.com; s=zohoarc; b=FAmfKDaRlNhePPw/MyfU66URR5eA6+Ba07HJFYLhYHjYuGyzdc1p+XIRuthRhXHcqmYRaHtA302rKyLDB1RFihS+Opd06I5weauASKpcJnaP3pp684RRAnuTM9JlO2yaIoel/u/IPEvZpEZrGIDp7/6Lld0C2bD1nLWmLxy/mhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538958; 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=ReNyxfS/w4yJD8swiQpRIsDZn0gx2m9kwhO585AUjpQ=; b=eWmQdTr7uWgiK+j6PxHnhmqRClxPAAyrnfsCJzEb82uBr5wqnhSEOLZBAIxYo60jcFpQNBIdaz6AlwuwJZj/A1iZniMEJa07mEzi0X5uBZnLfBumyIPHLpyms+VleIPXAToXwFn6bejIeMK2KRo10igZLvAvrz4FR8g4JTUqtog= 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 1769538958454541.300192771878; Tue, 27 Jan 2026 10:35:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknp5-0003bT-61; Tue, 27 Jan 2026 13:29:55 -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 1vknnQ-0008RW-W2 for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:13 -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 1vknnP-0003M0-BD for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:12 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-387-RtjzGYRONqm3O5sf1tEBiQ-1; Tue, 27 Jan 2026 13:28:08 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D3D2418002C2; Tue, 27 Jan 2026 18:28:07 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D0C8730002D6; Tue, 27 Jan 2026 18:28:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538490; 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=ReNyxfS/w4yJD8swiQpRIsDZn0gx2m9kwhO585AUjpQ=; b=UC4ktU+IWn4iS6PC38KqSLi2JZWKNNTDGEtJUhz5aJPsXmxFICYRNDzOz83BxGdZHPI7Ie 3qHIyzbXRLhyGuuPP61v48Qzq2XH+YPS+LUsYtoYwUsHwOJd8rrpkawBNPrjZsci4GMg6p 88mZoVpWyCvZZiH5GkN+zOHeQ1IhUgM= X-MC-Unique: RtjzGYRONqm3O5sf1tEBiQ-1 X-Mimecast-MFC-AGG-ID: RtjzGYRONqm3O5sf1tEBiQ_1769538487 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Alexandre Ratchov Subject: [PATCH 28/43] audio/sndio: replace custom logging with error_report Date: Tue, 27 Jan 2026 22:24:55 +0400 Message-ID: <20260127182516.289834-29-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.4.1 on 10.30.177.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+importer=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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538960334158500 From: Marc-Andr=C3=A9 Lureau Replace the custom audio logging infrastructure (dolog macro) with standard QEMU error reporting (error_report). Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/sndioaudio.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c index bc62f670a33..be491895532 100644 --- a/audio/sndioaudio.c +++ b/audio/sndioaudio.c @@ -18,12 +18,12 @@ #include #include #include "qemu/main-loop.h" +#include "qemu/error-report.h" #include "qemu/audio.h" -#include "trace.h" #include "qom/object.h" =20 -#define AUDIO_CAP "sndio" #include "audio_int.h" +#include "trace.h" =20 #define TYPE_AUDIO_SNDIO "audio-sndio" OBJECT_DECLARE_SIMPLE_TYPE(AudioSndio, AUDIO_SNDIO) @@ -348,7 +348,7 @@ static int sndio_init(SndioVoice *self, /* open the device in non-blocking mode */ self->hdl =3D sio_open(dev_name, mode, 1); if (self->hdl =3D=3D NULL) { - dolog("failed to open device\n"); + error_report("sndio: failed to open device"); return -1; } =20 @@ -382,7 +382,7 @@ static int sndio_init(SndioVoice *self, req.sig =3D 0; break; default: - dolog("unknown audio sample format\n"); + error_report("sndio: unknown audio sample format"); return -1; } =20 @@ -401,12 +401,12 @@ static int sndio_init(SndioVoice *self, req.appbufsz =3D req.rate * latency / 1000000; =20 if (!sio_setpar(self->hdl, &req)) { - dolog("failed set audio params\n"); + error_report("sndio: failed to set audio params"); goto fail; } =20 if (!sio_getpar(self->hdl, &self->par)) { - dolog("failed get audio params\n"); + error_report("sndio: failed to get audio params"); goto fail; } =20 @@ -419,7 +419,7 @@ static int sndio_init(SndioVoice *self, if (self->par.bits !=3D req.bits || self->par.bps !=3D req.bits / 8 || self->par.sig !=3D req.sig || (req.bits > 8 && self->par.le !=3D r= eq.le) || self->par.rate !=3D as->freq || nch !=3D as->nchannels) { - dolog("unsupported audio params\n"); + error_report("sndio: unsupported audio params"); goto fail; } =20 @@ -431,7 +431,7 @@ static int sndio_init(SndioVoice *self, =20 self->buf =3D g_malloc(self->buf_size); if (self->buf =3D=3D NULL) { - dolog("failed to allocate audio buffer\n"); + error_report("sndio: failed to allocate audio buffer"); goto fail; } =20 @@ -439,13 +439,13 @@ static int sndio_init(SndioVoice *self, =20 self->pfds =3D g_malloc_n(nfds, sizeof(struct pollfd)); if (self->pfds =3D=3D NULL) { - dolog("failed to allocate pollfd structures\n"); + error_report("sndio: failed to allocate pollfd structures"); goto fail; } =20 self->pindexes =3D g_malloc_n(nfds, sizeof(struct pollindex)); if (self->pindexes =3D=3D NULL) { - dolog("failed to allocate pollindex structures\n"); + error_report("sndio: failed to allocate pollindex structures"); goto fail; } =20 --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538893; cv=none; d=zohomail.com; s=zohoarc; b=W10MBW9WfZUGOcKqzXU24HQLPqbnTIx/Q5WJBd3R30rZXCHIsmTOx4lHt7LB+yFJGWEYW/IZa3bqbLFU0pioxktIaAZpE54V0w1ZpnFIQ+fEHLcayOvxQqMhWjDMdza2NY3/eK5pChF1+mzfCC9NEP5SkvMBgSnND6DHNRQBr0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538893; 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=C8NKxCyFuzj5z9bZpnCF9aj6rMnE6HAHnZAHwwF31K0=; b=LteRO4uBr/GtOxU9T1VrKGb3ghVGyeCf1JUi/E1m+7aIZETApgVCxUHOLM4pbaeMB60zA/DLi4jQjliMok4AJ3gjq1RrsFQgriX0K9S/m+kkqDsmwHDSp6AyrZHfnAUjPJFUa84W67c56UuaAR/fbn6JKCwjw0inshkH96RAj4s= 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 1769538893006286.50669586566414; Tue, 27 Jan 2026 10:34:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknp5-0003ei-DS; Tue, 27 Jan 2026 13:29:55 -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 1vknna-0001OS-9g for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:23 -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 1vknnX-0003Nk-9x for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:21 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-498-Oml20gYUPdO2mYJeYBBhOw-1; Tue, 27 Jan 2026 13:28:14 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ECBEC18002C2; Tue, 27 Jan 2026 18:28:13 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4ABEF18007D2; Tue, 27 Jan 2026 18:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538498; 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=C8NKxCyFuzj5z9bZpnCF9aj6rMnE6HAHnZAHwwF31K0=; b=ABdXqEHT/d5u6oA+2mWLNjjZv1ue7UCblghwvyBYR3iTCBcNN7JEDs9ZI0J6NhnI1tARa5 AN5pvXF5vn3exGBpje0Xhc+VUfsGnzwi0qrU1dNevAQaheOL5bzeTp79aIym7LggbtbfkR hfmVT13zf/58UHYUYOCgmX5RAF0CQis= X-MC-Unique: Oml20gYUPdO2mYJeYBBhOw-1 X-Mimecast-MFC-AGG-ID: Oml20gYUPdO2mYJeYBBhOw_1769538494 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 29/43] audio/spice: remove unused AUDIO_CAP macro Date: Tue, 27 Jan 2026 22:24:56 +0400 Message-ID: <20260127182516.289834-30-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538893716158500 From: Marc-Andr=C3=A9 Lureau The AUDIO_CAP macro is no longer used. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/spiceaudio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index fa1cb04dbf7..2547126994d 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -26,7 +26,6 @@ #include "ui/qemu-spice.h" #include "qom/object.h" =20 -#define AUDIO_CAP "spice" #include "qemu/audio.h" #include "audio_int.h" =20 --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538660; cv=none; d=zohomail.com; s=zohoarc; b=SoAlP4Wcq0pZXkOdXJol38H0UyOGjNRhMN64ORGWnfrc8Foxll1rkPTXz8KDYD1/l3Hx59qLre7ubpHHvLct0WlUHsdebw1FH6XzM2f7ize21awBLUcit9DQeFrwn0VU1TDU4+g4qtUeu9/LN9K6dUCLa/YYRMyDV6cA57NsBgs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538660; 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=RMQmS+opm7irL9efzEm3gEPqvkUMjXPW3JX3/rTd+vA=; b=cYfi3Wwr86i3vbLD+npPSw6cZgu3xRXOehlRCj26FJiR8AwzpYI4rXQKU1ZV+arNZPNqvsXlKruLSXUoPCObnpcJfxriCupQ9mzkqGOhb1okQAhjeksgCmHMmcrBoclkiY39M7s/JYOm2KPgwQXq0JSOMBP4fVpmWyRIiHjBUz4= 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 1769538660515226.6786212071197; Tue, 27 Jan 2026 10:31:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknp7-0003yW-Fj; Tue, 27 Jan 2026 13:29:57 -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 1vknng-0001Q9-96 for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:30 -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 1vknnd-0003PL-IS for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:28 -0500 Received: from mx-prod-mc-05.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-410-V3AHowQ7OgekKGi69_jwLQ-1; Tue, 27 Jan 2026 13:28:21 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2CB7719775E2; Tue, 27 Jan 2026 18:28:20 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B8D041800109; Tue, 27 Jan 2026 18:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538505; 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=RMQmS+opm7irL9efzEm3gEPqvkUMjXPW3JX3/rTd+vA=; b=Y1oe8qJkiHWIT98GHWfVVq7dT7EGS1nmOkBPvRw7wB9tZ2FSAP8/4S0KAe8W63mXnqVEK7 q7HRBq8jYg2TclwGie2nnFTZJFPQcWqbaCHMMN6FCfNDNRCzD7yTGcKn8gQ2bKfo7EFFkc N5bxG+i59gcu1EWZMKoUVzn6k6eCfNQ= X-MC-Unique: V3AHowQ7OgekKGi69_jwLQ-1 X-Mimecast-MFC-AGG-ID: V3AHowQ7OgekKGi69_jwLQ_1769538500 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 30/43] audio/wav: replace custom logging with error_report Date: Tue, 27 Jan 2026 22:24:57 +0400 Message-ID: <20260127182516.289834-31-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.4.1 on 10.30.177.111 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538662348158500 From: Marc-Andr=C3=A9 Lureau Replace the custom audio logging infrastructure (dolog macro) with standard QEMU error reporting (error_report). Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/wavaudio.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 090f3f4dc60..5c614ed3b51 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -24,10 +24,10 @@ =20 #include "qemu/osdep.h" #include "qemu/module.h" +#include "qemu/error-report.h" #include "qemu/audio.h" #include "qom/object.h" =20 -#define AUDIO_CAP "wav" #include "audio_int.h" =20 #define TYPE_AUDIO_WAV "audio-wav" @@ -51,8 +51,8 @@ static size_t wav_write_out(HWVoiceOut *hw, void *buf, si= ze_t len) assert(bytes % hw->info.bytes_per_frame =3D=3D 0); =20 if (bytes && fwrite(buf, bytes, 1, wav->f) !=3D 1) { - dolog("wav_write_out: fwrite of %" PRId64 " bytes failed\nReason: = %s\n", - bytes, strerror(errno)); + error_report("wav: fwrite of %" PRId64 " bytes failed: %s", + bytes, strerror(errno)); } =20 wav->total_samples +=3D bytes / hw->info.bytes_per_frame; @@ -98,11 +98,11 @@ static int wav_init_out(HWVoiceOut *hw, struct audsetti= ngs *as) =20 case AUDIO_FORMAT_S32: case AUDIO_FORMAT_U32: - dolog ("WAVE files can not handle 32bit formats\n"); + error_report("wav: WAVE files cannot handle 32-bit formats"); return -1; =20 case AUDIO_FORMAT_F32: - dolog("WAVE files can not handle float formats\n"); + error_report("wav: WAVE files cannot handle float formats"); return -1; =20 default: @@ -122,14 +122,13 @@ static int wav_init_out(HWVoiceOut *hw, struct audset= tings *as) =20 wav->f =3D fopen(wav_path, "wb"); if (!wav->f) { - dolog ("Failed to open wave file `%s'\nReason: %s\n", - wav_path, strerror(errno)); + error_report("wav: failed to open wave file '%s': %s", + wav_path, strerror(errno)); return -1; } =20 if (fwrite (hdr, sizeof (hdr), 1, wav->f) !=3D 1) { - dolog ("wav_init_out: failed to write header\nReason: %s\n", - strerror(errno)); + error_report("wav: failed to write header: %s", strerror(errno)); return -1; } =20 @@ -153,30 +152,25 @@ static void wav_fini_out (HWVoiceOut *hw) le_store (dlen, datalen, 4); =20 if (fseek (wav->f, 4, SEEK_SET)) { - dolog ("wav_fini_out: fseek to rlen failed\nReason: %s\n", - strerror(errno)); + error_report("wav: fseek to rlen failed: %s", strerror(errno)); goto doclose; } if (fwrite (rlen, 4, 1, wav->f) !=3D 1) { - dolog ("wav_fini_out: failed to write rlen\nReason: %s\n", - strerror (errno)); + error_report("wav: failed to write rlen: %s", strerror(errno)); goto doclose; } if (fseek (wav->f, 32, SEEK_CUR)) { - dolog ("wav_fini_out: fseek to dlen failed\nReason: %s\n", - strerror (errno)); + error_report("wav: fseek to dlen failed: %s", strerror(errno)); goto doclose; } if (fwrite (dlen, 4, 1, wav->f) !=3D 1) { - dolog ("wav_fini_out: failed to write dlen\nReaons: %s\n", - strerror (errno)); + error_report("wav: failed to write dlen: %s", strerror(errno)); goto doclose; } =20 doclose: if (fclose (wav->f)) { - dolog ("wav_fini_out: fclose %p failed\nReason: %s\n", - wav->f, strerror (errno)); + error_report("wav: fclose failed: %s", strerror(errno)); } wav->f =3D NULL; } --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538964; cv=none; d=zohomail.com; s=zohoarc; b=gD7G3cyhJ68VItN7n88zNjduPjTMrQfgk8H3SqnnK00GA/vTuUAid7qlopJJDVXCIPPyyj1dl08j6Pv8DvFG8GuRAVMwzFvjCJowqSTF+DXRyNfIZrUpbbuwIa67X+WaWWuOFueG+S8K+bQryCXmyWLXAY9SjTu6pFMIYLMP5m8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538964; 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=Nao6GR4PA+D5lNYLhp5P8F75FAU05Pi5/wDI5gnX4p8=; b=NjPQ54880xzLSQn/Dj+GOU0xREKQxcDee+fzOJb0adoVdk8eKeZz2BkqcwdOylIqzXp2iXwoT0a8eZWi1K9efvBf2pWtJroDv+hYZvlOgGoSTJvvoH5/wXjaZV5yFGU8kowhJI2EX5TKlU5Ld4NAKTs6omFme1uSrffXwz6Nlec= 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 1769538964640842.2841170566288; Tue, 27 Jan 2026 10:36:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknq2-0006Mk-Kk; Tue, 27 Jan 2026 13:30: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 1vknnq-0001mV-OG for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:45 -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 1vknnl-0003Qq-Bt for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:36 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-D_ikycIsPRuMpRdGJHRJhQ-1; Tue, 27 Jan 2026 13:28:27 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3A79218002F2; Tue, 27 Jan 2026 18:28:26 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9C82218001D5; Tue, 27 Jan 2026 18:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538511; 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=Nao6GR4PA+D5lNYLhp5P8F75FAU05Pi5/wDI5gnX4p8=; b=bpgv6fbMIij+5TrZSAeqA5ctx6TmPX4od5wyPs3hvq5zgAud2QlVBxiqsgtdSMfKTqs9WU fmmlKDFjXPFk1t9fDxxIMJbrOZBzKfDurHsWfpGhl+yYFqMzGZEDINvplpEpJpO3GDwSik hp5OiIYs+RcFZhWTyTPF8s3gzzjpFAA= X-MC-Unique: D_ikycIsPRuMpRdGJHRJhQ-1 X-Mimecast-MFC-AGG-ID: D_ikycIsPRuMpRdGJHRJhQ_1769538506 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , Akihiko Odaki Subject: [PATCH 31/43] audio/mixeng: replace redundant pcm_info fields with AudioFormat Date: Tue, 27 Jan 2026 22:24:58 +0400 Message-ID: <20260127182516.289834-32-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.4.1 on 10.30.177.111 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538966650154100 From: Marc-Andr=C3=A9 Lureau The audio_pcm_info structure stored three fields (bits, is_signed, is_float) that were always derived from the AudioFormat enum. This redundancy meant the same information was represented twice, with no type-level guarantee that they stayed in sync. Replace these fields with a single AudioFormat field, and add helper functions to extract the derived properties when needed: - audio_format_bits() - audio_format_is_signed() - audio_format_is_float() This improves type safety by making AudioFormat the single source of truth, eliminating the possibility of inconsistent state between the format enum and its derived boolean/integer representations. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki --- audio/audio_int.h | 4 +- audio/audio_template.h | 12 +-- include/qemu/audio.h | 49 +++++++++ audio/audio-mixeng-be.c | 218 ++++++++++++---------------------------- audio/dbusaudio.c | 12 +-- audio/coreaudio.m | 2 +- 6 files changed, 126 insertions(+), 171 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 5334c4baad2..dd5f2220d75 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -45,9 +45,7 @@ struct audio_callback { }; =20 struct audio_pcm_info { - int bits; - bool is_signed; - bool is_float; + AudioFormat af; int freq; int nchannels; int bytes_per_frame; diff --git a/audio/audio_template.h b/audio/audio_template.h index 08d60422589..3da91a4782c 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -173,7 +173,7 @@ static int glue (audio_pcm_sw_init_, TYPE) ( sw->empty =3D true; #endif =20 - if (sw->info.is_float) { + if (audio_format_is_float(hw->info.af)) { #ifdef DAC sw->conv =3D mixeng_conv_float[sw->info.nchannels =3D=3D 2] [sw->info.swap_endianness]; @@ -188,9 +188,9 @@ static int glue (audio_pcm_sw_init_, TYPE) ( sw->clip =3D mixeng_clip #endif [sw->info.nchannels =3D=3D 2] - [sw->info.is_signed] + [audio_format_is_signed(hw->info.af)] [sw->info.swap_endianness] - [audio_bits_to_index(sw->info.bits)]; + [audio_format_to_index(hw->info.af)]; } =20 sw->name =3D g_strdup (name); @@ -300,7 +300,7 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMixen= gBackend *s, goto err1; } =20 - if (hw->info.is_float) { + if (audio_format_is_float(hw->info.af)) { #ifdef DAC hw->clip =3D mixeng_clip_float[hw->info.nchannels =3D=3D 2] [hw->info.swap_endianness]; @@ -315,9 +315,9 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMixen= gBackend *s, hw->conv =3D mixeng_conv #endif [hw->info.nchannels =3D=3D 2] - [hw->info.is_signed] + [audio_format_is_signed(hw->info.af)] [hw->info.swap_endianness] - [audio_bits_to_index(hw->info.bits)]; + [audio_format_to_index(hw->info.af)]; } =20 glue(audio_pcm_hw_alloc_resources_, TYPE)(hw); diff --git a/include/qemu/audio.h b/include/qemu/audio.h index b6b6ee9b560..a2fbc286eb1 100644 --- a/include/qemu/audio.h +++ b/include/qemu/audio.h @@ -185,6 +185,55 @@ bool audio_be_set_dbus_server(AudioBackend *be, =20 const char *audio_application_name(void); =20 +static inline int audio_format_bits(AudioFormat fmt) +{ + switch (fmt) { + case AUDIO_FORMAT_S8: + case AUDIO_FORMAT_U8: + return 8; + + case AUDIO_FORMAT_S16: + case AUDIO_FORMAT_U16: + return 16; + + case AUDIO_FORMAT_F32: + case AUDIO_FORMAT_S32: + case AUDIO_FORMAT_U32: + return 32; + + case AUDIO_FORMAT__MAX: + break; + } + + g_assert_not_reached(); +} + +static inline bool audio_format_is_float(AudioFormat fmt) +{ + return fmt =3D=3D AUDIO_FORMAT_F32; +} + +static inline bool audio_format_is_signed(AudioFormat fmt) +{ + switch (fmt) { + case AUDIO_FORMAT_S8: + case AUDIO_FORMAT_S16: + case AUDIO_FORMAT_S32: + case AUDIO_FORMAT_F32: + return true; + + case AUDIO_FORMAT_U8: + case AUDIO_FORMAT_U16: + case AUDIO_FORMAT_U32: + return false; + + case AUDIO_FORMAT__MAX: + break; + } + + g_assert_not_reached(); +} + #define DEFINE_AUDIO_PROPERTIES(_s, _f) \ DEFINE_PROP_AUDIODEV("audiodev", _s, _f) =20 diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index a0e542754e5..146026d0b39 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -62,23 +62,28 @@ int audio_bug (const char *funcname, int cond) return cond; } =20 -static inline int audio_bits_to_index (int bits) +/* + * Convert audio format to mixeng_clip index. Used by audio_pcm_sw_init_ a= nd + * audio_mixeng_backend_add_capture() + */ +static int audio_format_to_index(AudioFormat af) { - switch (bits) { - case 8: + switch (af) { + case AUDIO_FORMAT_U8: + case AUDIO_FORMAT_S8: return 0; - - case 16: + case AUDIO_FORMAT_U16: + case AUDIO_FORMAT_S16: return 1; - - case 32: + case AUDIO_FORMAT_U32: + case AUDIO_FORMAT_S32: return 2; - - default: - audio_bug ("bits_to_index", 1); - AUD_log (NULL, "invalid bits %d\n", bits); - return 0; + case AUDIO_FORMAT_F32: + case AUDIO_FORMAT__MAX: + break; } + + g_assert_not_reached(); } =20 void AUD_vlog (const char *cap, const char *fmt, va_list ap) @@ -172,141 +177,68 @@ static int audio_validate_settings (const struct aud= settings *as) =20 static int audio_pcm_info_eq (struct audio_pcm_info *info, const struct au= dsettings *as) { - int bits =3D 8; - bool is_signed =3D false, is_float =3D false; - - switch (as->fmt) { - case AUDIO_FORMAT_S8: - is_signed =3D true; - /* fall through */ - case AUDIO_FORMAT_U8: - break; - - case AUDIO_FORMAT_S16: - is_signed =3D true; - /* fall through */ - case AUDIO_FORMAT_U16: - bits =3D 16; - break; - - case AUDIO_FORMAT_F32: - is_float =3D true; - /* fall through */ - case AUDIO_FORMAT_S32: - is_signed =3D true; - /* fall through */ - case AUDIO_FORMAT_U32: - bits =3D 32; - break; - - default: - abort(); - } - return info->freq =3D=3D as->freq + return info->af =3D=3D as->fmt + && info->freq =3D=3D as->freq && info->nchannels =3D=3D as->nchannels - && info->is_signed =3D=3D is_signed - && info->is_float =3D=3D is_float - && info->bits =3D=3D bits && info->swap_endianness =3D=3D (as->endianness !=3D HOST_BIG_ENDI= AN); } =20 void audio_pcm_init_info (struct audio_pcm_info *info, const struct audset= tings *as) { - int bits =3D 8, mul; - bool is_signed =3D false, is_float =3D false; - - switch (as->fmt) { - case AUDIO_FORMAT_S8: - is_signed =3D true; - /* fall through */ - case AUDIO_FORMAT_U8: - mul =3D 1; - break; - - case AUDIO_FORMAT_S16: - is_signed =3D true; - /* fall through */ - case AUDIO_FORMAT_U16: - bits =3D 16; - mul =3D 2; - break; - - case AUDIO_FORMAT_F32: - is_float =3D true; - /* fall through */ - case AUDIO_FORMAT_S32: - is_signed =3D true; - /* fall through */ - case AUDIO_FORMAT_U32: - bits =3D 32; - mul =3D 4; - break; - - default: - abort(); - } - + info->af =3D as->fmt; info->freq =3D as->freq; - info->bits =3D bits; - info->is_signed =3D is_signed; - info->is_float =3D is_float; info->nchannels =3D as->nchannels; - info->bytes_per_frame =3D as->nchannels * mul; + info->bytes_per_frame =3D as->nchannels * audio_format_bits(as->fmt) /= 8; info->bytes_per_second =3D info->freq * info->bytes_per_frame; info->swap_endianness =3D (as->endianness !=3D HOST_BIG_ENDIAN); } =20 -void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int= len) +void audio_pcm_info_clear_buf(struct audio_pcm_info *info, void *buf, int = len) { if (!len) { return; } =20 - if (info->is_signed || info->is_float) { - memset(buf, 0x00, len * info->bytes_per_frame); - } else { - switch (info->bits) { - case 8: - memset(buf, 0x80, len * info->bytes_per_frame); - break; - - case 16: - { - int i; - uint16_t *p =3D buf; - short s =3D INT16_MAX; - - if (info->swap_endianness) { - s =3D bswap16 (s); - } - - for (i =3D 0; i < len * info->nchannels; i++) { - p[i] =3D s; - } - } - break; + switch (info->af) { + case AUDIO_FORMAT_U8: + memset(buf, 0x80, len * info->bytes_per_frame); + break; + case AUDIO_FORMAT_U16: { + int i; + uint16_t *p =3D buf; + short s =3D INT16_MAX; =20 - case 32: - { - int i; - uint32_t *p =3D buf; - int32_t s =3D INT32_MAX; + if (info->swap_endianness) { + s =3D bswap16(s); + } =20 - if (info->swap_endianness) { - s =3D bswap32 (s); - } + for (i =3D 0; i < len * info->nchannels; i++) { + p[i] =3D s; + } + break; + } + case AUDIO_FORMAT_U32: { + int i; + uint32_t *p =3D buf; + int32_t s =3D INT32_MAX; =20 - for (i =3D 0; i < len * info->nchannels; i++) { - p[i] =3D s; - } - } - break; + if (info->swap_endianness) { + s =3D bswap32(s); + } =20 - default: - AUD_log (NULL, "audio_pcm_info_clear_buf: invalid bits %d\n", - info->bits); - break; + for (i =3D 0; i < len * info->nchannels; i++) { + p[i] =3D s; } + break; + } + case AUDIO_FORMAT_S8: + case AUDIO_FORMAT_S16: + case AUDIO_FORMAT_S32: + case AUDIO_FORMAT_F32: + memset(buf, 0x00, len * info->bytes_per_frame); + break; + case AUDIO_FORMAT__MAX: + g_assert_not_reached(); } } =20 @@ -719,8 +651,8 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t buf_len) #ifdef DEBUG_AUDIO static void audio_pcm_print_info (const char *cap, struct audio_pcm_info *= info) { - dolog("%s: bits %d, sign %d, float %d, freq %d, nchan %d\n", - cap, info->bits, info->is_signed, info->is_float, info->freq, + dolog("%s: %s, freq %d, nchan %d\n", + cap, AudioFormat_str(info->af), info->freq, info->nchannels); } #endif @@ -1759,15 +1691,15 @@ static CaptureVoiceOut *audio_mixeng_backend_add_ca= pture( =20 cap->buf =3D g_malloc0_n(hw->mix_buf.size, hw->info.bytes_per_fram= e); =20 - if (hw->info.is_float) { + if (audio_format_is_float(hw->info.af)) { hw->clip =3D mixeng_clip_float[hw->info.nchannels =3D=3D 2] [hw->info.swap_endianness]; } else { hw->clip =3D mixeng_clip [hw->info.nchannels =3D=3D 2] - [hw->info.is_signed] + [audio_format_is_signed(hw->info.af)] [hw->info.swap_endianness] - [audio_bits_to_index(hw->info.bits)]; + [audio_format_to_index(hw->info.af)]; } =20 QLIST_INSERT_HEAD (&s->cap_head, cap, entries); @@ -1869,29 +1801,6 @@ audsettings audiodev_to_audsettings(AudiodevPerDirec= tionOptions *pdo) }; } =20 -int audioformat_bytes_per_sample(AudioFormat fmt) -{ - switch (fmt) { - case AUDIO_FORMAT_U8: - case AUDIO_FORMAT_S8: - return 1; - - case AUDIO_FORMAT_U16: - case AUDIO_FORMAT_S16: - return 2; - - case AUDIO_FORMAT_U32: - case AUDIO_FORMAT_S32: - case AUDIO_FORMAT_F32: - return 4; - - case AUDIO_FORMAT__MAX: - ; - } - abort(); -} - - /* frames =3D freq * usec / 1e6 */ int audio_buffer_frames(AudiodevPerDirectionOptions *pdo, audsettings *as, int def_usecs) @@ -1914,8 +1823,7 @@ int audio_buffer_samples(AudiodevPerDirectionOptions = *pdo, int audio_buffer_bytes(AudiodevPerDirectionOptions *pdo, audsettings *as, int def_usecs) { - return audio_buffer_samples(pdo, as, def_usecs) * - audioformat_bytes_per_sample(as->fmt); + return audio_buffer_samples(pdo, as, def_usecs) * audio_format_bits(as= ->fmt) / 8; } =20 void audio_rate_start(RateCtl *rate) diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index e284542b2dd..72d6194033b 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -147,9 +147,9 @@ dbus_init_out_listener(QemuDBusDisplay1AudioOutListener= *listener, qemu_dbus_display1_audio_out_listener_call_init( listener, (uintptr_t)hw, - hw->info.bits, - hw->info.is_signed, - hw->info.is_float, + audio_format_bits(hw->info.af), + audio_format_is_signed(hw->info.af), + audio_format_is_float(hw->info.af), hw->info.freq, hw->info.nchannels, hw->info.bytes_per_frame, @@ -273,9 +273,9 @@ dbus_init_in_listener(QemuDBusDisplay1AudioInListener *= listener, HWVoiceIn *hw) qemu_dbus_display1_audio_in_listener_call_init( listener, (uintptr_t)hw, - hw->info.bits, - hw->info.is_signed, - hw->info.is_float, + audio_format_bits(hw->info.af), + audio_format_is_signed(hw->info.af), + audio_format_is_float(hw->info.af), hw->info.freq, hw->info.nchannels, hw->info.bytes_per_frame, diff --git a/audio/coreaudio.m b/audio/coreaudio.m index 40d7986b1d7..08bab353831 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -359,7 +359,7 @@ static OSStatus init_out_device(coreaudioVoiceOut *core) AudioValueRange frameRange; =20 AudioStreamBasicDescription streamBasicDescription =3D { - .mBitsPerChannel =3D core->hw.info.bits, + .mBitsPerChannel =3D audio_format_bits(core->hw.info.af), .mBytesPerFrame =3D core->hw.info.bytes_per_frame, .mBytesPerPacket =3D core->hw.info.bytes_per_frame, .mChannelsPerFrame =3D core->hw.info.nchannels, --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538865; cv=none; d=zohomail.com; s=zohoarc; b=A7VKwimBffuthThhsE220E41z7BusSBkUraPKxGPdR4jAUm6j9pQfg6JA6xulvG38Xrj5kZChuYWa0ZiLntVGLW35EFxoaE+cDfn/hMhlR9JgcFXEENQRvIdjgQmLN3pN4H8VJK4S76NDRozl48Mrc0qlES8QAwAUuOSUtLrU6g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538865; 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=sEd0Tmc1bxnYK9FQ4RrXvn5qI2xDS/nNhmG9phjTnHU=; b=nrVioA1TccJvEzWSjhxS9KQw8Dvp/ogH3oXj/s15Meu7QFw+gXzN6iXrqA7IGBCWwNBVWeJBn7FsDDMmzP/Ji4caiblToQRSls3/znS3t4O4NeQNSMgn0vqQ2wjU5dsACIYgTfJXeNAj6hB/rXZWsynwR+fFuXKW3fZshMpikl8= 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 176953886507972.6482037922143; Tue, 27 Jan 2026 10:34:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknpH-0005NK-QI; Tue, 27 Jan 2026 13:30: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 1vkno4-0001sC-OE for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:58 -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 1vknny-0003Te-DR for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:50 -0500 Received: from mx-prod-mc-03.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-262-C_tpzxSXPs2G40KY9ViV6g-1; Tue, 27 Jan 2026 13:28:36 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 670BD1955D98; Tue, 27 Jan 2026 18:28:34 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 562AF30001A2; Tue, 27 Jan 2026 18:28:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538523; 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=sEd0Tmc1bxnYK9FQ4RrXvn5qI2xDS/nNhmG9phjTnHU=; b=An0ENdcznDboI/Kx9azJZ5BNaq6r8gC14pYXct4FMmncspcFhhzC4nPGtEsXmdcjJPveyl RuClEMZz/ZhK2wg/bSxxqhq3GKmLCiZMVdsQX1uadBhQibsnI0TOKdVO6t+HN3H6zyGrtc e7/7ZKH6c+R9iqi4e2pnJf+PcH99nqc= X-MC-Unique: C_tpzxSXPs2G40KY9ViV6g-1 X-Mimecast-MFC-AGG-ID: C_tpzxSXPs2G40KY9ViV6g_1769538514 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , Thomas Huth , Alexandre Ratchov , Laurent Vivier , "Michael S. Tsirkin" , Manos Pitsidianakis , Alistair Francis , "Edgar E. Iglesias" , Peter Maydell , qemu-arm@nongnu.org (open list:Xilinx ZynqMP and...) Subject: [PATCH 32/43] audio: replace int endianness with bool big_endian in audsettings Date: Tue, 27 Jan 2026 22:24:59 +0400 Message-ID: <20260127182516.289834-33-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.4.1 on 10.30.177.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+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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable 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: 1769538883936158500 From: Marc-Andr=C3=A9 Lureau The endianness field used an int to represent a boolean concept, with 0 meaning little-endian and 1 meaning big-endian. This required runtime validation to reject invalid values and made the code less readable. Replace with a bool big_endian field that is self-documenting and type-safe. The compiler now enforces valid values, eliminating the need for the validation check in audio_validate_settings(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/dsound_template.h | 2 +- include/qemu/audio.h | 2 +- audio/alsaaudio.c | 8 ++++---- audio/audio-mixeng-be.c | 21 ++++----------------- audio/jackaudio.c | 4 ++-- audio/ossaudio.c | 22 +++++++++++----------- audio/paaudio.c | 22 +++++++++++----------- audio/pwaudio.c | 30 +++++++++++++++--------------- audio/sdlaudio.c | 26 +++++++++++++------------- audio/sndioaudio.c | 2 +- audio/spiceaudio.c | 4 ++-- audio/wavaudio.c | 2 +- audio/wavcapture.c | 2 +- hw/audio/ac97.c | 2 +- hw/audio/adlib.c | 2 +- hw/audio/asc.c | 2 +- hw/audio/cs4231a.c | 6 +++--- hw/audio/es1370.c | 2 +- hw/audio/gus.c | 2 +- hw/audio/lm4549.c | 6 +++--- hw/audio/sb16.c | 8 ++++---- hw/audio/via-ac97.c | 2 +- hw/audio/virtio-snd.c | 2 +- hw/audio/wm8750.c | 4 ++-- hw/display/xlnx_dp.c | 2 +- hw/usb/dev-audio.c | 2 +- tests/audio/test-audio.c | 2 +- ui/vnc.c | 2 +- 28 files changed, 90 insertions(+), 103 deletions(-) diff --git a/audio/dsound_template.h b/audio/dsound_template.h index af4019bcb34..f9761120875 100644 --- a/audio/dsound_template.h +++ b/audio/dsound_template.h @@ -244,7 +244,7 @@ static int dsound_init_out(HWVoiceOut *hw, struct audse= ttings *as) } =20 ds->first_time =3D true; - obt_as.endianness =3D 0; + obt_as.big_endian =3D false; audio_pcm_init_info (&hw->info, &obt_as); =20 if (bc.dwBufferBytes % hw->info.bytes_per_frame) { diff --git a/include/qemu/audio.h b/include/qemu/audio.h index a2fbc286eb1..94d81a2a2ec 100644 --- a/include/qemu/audio.h +++ b/include/qemu/audio.h @@ -38,7 +38,7 @@ typedef struct audsettings { int freq; int nchannels; AudioFormat fmt; - int endianness; + bool big_endian; } audsettings; =20 typedef struct SWVoiceOut SWVoiceOut; diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 3058af58e0b..a606ce0d4cd 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -666,7 +666,7 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsett= ings *as) struct audsettings obt_as; Audiodev *dev =3D hw->s->dev; =20 - req.fmt =3D aud_to_alsafmt (as->fmt, as->endianness); + req.fmt =3D aud_to_alsafmt (as->fmt, as->big_endian); req.freq =3D as->freq; req.nchannels =3D as->nchannels; =20 @@ -677,7 +677,7 @@ static int alsa_init_out(HWVoiceOut *hw, struct audsett= ings *as) obt_as.freq =3D obt.freq; obt_as.nchannels =3D obt.nchannels; obt_as.fmt =3D obt.fmt; - obt_as.endianness =3D obt.endianness; + obt_as.big_endian =3D obt.endianness; =20 audio_pcm_init_info (&hw->info, &obt_as); hw->samples =3D obt.samples; @@ -752,7 +752,7 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettin= gs *as) struct audsettings obt_as; Audiodev *dev =3D hw->s->dev; =20 - req.fmt =3D aud_to_alsafmt (as->fmt, as->endianness); + req.fmt =3D aud_to_alsafmt (as->fmt, as->big_endian); req.freq =3D as->freq; req.nchannels =3D as->nchannels; =20 @@ -763,7 +763,7 @@ static int alsa_init_in(HWVoiceIn *hw, struct audsettin= gs *as) obt_as.freq =3D obt.freq; obt_as.nchannels =3D obt.nchannels; obt_as.fmt =3D obt.fmt; - obt_as.endianness =3D obt.endianness; + obt_as.big_endian =3D obt.endianness; =20 audio_pcm_init_info (&hw->info, &obt_as); hw->samples =3D obt.samples; diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index 146026d0b39..e11c586c827 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -135,19 +135,7 @@ static void audio_print_settings (const struct audsett= ings *as) break; } =20 - AUD_log (NULL, " endianness=3D"); - switch (as->endianness) { - case 0: - AUD_log (NULL, "little"); - break; - case 1: - AUD_log (NULL, "big"); - break; - default: - AUD_log (NULL, "invalid"); - break; - } - AUD_log (NULL, "\n"); + AUD_log (NULL, " endianness=3D%s\n", as->big_endian ? "big" : "little"= ); } =20 static int audio_validate_settings (const struct audsettings *as) @@ -155,7 +143,6 @@ static int audio_validate_settings (const struct audset= tings *as) int invalid; =20 invalid =3D as->nchannels < 1; - invalid |=3D as->endianness !=3D 0 && as->endianness !=3D 1; =20 switch (as->fmt) { case AUDIO_FORMAT_S8: @@ -180,7 +167,7 @@ static int audio_pcm_info_eq (struct audio_pcm_info *in= fo, const struct audsetti return info->af =3D=3D as->fmt && info->freq =3D=3D as->freq && info->nchannels =3D=3D as->nchannels - && info->swap_endianness =3D=3D (as->endianness !=3D HOST_BIG_ENDI= AN); + && info->swap_endianness =3D=3D (as->big_endian !=3D HOST_BIG_ENDI= AN); } =20 void audio_pcm_init_info (struct audio_pcm_info *info, const struct audset= tings *as) @@ -190,7 +177,7 @@ void audio_pcm_init_info (struct audio_pcm_info *info, = const struct audsettings info->nchannels =3D as->nchannels; info->bytes_per_frame =3D as->nchannels * audio_format_bits(as->fmt) /= 8; info->bytes_per_second =3D info->freq * info->bytes_per_frame; - info->swap_endianness =3D (as->endianness !=3D HOST_BIG_ENDIAN); + info->swap_endianness =3D (as->big_endian !=3D HOST_BIG_ENDIAN); } =20 void audio_pcm_info_clear_buf(struct audio_pcm_info *info, void *buf, int = len) @@ -1797,7 +1784,7 @@ audsettings audiodev_to_audsettings(AudiodevPerDirect= ionOptions *pdo) .freq =3D pdo->frequency, .nchannels =3D pdo->channels, .fmt =3D pdo->format, - .endianness =3D HOST_BIG_ENDIAN, + .big_endian =3D HOST_BIG_ENDIAN, }; } =20 diff --git a/audio/jackaudio.c b/audio/jackaudio.c index 547672f6d36..58b9d2f04e2 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -531,7 +531,7 @@ static int qjack_init_out(HWVoiceOut *hw, struct audset= tings *as) .freq =3D jo->c.freq, .nchannels =3D jo->c.nchannels, .fmt =3D AUDIO_FORMAT_F32, - .endianness =3D 0 + .big_endian =3D false }; audio_pcm_init_info(&hw->info, &os); =20 @@ -566,7 +566,7 @@ static int qjack_init_in(HWVoiceIn *hw, struct audsetti= ngs *as) .freq =3D ji->c.freq, .nchannels =3D ji->c.nchannels, .fmt =3D AUDIO_FORMAT_F32, - .endianness =3D 0 + .big_endian =3D false }; audio_pcm_init_info(&hw->info, &is); =20 diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 8388f81343b..0f1c097a666 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -160,36 +160,36 @@ static int aud_to_ossfmt(AudioFormat fmt, bool big_en= dian) } } =20 -static int oss_to_audfmt (int ossfmt, AudioFormat *fmt, int *endianness) +static int oss_to_audfmt (int ossfmt, AudioFormat *fmt, bool *big_endian) { switch (ossfmt) { case AFMT_S8: - *endianness =3D 0; + *big_endian =3D false; *fmt =3D AUDIO_FORMAT_S8; break; =20 case AFMT_U8: - *endianness =3D 0; + *big_endian =3D false; *fmt =3D AUDIO_FORMAT_U8; break; =20 case AFMT_S16_LE: - *endianness =3D 0; + *big_endian =3D false; *fmt =3D AUDIO_FORMAT_S16; break; =20 case AFMT_U16_LE: - *endianness =3D 0; + *big_endian =3D false; *fmt =3D AUDIO_FORMAT_U16; break; =20 case AFMT_S16_BE: - *endianness =3D 1; + *big_endian =3D true; *fmt =3D AUDIO_FORMAT_S16; break; =20 case AFMT_U16_BE: - *endianness =3D 1; + *big_endian =3D true; *fmt =3D AUDIO_FORMAT_U16; break; =20 @@ -475,7 +475,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsetti= ngs *as) =20 oss->fd =3D -1; =20 - req.fmt =3D aud_to_ossfmt (as->fmt, as->endianness); + req.fmt =3D aud_to_ossfmt (as->fmt, as->big_endian); req.freq =3D as->freq; req.nchannels =3D as->nchannels; =20 @@ -483,7 +483,7 @@ static int oss_init_out(HWVoiceOut *hw, struct audsetti= ngs *as) return -1; } =20 - err =3D oss_to_audfmt(obt.fmt, &obt_as.fmt, &obt_as.endianness); + err =3D oss_to_audfmt(obt.fmt, &obt_as.fmt, &obt_as.big_endian); if (err) { oss_anal_close (&fd); return -1; @@ -601,14 +601,14 @@ static int oss_init_in(HWVoiceIn *hw, struct audsetti= ngs *as) =20 oss->fd =3D -1; =20 - req.fmt =3D aud_to_ossfmt (as->fmt, as->endianness); + req.fmt =3D aud_to_ossfmt (as->fmt, as->big_endian); req.freq =3D as->freq; req.nchannels =3D as->nchannels; if (oss_open(1, &req, as, &obt, &fd, dev)) { return -1; } =20 - err =3D oss_to_audfmt(obt.fmt, &obt_as.fmt, &obt_as.endianness); + err =3D oss_to_audfmt(obt.fmt, &obt_as.fmt, &obt_as.big_endian); if (err) { oss_anal_close (&fd); return -1; diff --git a/audio/paaudio.c b/audio/paaudio.c index bc6a8fa67b3..2a745ae38f9 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -352,28 +352,28 @@ static pa_sample_format_t audfmt_to_pa(AudioFormat af= mt, bool big_endian) return format; } =20 -static AudioFormat pa_to_audfmt (pa_sample_format_t fmt, int *endianness) +static AudioFormat pa_to_audfmt (pa_sample_format_t fmt, bool *big_endian) { switch (fmt) { case PA_SAMPLE_U8: return AUDIO_FORMAT_U8; case PA_SAMPLE_S16BE: - *endianness =3D 1; + *big_endian =3D true; return AUDIO_FORMAT_S16; case PA_SAMPLE_S16LE: - *endianness =3D 0; + *big_endian =3D false; return AUDIO_FORMAT_S16; case PA_SAMPLE_S32BE: - *endianness =3D 1; + *big_endian =3D true; return AUDIO_FORMAT_S32; case PA_SAMPLE_S32LE: - *endianness =3D 0; + *big_endian =3D false; return AUDIO_FORMAT_S32; case PA_SAMPLE_FLOAT32BE: - *endianness =3D 1; + *big_endian =3D true; return AUDIO_FORMAT_F32; case PA_SAMPLE_FLOAT32LE: - *endianness =3D 0; + *big_endian =3D false; return AUDIO_FORMAT_F32; default: error_report("pulseaudio: Internal logic error: Bad pa_sample_form= at %d", fmt); @@ -531,7 +531,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as) PAConnection *c =3D apa->conn; =20 pa->g =3D apa; - ss.format =3D audfmt_to_pa (as->fmt, as->endianness); + ss.format =3D audfmt_to_pa (as->fmt, as->big_endian); ss.channels =3D as->nchannels; ss.rate =3D as->freq; =20 @@ -541,7 +541,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as) ba.maxlength =3D -1; ba.prebuf =3D -1; =20 - obt_as.fmt =3D pa_to_audfmt (ss.format, &obt_as.endianness); + obt_as.fmt =3D pa_to_audfmt (ss.format, &obt_as.big_endian); =20 pa->stream =3D qpa_simple_new ( c, @@ -582,7 +582,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as) PAConnection *c =3D apa->conn; =20 pa->g =3D apa; - ss.format =3D audfmt_to_pa (as->fmt, as->endianness); + ss.format =3D audfmt_to_pa (as->fmt, as->big_endian); ss.channels =3D as->nchannels; ss.rate =3D as->freq; =20 @@ -592,7 +592,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as) ba.minreq =3D -1; ba.prebuf =3D -1; =20 - obt_as.fmt =3D pa_to_audfmt (ss.format, &obt_as.endianness); + obt_as.fmt =3D pa_to_audfmt (ss.format, &obt_as.big_endian); =20 pa->stream =3D qpa_simple_new ( c, diff --git a/audio/pwaudio.c b/audio/pwaudio.c index c30738c16ef..66ca1231541 100644 --- a/audio/pwaudio.c +++ b/audio/pwaudio.c @@ -365,7 +365,7 @@ audfmt_to_pw(AudioFormat fmt, bool big_endian) } =20 static AudioFormat -pw_to_audfmt(enum spa_audio_format fmt, int *endianness, +pw_to_audfmt(enum spa_audio_format fmt, bool *big_endian, uint32_t *sample_size) { switch (fmt) { @@ -377,43 +377,43 @@ pw_to_audfmt(enum spa_audio_format fmt, int *endianne= ss, return AUDIO_FORMAT_U8; case SPA_AUDIO_FORMAT_S16_BE: *sample_size =3D 2; - *endianness =3D 1; + *big_endian =3D true; return AUDIO_FORMAT_S16; case SPA_AUDIO_FORMAT_S16_LE: *sample_size =3D 2; - *endianness =3D 0; + *big_endian =3D false; return AUDIO_FORMAT_S16; case SPA_AUDIO_FORMAT_U16_BE: *sample_size =3D 2; - *endianness =3D 1; + *big_endian =3D true; return AUDIO_FORMAT_U16; case SPA_AUDIO_FORMAT_U16_LE: *sample_size =3D 2; - *endianness =3D 0; + *big_endian =3D false; return AUDIO_FORMAT_U16; case SPA_AUDIO_FORMAT_S32_BE: *sample_size =3D 4; - *endianness =3D 1; + *big_endian =3D true; return AUDIO_FORMAT_S32; case SPA_AUDIO_FORMAT_S32_LE: *sample_size =3D 4; - *endianness =3D 0; + *big_endian =3D false; return AUDIO_FORMAT_S32; case SPA_AUDIO_FORMAT_U32_BE: *sample_size =3D 4; - *endianness =3D 1; + *big_endian =3D true; return AUDIO_FORMAT_U32; case SPA_AUDIO_FORMAT_U32_LE: *sample_size =3D 4; - *endianness =3D 0; + *big_endian =3D false; return AUDIO_FORMAT_U32; case SPA_AUDIO_FORMAT_F32_BE: *sample_size =3D 4; - *endianness =3D 1; + *big_endian =3D true; return AUDIO_FORMAT_F32; case SPA_AUDIO_FORMAT_F32_LE: *sample_size =3D 4; - *endianness =3D 0; + *big_endian =3D false; return AUDIO_FORMAT_F32; default: *sample_size =3D 1; @@ -534,13 +534,13 @@ qpw_init_out(HWVoiceOut *hw, struct audsettings *as) =20 pw_thread_loop_lock(c->thread_loop); =20 - v->info.format =3D audfmt_to_pw(as->fmt, as->endianness); + v->info.format =3D audfmt_to_pw(as->fmt, as->big_endian); v->info.channels =3D as->nchannels; qpw_set_position(as->nchannels, v->info.position); v->info.rate =3D as->freq; =20 obt_as.fmt =3D - pw_to_audfmt(v->info.format, &obt_as.endianness, &v->frame_size); + pw_to_audfmt(v->info.format, &obt_as.big_endian, &v->frame_size); v->frame_size *=3D as->nchannels; =20 v->req =3D (uint64_t)AUDIO_MIXENG_BACKEND(c)->dev->timer_period * v->i= nfo.rate @@ -581,13 +581,13 @@ qpw_init_in(HWVoiceIn *hw, struct audsettings *as) =20 pw_thread_loop_lock(c->thread_loop); =20 - v->info.format =3D audfmt_to_pw(as->fmt, as->endianness); + v->info.format =3D audfmt_to_pw(as->fmt, as->big_endian); v->info.channels =3D as->nchannels; qpw_set_position(as->nchannels, v->info.position); v->info.rate =3D as->freq; =20 obt_as.fmt =3D - pw_to_audfmt(v->info.format, &obt_as.endianness, &v->frame_size); + pw_to_audfmt(v->info.format, &obt_as.big_endian, &v->frame_size); v->frame_size *=3D as->nchannels; =20 /* call the function that creates a new stream for recording */ diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index bb667ef9525..b404adbc1e9 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -107,56 +107,56 @@ static int aud_to_sdlfmt (AudioFormat fmt) } } =20 -static int sdl_to_audfmt(int sdlfmt, AudioFormat *fmt, int *endianness) +static int sdl_to_audfmt(int sdlfmt, AudioFormat *fmt, bool *big_endian) { switch (sdlfmt) { case AUDIO_S8: - *endianness =3D 0; + *big_endian =3D false; *fmt =3D AUDIO_FORMAT_S8; break; =20 case AUDIO_U8: - *endianness =3D 0; + *big_endian =3D false; *fmt =3D AUDIO_FORMAT_U8; break; =20 case AUDIO_S16LSB: - *endianness =3D 0; + *big_endian =3D false; *fmt =3D AUDIO_FORMAT_S16; break; =20 case AUDIO_U16LSB: - *endianness =3D 0; + *big_endian =3D false; *fmt =3D AUDIO_FORMAT_U16; break; =20 case AUDIO_S16MSB: - *endianness =3D 1; + *big_endian =3D true; *fmt =3D AUDIO_FORMAT_S16; break; =20 case AUDIO_U16MSB: - *endianness =3D 1; + *big_endian =3D true; *fmt =3D AUDIO_FORMAT_U16; break; =20 case AUDIO_S32LSB: - *endianness =3D 0; + *big_endian =3D false; *fmt =3D AUDIO_FORMAT_S32; break; =20 case AUDIO_S32MSB: - *endianness =3D 1; + *big_endian =3D true; *fmt =3D AUDIO_FORMAT_S32; break; =20 case AUDIO_F32LSB: - *endianness =3D 0; + *big_endian =3D false; *fmt =3D AUDIO_FORMAT_F32; break; =20 case AUDIO_F32MSB: - *endianness =3D 1; + *big_endian =3D true; *fmt =3D AUDIO_FORMAT_F32; break; =20 @@ -361,7 +361,7 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsetti= ngs *as) return -1; } =20 - err =3D sdl_to_audfmt(obt.format, &obt_as.fmt, &obt_as.endianness); + err =3D sdl_to_audfmt(obt.format, &obt_as.fmt, &obt_as.big_endian); if (err) { sdl_close_out(sdl); return -1; @@ -417,7 +417,7 @@ static int sdl_init_in(HWVoiceIn *hw, audsettings *as) return -1; } =20 - err =3D sdl_to_audfmt(obt.format, &obt_as.fmt, &obt_as.endianness); + err =3D sdl_to_audfmt(obt.format, &obt_as.fmt, &obt_as.big_endian); if (err) { sdl_close_in(sdl); return -1; diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c index be491895532..69fa9d8ba54 100644 --- a/audio/sndioaudio.c +++ b/audio/sndioaudio.c @@ -387,7 +387,7 @@ static int sndio_init(SndioVoice *self, } =20 if (req.bits > 8) { - req.le =3D as->endianness ? 0 : 1; + req.le =3D as->big_endian ? 0 : 1; } =20 req.rate =3D as->freq; diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 2547126994d..1b67fe2a540 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -106,7 +106,7 @@ static int line_out_init(HWVoiceOut *hw, struct audsett= ings *as) #endif settings.nchannels =3D SPICE_INTERFACE_PLAYBACK_CHAN; settings.fmt =3D AUDIO_FORMAT_S16; - settings.endianness =3D HOST_BIG_ENDIAN; + settings.big_endian =3D HOST_BIG_ENDIAN; =20 audio_pcm_init_info (&hw->info, &settings); hw->samples =3D LINE_OUT_SAMPLES; @@ -222,7 +222,7 @@ static int line_in_init(HWVoiceIn *hw, struct audsettin= gs *as) #endif settings.nchannels =3D SPICE_INTERFACE_RECORD_CHAN; settings.fmt =3D AUDIO_FORMAT_S16; - settings.endianness =3D HOST_BIG_ENDIAN; + settings.big_endian =3D HOST_BIG_ENDIAN; =20 audio_pcm_init_info (&hw->info, &settings); hw->samples =3D LINE_IN_SAMPLES; diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 5c614ed3b51..217fb9937f8 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -111,7 +111,7 @@ static int wav_init_out(HWVoiceOut *hw, struct audsetti= ngs *as) =20 hdr[34] =3D bits16 ? 0x10 : 0x08; =20 - wav_as.endianness =3D 0; + wav_as.big_endian =3D false; audio_pcm_init_info (&hw->info, &wav_as); =20 hw->samples =3D 1024; diff --git a/audio/wavcapture.c b/audio/wavcapture.c index 69aa91e35f6..2dac9461710 100644 --- a/audio/wavcapture.c +++ b/audio/wavcapture.c @@ -137,7 +137,7 @@ int wav_start_capture(AudioBackend *state, CaptureState= *s, const char *path, as.freq =3D freq; as.nchannels =3D 1 << stereo; as.fmt =3D bits16 ? AUDIO_FORMAT_S16 : AUDIO_FORMAT_U8; - as.endianness =3D 0; + as.big_endian =3D false; =20 ops.notify =3D wav_notify; ops.capture =3D wav_capture; diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index 5d442b7e067..fd74c249949 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -313,7 +313,7 @@ static void open_voice(AC97LinkState *s, int index, int= freq) as.freq =3D freq; as.nchannels =3D 2; as.fmt =3D AUDIO_FORMAT_S16; - as.endianness =3D 0; + as.big_endian =3D false; =20 if (freq > 0) { s->invalid_freq[index] =3D 0; diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index ce17e21d5fd..52ee5cb6256 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -254,7 +254,7 @@ static void adlib_realizefn (DeviceState *dev, Error **= errp) as.freq =3D s->freq; as.nchannels =3D SHIFT; as.fmt =3D AUDIO_FORMAT_S16; - as.endianness =3D HOST_BIG_ENDIAN; + as.big_endian =3D HOST_BIG_ENDIAN; =20 s->voice =3D audio_be_open_out( s->audio_be, diff --git a/hw/audio/asc.c b/hw/audio/asc.c index 35c7b5750d6..ea59bdde7b8 100644 --- a/hw/audio/asc.c +++ b/hw/audio/asc.c @@ -648,7 +648,7 @@ static void asc_realize(DeviceState *dev, Error **errp) as.freq =3D ASC_FREQ; as.nchannels =3D 2; as.fmt =3D AUDIO_FORMAT_U8; - as.endianness =3D HOST_BIG_ENDIAN; + as.big_endian =3D HOST_BIG_ENDIAN; =20 s->voice =3D audio_be_open_out(s->audio_be, s->voice, "asc.out", s, as= c_out_cb, &as); diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c index e6cae9c988e..c589670e855 100644 --- a/hw/audio/cs4231a.c +++ b/hw/audio/cs4231a.c @@ -289,7 +289,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) } =20 as.nchannels =3D (val & (1 << 4)) ? 2 : 1; - as.endianness =3D 0; + as.big_endian =3D false; s->tab =3D NULL; =20 switch ((val >> 5) & ((s->dregs[MODE_And_ID] & MODE2) ? 7 : 3)) { @@ -305,12 +305,12 @@ static void cs_reset_voices (CSState *s, uint32_t val) s->tab =3D ALawDecompressTable; x_law: as.fmt =3D AUDIO_FORMAT_S16; - as.endianness =3D HOST_BIG_ENDIAN; + as.big_endian =3D HOST_BIG_ENDIAN; s->shift =3D as.nchannels =3D=3D 2; break; =20 case 6: - as.endianness =3D 1; + as.big_endian =3D true; /* fall through */ case 2: as.fmt =3D AUDIO_FORMAT_S16; diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index e1658393c6a..ca7ad16df49 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -407,7 +407,7 @@ static void es1370_update_voices (ES1370State *s, uint3= 2_t ctl, uint32_t sctl) as.freq =3D new_freq; as.nchannels =3D 1 << (new_fmt & 1); as.fmt =3D (new_fmt & 2) ? AUDIO_FORMAT_S16 : AUDIO_FORMAT= _U8; - as.endianness =3D 0; + as.big_endian =3D false; =20 if (i =3D=3D ADC_CHANNEL) { s->adc_voice =3D diff --git a/hw/audio/gus.c b/hw/audio/gus.c index 5c2a34c09d2..196c4f72205 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -256,7 +256,7 @@ static void gus_realizefn (DeviceState *dev, Error **er= rp) as.freq =3D s->freq; as.nchannels =3D 2; as.fmt =3D AUDIO_FORMAT_S16; - as.endianness =3D HOST_BIG_ENDIAN; + as.big_endian =3D HOST_BIG_ENDIAN; =20 s->voice =3D audio_be_open_out( s->audio_be, diff --git a/hw/audio/lm4549.c b/hw/audio/lm4549.c index 14e15a844ba..a891e975106 100644 --- a/hw/audio/lm4549.c +++ b/hw/audio/lm4549.c @@ -202,7 +202,7 @@ void lm4549_write(lm4549_state *s, as.freq =3D value; as.nchannels =3D 2; as.fmt =3D AUDIO_FORMAT_S16; - as.endianness =3D 0; + as.big_endian =3D false; =20 s->voice =3D audio_be_open_out( s->audio_be, @@ -272,7 +272,7 @@ static int lm4549_post_load(void *opaque, int version_i= d) as.freq =3D freq; as.nchannels =3D 2; as.fmt =3D AUDIO_FORMAT_S16; - as.endianness =3D 0; + as.big_endian =3D false; =20 s->voice =3D audio_be_open_out( s->audio_be, @@ -312,7 +312,7 @@ void lm4549_init(lm4549_state *s, lm4549_callback data_= req_cb, void* opaque, as.freq =3D 48000; as.nchannels =3D 2; as.fmt =3D AUDIO_FORMAT_S16; - as.endianness =3D 0; + as.big_endian =3D false; =20 s->voice =3D audio_be_open_out( s->audio_be, diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index c8fc7df8b44..1b5e452a29b 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -213,7 +213,7 @@ static void continue_dma8 (SB16State *s) as.freq =3D s->freq; as.nchannels =3D 1 << s->fmt_stereo; as.fmt =3D s->fmt; - as.endianness =3D 0; + as.big_endian =3D false; =20 s->voice =3D audio_be_open_out( s->audio_be, @@ -376,7 +376,7 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8_t= d0, int dma_len) as.freq =3D s->freq; as.nchannels =3D 1 << s->fmt_stereo; as.fmt =3D s->fmt; - as.endianness =3D 0; + as.big_endian =3D false; =20 s->voice =3D audio_be_open_out( s->audio_be, @@ -877,7 +877,7 @@ static void legacy_reset (SB16State *s) as.freq =3D s->freq; as.nchannels =3D 1; as.fmt =3D AUDIO_FORMAT_U8; - as.endianness =3D 0; + as.big_endian =3D false; =20 s->voice =3D audio_be_open_out( s->audio_be, @@ -1300,7 +1300,7 @@ static int sb16_post_load (void *opaque, int version_= id) as.freq =3D s->freq; as.nchannels =3D 1 << s->fmt_stereo; as.fmt =3D s->fmt; - as.endianness =3D 0; + as.big_endian =3D false; =20 s->voice =3D audio_be_open_out( s->audio_be, diff --git a/hw/audio/via-ac97.c b/hw/audio/via-ac97.c index 84d137b41a3..9d61283542a 100644 --- a/hw/audio/via-ac97.c +++ b/hw/audio/via-ac97.c @@ -237,7 +237,7 @@ static void open_voice_out(ViaAC97State *s) .freq =3D CODEC_REG(s, AC97_PCM_Front_DAC_Rate), .nchannels =3D s->aur.type & BIT(4) ? 2 : 1, .fmt =3D s->aur.type & BIT(5) ? AUDIO_FORMAT_S16 : AUDIO_FORMAT_S8, - .endianness =3D 0, + .big_endian =3D false, }; s->vo =3D audio_be_open_out(s->audio_be, s->vo, "via-ac97.out", s, out= _cb, &as); } diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index 89e24c0a8e0..8b949146468 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -378,7 +378,7 @@ static void virtio_snd_get_qemu_audsettings(audsettings= *as, as->nchannels =3D MIN(AUDIO_MAX_CHANNELS, params->channels); as->fmt =3D virtio_snd_get_qemu_format(params->format); as->freq =3D virtio_snd_get_qemu_freq(params->rate); - as->endianness =3D 0; /* Conforming to VIRTIO 1.0: always little endia= n. */ + as->big_endian =3D false; /* Conforming to VIRTIO 1.0: always little e= ndian. */ } =20 /* diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c index 2a286515b14..e2507b0269a 100644 --- a/hw/audio/wm8750.c +++ b/hw/audio/wm8750.c @@ -202,7 +202,7 @@ static void wm8750_set_format(WM8750State *s) return; =20 /* Setup input */ - in_fmt.endianness =3D 0; + in_fmt.big_endian =3D false; in_fmt.nchannels =3D 2; in_fmt.freq =3D s->adc_hz; in_fmt.fmt =3D AUDIO_FORMAT_S16; @@ -215,7 +215,7 @@ static void wm8750_set_format(WM8750State *s) CODEC ".input3", s, wm8750_audio_in_cb, &in_fmt); =20 /* Setup output */ - out_fmt.endianness =3D 0; + out_fmt.big_endian =3D false; out_fmt.nchannels =3D 2; out_fmt.freq =3D s->dac_hz; out_fmt.fmt =3D AUDIO_FORMAT_S16; diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c index 9aa4709b411..7d037b46a35 100644 --- a/hw/display/xlnx_dp.c +++ b/hw/display/xlnx_dp.c @@ -1393,7 +1393,7 @@ static void xlnx_dp_realize(DeviceState *dev, Error *= *errp) as.freq =3D 44100; as.nchannels =3D 2; as.fmt =3D AUDIO_FORMAT_S16; - as.endianness =3D 0; + as.big_endian =3D false; =20 s->amixer_output_stream =3D audio_be_open_out(s->audio_be, s->amixer_output_stream, diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c index 7b758718c12..e18e0a1dfd6 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -975,7 +975,7 @@ static void usb_audio_reinit(USBDevice *dev, unsigned c= hannels) s->out.as.freq =3D USBAUDIO_SAMPLE_RATE; s->out.as.nchannels =3D s->out.channels; s->out.as.fmt =3D AUDIO_FORMAT_S16; - s->out.as.endianness =3D 0; + s->out.as.big_endian =3D false; streambuf_init(&s->out.buf, s->buffer, s->out.channels); =20 s->out.voice =3D audio_be_open_out(s->audio_be, s->out.voice, TYPE_USB= _AUDIO, diff --git a/tests/audio/test-audio.c b/tests/audio/test-audio.c index e403f11f093..98e77cf542b 100644 --- a/tests/audio/test-audio.c +++ b/tests/audio/test-audio.c @@ -49,7 +49,7 @@ static const struct audsettings default_test_settings =3D= { .freq =3D SAMPLE_RATE, .nchannels =3D CHANNELS, .fmt =3D AUDIO_FORMAT_S16, - .endianness =3D 0, + .big_endian =3D false, }; =20 static void dummy_audio_callback(void *opaque, int avail) diff --git a/ui/vnc.c b/ui/vnc.c index d56fe2c180e..daf5b01d342 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3372,7 +3372,7 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSoc= ket *sioc, vs->as.freq =3D 44100; vs->as.nchannels =3D 2; vs->as.fmt =3D AUDIO_FORMAT_S16; - vs->as.endianness =3D 0; + vs->as.big_endian =3D false; =20 qemu_mutex_init(&vs->output_mutex); vs->bh =3D qemu_bh_new(vnc_jobs_bh, vs); --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538813; cv=none; d=zohomail.com; s=zohoarc; b=fOeDUvuc7/z318NYGCw7x3AnuvRsFT3fps/6zg/2eb5J2HDwv7ZUmuH4XOHojcntOUZzJ7i5IO1YPdDNq4u0JWoECWQy1JYf90rYN2L5SJmwGaCzbXPykIMO6RVJHMh3NmUD0PpVlWLU61XSC0tWTtCVScJ6j2H4AEtzcdSKyzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538813; 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=LrE+hvQ4e8eJIfVrnDHPHxQPv04Waou3LZweDimE0qg=; b=K9Dhf7EvzMXYFLAlRDGKZB3qr+IVgkIfJ5nvQEoTiZQhe3ahEdlxp7yoS5Pa+X6033HexprCr/7yOpe/lgV437VdV6G62KQ2NuMSJCugDOxYb8I5FtzE3UfHpJwtRMWISE11xFmqEVgDnhUBle15sqmLr23L2BfUyXTvb+Q2oAY= 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 176953881344528.595260336903493; Tue, 27 Jan 2026 10:33:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknpG-0005GV-Gj; Tue, 27 Jan 2026 13:30:06 -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 1vkno2-0001rH-2o for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:58 -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 1vknny-0003Tu-EZ for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:49 -0500 Received: from mx-prod-mc-05.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-149-beFMKLKTPPCCKdOzkbfhUQ-1; Tue, 27 Jan 2026 13:28:41 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4641019775F8; Tue, 27 Jan 2026 18:28:40 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CDEE61956095; Tue, 27 Jan 2026 18:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538524; 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=LrE+hvQ4e8eJIfVrnDHPHxQPv04Waou3LZweDimE0qg=; b=OXtMvCAUMSAoTX1Abrfs7Il8kGOTl1D5tCS/I/BW9z5bF+XGTYuiB+NKQxgi9Rp0q4iK7F hYbZ8YQMmUmZzAQ1r8Za5dIcw+VUW3j9Wtxv0pvpJ7a0FpKqXunOksKZwD0abOLEISlPqW 1pXbNXsg5OlozhEeif7e5pet+dkEbUY= X-MC-Unique: beFMKLKTPPCCKdOzkbfhUQ-1 X-Mimecast-MFC-AGG-ID: beFMKLKTPPCCKdOzkbfhUQ_1769538520 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 33/43] audio: replace ldebug with trace events Date: Tue, 27 Jan 2026 22:25:00 +0400 Message-ID: <20260127182516.289834-34-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.17 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538815861154100 From: Marc-Andr=C3=A9 Lureau Replace the ldebug macro calls with proper trace events: - audio_get_avail: traces available samples in capture stream - audio_open_out/audio_open_in: traces stream open parameters This provides structured tracing that can be enabled at runtime without requiring debug builds. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_template.h | 7 +++++-- audio/audio-mixeng-be.c | 6 +----- audio/trace-events | 7 +++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index 3da91a4782c..c47a2f202f0 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -507,8 +507,11 @@ static SW *glue(audio_mixeng_backend_open_, TYPE) ( k =3D AUDIO_MIXENG_BACKEND_GET_CLASS(s); pdo =3D glue(audio_get_pdo_, TYPE)(s->dev); =20 - ldebug ("open %s, freq %d, nchannels %d, fmt %d\n", - name, as->freq, as->nchannels, as->fmt); +#ifdef DAC + trace_audio_open_out(name, as->freq, as->nchannels, as->fmt); +#else + trace_audio_open_in(name, as->freq, as->nchannels, as->fmt); +#endif =20 if (audio_bug(__func__, audio_validate_settings(as))) { audio_print_settings (as); diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index e11c586c827..343f6ec181e 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -881,11 +881,7 @@ static size_t audio_get_avail(SWVoiceIn *sw) return 0; } =20 - ldebug ( - "%s: get_avail live %zu frontend frames %u\n", - SW_NAME (sw), - live, st_rate_frames_out(sw->rate, live) - ); + trace_audio_get_avail(SW_NAME(sw), live, st_rate_frames_out(sw->rate, = live)); =20 return live; } diff --git a/audio/trace-events b/audio/trace-events index f33be2dd8e3..4749c54fc04 100644 --- a/audio/trace-events +++ b/audio/trace-events @@ -58,3 +58,10 @@ audio_be_set_active_out(void *sw, bool on) "sw=3D%p, on= =3D%d" audio_timer_start(int interval) "interval %d ms" audio_timer_stop(void) "" audio_timer_delayed(int interval) "interval %d ms" + +# audio-mixeng-be.c +audio_get_avail(const char *name, size_t live, uint32_t frontend_frames) "= %s: get_avail live %zu frontend frames %u" + +# audio_template.h +audio_open_out(const char *name, int freq, int nchannels, int fmt) "open %= s, freq %d, nchannels %d, fmt %d" +audio_open_in(const char *name, int freq, int nchannels, int fmt) "open %s= , freq %d, nchannels %d, fmt %d" --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538988; cv=none; d=zohomail.com; s=zohoarc; b=k7vTeG3hCp4yWv/iZ6q3rxD6P9i0VlbWPTGytUqrsh8EbSHRSYOc43Pmy6d7z63t9tKqS2q0AfMo2cU9ROvuBeMT2ZAWhDVQ6wpClvtv2McfDTlOBD1aQyJoU6DKMQR8dKDIeusu6o/hj12lO6KxsxaMy1hflUDy9t5GTh2tACo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538988; 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=V6cPOosgUiYuD3qWVnoiVKnPVAJlhUfzQHjo0xv9bGo=; b=IoS1nX7xEnJtfW+botS/ZZMiX5K3r1qHqB72951JG4N15bLiC+tgU1s+NWjGd0RsUvjzLV/4ICv7ZvkX6qhSV4qicTb35PP6gt+eN+3C87qowSx4ePkk7LM4mjtkKEx67BW4VWWjKlaQ9vsNpyFPIspoDS4HXBijkHEaZWU/x4Y= 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 1769538988743170.83935172973077; Tue, 27 Jan 2026 10:36:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknp5-0003aX-8H; Tue, 27 Jan 2026 13:29:55 -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 1vkno6-0001sr-Dv for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:58 -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 1vkno4-0003VV-Hn for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:28:54 -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-135-0xSAO_wLMCuBoo6kzsLjuQ-1; Tue, 27 Jan 2026 13:28:46 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 D38941944E45; Tue, 27 Jan 2026 18:28:45 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BF6D81956095; Tue, 27 Jan 2026 18:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538531; 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=V6cPOosgUiYuD3qWVnoiVKnPVAJlhUfzQHjo0xv9bGo=; b=V9k5i5jT+yBCTovxyr23feW0lepVf94ldJNpP5WrvTCBi0jjMqY+J9Ky9SJvx+3T1Y9Zxe WOeyIK1WVqGeETVVIPgc2p1mqbrqMPBT9Efh8C/TMkOyR2+0FUmqlbGX2zzlP3DOlNw/HF A18i5AyCEnKAaPcibTiEJloI6AoP9c8= X-MC-Unique: 0xSAO_wLMCuBoo6kzsLjuQ-1 X-Mimecast-MFC-AGG-ID: 0xSAO_wLMCuBoo6kzsLjuQ_1769538525 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 34/43] audio: rework DEBUG_POLL Date: Tue, 27 Jan 2026 22:25:01 +0400 Message-ID: <20260127182516.289834-35-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.17 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538992582154100 From: Marc-Andr=C3=A9 Lureau Use more correct GTimer, specific for each backend, with a trace event. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 1 + audio/audio-mixeng-be.c | 25 +++++++++---------------- audio/trace-events | 1 + 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index dd5f2220d75..e0ed6af67ed 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -224,6 +224,7 @@ struct AudioMixengBackend { Audiodev *dev; =20 QEMUTimer *ts; + GTimer *run_timer; QLIST_HEAD (hw_in_listhead, HWVoiceIn) hw_head_in; QLIST_HEAD (hw_out_listhead, HWVoiceOut) hw_head_out; QLIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head; diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index 343f6ec181e..1b2c1fafa87 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -24,13 +24,13 @@ #include "system/replay.h" #include "system/runstate.h" #include "trace.h" +#include "trace/control.h" =20 #define AUDIO_CAP "audio" #include "audio_int.h" =20 /* #define DEBUG_OUT */ /* #define DEBUG_CAPTURE */ -/* #define DEBUG_POLL */ =20 #define SW_NAME(sw) (sw)->name ? (sw)->name : "unknown" =20 @@ -1269,22 +1269,12 @@ void audio_run(AudioMixengBackend *s, const char *m= sg) audio_run_in(s); audio_run_capture(s); =20 -#ifdef DEBUG_POLL - { - static double prevtime; - double currtime; - struct timeval tv; - - if (gettimeofday (&tv, NULL)) { - perror ("audio_run: gettimeofday"); - return; - } - - currtime =3D tv.tv_sec + tv.tv_usec * 1e-6; - dolog ("Elapsed since last %s: %f\n", msg, currtime - prevtime); - prevtime =3D currtime; + if (trace_event_get_state(TRACE_AUDIO_RUN_POLL)) { + /* Convert seconds to microseconds for trace event */ + int64_t elapsed_us =3D g_timer_elapsed(s->run_timer, NULL) * 10000= 00; + trace_audio_run_poll(msg, elapsed_us); + g_timer_start(s->run_timer); } -#endif } =20 void audio_generic_run_buffer_in(HWVoiceIn *hw) @@ -1545,6 +1535,7 @@ static void audio_mixeng_backend_init(Object *obj) QLIST_INIT(&s->hw_head_in); QLIST_INIT(&s->cap_head); s->ts =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s); + s->run_timer =3D g_timer_new(); =20 s->vmse =3D qemu_add_vm_change_state_handler(audio_vm_change_state_han= dler, s); assert(s->vmse !=3D NULL); @@ -1596,6 +1587,8 @@ static void audio_mixeng_backend_finalize(Object *obj) s->ts =3D NULL; } =20 + g_clear_pointer(&s->run_timer, g_timer_destroy); + if (s->vmse) { qemu_del_vm_change_state_handler(s->vmse); s->vmse =3D NULL; diff --git a/audio/trace-events b/audio/trace-events index 4749c54fc04..d66a712e871 100644 --- a/audio/trace-events +++ b/audio/trace-events @@ -61,6 +61,7 @@ audio_timer_delayed(int interval) "interval %d ms" =20 # audio-mixeng-be.c audio_get_avail(const char *name, size_t live, uint32_t frontend_frames) "= %s: get_avail live %zu frontend frames %u" +audio_run_poll(const char *msg, int64_t elapsed_us) "Elapsed since last %s= : %" PRId64 " us" =20 # audio_template.h audio_open_out(const char *name, int freq, int nchannels, int fmt) "open %= s, freq %d, nchannels %d, fmt %d" --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538905; cv=none; d=zohomail.com; s=zohoarc; b=MqE7khEzf8tTUsTiXHmuYvEzWLJcmmnipaZbN22ShClNVTrCAgU23qiAO4MyNpUcI3d3Z0TCStHPnZu6VOb5SH+XxEPLONtv3wMBavRpXQVOZhfgMDlOXYiQzr0XjLogRyDMOcz6oM1pfWLO0Mnt826/Imuyatnv9rxbO72Fkso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538905; 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=gGJ9wEi0Ea/FwUAjPdk5jFMF6q7wBHiicI9uGTxVy7Y=; b=IWSohemcv849deBNGllK5qT3DqW28yp3ElrL93gICZXmFhzj3qf6ibKuiq3jmF3rHR2FGiL0uE0UT0ZP0QMxtXBR2atq1wMVX2Kras1lo+yVC0cEE+YYap1bUMGW1cfQXjW8i9K8vRHE6Z2ObmKWqsGsrc1KcV7dgmEXqDms4nI= 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 1769538905391117.25978616471662; Tue, 27 Jan 2026 10:35:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknrH-0000Te-GR; Tue, 27 Jan 2026 13:32:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vknoi-00027g-65 for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:29:38 -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 1vknof-0003j5-0U for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:29:31 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-5-q0FUWKwFN_OtesEiO0UMfA-1; Tue, 27 Jan 2026 13:28:51 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 09A1D18005AF; Tue, 27 Jan 2026 18:28:51 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 101931956095; Tue, 27 Jan 2026 18:28:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538565; 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=gGJ9wEi0Ea/FwUAjPdk5jFMF6q7wBHiicI9uGTxVy7Y=; b=I//6X2koqCv4P1FqxzrekvOAjtK8C1WntphB78zq08CGF8EN8hOIp4qH72e5oi6lHRD+pK DykdJ50hbIbiPq4cYbs7h8oHD2nFVEOYJGXHLJ2/6k9FF8IgVP957XaA+7PYDVMzX99NV0 uS0raLoG/Jwu/bYNgJxdsMt7ED853VM= X-MC-Unique: q0FUWKwFN_OtesEiO0UMfA-1 X-Mimecast-MFC-AGG-ID: q0FUWKwFN_OtesEiO0UMfA_1769538531 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 35/43] audio: replace DEBUG_CAPTURE with traces Date: Tue, 27 Jan 2026 22:25:02 +0400 Message-ID: <20260127182516.289834-36-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.17 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538907241154100 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio-mixeng-be.c | 20 +++++++------------- audio/trace-events | 3 +++ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index 1b2c1fafa87..c3234aafb1b 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -30,7 +30,6 @@ #include "audio_int.h" =20 /* #define DEBUG_OUT */ -/* #define DEBUG_CAPTURE */ =20 #define SW_NAME(sw) (sw)->name ? (sw)->name : "unknown" =20 @@ -249,9 +248,8 @@ static void audio_notify_capture (CaptureVoiceOut *cap,= audcnotification_e cmd) { struct capture_callback *cb; =20 -#ifdef DEBUG_CAPTURE - dolog ("notification %d sent\n", cmd); -#endif + trace_audio_notify_capture(cmd); + for (cb =3D cap->cb_head.lh_first; cb; cb =3D cb->entries.le_next) { cb->ops.notify (cb->opaque, cmd); } @@ -333,12 +331,10 @@ static int audio_attach_capture (HWVoiceOut *hw) sw->rate =3D st_rate_start (sw->info.freq, hw_cap->info.freq); QLIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries); QLIST_INSERT_HEAD (&hw->cap_head, sc, entries); -#ifdef DEBUG_CAPTURE - sw->name =3D g_strdup_printf ("for %p %d,%d,%d", - hw, sw->info.freq, sw->info.bits, - sw->info.nchannels); - dolog ("Added %s active =3D %d\n", sw->name, sw->active); -#endif + sw->name =3D g_strdup_printf("for %p %d,%s,%d", + hw, sw->info.freq, AudioFormat_str(sw->= info.af), + sw->info.nchannels); + trace_audio_capture_attach(sw->name, sw->active); if (sw->active) { audio_capture_maybe_changed (cap, 1); } @@ -1707,10 +1703,8 @@ static void audio_mixeng_backend_del_capture( =20 while (sw) { SWVoiceCap *sc =3D (SWVoiceCap *) sw; -#ifdef DEBUG_CAPTURE - dolog ("freeing %s\n", sw->name); -#endif =20 + trace_audio_capture_free_sw(sw->name); sw1 =3D sw->entries.le_next; if (sw->rate) { st_rate_stop (sw->rate); diff --git a/audio/trace-events b/audio/trace-events index d66a712e871..3f8ebf9c6cb 100644 --- a/audio/trace-events +++ b/audio/trace-events @@ -58,10 +58,13 @@ audio_be_set_active_out(void *sw, bool on) "sw=3D%p, on= =3D%d" audio_timer_start(int interval) "interval %d ms" audio_timer_stop(void) "" audio_timer_delayed(int interval) "interval %d ms" +audio_notify_capture(int cmd) "notification %d sent" +audio_capture_attach(const char *name, bool active) "capture %s active=3D%= d" =20 # audio-mixeng-be.c audio_get_avail(const char *name, size_t live, uint32_t frontend_frames) "= %s: get_avail live %zu frontend frames %u" audio_run_poll(const char *msg, int64_t elapsed_us) "Elapsed since last %s= : %" PRId64 " us" +audio_capture_free_sw(const char *name) "freeing %s" =20 # audio_template.h audio_open_out(const char *name, int freq, int nchannels, int fmt) "open %= s, freq %d, nchannels %d, fmt %d" --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769539164; cv=none; d=zohomail.com; s=zohoarc; b=cw3TuRJ5xB2bdyMrRbbwYyHuLqRlzyKWyO8RZ9Xl9BgRbjFGMXuK4ylFS8JW1lwttqEdNNmO3ZMXO+TZQgD8WQ/ledObLLPniz+mEaWZXMieyANWBWtc/IZb0YfznQ9y3JDg4vI6y2GMRCkcn4GXgEFyG/6Vt2FksPgdSOqNMHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769539164; 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=b36zKFl1eTvXCE4LVYy6WoOs1hux1pYpscdduj5xdoc=; b=QlDpIOoPS4ztDAhSh+CAzN38rRuhuGVhbz8P/kdG2Od2GGdtzqDavCqjvkYzdl/vnqUoiVSmGnII0WcBz1n2GmHdtZovijcRFm7mF++IXZDTJj94tFatOfSjiATzG97yFrXUzyFS3Zm/lrDTGIyRMF7TM+aSOL+SkliWQE/7pPo= 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 1769539164712391.5177324758296; Tue, 27 Jan 2026 10:39:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknqA-0007E7-CU; Tue, 27 Jan 2026 13:31:02 -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 1vknoL-00021t-WA for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:29:23 -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 1vknoC-0003Xf-BQ for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:29:03 -0500 Received: from mx-prod-mc-05.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-122-jmOdHWxHN4mOww_Lm29A2w-1; Tue, 27 Jan 2026 13:28:57 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D247E19775AA; Tue, 27 Jan 2026 18:28:56 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8C3861955F66; Tue, 27 Jan 2026 18:28:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538539; 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=b36zKFl1eTvXCE4LVYy6WoOs1hux1pYpscdduj5xdoc=; b=bjlJ0IsjRMNOSlVMEtBcJLZdUEeDM5AAGN4i/AZGdeUGO6EtiidsXntRyf3uNHUTcRvJUE YcVtM0rv+Na+sWeShFqr9WVrDnwUiF5y/zbSEQraHngQdAFGAnCwDv8h2qzTl8+jxXjXov e3udeFnb69AHL2Pb5mJLa6eQHFwocSw= X-MC-Unique: jmOdHWxHN4mOww_Lm29A2w-1 X-Mimecast-MFC-AGG-ID: jmOdHWxHN4mOww_Lm29A2w_1769538536 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 36/43] audio: replace DEBUG_OUT with traces Date: Tue, 27 Jan 2026 22:25:03 +0400 Message-ID: <20260127182516.289834-37-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.12 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769539166428154100 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio-mixeng-be.c | 32 ++++++++------------------------ audio/trace-events | 5 +++++ 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index c3234aafb1b..5303c08a285 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -29,8 +29,6 @@ #define AUDIO_CAP "audio" #include "audio_int.h" =20 -/* #define DEBUG_OUT */ - #define SW_NAME(sw) (sw)->name ? (sw)->name : "unknown" =20 const struct mixeng_volume nominal_volume =3D { @@ -568,9 +566,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t buf_len) } =20 if (live =3D=3D hw->mix_buf.size) { -#ifdef DEBUG_OUT - dolog ("%s is full %zu\n", sw->name, live); -#endif + trace_audio_out_full(sw->name, live); return 0; } =20 @@ -618,15 +614,8 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void = *buf, size_t buf_len) sw->resample_buf.pos =3D 0; } =20 -#ifdef DEBUG_OUT - dolog ( - "%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 + trace_audio_sw_write(SW_NAME(sw), buf_len / sw->info.bytes_per_frame, + total_in, sw->total_hw_samples_mixed); =20 return total_in * sw->info.bytes_per_frame; } @@ -900,10 +889,8 @@ static size_t audio_get_free(SWVoiceOut *sw) =20 dead =3D sw->hw->mix_buf.size - live; =20 -#ifdef DEBUG_OUT - 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 + trace_audio_get_free(SW_NAME(sw), live, dead, + st_rate_frames_in(sw->rate, dead)); =20 return dead; } @@ -1058,9 +1045,8 @@ static void audio_run_out(AudioMixengBackend *s) =20 if (hw->pending_disable && !nb_live) { SWVoiceCap *sc; -#ifdef DEBUG_OUT - dolog ("Disabling voice\n"); -#endif + + trace_audio_out_disable(); hw->enabled =3D false; hw->pending_disable =3D false; if (k->enable_out) { @@ -1089,9 +1075,7 @@ static void audio_run_out(AudioMixengBackend *s) hw->mix_buf.pos =3D 0; } =20 -#ifdef DEBUG_OUT - dolog("played=3D%zu\n", played); -#endif + trace_audio_out_played(played); =20 if (played) { audio_capture_mix_and_clear (hw, prev_rpos, played); diff --git a/audio/trace-events b/audio/trace-events index 3f8ebf9c6cb..7a73d6eb84f 100644 --- a/audio/trace-events +++ b/audio/trace-events @@ -65,6 +65,11 @@ audio_capture_attach(const char *name, bool active) "cap= ture %s active=3D%d" audio_get_avail(const char *name, size_t live, uint32_t frontend_frames) "= %s: get_avail live %zu frontend frames %u" audio_run_poll(const char *msg, int64_t elapsed_us) "Elapsed since last %s= : %" PRId64 " us" audio_capture_free_sw(const char *name) "freeing %s" +audio_out_full(const char *name, size_t live) "%s is full %zu" +audio_sw_write(const char *name, size_t size, size_t written, size_t total= _mixed) "%s: write size %zu written %zu total mixed %zu" +audio_get_free(const char *name, size_t live, size_t dead, uint32_t fronte= nd_frames) "%s: get_free live %zu dead %zu frontend frames %u" +audio_out_disable(void) "Disabling voice" +audio_out_played(size_t played) "played=3D%zu" =20 # audio_template.h audio_open_out(const char *name, int freq, int nchannels, int fmt) "open %= s, freq %d, nchannels %d, fmt %d" --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538914; cv=none; d=zohomail.com; s=zohoarc; b=bPtRIsFQa9/G2IsR/l0gcxDrcGj9Egp9LdoLGAfZFxcj1jBjqkxTuVwjfiDbxVfxvmH7mUB+EAqyWfvI0NZiUps2vdKOHJVV6JpRh0ebgKs30VC+Wh/mRE25rL3QjeYG3+h+TSiHgVJWrTrFiGwI/tW3iDh0yOxirT8qCmC1wRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538914; 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=JBLZzFOFTuMbO24GgEzA2JXkR7wNLOYd6Ot73CMXjXQ=; b=MPcPGr/7y0wlv2FcDbuZiYMCAeTfOxwDNaVUCVFO54iZIqCEKvL1Qh7lFkJGW1Og0OftMyGp6xTZvh9m1sFZ2KoiLgQEoisiN67K87N3DBGANpkhV3UyPVLatGwr6npFfGvezM751ezp+5D7aGsgtcr8zEQP+vR+3X4SCqa4O7o= 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 1769538914406373.3899389304678; Tue, 27 Jan 2026 10:35:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknrG-0000GI-0k; Tue, 27 Jan 2026 13:32: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 1vknoV-00023u-V8 for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:29: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 1vknoT-0003aB-NJ for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:29:19 -0500 Received: from mx-prod-mc-05.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-343-fhnXwbArNzSJyEJPiY3oZA-1; Tue, 27 Jan 2026 13:29:12 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 10A20192D0F6; Tue, 27 Jan 2026 18:29:05 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 57480195419C; Tue, 27 Jan 2026 18:29:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538554; 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=JBLZzFOFTuMbO24GgEzA2JXkR7wNLOYd6Ot73CMXjXQ=; b=Wk89FFa3vwPwEgRiqB1X72/uRYdW0Wfa2ZM866juONeJtqNDHZfEj+VbCnhSmZgXggJljL 0lk9WG0WNtzqmIR1h0XBbURZEc7W1TQBwrJmRXznoUegwFdI3niFbc+pH7M1UVB2hNMWFi +F18M0KYbgoU0UsN8R63qTGXIpyarrI= X-MC-Unique: fhnXwbArNzSJyEJPiY3oZA-1 X-Mimecast-MFC-AGG-ID: fhnXwbArNzSJyEJPiY3oZA_1769538547 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 37/43] audio: replace DEBUG_AUDIO with trace Date: Tue, 27 Jan 2026 22:25:04 +0400 Message-ID: <20260127182516.289834-38-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.17 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.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1769538915324154100 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_template.h | 10 +++++----- audio/audio-mixeng-be.c | 9 --------- audio/trace-events | 1 + 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index c47a2f202f0..e884c8e9b1a 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -556,11 +556,11 @@ static SW *glue(audio_mixeng_backend_open_, TYPE) ( sw->callback.fn =3D callback_fn; sw->callback.opaque =3D callback_opaque; =20 -#ifdef DEBUG_AUDIO - dolog ("%s\n", name); - audio_pcm_print_info ("hw", &sw->hw->info); - audio_pcm_print_info ("sw", &sw->info); -#endif + trace_audio_voice_pair(G_STRINGIFY(TYPE), name, + AudioFormat_str(sw->hw->info.af), + sw->hw->info.freq, sw->hw->info.nchannels, + AudioFormat_str(sw->info.af), + sw->info.freq, sw->info.nchannels); =20 return sw; =20 diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index 5303c08a285..5165768a531 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -620,15 +620,6 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void = *buf, size_t buf_len) return total_in * sw->info.bytes_per_frame; } =20 -#ifdef DEBUG_AUDIO -static void audio_pcm_print_info (const char *cap, struct audio_pcm_info *= info) -{ - dolog("%s: %s, freq %d, nchan %d\n", - cap, AudioFormat_str(info->af), info->freq, - info->nchannels); -} -#endif - #define DAC #include "audio_template.h" #undef DAC diff --git a/audio/trace-events b/audio/trace-events index 7a73d6eb84f..ed04792d508 100644 --- a/audio/trace-events +++ b/audio/trace-events @@ -74,3 +74,4 @@ audio_out_played(size_t played) "played=3D%zu" # audio_template.h audio_open_out(const char *name, int freq, int nchannels, int fmt) "open %= s, freq %d, nchannels %d, fmt %d" audio_open_in(const char *name, int freq, int nchannels, int fmt) "open %s= , freq %d, nchannels %d, fmt %d" +audio_voice_pair(const char *type, const char *name, const char *hw_fmt, i= nt hw_freq, int hw_nchannels, const char *sw_fmt, int sw_freq, int sw_nchan= nels) "%s: name=3D%s hw=3D%s/%d/%d sw=3D%s/%d/%d" --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769539156; cv=none; d=zohomail.com; s=zohoarc; b=nsq3im7h83kmHSz6nyp8R8SE/eCp96ny/cumG3Hg1oBpyC4OanvNTT4wWSMRRBHEcKTo4M+VA08CzHYaAvY9xFlkB7fsrASXPUydZ7Ppf0vRJs469u/sW5ehcqybxjJZxUxPcEOLCEuL/5owNw4hwIKTW4eiNnvCdhp1O7Adlbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769539156; 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=ltuilmzt4PZngVQxLolrP0mSSfGQKTLY8px/kEQ1sRQ=; b=nsOcU31D5PeSbtcvejmqnmo/IRumOIT2Mn/hIUUuL+Jv/tbL9FapdiMw947zeixanZSHT1UHBYyaK5dYRB6ClKG4nGvANxOFe3JSm3VCL7TmklSid4/m1A3FsEf1w7kEko/LRwyufO6aTSZrCtiJXlPCt/p/8C70rZ395tsOB2c= 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 1769539156001627.8490694119888; Tue, 27 Jan 2026 10:39:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknrJ-0000t5-Rp; Tue, 27 Jan 2026 13:32:13 -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 1vknoi-00027f-5f for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:29:38 -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 1vknob-0003hN-U5 for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:29:30 -0500 Received: from mx-prod-mc-03.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-624-bJxM5jCgMCSMvHnPpJ_OLQ-1; Tue, 27 Jan 2026 13:29:19 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CCC4B1891055; Tue, 27 Jan 2026 18:29:10 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6D46F195419A; Tue, 27 Jan 2026 18:29:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538563; 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=ltuilmzt4PZngVQxLolrP0mSSfGQKTLY8px/kEQ1sRQ=; b=RHceb/qnB8EFWoGefAGXHa5NQplT0GMAnTtzdPJh8urMzHoUpdrBOMcAIsUJlfLzF55ENl ElNK0Cif+a/amQZBGP7bIQ6XaPJWrwTK0CDbcXUWB1wiqeQJVEoVznni0vp9hLAOtp5V4C lVGpxjJq6ZMhcGM3ZKeEe7E5Tns6lD0= X-MC-Unique: bJxM5jCgMCSMvHnPpJ_OLQ-1 X-Mimecast-MFC-AGG-ID: bJxM5jCgMCSMvHnPpJ_OLQ_1769538559 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 38/43] tests/audio: add an invalid settings test Date: Tue, 27 Jan 2026 22:25:05 +0400 Message-ID: <20260127182516.289834-39-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.17 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769539157927158500 From: Marc-Andr=C3=A9 Lureau As we are going to change the related code next. Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/audio/test-audio.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/audio/test-audio.c b/tests/audio/test-audio.c index 98e77cf542b..4590e2f7259 100644 --- a/tests/audio/test-audio.c +++ b/tests/audio/test-audio.c @@ -519,6 +519,26 @@ static void test_audio_multiple_voices(void) audio_be_close_out(be, out1); } =20 +static const struct audsettings invalid_test_settings =3D { + .nchannels =3D 0, + .freq =3D SAMPLE_RATE, + .fmt =3D AUDIO_FORMAT_S16, + .big_endian =3D false, +}; + +static void test_audio_invalid_settings(void) +{ + AudioBackend *be =3D get_test_audio_backend(); + void *voice; + + voice =3D audio_be_open_out(be, NULL, "invalid", NULL, + dummy_audio_callback, &invalid_test_settings= ); + g_assert_null(voice); + voice =3D audio_be_open_in(be, NULL, "invalid", NULL, + dummy_audio_callback, &invalid_test_settings); + g_assert_null(voice); +} + int main(int argc, char **argv) { GOptionContext *context; @@ -573,6 +593,7 @@ int main(int argc, char **argv) =20 g_test_add_func("/audio/null-handling", test_audio_null_handling); g_test_add_func("/audio/multiple-voices", test_audio_multiple_voices); + g_test_add_func("/audio/invalid-settings", test_audio_invalid_settings= ); =20 ret =3D g_test_run(); =20 --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769539026; cv=none; d=zohomail.com; s=zohoarc; b=FBgPbciQlEehlzWrNyR6RmEZrZDT7swMXW/2Y5rrNyNaRBZC2LJfmc+Er+gf1rS1OO/EH46dk/svHPMpVpSdAawhxlfI/MqB8OjxFxc7T7lFUSnHoD80W2EGvehHUxVDHrLUlI9ou/X7jQt2L5uDGSlz90SXcNkFL66+PSo1xUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769539026; 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=sfrZY2yrYbtBdm8NY08D0va2e2kNv/cD6NJjXP0WpTk=; b=gmeBnnkLEP+n0Lrf+EhlJOF6QEngV+LX0/d934+j9Vsv9BJ1epqGZLD4r5IaYRMm7EjGWfiwFGFLq5TL2U6iQi31mNzBIRltaOhWJ/2pfrWzL6Bd7xBiNt3fanE2C7A7E1ooFlT1CFzGYUV4Y7j/aBzBlPxFQWzCtJX/JLOr8Tk= 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 17695390267081013.211125468348; Tue, 27 Jan 2026 10:37:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknrM-0001DY-5g; Tue, 27 Jan 2026 13:32: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 1vknor-0002Dx-Hk for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:29:42 -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 1vknol-0003l8-8C for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:29:39 -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-204--HEW5RWUOVGVnsmokwWG2A-1; Tue, 27 Jan 2026 13:29:29 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 EC1471977300; Tue, 27 Jan 2026 18:29:16 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5DEE71955F66; Tue, 27 Jan 2026 18:29:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538571; 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=sfrZY2yrYbtBdm8NY08D0va2e2kNv/cD6NJjXP0WpTk=; b=aw5a+5OH79MWH2SK96ROxP0JRlENVGkx1m+dRcZ2e1idyTDggcaEEXtfmv44yDGsmr3Y44 jC8Pklc4iT612W7rnzzF47uoNW6mIgfHvddY6btx+VbUMq7JlteD8RWMI9gLfJeRgvmaUs kO6tCZfvZoG92PLSziHyEgrwglQOfYA= X-MC-Unique: -HEW5RWUOVGVnsmokwWG2A-1 X-Mimecast-MFC-AGG-ID: -HEW5RWUOVGVnsmokwWG2A_1769538567 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 39/43] audio: rework invalid audsettings error Date: Tue, 27 Jan 2026 22:25:06 +0400 Message-ID: <20260127182516.289834-40-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.12 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769539028526154100 From: Marc-Andr=C3=A9 Lureau Currently, when given invalid settings, QEMU will print to stderr: A bug was just triggered in audio_mixeng_backend_open_out Save all your work and restart without audio I am sorry Context: audio: frequency=3D44100 nchannels=3D0 fmt=3DS16 endianness=3Dlittle Now it will use error_report() and simply report: audio: Invalid audio settings: frequency=3D44100 nchannels=3D0 fmt=3Ds16 en= dian=3Dlittle Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_template.h | 5 +++-- audio/audio-mixeng-be.c | 41 +++++++---------------------------------- 2 files changed, 10 insertions(+), 36 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index e884c8e9b1a..5711f4a26e1 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -513,8 +513,9 @@ static SW *glue(audio_mixeng_backend_open_, TYPE) ( trace_audio_open_in(name, as->freq, as->nchannels, as->fmt); #endif =20 - if (audio_bug(__func__, audio_validate_settings(as))) { - audio_print_settings (as); + if (audio_validate_settings(as)) { + g_autofree char *str =3D audsettings_to_string(as); + error_report("audio: Invalid audio settings: %s", str); goto fail; } =20 diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index 5165768a531..e8fae2ab977 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -101,38 +101,11 @@ void AUD_log (const char *cap, const char *fmt, ...) va_end (ap); } =20 -static void audio_print_settings (const struct audsettings *as) +static char *audsettings_to_string(const struct audsettings *as) { - dolog ("frequency=3D%d nchannels=3D%d fmt=3D", as->freq, as->nchannels= ); - - switch (as->fmt) { - case AUDIO_FORMAT_S8: - AUD_log (NULL, "S8"); - break; - case AUDIO_FORMAT_U8: - AUD_log (NULL, "U8"); - break; - case AUDIO_FORMAT_S16: - AUD_log (NULL, "S16"); - break; - case AUDIO_FORMAT_U16: - AUD_log (NULL, "U16"); - break; - case AUDIO_FORMAT_S32: - AUD_log (NULL, "S32"); - break; - case AUDIO_FORMAT_U32: - AUD_log (NULL, "U32"); - break; - case AUDIO_FORMAT_F32: - AUD_log (NULL, "F32"); - break; - default: - AUD_log (NULL, "invalid(%d)", as->fmt); - break; - } - - AUD_log (NULL, " endianness=3D%s\n", as->big_endian ? "big" : "little"= ); + return g_strdup_printf("frequency=3D%d nchannels=3D%d fmt=3D%s endian= =3D%s", + as->freq, as->nchannels, AudioFormat_str(as->fm= t), + as->big_endian ? "big" : "little"); } =20 static int audio_validate_settings (const struct audsettings *as) @@ -1607,9 +1580,9 @@ static CaptureVoiceOut *audio_mixeng_backend_add_capt= ure( return NULL; } =20 - if (audio_validate_settings (as)) { - dolog ("Invalid settings were passed when trying to add capture\n"= ); - audio_print_settings (as); + if (audio_validate_settings(as)) { + g_autofree char *str =3D audsettings_to_string(as); + error_report("audio: Invalid audio settings when trying to add cap= ture: %s", str); return NULL; } =20 --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538813; cv=none; d=zohomail.com; s=zohoarc; b=CQzcioVJjv/pk8KmTXv519LtOekH/AuPMRS/FkUYBjZmCKHG+apchwGXf3OtOAw5uZ+U1SI4KV7blJN8L8Xeu8hozJJvDeiM1mgveAWrJ87xAtmHw8YbAq2u0Huv6E9Uzsixr+2Idf92nPleSa5df+HIoVgeHt/gESgILcTipdk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538813; 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=+uJXgzbYwnd2Ft9E/FZODhsTxW5YrI2UjjBzGSgxpz8=; b=l//0S7kG/OejeylgBKTldhImwWzb/WNMjdxQVbjncIW1ceIiliNNQnrnBotXru0RZEHPR6gJKfJCV66Ol0lDUw95/9BaiGxa+AZQqJpbwBw1iBGOoqM4l9oroyhj9rNacdafg60aZ4YlN4LSdmshmzflz7evYspXY+d5BKzfgEo= 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 1769538813711172.78187309750479; Tue, 27 Jan 2026 10:33:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknrL-0001A0-NU; Tue, 27 Jan 2026 13:32: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 1vknot-0002IF-5I for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:29:43 -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 1vknoo-0003na-Ty for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:29:42 -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-338-LBPM0o0dMWKpz6qtqT5iUQ-1; Tue, 27 Jan 2026 13:29:36 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 8755D18E6DA1; Tue, 27 Jan 2026 18:29:22 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0F2C830001A2; Tue, 27 Jan 2026 18:29:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538578; 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=+uJXgzbYwnd2Ft9E/FZODhsTxW5YrI2UjjBzGSgxpz8=; b=IEhMe6dLXrMoPPpoVD20g34O/l8JmI1NNx7+D0chs6BAsRXejR6oSVaSZpZoxkBDuy4hXI rXd+LsGvVqSLWHrka5cM7MK8TbMc9XKr1UiiA70V4rxWvTgMoKEJyKcFMY0RBk9c4tm+Sl LBaK0HObi3XaP2WRzVtXSV/T9nFjbXY= X-MC-Unique: LBPM0o0dMWKpz6qtqT5iUQ-1 X-Mimecast-MFC-AGG-ID: LBPM0o0dMWKpz6qtqT5iUQ_1769538575 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 40/43] audio: rework audio_bug() Date: Tue, 27 Jan 2026 22:25:07 +0400 Message-ID: <20260127182516.289834-41-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.4.1 on 10.30.177.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+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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538815502158500 From: Marc-Andr=C3=A9 Lureau 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 --- 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 e8fae2ab977..4988627279e 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.52.0 From nobody Mon Feb 9 20:12:08 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=1769539013; cv=none; d=zohomail.com; s=zohoarc; b=XDZqAXCBZpgUUiYa1IC9unx/KKPADFP1uEqh855NfYH5V/4QHHjw7qk3K5HNbwSMxuSKXjCtejYQmkrisSwQzz2q2+ELqDH7OdKItYimrDhltCJmm9McOa0LBOCaxguOUtgzbQdOhCoQNx0xIH2miGj6h0ewWsDQNXrA9WeDKQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769539013; 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=U3JsBPxka2f+y8prTonEEdvisKEji5FTWNaZtcfa+Ho=; b=HDpVhImK2aQZdCnNgc0L5quCi/AGEvFInnnzL449SLLSlbQVHvHP4sqzFtUunV34jNHO6t6q4oOanjR+gIQjntvTnpru3I/nueKuQjKjzcpAfp19gm3GCzeG6IhckyGhhe4HQW1zxzHt3Xa8DSFgcmJzsDrrWss8xd5lzMLao38= 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 1769539013868981.6963294689469; Tue, 27 Jan 2026 10:36:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknsS-0002hf-Sq; Tue, 27 Jan 2026 13:33:26 -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 1vknp0-00031V-Pn for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:29: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 1vknoy-0003qo-Or for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:29:50 -0500 Received: from mx-prod-mc-03.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-606-sGjhhH1vNGiHs_rVL7iOYg-1; Tue, 27 Jan 2026 13:29:44 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4CD46189118F; Tue, 27 Jan 2026 18:29:28 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EAD7530002D6; Tue, 27 Jan 2026 18:29:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538587; 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=U3JsBPxka2f+y8prTonEEdvisKEji5FTWNaZtcfa+Ho=; b=dfGK6vdzWJAkUB84/+bbH8pZEabrnIpgibkZr6yVaAeBXyheNonPpvvwDc7ttzsbf9ExaW RxMRi6ikJaZOPkqUZZfhRcxVzfzc8+mzN+3aEj9bi8RNhXi40uHDihC3D826eXRRa2rf8M TdndAgPmaYiEY6COw0TVnAUMixnRPLI= X-MC-Unique: sGjhhH1vNGiHs_rVL7iOYg-1 X-Mimecast-MFC-AGG-ID: sGjhhH1vNGiHs_rVL7iOYg_1769538583 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 41/43] audio: replace remaining dolog() and AUD_log Date: Tue, 27 Jan 2026 22:25:08 +0400 Message-ID: <20260127182516.289834-42-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.4.1 on 10.30.177.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+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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769539015173158500 From: Marc-Andr=C3=A9 Lureau Use warn_report/error_report and trace instead. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_template.h | 19 ++++++++----------- audio/audio-mixeng-be.c | 14 ++++++-------- audio/trace-events | 1 + 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index 9dde36738bc..760aaf5f31f 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -47,21 +47,19 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioMixe= ngBackend *s, if (glue(s->nb_hw_voices_, TYPE) > max_voices) { if (!max_voices) { #ifdef DAC - dolog("Driver `%s' does not support " NAME "\n", k->name); + warn_report("audio: Driver '%s' does not support " NAME, k->na= me); #endif } else { - dolog("Driver `%s' does not support %d " NAME " voices, max %d= \n", - k->name, - glue(s->nb_hw_voices_, TYPE), - max_voices); + warn_report("audio: Driver '%s' does not support %d " NAME " v= oices, max %d", + k->name, glue(s->nb_hw_voices_, TYPE), max_voices); } glue(s->nb_hw_voices_, TYPE) =3D max_voices; } =20 if (glue(s->nb_hw_voices_, TYPE) < min_voices) { - dolog("Bogus number of " NAME " voices %d, setting to %d\n", - glue(s->nb_hw_voices_, TYPE), - min_voices); + warn_report("audio: Bogus number of " NAME " voices %d, setting to= %d", + glue(s->nb_hw_voices_, TYPE), + min_voices); } =20 if (!voice_size && max_voices) { @@ -443,7 +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); + error_report("audio: Could not create a backend for voice '%s'", s= w_name); goto err1; } =20 @@ -537,8 +535,7 @@ static SW *glue(audio_mixeng_backend_open_, TYPE) ( HW *hw =3D sw->hw; =20 if (!hw) { - dolog("Internal logic error: voice `%s' has no backend\n", - SW_NAME(sw)); + audio_bug("Internal logic error: voice '%s' has no backend", S= W_NAME(sw)); goto fail; } =20 diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index 4988627279e..6799b7664b8 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -654,7 +654,7 @@ static size_t audio_mixeng_backend_write(AudioBackend *= be, SWVoiceOut *sw, hw =3D sw->hw; =20 if (!hw->enabled) { - dolog("Writing to disabled voice %s\n", SW_NAME(sw)); + warn_report("audio: Writing to disabled voice %s", SW_NAME(sw)); return 0; } =20 @@ -677,7 +677,7 @@ static size_t audio_mixeng_backend_read(AudioBackend *b= e, hw =3D sw->hw; =20 if (!hw->enabled) { - dolog("Reading from disabled voice %s\n", SW_NAME(sw)); + warn_report("audio: Reading from disabled voice %s", SW_NAME(sw)); return 0; } =20 @@ -874,9 +874,8 @@ static void audio_capture_mix_and_clear(HWVoiceOut *hw,= size_t rpos, sw->empty =3D sw->total_hw_samples_mixed =3D=3D 0; =20 if (to_read - frames_in) { - dolog("Could not mix %zu frames into a capture " - "buffer, mixed %zu\n", - to_read, frames_in); + audio_bug("Could not mix %zu frames into a capture " + "buffer, mixed %zu", to_read, frames_in); break; } n -=3D to_read; @@ -1561,7 +1560,7 @@ static CaptureVoiceOut *audio_mixeng_backend_add_capt= ure( } =20 if (!audio_get_pdo_out(s->dev)->mixing_engine) { - dolog("Can't capture with mixeng disabled\n"); + error_report("audio: Can't capture with mixeng disabled"); return NULL; } =20 @@ -1754,8 +1753,7 @@ size_t audio_rate_peek_bytes(RateCtl *rate, struct au= dio_pcm_info *info) void audio_rate_add_bytes(RateCtl *rate, size_t bytes_used) { if (rate->peeked_frames < 0 || rate->peeked_frames > 65536) { - AUD_log(NULL, "Resetting rate control (%" PRId64 " frames)\n", - rate->peeked_frames); + trace_audio_rate_reset(rate->peeked_frames); audio_rate_start(rate); } =20 diff --git a/audio/trace-events b/audio/trace-events index ed04792d508..222e73c7e88 100644 --- a/audio/trace-events +++ b/audio/trace-events @@ -70,6 +70,7 @@ audio_sw_write(const char *name, size_t size, size_t writ= ten, size_t total_mixed audio_get_free(const char *name, size_t live, size_t dead, uint32_t fronte= nd_frames) "%s: get_free live %zu dead %zu frontend frames %u" audio_out_disable(void) "Disabling voice" audio_out_played(size_t played) "played=3D%zu" +audio_rate_reset(int64_t frames) "Resetting rate control (%" PRId64 " fram= es)" =20 # audio_template.h audio_open_out(const char *name, int freq, int nchannels, int fmt) "open %= s, freq %d, nchannels %d, fmt %d" --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538883; cv=none; d=zohomail.com; s=zohoarc; b=HTKZoHqCrXfoLdhrYGLmxf67oTbmbjjPvsAwEUiH9fZUlvfUgJlkfl+8wfBqFxbqkIolWF//JHAomZim+PdD7aZs6IBgGKJ+4xUwAYgPSka1yRnX5SbJyxFYurCjaqAoEfiQqhlqX48r4vt7ybSW0wHLz1MfWq4SvNkyfF5RPTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538883; 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=f2Pjd0su5K0He3AzlPEAFNiJEDUHYmTEYEST1ewVR6w=; b=SMvypr22wzyCylnIDOQwW8KaM2QP9OsbpBsS+istqM9CAt3lREsJsvQ4HWkf2R5aXEpeaMM7Fj8k5BcAv89BaU6s77M3AybU+ukT92h5SwLl2m97fd7IfvpqsNXrHIGfGUthYCC0Ul5pLPboVGTxAFnFvcpUaaD4lg5mwrOQEGk= 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 1769538883839425.28391906819195; Tue, 27 Jan 2026 10:34:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vknt9-0003Hj-3d; Tue, 27 Jan 2026 13:34: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 1vknpA-0004R3-RQ for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:30:01 -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 1vknp8-0003uw-MD for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:30:00 -0500 Received: from mx-prod-mc-05.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-446-kKYcGqQGOsqb3fxywZB0GQ-1; Tue, 27 Jan 2026 13:29:54 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A22C818941F3; Tue, 27 Jan 2026 18:29:34 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CBC82180097D; Tue, 27 Jan 2026 18:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538598; 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=f2Pjd0su5K0He3AzlPEAFNiJEDUHYmTEYEST1ewVR6w=; b=SuKuxj9z8jC8KMDk/oz97yyctWId0vZ2OnSh7yg4YAUCBPa3WVjf5MxpNdbhk15wxEabyr imk+dvJlK7zBvQv3R78CKcCFXHk2AyDu3LrC7U0lkGoUYfhwlFE7SJxfKFHdAr48fjQxqu rXKNXG6WW+V4aoCTSMUqGknbp2c+nFI= X-MC-Unique: kKYcGqQGOsqb3fxywZB0GQ-1 X-Mimecast-MFC-AGG-ID: kKYcGqQGOsqb3fxywZB0GQ_1769538593 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 42/43] audio: remove AUD_log/ldebug Date: Tue, 27 Jan 2026 22:25:09 +0400 Message-ID: <20260127182516.289834-43-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.4.1 on 10.30.177.111 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538885726158500 From: Marc-Andr=C3=A9 Lureau audio/ is now converted to use QEMU standard trace & error reporting. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 14 -------------- audio/audio_template.h | 2 +- audio/audio-mixeng-be.c | 19 ------------------- audio/mixeng.c | 1 - 4 files changed, 1 insertion(+), 35 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 20ec7883aab..3fc4b516878 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -33,12 +33,6 @@ #include "qemu/audio-capture.h" #include "mixeng.h" =20 -void G_GNUC_PRINTF(2, 0) -AUD_vlog(const char *cap, const char *fmt, va_list ap); - -void G_GNUC_PRINTF(2, 3) -AUD_log(const char *cap, const char *fmt, ...); - struct audio_callback { void *opaque; audio_callback_fn fn; @@ -276,14 +270,6 @@ static inline size_t audio_ring_posb(size_t pos, size_= t dist, size_t len) return pos >=3D dist ? pos - dist : len - dist + pos; } =20 -#define dolog(fmt, ...) AUD_log(AUDIO_CAP, fmt, ## __VA_ARGS__) - -#ifdef DEBUG -#define ldebug(fmt, ...) AUD_log(AUDIO_CAP, fmt, ## __VA_ARGS__) -#else -#define ldebug(fmt, ...) (void)0 -#endif - AudiodevPerDirectionOptions *audio_get_pdo_in(Audiodev *dev); AudiodevPerDirectionOptions *audio_get_pdo_out(Audiodev *dev); =20 diff --git a/audio/audio_template.h b/audio/audio_template.h index 760aaf5f31f..85a128e2f47 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -128,7 +128,7 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) (= SW *sw) /* f_fe_min =3D ceil(1 [frames] * f_be [Hz] / size_be [frames]) */ 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" + "audio: The guest selected a " NAME " sample rate" " of %d Hz for %s. Only sample rates >=3D %" PRIu64 = " Hz" " are supported.\n", sw->info.freq, sw->name, f_fe_min); diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index 6799b7664b8..2ee05a18055 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -26,7 +26,6 @@ #include "trace.h" #include "trace/control.h" =20 -#define AUDIO_CAP "audio" #include "audio_int.h" =20 #define SW_NAME(sw) (sw)->name ? (sw)->name : "unknown" @@ -68,24 +67,6 @@ static int audio_format_to_index(AudioFormat af) g_assert_not_reached(); } =20 -void AUD_vlog (const char *cap, const char *fmt, va_list ap) -{ - if (cap) { - fprintf(stderr, "%s: ", cap); - } - - vfprintf(stderr, fmt, ap); -} - -void AUD_log (const char *cap, const char *fmt, ...) -{ - va_list ap; - - va_start (ap, fmt); - AUD_vlog (cap, fmt, ap); - va_end (ap); -} - static char *audsettings_to_string(const struct audsettings *as) { return g_strdup_printf("frequency=3D%d nchannels=3D%d fmt=3D%s endian= =3D%s", diff --git a/audio/mixeng.c b/audio/mixeng.c index e63c76e021d..a209737a913 100644 --- a/audio/mixeng.c +++ b/audio/mixeng.c @@ -26,7 +26,6 @@ #include "qemu/bswap.h" #include "qemu/audio.h" =20 -#define AUDIO_CAP "mixeng" #include "audio_int.h" #ifdef FLOAT_MIXENG #include "qemu/error-report.h" --=20 2.52.0 From nobody Mon Feb 9 20:12:08 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=1769538990; cv=none; d=zohomail.com; s=zohoarc; b=Pek/fQy8tk47K3p0YUGMalrpmwMHDXHgvEMOSxCh5+pIjddL2ENb6pYO1eNH3+w5wOzAyM/eaysHj/HALOrfyhfsF8hZmjloNwO+MfZg6RdpZx2Bby41Igwio7AmdmbqHIg//7HUpkvTTGv/BKRFtH8T5ap+aNpXAg7udNaZwt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769538990; 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=J24encwNomACtWWbe3QlWc3Pud9f3qITiL4ZBBr21B0=; b=CIX4vZ39hodbju+ga+q1F+x3pucmmmIfV2M2NVKOSqDo54rNgM5ZVnBcFqpYbNEMMLKDaZ1h4OuZV5okTC9TwBN93q2s4wv4ZL95EN2czF6jwvmXUjApJsQFFeZYJJ/2IiHU1bUCIyUuFCV2C4dtPgdOe9dE4+mU2S5axXePuic= 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 176953899024569.1739724535613; Tue, 27 Jan 2026 10:36:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vkntD-00043g-VV; Tue, 27 Jan 2026 13:34:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vknpO-0005jr-Dy for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:30:22 -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 1vknpK-00049W-8F for qemu-devel@nongnu.org; Tue, 27 Jan 2026 13:30:12 -0500 Received: from mx-prod-mc-05.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-340-w2BbGwwePLqNzyJ5atpF5Q-1; Tue, 27 Jan 2026 13:30:04 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 12F8219E5767; Tue, 27 Jan 2026 18:29:41 +0000 (UTC) Received: from localhost (unknown [10.45.242.23]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2321B19560B4; Tue, 27 Jan 2026 18:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769538609; 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=J24encwNomACtWWbe3QlWc3Pud9f3qITiL4ZBBr21B0=; b=PVqfMhQDEgwbBnQGx9+gD12ZagG5CaMxop80TloAXc9DRKN8HQZ1XB9pHqMMuI8KwA8i5P EyLHKJAiw7FwvHd0Kx6xgrQtZ7kX7ph7aA4OytDBfqUFOY+MZnLPA08nEdj7cKu0HYeilV goz5hZE4TVHmbqu+pFKzKqWuR/qvlWk= X-MC-Unique: w2BbGwwePLqNzyJ5atpF5Q-1 X-Mimecast-MFC-AGG-ID: w2BbGwwePLqNzyJ5atpF5Q_1769538602 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Christian Schoenebeck , Akihiko Odaki , Thomas Huth , Alexandre Ratchov Subject: [PATCH 43/43] audio: remove AudioMixengBackendClass.name Date: Tue, 27 Jan 2026 22:25:10 +0400 Message-ID: <20260127182516.289834-44-marcandre.lureau@redhat.com> In-Reply-To: <20260127182516.289834-1-marcandre.lureau@redhat.com> References: <20260127182516.289834-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.0 on 10.30.177.12 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_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: 1769538997274158500 From: Marc-Andr=C3=A9 Lureau Simply use the class name instead. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki --- audio/audio_int.h | 1 - audio/audio_template.h | 15 ++++++++------- audio/alsaaudio.c | 1 - audio/dbusaudio.c | 1 - audio/dsoundaudio.c | 1 - audio/jackaudio.c | 1 - audio/noaudio.c | 1 - audio/ossaudio.c | 1 - audio/paaudio.c | 1 - audio/pwaudio.c | 1 - audio/sdlaudio.c | 1 - audio/sndioaudio.c | 1 - audio/spiceaudio.c | 1 - audio/wavaudio.c | 1 - audio/coreaudio.m | 1 - 15 files changed, 8 insertions(+), 21 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 3fc4b516878..06f79ade6b0 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -173,7 +173,6 @@ struct SWVoiceCap { struct AudioMixengBackendClass { AudioBackendClass parent_class; =20 - const char *name; int max_voices_out; int max_voices_in; size_t voice_size_out; diff --git a/audio/audio_template.h b/audio/audio_template.h index 85a128e2f47..228369cf9a1 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -40,6 +40,7 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioMixeng= Backend *s, AudioMixengBackendClass *k, int min_voices) { + const char *be_name =3D object_class_get_name(OBJECT_CLASS(k)); int max_voices =3D glue(k->max_voices_, TYPE); size_t voice_size =3D glue(k->voice_size_, TYPE); =20 @@ -47,11 +48,11 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioMixe= ngBackend *s, if (glue(s->nb_hw_voices_, TYPE) > max_voices) { if (!max_voices) { #ifdef DAC - warn_report("audio: Driver '%s' does not support " NAME, k->na= me); + warn_report("audio: '%s' backend does not support " NAME, be_n= ame); #endif } else { - warn_report("audio: Driver '%s' does not support %d " NAME " v= oices, max %d", - k->name, glue(s->nb_hw_voices_, TYPE), max_voices); + warn_report("audio: '%s' backend does not support %d " NAME " = voices, max %d", + be_name, glue(s->nb_hw_voices_, TYPE), max_voices); } glue(s->nb_hw_voices_, TYPE) =3D max_voices; } @@ -63,14 +64,14 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioMixe= ngBackend *s, } =20 if (!voice_size && max_voices) { - audio_bug("drv=3D`%s' voice_size=3D0 max_voices=3D%d", - k->name, max_voices); + audio_bug("backend=3D`%s' voice_size=3D0 max_voices=3D%d", + be_name, max_voices); glue(s->nb_hw_voices_, TYPE) =3D 0; } =20 if (voice_size && !max_voices) { - audio_bug("drv=3D`%s' voice_size=3D%zu max_voices=3D0", - k->name, voice_size); + audio_bug("backend=3D`%s' voice_size=3D%zu max_voices=3D0", + be_name, voice_size); } } =20 diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index a606ce0d4cd..7acbc4d9831 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -895,7 +895,6 @@ static void audio_alsa_class_init(ObjectClass *klass, c= onst void *data) audio_alsa_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_paren= t(klass)); =20 b->realize =3D audio_alsa_realize; - k->name =3D "alsa"; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(ALSAVoiceOut); diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index 72d6194033b..5fc85ae8f5e 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -699,7 +699,6 @@ static void audio_dbus_class_init(ObjectClass *klass, c= onst void *data) =20 b->realize =3D audio_dbus_realize; b->set_dbus_server =3D dbus_audio_set_server; - k->name =3D "dbus"; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(DBusVoiceOut); diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 2f17ab49730..ece7b4acf9c 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -649,7 +649,6 @@ static void audio_dsound_class_init(ObjectClass *klass,= const void *data) audio_dsound_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_par= ent(klass)); =20 b->realize =3D audio_dsound_realize; - k->name =3D "dsound"; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D 1; k->voice_size_out =3D sizeof(DSoundVoiceOut); diff --git a/audio/jackaudio.c b/audio/jackaudio.c index 58b9d2f04e2..ae04acf04fc 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -663,7 +663,6 @@ static void audio_jack_class_init(ObjectClass *klass, c= onst void *data) { AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); =20 - k->name =3D "jack"; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(QJackOut); diff --git a/audio/noaudio.c b/audio/noaudio.c index 20208c71069..f636ab09b08 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -113,7 +113,6 @@ static void audio_none_class_init(ObjectClass *klass, c= onst void *data) { AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); =20 - k->name =3D "none"; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(NoVoiceOut); diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 0f1c097a666..7e992cee1c6 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -739,7 +739,6 @@ static void audio_oss_class_init(ObjectClass *klass, co= nst void *data) audio_oss_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_parent= (klass)); =20 b->realize =3D audio_oss_realize; - k->name =3D "oss"; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(OSSVoiceOut); diff --git a/audio/paaudio.c b/audio/paaudio.c index 2a745ae38f9..0f17df38da1 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -920,7 +920,6 @@ static void audio_pa_class_init(ObjectClass *klass, con= st void *data) audio_pa_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_parent(= klass)); =20 b->realize =3D audio_pa_realize; - k->name =3D "pa"; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(PAVoiceOut); diff --git a/audio/pwaudio.c b/audio/pwaudio.c index 66ca1231541..9bae4eaecc8 100644 --- a/audio/pwaudio.c +++ b/audio/pwaudio.c @@ -829,7 +829,6 @@ static void audio_pw_class_init(ObjectClass *klass, con= st void *data) audio_pw_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_parent(= klass)); =20 b->realize =3D audio_pw_realize; - k->name =3D "pipewire"; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(PWVoiceOut); diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index b404adbc1e9..07b2b2ecf6d 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -469,7 +469,6 @@ static void audio_sdl_class_init(ObjectClass *klass, co= nst void *data) audio_sdl_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_parent= (klass)); =20 b->realize =3D audio_sdl_realize; - k->name =3D "sdl"; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(SDLVoiceOut); diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c index 69fa9d8ba54..7c4875247dc 100644 --- a/audio/sndioaudio.c +++ b/audio/sndioaudio.c @@ -531,7 +531,6 @@ static void audio_sndio_class_init(ObjectClass *klass, = const void *data) { AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); =20 - k->name =3D "sndio"; k->max_voices_out =3D INT_MAX; k->max_voices_in =3D INT_MAX; k->voice_size_out =3D sizeof(SndioVoice); diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 1b67fe2a540..9ce2a612ed5 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -303,7 +303,6 @@ static void audio_spice_class_init(ObjectClass *klass, = const void *data) audio_spice_parent_class =3D AUDIO_BACKEND_CLASS(object_class_get_pare= nt(klass)); =20 b->realize =3D spice_audio_realize; - k->name =3D "spice"; k->max_voices_out =3D 1; k->max_voices_in =3D 1; k->voice_size_out =3D sizeof(SpiceVoiceOut); diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 217fb9937f8..afe09e27c78 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -188,7 +188,6 @@ static void audio_wav_class_init(ObjectClass *klass, co= nst void *data) { AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); =20 - k->name =3D "wav"; k->max_voices_out =3D 1; k->max_voices_in =3D 0; k->voice_size_out =3D sizeof(WAVVoiceOut); diff --git a/audio/coreaudio.m b/audio/coreaudio.m index 08bab353831..145c0da1b71 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -646,7 +646,6 @@ static void audio_coreaudio_class_init(ObjectClass *kla= ss, const void *data) { AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); =20 - k->name =3D "coreaudio"; k->max_voices_out =3D 1; k->max_voices_in =3D 0; k->voice_size_out =3D sizeof(coreaudioVoiceOut); --=20 2.52.0