From nobody Sun Apr 12 02:50:02 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=1771854497; cv=none; d=zohomail.com; s=zohoarc; b=abH7he/ucvbvJTqC8JvOmv2K/fzj1w40erQmr5k7+TuarNUUGFi+DdmrMnZfU2qVYxkmCBkgwWdDLvg2DxhWAozOzE1SpzYiB5WYLOKG4jmfYxeTVNx146izdTaihvCzd3i4xpljnRLTthHe3NzLVjGnYUXaAFSkOcicp/75pZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854497; 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=LHlqBgh12YKNNRewWHcvCXhGSyIOzkU8EAa1DmmKP+0=; b=RIn8l/9oquC0ZZCBk2JMWfitduELbfyWcYZ5KZh19ppqZQYJmEQOQg10KeATxIA+klCopAuifHKpeoFvprXkbxutaQ742NxYNeOkqEUKw9PRaCONUxy8nl1IskyGlAv9gPx6xpc4JdoW7UT0eG8K+bzPWeRB3TM9D06lmJIWJ5k= 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 177185449763299.20472608482885; Mon, 23 Feb 2026 05:48:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWI2-0008OY-Ot; Mon, 23 Feb 2026 08:48: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 1vuWHm-0008Fl-6w for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:47:42 -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 1vuWHk-0006x1-Kh for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:47:41 -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-339-0vlF68kuP9-7OjFb3h-2TA-1; Mon, 23 Feb 2026 08:47:38 -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 449E1180049D; Mon, 23 Feb 2026 13:47:37 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 315401800465; Mon, 23 Feb 2026 13:47:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854459; 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=LHlqBgh12YKNNRewWHcvCXhGSyIOzkU8EAa1DmmKP+0=; b=IgAVXhOj5Uo5ZESTM8V4UMO7WsfP1+6YoYqMylak/yOO7y+sFZOXqhx47by2ZoDbNPnH48 mvCzoygJzEFhuVMYus3PkWug9wpqYrmylw5mys7mvlR5U5Q9MnmNIF+9ZsByosZHUBMFf8 udf7DVyTvT3PGVhEoneRkrnjRXPGvMc= X-MC-Unique: 0vlF68kuP9-7OjFb3h-2TA-1 X-Mimecast-MFC-AGG-ID: 0vlF68kuP9-7OjFb3h-2TA_1771854457 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Eduardo Habkost Subject: [PULL v3 01/85] audio: remove obsolete/obscure functions Date: Mon, 23 Feb 2026 14:46:02 +0100 Message-ID: <20260223134731.2377432-2-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854498446158500 From: Marc-Andr=C3=A9 Lureau AUD_init_time_stamp_{in,out} and AUD_get_elapsed_usec_{in,out} are only used by the adlib device. The result isn't actually being used since ADLIB_KILL_TIMERS was set some 20y ago. Let's drop this dead code now. Drop QEMUAudioTimeStamp as well as reported by Akihiko Odaki. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_template.h | 34 ------------------- include/qemu/audio.h | 10 ------ hw/audio/adlib.c | 18 +--------- .../codeconverter/test_regexps.py | 1 - 4 files changed, 1 insertion(+), 62 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index 7a8c431f2d7..1ab3c47fd76 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -569,40 +569,6 @@ bool glue(AUD_is_active_, TYPE)(SW *sw) return sw ? sw->active : 0; } =20 -void glue (AUD_init_time_stamp_, TYPE) (SW *sw, QEMUAudioTimeStamp *ts) -{ - if (!sw) { - return; - } - - ts->old_ts =3D sw->hw->ts_helper; -} - -uint64_t glue (AUD_get_elapsed_usec_, TYPE) (SW *sw, QEMUAudioTimeStamp *t= s) -{ - uint64_t delta, cur_ts, old_ts; - - if (!sw) { - return 0; - } - - cur_ts =3D sw->hw->ts_helper; - old_ts =3D ts->old_ts; - /* dolog ("cur %" PRId64 " old %" PRId64 "\n", cur_ts, old_ts); */ - - if (cur_ts >=3D old_ts) { - delta =3D cur_ts - old_ts; - } else { - delta =3D UINT64_MAX - old_ts + cur_ts; - } - - if (!delta) { - return 0; - } - - return muldiv64 (delta, sw->hw->info.freq, 1000000); -} - #undef TYPE #undef HW #undef SW diff --git a/include/qemu/audio.h b/include/qemu/audio.h index a92e0b70ef0..a1a64ad340d 100644 --- a/include/qemu/audio.h +++ b/include/qemu/audio.h @@ -50,10 +50,6 @@ struct AudioBackendClass { =20 typedef struct AudioBackend AudioBackend; =20 -typedef struct QEMUAudioTimeStamp { - uint64_t old_ts; -} QEMUAudioTimeStamp; - bool AUD_backend_check(AudioBackend **be, Error **errp); =20 SWVoiceOut *AUD_open_out ( @@ -71,9 +67,6 @@ int AUD_get_buffer_size_out (SWVoiceOut *sw); void AUD_set_active_out(SWVoiceOut *sw, bool on); bool AUD_is_active_out(SWVoiceOut *sw); =20 -void AUD_init_time_stamp_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts); -uint64_t AUD_get_elapsed_usec_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts); - #define AUDIO_MAX_CHANNELS 16 typedef struct Volume { bool mute; @@ -112,9 +105,6 @@ size_t AUD_read (SWVoiceIn *sw, void *pcm_buf, size_t s= ize); void AUD_set_active_in(SWVoiceIn *sw, bool on); bool AUD_is_active_in(SWVoiceIn *sw); =20 -void AUD_init_time_stamp_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts); -uint64_t AUD_get_elapsed_usec_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts); - void audio_cleanup(void); =20 typedef struct st_sample st_sample; diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index 8b9fe53e17b..efab5107a4c 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -34,8 +34,6 @@ =20 #define DEBUG 0 =20 -#define ADLIB_KILL_TIMERS 1 - #define ADLIB_DESC "Yamaha YM3812 (OPL2)" =20 #if DEBUG @@ -71,7 +69,6 @@ struct AdlibState { uint64_t dexp[2]; SWVoiceOut *voice; int left, pos, samples; - QEMUAudioTimeStamp ats; FM_OPL *opl; PortioList port_list; }; @@ -88,19 +85,7 @@ static void adlib_kill_timers (AdlibState *s) =20 for (i =3D 0; i < 2; ++i) { if (s->ticking[i]) { - uint64_t delta; - - delta =3D AUD_get_elapsed_usec_out (s->voice, &s->ats); - ldebug ( - "delta =3D %f dexp =3D %f expired =3D> %d", - delta / 1000000.0, - s->dexp[i] / 1000000.0, - delta >=3D s->dexp[i] - ); - if (ADLIB_KILL_TIMERS || delta >=3D s->dexp[i]) { - adlib_stop_opl_timer (s, i); - AUD_init_time_stamp_out (s->voice, &s->ats); - } + adlib_stop_opl_timer(s, i); } } } @@ -149,7 +134,6 @@ static void timer_handler (void *opaque, int c, double = interval_Sec) #endif =20 s->dexp[n] =3D interval_Sec * 1000000.0; - AUD_init_time_stamp_out (s->voice, &s->ats); } =20 static int write_audio (AdlibState *s, int samples) diff --git a/scripts/codeconverter/codeconverter/test_regexps.py b/scripts/= codeconverter/codeconverter/test_regexps.py index 2b9f5b80111..f92389e9618 100644 --- a/scripts/codeconverter/codeconverter/test_regexps.py +++ b/scripts/codeconverter/codeconverter/test_regexps.py @@ -202,7 +202,6 @@ def test_struct_re(): uint64_t dexp[2]; SWVoiceOut *voice; int left, pos, samples; - QEMUAudioTimeStamp ats; FM_OPL *opl; PortioList port_list; } AdlibState; --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854497; cv=none; d=zohomail.com; s=zohoarc; b=Maqdyq47NRLr2/ZYGAnnnPxECLxjNi8JVMOANuDW5QijWSzPTKL9hTlXtNPWO5YS4TIwT1CIG/R5Pe1sHlGenfCcsXxEQrmK3E+ag5W18oS94JAqk9x4IcCPruzgnL7RM6t41z5xkojIHLeODG7uuaFsI0T3NZDB7yCR2rjAHKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854497; 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=vlXsfrxNTTwtktc7+v5NGne8/II769oIaK6YKxokHKU=; b=DB9ohck2ys+8XoAYeqVKK+/ZyDEch1ejYOsZOxA7X6bCLUZTDz1ZkBoWDT9r0toOasYHtQIe+gLRzvI8QwrpkuvmwpjfrsICKMc3uTJOinlx1ajA+8cfvfQm/JQLjETI12e4cCNeYtVcTm7HdHp+Vc0DF0UL4QXGNMo5oDmLt/g= 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 17718544976871006.653069541114; Mon, 23 Feb 2026 05:48:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWIB-0008Q2-Vv; Mon, 23 Feb 2026 08:48:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWHq-0008LB-HT for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:47:47 -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 1vuWHp-0006xW-79 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:47:46 -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-489-ilOKLJ19MUqI2TJ499ZBsQ-1; Mon, 23 Feb 2026 08:47: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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4FA73195606B; Mon, 23 Feb 2026 13:47:40 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4D2141955F22; Mon, 23 Feb 2026 13:47:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854464; 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=vlXsfrxNTTwtktc7+v5NGne8/II769oIaK6YKxokHKU=; b=SDMGnwnAdLU/KFUYsO0gWDXtz9uP2EQKreQxUfvq2GHEDns4pUouxDBemqK6bbXz+gA9GN V+rz0OgPLsykgs+4zp2waH2pWYNeZ0cr7f2ruZxvWJbDTjCKTIlA6jI36uoWpTofpcRmsc t1CEwJQsR7DfgAaOMlYODHpmZFkpAAk= X-MC-Unique: ilOKLJ19MUqI2TJ499ZBsQ-1 X-Mimecast-MFC-AGG-ID: ilOKLJ19MUqI2TJ499ZBsQ_1771854460 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 02/85] adlib: remove dead code Date: Mon, 23 Feb 2026 14:46:03 +0100 Message-ID: <20260223134731.2377432-3-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854498454158500 From: Marc-Andr=C3=A9 Lureau Previous commit drop the need for this field. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/audio/adlib.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index efab5107a4c..f79654627f5 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -66,7 +66,6 @@ struct AdlibState { int64_t exp[2]; #endif int16_t *mixbuf; - uint64_t dexp[2]; SWVoiceOut *voice; int left, pos, samples; FM_OPL *opl; @@ -133,7 +132,6 @@ static void timer_handler (void *opaque, int c, double = interval_Sec) s->exp[n] =3D exp; #endif =20 - s->dexp[n] =3D interval_Sec * 1000000.0; } =20 static int write_audio (AdlibState *s, int samples) --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854545; cv=none; d=zohomail.com; s=zohoarc; b=k63UQkHMQS77uTVjJ/ckOxORvT7hJBnD+6NFkINHVxUoB1E833IAmBKQhQ2DsmOllL0CaL6teZIOtkp1SvMW/n2qJ2a0qf56Bw8HAxHXVAN1W6EoUX3975Sg6fQx404F3x70BcXmp4CedvkFCVWEPY3+CvHpj4SzPnFss2E/Bp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854545; 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=trO6A6IjlpgNbzVR7kz3ETeP3M3fhTsm0v2ihyysHDg=; b=EQMnBqYlBAeVAcyMEX6amh/awSqYmZjxkHQWDnJMr40ey+Nvix/UI1Rbjx2TD1cBh6/P6Wp/p7j3GLPcDqoGWQN/d5q5RPmpfdOjuggBjo7jCpBfnx7uEA6vjRaptBsZvWyj+Y/YFdq7Huj65xcLCpZdecsYEGol/1H1O2x6v00= 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 1771854544994368.71632735625894; Mon, 23 Feb 2026 05:49:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWIT-0000NG-6w; Mon, 23 Feb 2026 08:48:25 -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 1vuWHs-0008Mo-Su for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:47: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 1vuWHr-0006xi-5t for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:47:48 -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-398-8XXJtBQ2MEyEArMW8YSalA-1; Mon, 23 Feb 2026 08:47:44 -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 AC70F1956088; Mon, 23 Feb 2026 13:47:43 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CDB851800370; Mon, 23 Feb 2026 13:47:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854466; 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=trO6A6IjlpgNbzVR7kz3ETeP3M3fhTsm0v2ihyysHDg=; b=Hl3x9njyYFL2zTlERoE2Vl4HxRoUqMqXJie2vNuAkhvc35a2JdE/GFpsgRmg68DhoOFBam zToLX3N8FtzZXCnCpILmqTV/GLrbetb88TI1iecBSMtOcnujCxpUpnwbuKtw3jHOtVzKKq tn25ePFi/uNKPA3C/TL9cSRSTsQSX3s= X-MC-Unique: 8XXJtBQ2MEyEArMW8YSalA-1 X-Mimecast-MFC-AGG-ID: 8XXJtBQ2MEyEArMW8YSalA_1771854463 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 03/85] audio/adlib: drop ts_helper HWVoice field Date: Mon, 23 Feb 2026 14:46:04 +0100 Message-ID: <20260223134731.2377432-4-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854546721158500 From: Marc-Andr=C3=A9 Lureau Previous commits made this dead code. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 2 -- audio/audio.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index b2b8002477c..20b4c87b0b6 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -77,7 +77,6 @@ typedef struct HWVoiceOut { struct audio_pcm_info info; =20 f_sample *clip; - uint64_t ts_helper; =20 STSampleBuffer mix_buf; void *buf_emul; @@ -99,7 +98,6 @@ typedef struct HWVoiceIn { t_sample *conv; =20 size_t total_samples_captured; - uint64_t ts_helper; =20 STSampleBuffer conv_buf; void *buf_emul; diff --git a/audio/audio.c b/audio/audio.c index b7a28f79d4f..a218570a4f4 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1240,7 +1240,6 @@ static void audio_run_out(AudioBackend *s) #endif =20 if (played) { - hw->ts_helper +=3D played; audio_capture_mix_and_clear (hw, prev_rpos, played); } =20 @@ -1320,7 +1319,6 @@ static void audio_run_in(AudioBackend *s) =20 min =3D audio_pcm_hw_find_min_in (hw); hw->total_samples_captured +=3D captured - min; - hw->ts_helper +=3D captured; =20 for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { sw->total_hw_samples_acquired -=3D min; --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854973; cv=none; d=zohomail.com; s=zohoarc; b=ZUZKGEDgrHO7iFfl4Y5baXB4CkFHIvzENnl8SQat9eM9F1oL9Ly3TvUc70EIzPRvv7R/U57V5rZkN28ldZdXGpo4GE8CKLdo3URW0RL89r+ueiBole52T/RpD77eGRQefdNnJM5oDefUsdloBfnINGShWwwRkSZY+wzhLm4vCmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854973; 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=ujWq/rwNALQFkeirBbxCFeLO6/J9v14zN5YQDxoVzL8=; b=k69B+xLvCRYxq8d6qvXV+PXbKCmSatqmZNoZ9v34rgitL4SO0Bk0cecryUHns6f3rVGPspfb73LELY9a6cWdte4pLbVpI06jEVBxkYxk/e1yMeUUQaPu0Hb28PpePWdWEY7L9HmIJtLiJY9lsPhFLyoG8HC09q6xZj8ME/Rekzk= 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 1771854973294282.99097836194767; Mon, 23 Feb 2026 05:56:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJg-0003FO-74; Mon, 23 Feb 2026 08:49:41 -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 1vuWHz-0008Pl-H5 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:47: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 1vuWHw-0006y1-KQ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:47:55 -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-682-tFj2u4q6O6acPWAnVpka3Q-1; Mon, 23 Feb 2026 08:47:47 -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 408CC18002C4; Mon, 23 Feb 2026 13:47:46 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8999C3000C26; Mon, 23 Feb 2026 13:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854470; 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=ujWq/rwNALQFkeirBbxCFeLO6/J9v14zN5YQDxoVzL8=; b=SEWgjNbUxuZnIlst+lJoSrT7c2b2YNI6EjXbKoKfeH3kct75Q7XGF+W8+TgrMcSvGyiiNe Qn4oUMEY562stFC6EWNW4OupLgLNwlMEssdWpNRw7wLbLzk0YSMvvnjxcm+k0TtqsdzFvw OinV51LaMulw4SUFU0y8We/KzdoIkOI= X-MC-Unique: tFj2u4q6O6acPWAnVpka3Q-1 X-Mimecast-MFC-AGG-ID: tFj2u4q6O6acPWAnVpka3Q_1771854466 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 04/85] audio/dbus: make "dbus" the default backend when using -display dbus Date: Mon, 23 Feb 2026 14:46:05 +0100 Message-ID: <20260223134731.2377432-5-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854975196158500 From: Marc-Andr=C3=A9 Lureau Set "using_dbus_display" during early_dbus_init(), so that we can try to create the "dbus" audio backend by default from audio_prio_list. This makes dbus audio work by default when using an audio device, without having to setup and wire up the -audiodev manually. The added FIXME is addressed in the following commits. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio.c | 3 +++ audio/dbusaudio.c | 8 +++++++- ui/dbus.c | 22 +++++++++++++++++----- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index a218570a4f4..9563583cd1e 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -58,6 +58,9 @@ that we generate the list. */ const char *audio_prio_list[] =3D { +#ifdef CONFIG_GIO + "dbus", +#endif "spice", CONFIG_AUDIO_DRIVERS "none", diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index d729a810aa6..1fe7c4ed647 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -32,6 +32,7 @@ #endif =20 #include "ui/dbus.h" +#include "ui/dbus-display.h" #include "ui/dbus-display1.h" =20 #define AUDIO_CAP "dbus" @@ -408,8 +409,13 @@ dbus_enable_in(HWVoiceIn *hw, bool enable) static void * dbus_audio_init(Audiodev *dev, Error **errp) { - DBusAudio *da =3D g_new0(DBusAudio, 1); + DBusAudio *da; =20 + if (!qemu_using_dbus_display(errp)) { + return NULL; + } + + 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); diff --git a/ui/dbus.c b/ui/dbus.c index 31f6eb1189f..0be1931d208 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -35,6 +35,7 @@ #include "ui/egl-context.h" #endif #include "qemu/audio.h" +#include "audio/audio_int.h" /* FIXME: use QOM dynamic cast instead of drv= ->name */ #include "qapi/error.h" #include "trace.h" =20 @@ -218,9 +219,20 @@ dbus_display_complete(UserCreatable *uc, Error **errp) return; } =20 - if (dd->audiodev && *dd->audiodev) { - AudioBackend *audio_be =3D audio_be_by_name(dd->audiodev, errp); - if (!audio_be || !audio_be_set_dbus_server(audio_be, dd->server, d= d->p2p, errp)) { + { + AudioBackend *audio_be =3D audio_get_default_audio_be(NULL); + + if (audio_be && !g_str_equal(audio_be->drv->name, "dbus")) { + audio_be =3D NULL; + } + if (dd->audiodev && *dd->audiodev) { + audio_be =3D audio_be_by_name(dd->audiodev, errp); + if (!audio_be) { + return; + } + } + if (audio_be && + !audio_be_set_dbus_server(audio_be, dd->server, dd->p2p, errp)= ) { return; } } @@ -475,6 +487,8 @@ early_dbus_init(DisplayOptions *opts) #endif } =20 + using_dbus_display =3D 1; + type_register_static(&dbus_vc_type_info); } =20 @@ -488,8 +502,6 @@ dbus_init(DisplayState *ds, DisplayOptions *opts) exit(1); } =20 - using_dbus_display =3D 1; - object_new_with_props(TYPE_DBUS_DISPLAY, object_get_objects_root(), "dbus-display", &error_fatal, --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854505; cv=none; d=zohomail.com; s=zohoarc; b=H5u3pOymzxNEfthF+BgDHQ03cVHFR2QEe77wDfgR/K0mTOoX1e5enta90XyhRViq0AIAoc05BWFAyKSP81vrPvJ0mqMiL3JX71SGkbFY5G5ihr9GGF+Fkuns6DL10Ksk2LzVNQd8FIwiLeSXEvvfxJpQbVsxFxArkreEflMWnFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854505; 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=ukYPq8MtY8MhpchonEYSa7OftrFfRLjZUE2yTfR+prM=; b=aLOZAk5wAw7FxeFBBXV9wtakilDAXTjHaEewqbByWu+SeXmwGfevpVpB+5x93H108YEOb4puSn7RR5p4mqhqjC5nOTZV2uL+Ob79gOYTrKYco4RfyTCA6le0qu2LdUYj97lICbBORdTy1o+M47/R2iostXMpKTB42fA++xynV1A= 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 177185450566689.76578688335849; Mon, 23 Feb 2026 05:48:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWII-0008W1-7N; Mon, 23 Feb 2026 08:48: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 1vuWHy-0008P5-A7 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:47:55 -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 1vuWHw-0006y7-LD for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:47:54 -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-139-krQtQECUMGeAa97qxQfOKQ-1; Mon, 23 Feb 2026 08:47:49 -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 C4A7A18002FF; Mon, 23 Feb 2026 13:47:48 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 30FE219560A2; Mon, 23 Feb 2026 13:47:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854471; 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=ukYPq8MtY8MhpchonEYSa7OftrFfRLjZUE2yTfR+prM=; b=XpYQCUQTHqX6TBlyNlWtEOTIrvCQkyDDf4BTF6ef9KA+MNPLc3NoQ3ak2JcUyu3arENY4G PKW1EqHk3XKiFZSYqNMgN1qmZin/0eWtbK2uzUGniyDO+VIWOy9TYAZUhrGb/28P43l6+6 +Dly1LDukM1sa4m/R6fVZIuCswpe2GQ= X-MC-Unique: krQtQECUMGeAa97qxQfOKQ-1 X-Mimecast-MFC-AGG-ID: krQtQECUMGeAa97qxQfOKQ_1771854468 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v3 05/85] qemu-options.hx: clarify default audio backend selection Date: Mon, 23 Feb 2026 14:46:06 +0100 Message-ID: <20260223134731.2377432-6-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854506443158500 From: Marc-Andr=C3=A9 Lureau Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- qemu-options.hx | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 33fcfe7ce66..15a6f82043a 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -896,11 +896,16 @@ DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, QEMU_ARCH_ALL) SRST ``-audiodev [driver=3D]driver,id=3Did[,prop[=3Dvalue][,...]]`` - Adds a new audio backend driver identified by id. There are global - and driver specific properties. Some values can be set differently - for input and output, they're marked with ``in|out.``. You can set - the input's property with ``in.prop`` and the output's property with - ``out.prop``. For example: + Adds a new audio backend driver identified by id. + + If no audio backend is specified, QEMU will attempt to select a + default one. The ``-display`` option may influence which backend is + selected. + + There are global and driver specific properties. Some values can be + set differently for input and output, they're marked with ``in|out.``. + You can set the input's property with ``in.prop`` and the output's + property with ``out.prop``. For example: =20 :: =20 @@ -2198,8 +2203,11 @@ DEF("display", HAS_ARG, QEMU_OPTION_display, , QEMU_ARCH_ALL) SRST ``-display type`` - Select type of display to use. Use ``-display help`` to list the avail= able - display types. Valid values for type are + Select type of display to use. This may also influence the default + audio backend selection. + + Use ``-display help`` to list the available display types. Valid values + for type are =20 ``spice-app[,gl=3Don|off]`` Start QEMU as a Spice server and launch the default Spice client @@ -2209,6 +2217,9 @@ SRST ``dbus`` Export the display over D-Bus interfaces. (Since 7.0) =20 + If no audio backend is specified and the dbus display backend is + specified, the dbus audio backend is used by default. + The connection is registered with the "org.qemu" name (and queued = when already owned). =20 --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854563; cv=none; d=zohomail.com; s=zohoarc; b=jxVW31T4yfPA/NdljTgqHX/TyyCx9QpXLq9av70N0xht+NcNKcp9sqre2Lie4t5KX1p8d0ndE6WrvZ3Pk9zvoLuwyEP7nLOr3XbJpxaU0mVTGJsyZLURRocs8cSnZ4Z1AWvwCvCnz8GPEp8zpz4JDk+iJkOpQkeejZD48vxTSsM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854563; 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=eqJqOaFBhQo9nD7FEbMCGjK4JwbAAf6+iYJVKsykfmQ=; b=Dg4fAfr095aNqH/xGvuIWM2g51ZLbaP2ulsZhx8jQS54qyTTcvWzhVKanug6ZmThTZIKHvWEloOwUFPga+ddY4/g55YDZPVksntEm7N42DwkWHW7SfcHy/tpu3BBxp/g8BvVKS+IxcH1AzVEEyriYKAYpA6KeKgicjtIxPxYB7Q= 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 1771854563313317.45230079794123; Mon, 23 Feb 2026 05:49:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJK-0001yT-U8; Mon, 23 Feb 2026 08:49:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWI2-0008QX-FL for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:47:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWI0-0006yP-91 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:47:57 -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-524-RdlyhVTGMT-YGmVVsEuhjw-1; Mon, 23 Feb 2026 08:47:52 -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 43A5E19560B2; Mon, 23 Feb 2026 13:47:51 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B68221800370; Mon, 23 Feb 2026 13:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854474; 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=eqJqOaFBhQo9nD7FEbMCGjK4JwbAAf6+iYJVKsykfmQ=; b=R69rK5/FG+z4soxOi1EzLVpl0SJ+gKMsWOEdUUElTVK3w1grSNutzFE0Xk4pKH/oKrDlWf Dal5Xpfjrh2S7mXILQQTmGpuRc7RHCDGuwI4Q2Iq0eXoCkGdpPCpE4tp2BrxJJKErcncBO qFo5K8UtN+6lHsSBWk+kyM3VZQfIO2U= X-MC-Unique: RdlyhVTGMT-YGmVVsEuhjw-1 X-Mimecast-MFC-AGG-ID: RdlyhVTGMT-YGmVVsEuhjw_1771854471 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v3 06/85] qemu-options.hx: document -audiodev dbus Date: Mon, 23 Feb 2026 14:46:07 +0100 Message-ID: <20260223134731.2377432-7-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854564786158500 From: Marc-Andr=C3=A9 Lureau Document the backend introduced in commit 739362d420 ("audio: add dbus audio backend"). Reported-by: Mark Cave-Ayland Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- qemu-options.hx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index 15a6f82043a..4043e8ca22b 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -991,6 +991,16 @@ SRST ``in|out.buffer-count=3Dcount`` Sets the count of the buffers. =20 +``-audiodev dbus,id=3Did[,prop[=3Dvalue][,...]]`` + Creates a D-Bus backend. It must be associated with the display + (as ``-display dbus,audiodev=3Did``). (Since 7.0) + + D-Bus specific options are: + + ``nsamples`` + Number of samples per read/write (default to 480, 10ms at 48kHz) + (Since 10.0) + ``-audiodev dsound,id=3Did[,prop[=3Dvalue][,...]]`` Creates a backend using Microsoft's DirectSound. This backend is only available on Windows and only supports playback. --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854616; cv=none; d=zohomail.com; s=zohoarc; b=Daz7c+d4qlJLIZm5SwBRuRbr/KSqmytUF/mgEPIlHY2aVZmvnhHNE1G/XlFyxH5Dj2FoqD2Q1gfcNRrEdaO9wQiKHOmtjdcFnOLp2cSB/CQI2711qm6wBix19V184Ak6UnNttJ/k0bzByRrO5OEhZApAq1TmmJyAp90pAp827BM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854616; 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=8/8Lhqa9JuzvRQV6JBHOjcSWNe/Ygi7du2NsJ7/nJWM=; b=QPHVYXNwjyfAK+msd+cxvLkXXqOfe1ZEvcNlsmJIMC1vgrEOXYunesNNXOnc2FBJjlR1218Icn9dE9c1QpuGM/PeB5dcFS6MV0MP0/oZ3T8KPwewXbczq7kPzsqiUiPSYHoWpGL3EY8ONuoNVdXVIRQm9K4ID+Zpc4z6GE+myFQ= 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 1771854616613881.3946664114577; Mon, 23 Feb 2026 05:50:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJN-0002IW-F6; Mon, 23 Feb 2026 08:49:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWI6-0008T6-G7 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWI4-0006yv-8Y for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:01 -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-687-36BV2nz3NP-JVzfqs-g8PA-1; Mon, 23 Feb 2026 08:47:55 -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 3DF071955F44; Mon, 23 Feb 2026 13:47:54 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 63E6830001BE; Mon, 23 Feb 2026 13:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854479; 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=8/8Lhqa9JuzvRQV6JBHOjcSWNe/Ygi7du2NsJ7/nJWM=; b=H+40IQMUDFm0+cX8tfGHxMWwR0B40ND+fzRmEwtfOIQe92UV5Rr2GFQRGNZ+AyqBX3yLPZ RGiSqOeudJurgZko7GFQuA3PAx4ll3w6AqkrA4SZe78B7ndAGQt7FiOvBlpe+AW8sDxTFD XwcYgZsU/jOmp9RYDaIGOB8QO5DDvB0= X-MC-Unique: 36BV2nz3NP-JVzfqs-g8PA-1 X-Mimecast-MFC-AGG-ID: 36BV2nz3NP-JVzfqs-g8PA_1771854474 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 07/85] audio: replace vm_running with runstate_is_running() Date: Mon, 23 Feb 2026 14:46:08 +0100 Message-ID: <20260223134731.2377432-8-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854617126158500 From: Marc-Andr=C3=A9 Lureau AudioBackend had a vm_running field which was set in audio_vm_change_state_handler(). The state change handler "bool running" argument is true when vm_prepare_start() calls it, and the VM runstate is either SUSPENDED or RUNNING. Audio hw voices shouldn't be running when the VM is suspended, but only when running. Thus replacing the vm_running field with a call to runstate_is_running() is both simpler and more correct. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 1 - audio/audio.c | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 20b4c87b0b6..25de0e3f9cf 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -252,7 +252,6 @@ typedef struct AudioBackend { QLIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head; int nb_hw_voices_out; int nb_hw_voices_in; - int vm_running; int64_t period_ticks; =20 bool timer_running; diff --git a/audio/audio.c b/audio/audio.c index 9563583cd1e..68698b13e15 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -933,7 +933,7 @@ void AUD_set_active_out(SWVoiceOut *sw, bool on) hw->pending_disable =3D 0; if (!hw->enabled) { hw->enabled =3D true; - if (s->vm_running) { + if (runstate_is_running()) { if (hw->pcm_ops->enable_out) { hw->pcm_ops->enable_out(hw, true); } @@ -979,7 +979,7 @@ void AUD_set_active_in(SWVoiceIn *sw, bool on) if (on) { if (!hw->enabled) { hw->enabled =3D true; - if (s->vm_running) { + if (runstate_is_running()) { if (hw->pcm_ops->enable_in) { hw->pcm_ops->enable_in(hw, true); } @@ -1598,7 +1598,6 @@ static void audio_vm_change_state_handler (void *opaq= ue, bool running, HWVoiceOut *hwo =3D NULL; HWVoiceIn *hwi =3D NULL; =20 - s->vm_running =3D running; 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); --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854696; cv=none; d=zohomail.com; s=zohoarc; b=SkbiHarC/DThD7KN+5Z4vtmrHlXERhL2p6hrQ1MgtwQ2yjw6/GTxVeG7B06b2Wer9Jkocp65/2REQiZTNSeNBxGCHJM+dngP9VJDAEFkO88MhEoZ8wswr40+jBjfZqJnU7uVhLG4OctAV7IL7WddbSbehXa9TuBc0U4F4Zl90pM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854696; 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=vpLVOYM8Wde55LfgKpbzEakLLTFw5alf2wV81ekIxNk=; b=XH1h6AuveFP3eVG+JpRbiKqq1yEpIpaUY98JiQLp8g0onMXltqdHVjAFJ3vxuumw7mYdVbMsTUVWJfM1D4krMGFgUf6QK98mIzp0fG/FRRy2XEGATCF4kBU8ClgAenuAEZFFHJP/TDwJ316J/Y+js7wc2yZBRQRna3YWeknYC9Q= 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 1771854696082294.6176626329783; Mon, 23 Feb 2026 05:51:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJK-0001so-8D; Mon, 23 Feb 2026 08:49:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWI5-0008SR-Jb for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:09 -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 1vuWI3-0006ys-Ow for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:00 -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-94-_vSmZ5OnOk6kqprfpeyQKQ-1; Mon, 23 Feb 2026 08:47:57 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0398C1800267; Mon, 23 Feb 2026 13:47:57 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 106011800465; Mon, 23 Feb 2026 13:47:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854479; 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=vpLVOYM8Wde55LfgKpbzEakLLTFw5alf2wV81ekIxNk=; b=GPlYRy+U9OynEYGPBmc9P+6J0D0+aIhccGmiOJ0FZfISb+3bqalAsHchp0UgI6S905jAdy 86GKwywkia8LGI4WzPiduZcdyETrtnllZcsY4L2OC5X3vqZZ/c2sARSvRZk3/klaswL12h rBkY1tBNHd6bMQHIDZBFRO+EQNpuAR0= X-MC-Unique: _vSmZ5OnOk6kqprfpeyQKQ-1 X-Mimecast-MFC-AGG-ID: _vSmZ5OnOk6kqprfpeyQKQ_1771854477 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 08/85] audio: list backends as modules Date: Mon, 23 Feb 2026 14:46:09 +0100 Message-ID: <20260223134731.2377432-9-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854697575158500 From: Marc-Andr=C3=A9 Lureau Windows doesn't support modules, atm, but we can treat it as a regular audio unit regardless. MacOs does support module, so this is fine. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/meson.build | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/audio/meson.build b/audio/meson.build index b2dca2c6409..23fb66d571f 100644 --- a/audio/meson.build +++ b/audio/meson.build @@ -8,12 +8,11 @@ system_ss.add(files( # deprecated since v10.2, to be removed system_ss.add(files('audio-hmp-cmds.c', 'wavcapture.c')) =20 -system_ss.add(when: coreaudio, if_true: files('coreaudio.m')) -system_ss.add(when: dsound, if_true: files('dsoundaudio.c', 'audio_win_int= .c')) - audio_modules =3D {} foreach m : [ ['alsa', alsa, files('alsaaudio.c')], + ['coreaudio', coreaudio, files('coreaudio.m')], + ['dsound', dsound, files('dsoundaudio.c', 'audio_win_int.c')], ['oss', oss, files('ossaudio.c')], ['pa', pulse, files('paaudio.c')], ['sdl', sdl, files('sdlaudio.c')], --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854535; cv=none; d=zohomail.com; s=zohoarc; b=NAC3ykwmS3JqEQC4KhkdV812N8/Sx1VMvxNLU8+8ECOkMQMLJmKFAEYfv3/Ws+QY8FMHqqHCvqt5UxyT0iea5c2ooyQN6EBQjK4RsO2ydhS0edBuX3e8rthJf0VOMbhxKFM0OHljqfg8mIbY+O7L6JXWt0JsFvmL/zee8Bd6TKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854535; 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=a/ZoD/re91y5SYM5meQEmubIyLCGZRNsMLl9W/pwViw=; b=XyroN6DXyGEfp9ABbnGvMil+luaVP1wAQyARjIGwaMdpFAvdxNM0LUqBfwnY6bIbivjKFHWZBoYVMHI2fYmsQdmsnpbyP+TBp6ruhf8aL8mJoqFOdDbGrJH6A7XIHJJGulIWcYitHbPW7oTxxM/bFOhSpxdaW2Hpwz4o4Dzf4nE= 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 177185453592147.5102911332433; Mon, 23 Feb 2026 05:48:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWIu-0000kc-6V; Mon, 23 Feb 2026 08:48: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 1vuWIA-0008Tk-If for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:09 -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 1vuWI9-0006zN-5P for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:06 -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-284-iXU2p0MMNHuMhRsQkWoQZw-1; Mon, 23 Feb 2026 08:48:00 -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 04FF1195605F; Mon, 23 Feb 2026 13:48:00 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 02DC619560A3; Mon, 23 Feb 2026 13:47:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854484; 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=a/ZoD/re91y5SYM5meQEmubIyLCGZRNsMLl9W/pwViw=; b=a4+0bJbQ2o8xP6SCj00jehSX//fvo70mFDUyIQ/yNhIZ+xshIGInZp1f7xYq8qKhFrTEOb BgK4BUQOzQTeHt0bomRe2JdaoIu5vkavsDkD6z3awNvYauzgvyvv9ALhDX57wTW5rBx0cj Bj6vf7AnN60n0F95hX/XDlNmUoJpnCY= X-MC-Unique: iXU2p0MMNHuMhRsQkWoQZw-1 X-Mimecast-MFC-AGG-ID: iXU2p0MMNHuMhRsQkWoQZw_1771854480 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL v3 09/85] build-sys: create a libaudio Date: Mon, 23 Feb 2026 14:46:10 +0100 Message-ID: <20260223134731.2377432-10-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854536783158500 From: Marc-Andr=C3=A9 Lureau This can help create tests, for example. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- meson.build | 10 +++++++++- audio/meson.build | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 620b2ad903e..17c4afdd45e 100644 --- a/meson.build +++ b/meson.build @@ -4070,11 +4070,19 @@ libhwcore =3D static_library('hwcore', sources: hwc= ore_ss.sources() + genh, hwcore =3D declare_dependency(objects: libhwcore.extract_all_objects(recur= sive: false)) common_ss.add(hwcore) =20 +audio_ss =3D audio_ss.apply({}) +libaudio =3D static_library('qemuaudio', audio_ss.sources() + genh, + dependencies: [audio_ss.dependencies()], + build_by_default: false) + +audio =3D declare_dependency(objects: libaudio.extract_all_objects(recursi= ve: false), + dependencies: [audio_ss.dependencies(), qom]) + ########### # Targets # ########### =20 -system_ss.add(authz, blockdev, chardev, crypto, io, qmp) +system_ss.add(authz, blockdev, chardev, crypto, io, qmp, audio) common_ss.add(qom, qemuutil) =20 libuser =3D static_library('user', diff --git a/audio/meson.build b/audio/meson.build index 23fb66d571f..a5fec14fb3a 100644 --- a/audio/meson.build +++ b/audio/meson.build @@ -1,4 +1,5 @@ -system_ss.add(files( +audio_ss =3D ss.source_set() +audio_ss.add(files( 'audio.c', 'mixeng.c', 'noaudio.c', --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854559; cv=none; d=zohomail.com; s=zohoarc; b=YpQMNhy1epcy3xUSVOqo9NqecHN16spJdpUBWeJCc9xo/f0FSygUBVmifG6eWM0z+mxu2lIIdAoVIBcBJzOobMSgu8cdI/ikZYrw7glZ2GPdzb7YIR27eVE6v5WAKVAAoKqNCjh2C2RJcnKg6xiU9fYEJD3eurHkA7R0UvTc6cU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854559; 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=xylTBKBAhBBCEFQDa1PQFtrPBq4ip0t0I/XcTSk6BaU=; b=U7D843w0eVV+5K91HBQmFe7ao8XZ0nup3S7jrFY/mbnGFDdHjaHlr4+AaoneuLoGZNAOEdjjHIZjoVub+u+MjmjQ+3YAlo/QH9/rR1Q2n4TegSdTx6xZFZhw67opcM85u1FB/lf7Eczwh5v4tBW8BC5NcTy8zwLDByHwgmCmCzc= 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 1771854559651231.94091367325893; Mon, 23 Feb 2026 05:49:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWIw-00010Q-Tt; Mon, 23 Feb 2026 08:48:56 -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 1vuWIC-0008UL-Kz for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWIB-0006zh-AZ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:08 -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-537-PMnId1OMNEy1LUtnBNA_pw-1; Mon, 23 Feb 2026 08:48:03 -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 3A17119560AD; Mon, 23 Feb 2026 13:48:02 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A03EE1955F22; Mon, 23 Feb 2026 13:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854486; 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=xylTBKBAhBBCEFQDa1PQFtrPBq4ip0t0I/XcTSk6BaU=; b=I3mST2HXUJD47deVF5cowybKvfjStAyG9nQAN4eoORjZvOLiV7Clwk+k766YvT6qiE79sH OgO/q4zXjzLXtITJUnoQPruD5gTJf+4x+7CeGtaZYg0JuuMEjrfVf0ScDmUdKiXEaJHE8k 3LRh6eXopX1PAlhiurJuWTTL2Y0an1k= X-MC-Unique: PMnId1OMNEy1LUtnBNA_pw-1 X-Mimecast-MFC-AGG-ID: PMnId1OMNEy1LUtnBNA_pw_1771854482 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow , Cleber Rosa Subject: [PULL v3 10/85] scripts/modinfo: add type annotations Date: Mon, 23 Feb 2026 14:46:11 +0100 Message-ID: <20260223134731.2377432-11-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854560822158500 From: Marc-Andr=C3=A9 Lureau Type annotations allow easier code reading, refactoring, checking etc. Reviewed-by: Yodel Eldar Tested-by: Yodel Eldar Acked-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/modinfo-generate.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/modinfo-generate.py b/scripts/modinfo-generate.py index aaf23544c46..5a8abcae5d3 100644 --- a/scripts/modinfo-generate.py +++ b/scripts/modinfo-generate.py @@ -2,14 +2,16 @@ =20 import os import sys +from typing import Optional =20 -def print_array(name, values): + +def print_array(name: str, values: list[str]) -> None: if len(values) =3D=3D 0: return list =3D ", ".join(values) print(" .%s =3D ((const char*[]){ %s, NULL })," % (name, list)) =20 -def parse_line(line): +def parse_line(line: str) -> tuple[str, str]: kind =3D "" data =3D "" get_kind =3D False @@ -31,7 +33,7 @@ def parse_line(line): continue return (kind, data) =20 -def generate(name, lines, enabled): +def generate(name: str, lines: list[str], enabled: set[str]) -> Optional[s= et[str]]: arch =3D "" objs =3D [] deps =3D [] @@ -68,17 +70,17 @@ def generate(name, lines, enabled): print("},{") return {dep.strip('" ') for dep in deps} =20 -def print_pre(): +def print_pre() -> None: print("/* generated by scripts/modinfo-generate.py */") print("#include \"qemu/osdep.h\"") print("#include \"qemu/module.h\"") print("const QemuModinfo qemu_modinfo[] =3D {{") =20 -def print_post(): +def print_post() -> None: print(" /* end of list */") print("}};") =20 -def main(args): +def main(args: list[str]) -> None: if len(args) < 3 or args[0] !=3D '--devices': print('Expected: modinfo-generate.py --devices ' 'config-device.mak [modinfo files]', file=3Dsys.stderr) --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854613; cv=none; d=zohomail.com; s=zohoarc; b=iyZ9+B3NIJtV6zkKnYfuPHr4oSDRUIXDSOv2LL1Va0XCMmnfMzHor96qzmLWI1hBBSbUYZLmFVt6mlFz2SkxtLwhUmWzXCMhS+WRtwOD3JZnbcFnOMZAwGh5Ic3p4AOZzWXYADaTRYYJpohGqP1ZLZeJLO15YRpRykdhs/IAWyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854613; 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=Ex1BhPZEiEoWTRDPNijsup8gKIZQD3MmR5Eqo0tOGaA=; b=QUQfEm8UL6xgaQBb05oxtCn12nahuJ1NS854KNieDWs3aFfncvM5rFkfwy43Lu0p0iotPQwKwv5jcOGu+RrbHBGPn1dZjJ4fz1YcNghMLhuALRzhf26mC3NO9+PiBcwQaeAGNvT/k/McvHYG+AjAj4vcv2NhZY8MoU4tjyvoTXA= 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 1771854613469710.1938049384381; Mon, 23 Feb 2026 05:50:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWK6-0003fr-48; Mon, 23 Feb 2026 08:50: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 1vuWID-0008Ux-Ti for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:11 -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 1vuWIC-0006zn-Ax for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:09 -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-593-MYGLfUPANky17QZ2UfIVpA-1; Mon, 23 Feb 2026 08:48:06 -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 DAEFB1800465; Mon, 23 Feb 2026 13:48:04 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4046530001BE; Mon, 23 Feb 2026 13:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854487; 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=Ex1BhPZEiEoWTRDPNijsup8gKIZQD3MmR5Eqo0tOGaA=; b=dyhRYokdtpxjjjyYcRqrxf9GTcNebA6/10Ly77O1tWBUFMSovL+svxqMXnYR0yHgNmqwQd HdP/89sx0j4+VoYYRgO5Z9vWi0iceB+ohc2O+/7zxSgV+TNS4cbv2zyespdy6kzrNW+442 2HivmxfpZej39WG8pWi5up4I6e+Zo3E= X-MC-Unique: MYGLfUPANky17QZ2UfIVpA-1 X-Mimecast-MFC-AGG-ID: MYGLfUPANky17QZ2UfIVpA_1771854485 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow , Cleber Rosa Subject: [PULL v3 11/85] scripts/modinfo: remove trailing ; Date: Mon, 23 Feb 2026 14:46:12 +0100 Message-ID: <20260223134731.2377432-12-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854615042158500 From: Marc-Andr=C3=A9 Lureau Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/modinfo-generate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/modinfo-generate.py b/scripts/modinfo-generate.py index 5a8abcae5d3..83ffa4a7c52 100644 --- a/scripts/modinfo-generate.py +++ b/scripts/modinfo-generate.py @@ -48,7 +48,7 @@ def generate(name: str, lines: list[str], enabled: set[st= r]) -> Optional[set[str elif kind =3D=3D 'opts': opts.append(data) elif kind =3D=3D 'arch': - arch =3D data; + arch =3D data elif kind =3D=3D 'kconfig': # don't add a module which dependency is not enabled # in kconfig --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854541; cv=none; d=zohomail.com; s=zohoarc; b=aU2dYX7Z2tgi8/+xSK9Agms+KMUyMJfQJTXWMnQyj4QUBdpDRJwAQGouWUpqUAyoN9ummT+qmy2px2jxmvFwG0MZQxz/mSIXFLgkvx7rTwDWcK51Sb4y+qC1f685wupCogiX1PMfH+YR5nShSmtv0EaTx93fpwRnt8QPUFiMksc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854541; 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=M0k6yPn5T0eyovPQGjxm9xWt0P64UFL1Hu5yvpemZYs=; b=L8TFpQbCLUprsG193PSgnXyBDY+vVZ8+mhDhlateiiI7R4dfRLYaIOzJcOEXZmZC3TBR2ndJIQq2vT27EXBK5dXZ+Z0/s5kmm8vgVEyVHHBI9PJbVu03Ma889txS2Mx0evmkg4rLmdxWgv/nbuIdi5Eqo7WInmArcm6aPO0IOdo= 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 1771854541684920.1277954533335; Mon, 23 Feb 2026 05:49:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWIt-0000j3-TU; Mon, 23 Feb 2026 08:48: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 1vuWII-00008K-3D for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:15 -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 1vuWIG-00070T-J0 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:13 -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-88--S0p322oNCC6j4516foiXw-1; Mon, 23 Feb 2026 08:48:08 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2523B1955F0E; Mon, 23 Feb 2026 13:48:07 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 97A7919560A2; Mon, 23 Feb 2026 13:48:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854491; 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=M0k6yPn5T0eyovPQGjxm9xWt0P64UFL1Hu5yvpemZYs=; b=cAXnQaz+nZGr6BqB3/t55MZ+pIBlg4u2WdH2IZuozRAKrzMgLKjsOi5tmM/3UAguN5bEVK eMWqmsPpwKIHRYNvk0pPXEWWWVqGl3iPdp+QsoqQcauOOQBfq9nyr//LZTB4QNbifT2Xfy 1k/Big4NhSmR1rxe3l7zmKralda111o= X-MC-Unique: -S0p322oNCC6j4516foiXw-1 X-Mimecast-MFC-AGG-ID: -S0p322oNCC6j4516foiXw_1771854487 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow , Cleber Rosa Subject: [PULL v3 12/85] scripts/modinfo: use in instead of find() Date: Mon, 23 Feb 2026 14:46:13 +0100 Message-ID: <20260223134731.2377432-13-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854542675158500 From: Marc-Andr=C3=A9 Lureau Minor style improvement Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/modinfo-generate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/modinfo-generate.py b/scripts/modinfo-generate.py index 83ffa4a7c52..63093a0f820 100644 --- a/scripts/modinfo-generate.py +++ b/scripts/modinfo-generate.py @@ -39,7 +39,7 @@ def generate(name: str, lines: list[str], enabled: set[st= r]) -> Optional[set[str deps =3D [] opts =3D [] for line in lines: - if line.find("MODINFO_START") !=3D -1: + if "MODINFO_START" in line: (kind, data) =3D parse_line(line) if kind =3D=3D 'obj': objs.append(data) --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854558; cv=none; d=zohomail.com; s=zohoarc; b=gCASp96fUmOT/i5bihSl6IEpi8NctLZXJRoehAh5nlm+uv35sFz+hp4/d+zpgseGLcNqechKVWC/e/LAWOvPk19futcLE9ofrUdg4U4teWlDAfGdBfHgwxpU7cAduOsBWmOzsNjxH2V+m52rTrIb+GQRblPf8Y+cmFTXxK6Qpqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854558; 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=yil/qSkj5M/csFVMtFlx3NiFAc3Upos8qedBJ8xz6r4=; b=jetny5qyyz9G8OjAtN2wjBiDJUilUPM8SlNKnJNtv275tC7nvit60wwnPkJyipBYIPWK9jxaSl7yO0eyPsGggQNH0FmNA0c+M1uj2U7ctIjPVpfiezBBzF7UXNQig7NYHVcngrbB3s0D1FPzXJgcJWlsanQuyfk3pR7xAD2W1b8= 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 1771854558042299.1116638584307; Mon, 23 Feb 2026 05:49:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWIw-0000zM-Mb; Mon, 23 Feb 2026 08:48: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 1vuWIK-0000Cp-BW for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWII-00070r-Gn for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:15 -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-664-Zbvm44bXP_uDpkpObTfHCw-1; Mon, 23 Feb 2026 08:48:10 -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 B5BE11956057; Mon, 23 Feb 2026 13:48:09 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3AE321800361; Mon, 23 Feb 2026 13:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854493; 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=yil/qSkj5M/csFVMtFlx3NiFAc3Upos8qedBJ8xz6r4=; b=ceihweFHPNJYIDfKWGQKt8o08AwS6lsLgHJdMTEyaLXaZb5a9EE1R1oPcdM3tgcSwz0EDS iMnyQ6gDAg/cJoZ8C2iKReDFmi/gNPDwlm9p8YFslY/Z+fc9DjPlTzbj0uVGxhCXcnjSgr CkHPG9Fc6ggQkS8UgxdoVYY64QfVybA= X-MC-Unique: Zbvm44bXP_uDpkpObTfHCw-1 X-Mimecast-MFC-AGG-ID: Zbvm44bXP_uDpkpObTfHCw_1771854489 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow , Cleber Rosa Subject: [PULL v3 13/85] scripts/modinfo: use f-strings Date: Mon, 23 Feb 2026 14:46:14 +0100 Message-ID: <20260223134731.2377432-14-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854558775158500 From: Marc-Andr=C3=A9 Lureau Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/modinfo-generate.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/modinfo-generate.py b/scripts/modinfo-generate.py index 63093a0f820..8011c842caf 100644 --- a/scripts/modinfo-generate.py +++ b/scripts/modinfo-generate.py @@ -9,7 +9,7 @@ def print_array(name: str, values: list[str]) -> None: if len(values) =3D=3D 0: return list =3D ", ".join(values) - print(" .%s =3D ((const char*[]){ %s, NULL })," % (name, list)) + print(f" .{name} =3D ((const char*[]){{ {list}, NULL }}),") =20 def parse_line(line: str) -> tuple[str, str]: kind =3D "" @@ -53,17 +53,16 @@ def generate(name: str, lines: list[str], enabled: set[= str]) -> Optional[set[str # don't add a module which dependency is not enabled # in kconfig if data.strip() not in enabled: - print(" /* module {} isn't enabled in Kconfig. */" - .format(data.strip())) + print(f" /* module {data.strip()} isn't enabled in = Kconfig. */") print("/* },{ */") return None else: print("unknown:", kind) exit(1) =20 - print(" .name =3D \"%s\"," % name) + print(f' .name =3D "{name}",') if arch !=3D "": - print(" .arch =3D %s," % arch) + print(f" .arch =3D {arch},") print_array("objs", objs) print_array("deps", deps) print_array("opts", opts) @@ -100,7 +99,7 @@ def main(args: list[str]) -> None: for modinfo in args[2:]: with open(modinfo) as f: lines =3D f.readlines() - print(" /* %s */" % modinfo) + print(f" /* {modinfo} */") (basename, _) =3D os.path.splitext(modinfo) moddeps =3D generate(basename, lines, enabled) if moddeps is not None: @@ -110,8 +109,7 @@ def main(args: list[str]) -> None: =20 error =3D False for dep in deps.difference(modules): - print("Dependency {} cannot be satisfied".format(dep), - file=3Dsys.stderr) + print(f"Dependency {dep} cannot be satisfied", file=3Dsys.stderr) error =3D True =20 if error: --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854612; cv=none; d=zohomail.com; s=zohoarc; b=IUumsPzGMUEUr1gmBpU9LUsCahmI7S557VDq5LI99sOazDoFXnqNridSy+BkLTgnnaa3KLcUnQGk+7104E62+nDCsjaQBG48596UJ/J5pmGgNECKGyExaeqgraCxpm/oytMqDTKBdSzFqrULmI+md/LEao7zVIwzD/WYOAaMGBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854612; 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=5fyZcdE9s/wqXZGBK+GCcVOqAQZtud4UZZpyJvMPL/w=; b=XDjFD5J3cfhD1zwXbINzgU8+/y27x/prLQ/S77IxL20WjY1+e2zRLpuvXislPfcL+KMraVOzVDlOarcQWz/yhwPfDF1F8gvbhDI6nfsuPQKcbmoC9b6VBjA+sB63PEVV7Rqz9nKfVvKrYDsFxV/IkM1JECLTyLZAn05Xz8T4WD4= 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 1771854612724895.612728436887; Mon, 23 Feb 2026 05:50:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJJ-0001lE-8R; Mon, 23 Feb 2026 08:49: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 1vuWIK-0000F9-Q7 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:17 -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 1vuWII-00070w-Uo for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:16 -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-381-OMTi_iPONDqoNwxcjDEWNg-1; Mon, 23 Feb 2026 08:48:12 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E46C91956059; Mon, 23 Feb 2026 13:48:11 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6A2581800465; Mon, 23 Feb 2026 13:48:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854494; 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=5fyZcdE9s/wqXZGBK+GCcVOqAQZtud4UZZpyJvMPL/w=; b=FlWqbt5700E+sXTvHTpG0jRubkdItUf93k38BQOm0VwtvMmrsJKDu3PQbFrbVYpP0C/J6D sRXCiRHw0beV1b8NQrEj6tycwGS8nzciG/B29TuKveVNBXPy53zkMNWo77xgDbYUYqOfPs 7kqAyE1b5Ybb5OFVEXsRHBhBT3LwXQE= X-MC-Unique: OMTi_iPONDqoNwxcjDEWNg-1 X-Mimecast-MFC-AGG-ID: OMTi_iPONDqoNwxcjDEWNg_1771854492 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow , Cleber Rosa Subject: [PULL v3 14/85] scripts/modinfo: use argparse Date: Mon, 23 Feb 2026 14:46:15 +0100 Message-ID: <20260223134731.2377432-15-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854613224158500 From: Marc-Andr=C3=A9 Lureau This will allow to tweak argument handling more easily next. Acked-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/modinfo-generate.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/scripts/modinfo-generate.py b/scripts/modinfo-generate.py index 8011c842caf..777d419aa33 100644 --- a/scripts/modinfo-generate.py +++ b/scripts/modinfo-generate.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 =20 +import argparse import os import sys from typing import Optional @@ -79,24 +80,28 @@ def print_post() -> None: print(" /* end of list */") print("}};") =20 -def main(args: list[str]) -> None: - if len(args) < 3 or args[0] !=3D '--devices': - print('Expected: modinfo-generate.py --devices ' - 'config-device.mak [modinfo files]', file=3Dsys.stderr) - exit(1) +def main() -> None: + parser =3D argparse.ArgumentParser( + description=3D'Generate C code for QEMU module info' + ) + parser.add_argument('--devices', required=3DTrue, + help=3D'path to config-device.mak') + parser.add_argument('modinfo', nargs=3D'+', + help=3D'modinfo files to process') + args =3D parser.parse_args() =20 # get all devices enabled in kconfig, from *-config-device.mak enabled =3D set() - with open(args[1]) as file: + with open(args.devices) as file: for line in file.readlines(): config =3D line.split('=3D') if config[1].rstrip() =3D=3D 'y': - enabled.add(config[0][7:]) # remove CONFIG_ + enabled.add(config[0][7:]) # remove CONFIG_ =20 deps =3D set() modules =3D set() print_pre() - for modinfo in args[2:]: + for modinfo in args.modinfo: with open(modinfo) as f: lines =3D f.readlines() print(f" /* {modinfo} */") @@ -116,4 +121,4 @@ def main(args: list[str]) -> None: exit(1) =20 if __name__ =3D=3D "__main__": - main(sys.argv[1:]) + main() --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854614; cv=none; d=zohomail.com; s=zohoarc; b=lrsd11JtF0x+Z69vA95DlxsW492KPivGsIvF/p9QZZlvFXboXY3LC8dAb7ZHDSrGKKlbMdx+1LqGxxI5Mx6fkzf4HjuxGrFw/MW5iM74rXG4Az0pKke4AGYNE8S7exlBGjWddkQecI1V+g2YyvRyGyPN4GJ42sKEJbcyKC86JZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854614; 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=u/09w0J2YpkpDAMjN66q20SGVs5ABPk/vfQW5xglbdY=; b=C2S9yiWIiOBC8OrA+ZouPQGtQeYr1ch8ErYljJ55zl4q5HHhCfimyR+dEmSMBZIgguc86fmopsrKLzkyKugyjum57+n80UnPAXIR80YSAAw5rirkkBRljq3EtbC2gCioT1IEXEhiSbdfnBsoOs3pLVs1yTRFoI3dhHVoaoiEoi0= 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 177185461469992.11592933581665; Mon, 23 Feb 2026 05:50:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJP-0002T1-5I; Mon, 23 Feb 2026 08:49: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 1vuWIO-0000ML-To for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48: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 1vuWIN-00071W-GQ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:20 -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-396-Mt4HZNWuP7WA_z6BKT4Rww-1; Mon, 23 Feb 2026 08:48:15 -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 744501955F3B; Mon, 23 Feb 2026 13:48:14 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E6E2B19560A3; Mon, 23 Feb 2026 13:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854498; 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=u/09w0J2YpkpDAMjN66q20SGVs5ABPk/vfQW5xglbdY=; b=YpG2KJzVAVRGg+dMOgYEyP81rkpqu90VlfSfZPOfSHNfEYbT21+lfRNxd+8+CsV0x511hF 3yPvWmkHOXwJhbrZK/2kOaXTQL+TG16ojgKEWnTkMHx1fKvLgdapOQ3Ow8DTpEt3c2B44U ZayD40O7OdKezH4jaqO5+h34lCZPfbU= X-MC-Unique: Mt4HZNWuP7WA_z6BKT4Rww-1 X-Mimecast-MFC-AGG-ID: Mt4HZNWuP7WA_z6BKT4Rww_1771854494 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow , Cleber Rosa Subject: [PULL v3 15/85] scripts/modinfo: make --devices optional Date: Mon, 23 Feb 2026 14:46:16 +0100 Message-ID: <20260223134731.2377432-16-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854615073158500 From: Marc-Andr=C3=A9 Lureau This will allow to use modinfo-generate in cases where devices aren't relevant (tests etc) Acked-by: Mark Cave-Ayland w Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/modinfo-generate.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/modinfo-generate.py b/scripts/modinfo-generate.py index 777d419aa33..e7d35242414 100644 --- a/scripts/modinfo-generate.py +++ b/scripts/modinfo-generate.py @@ -84,7 +84,7 @@ def main() -> None: parser =3D argparse.ArgumentParser( description=3D'Generate C code for QEMU module info' ) - parser.add_argument('--devices', required=3DTrue, + parser.add_argument('--devices', help=3D'path to config-device.mak') parser.add_argument('modinfo', nargs=3D'+', help=3D'modinfo files to process') @@ -92,11 +92,12 @@ def main() -> None: =20 # get all devices enabled in kconfig, from *-config-device.mak enabled =3D set() - with open(args.devices) as file: - for line in file.readlines(): - config =3D line.split('=3D') - if config[1].rstrip() =3D=3D 'y': - enabled.add(config[0][7:]) # remove CONFIG_ + if args.devices: + with open(args.devices) as file: + for line in file.readlines(): + config =3D line.split('=3D') + if config[1].rstrip() =3D=3D 'y': + enabled.add(config[0][7:]) # remove CONFIG_ =20 deps =3D set() modules =3D set() --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854614; cv=none; d=zohomail.com; s=zohoarc; b=M+ctLZbRaXxATSNeTJnVRwiWIU6zsaiiIZ4RgBHyg9Cvkw50BcMuZNIUE73JGLpc8Eo7GAAf6JTgJS4AIMoL92l7ffDtcPWaBNbpJDAbugs319z/sjG0IkWM+GkwBaugoPKsBS/pgx16c9niNsl9EeYexuFL5I6Xw485IVJ2hoE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854614; 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=EisfrH5uyaZ3Qtm/HElCzA94VR6sfQSsWLN8AQdU/No=; b=JbJupa6VmZ9dHflWS6tfUCsXwFmV1Rnh5sifbdyECxSrlJmyGnx7KXbt8uvJnj8r45RFOoFdk/kPnryOdSDblbd/oktai1UraKjbseC8DWdXR/m6M40aYd1IYq75iLnwbr30xymDLqJEAoLA7IAkm40ga/E7JWb5703tyoxFcbk= 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 1771854614439344.9757510322903; Mon, 23 Feb 2026 05:50:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJI-0001Us-1z; Mon, 23 Feb 2026 08:49: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 1vuWIP-0000MZ-AX for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:22 -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 1vuWIN-00071c-Ke for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:21 -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-681-oG-AOCxnMMOVFvO8EWh9Zg-1; Mon, 23 Feb 2026 08:48:17 -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 A69B219560B3; Mon, 23 Feb 2026 13:48:16 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2661530001BE; Mon, 23 Feb 2026 13:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854498; 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=EisfrH5uyaZ3Qtm/HElCzA94VR6sfQSsWLN8AQdU/No=; b=YNfCaKqcKY8LX404K7Ly9k9yxIx8bvfAoVBjwJA/+eJVOpWFExPwpbPO+e6z0+g02ULmPr i9N4W2uHhIJxHpj87GPlxubpR0vihKeyGoqMWxwe4J50zPOJiqy9xgYneliT6l2p7MYYfr Fqw6+EIMtD8adRhVSBnvwFp4SfTTXgE= X-MC-Unique: oG-AOCxnMMOVFvO8EWh9Zg-1 X-Mimecast-MFC-AGG-ID: oG-AOCxnMMOVFvO8EWh9Zg_1771854496 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow , Cleber Rosa Subject: [PULL v3 16/85] scripts/modinfo: add --skip-missing-deps Date: Mon, 23 Feb 2026 14:46:17 +0100 Message-ID: <20260223134731.2377432-17-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854615115158500 From: Marc-Andr=C3=A9 Lureau Add --skip-missing-deps flag that prints warnings for missing dependencies but continues without exiting with error code 1. Acked-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/modinfo-generate.py | 94 ++++++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 23 deletions(-) diff --git a/scripts/modinfo-generate.py b/scripts/modinfo-generate.py index e7d35242414..e231c129196 100644 --- a/scripts/modinfo-generate.py +++ b/scripts/modinfo-generate.py @@ -34,7 +34,8 @@ def parse_line(line: str) -> tuple[str, str]: continue return (kind, data) =20 -def generate(name: str, lines: list[str], enabled: set[str]) -> Optional[s= et[str]]: +def parse_modinfo(name: str, lines: list[str], enabled: set[str]) -> Optio= nal[dict]: + """Parse a modinfo file and return module metadata, or None if disable= d.""" arch =3D "" objs =3D [] deps =3D [] @@ -54,21 +55,39 @@ def generate(name: str, lines: list[str], enabled: set[= str]) -> Optional[set[str # don't add a module which dependency is not enabled # in kconfig if data.strip() not in enabled: - print(f" /* module {data.strip()} isn't enabled in = Kconfig. */") - print("/* },{ */") return None else: print("unknown:", kind) exit(1) =20 - print(f' .name =3D "{name}",') - if arch !=3D "": - print(f" .arch =3D {arch},") - print_array("objs", objs) - print_array("deps", deps) - print_array("opts", opts) + return { + 'name': name, + 'arch': arch, + 'objs': objs, + 'deps': deps, + 'opts': opts, + 'dep_names': {dep.strip('" ') for dep in deps} + } + +def generate(modinfo: str, mod: Optional[dict], + skip_reason: Optional[str]) -> None: + """Generate C code for a module.""" + print(f" /* {modinfo} */") + if mod is None: + if skip_reason =3D=3D "missing_deps": + print(" /* module has missing dependencies. */") + else: + print(" /* module isn't enabled in Kconfig. */") + print("/* },{ */") + return + + print(f' .name =3D "{mod["name"]}",') + if mod['arch'] !=3D "": + print(f" .arch =3D {mod['arch']},") + print_array("objs", mod['objs']) + print_array("deps", mod['deps']) + print_array("opts", mod['opts']) print("},{") - return {dep.strip('" ') for dep in deps} =20 def print_pre() -> None: print("/* generated by scripts/modinfo-generate.py */") @@ -86,6 +105,8 @@ def main() -> None: ) parser.add_argument('--devices', help=3D'path to config-device.mak') + parser.add_argument('--skip-missing-deps', action=3D'store_true', + help=3D'warn if a dependency is missing and contin= ue') parser.add_argument('modinfo', nargs=3D'+', help=3D'modinfo files to process') args =3D parser.parse_args() @@ -99,27 +120,54 @@ def main() -> None: if config[1].rstrip() =3D=3D 'y': enabled.add(config[0][7:]) # remove CONFIG_ =20 - deps =3D set() - modules =3D set() - print_pre() + # all_modules: modinfo path -> (basename, parsed module or None, skip_= reason) + all_modules =3D {} for modinfo in args.modinfo: with open(modinfo) as f: lines =3D f.readlines() - print(f" /* {modinfo} */") (basename, _) =3D os.path.splitext(modinfo) - moddeps =3D generate(basename, lines, enabled) - if moddeps is not None: - modules.add(basename) - deps.update(moddeps) - print_post() + mod =3D parse_modinfo(basename, lines, enabled) + skip_reason =3D "kconfig" if mod is None else None + all_modules[modinfo] =3D (basename, mod, skip_reason) + + # Collect all available module names + available =3D {basename for basename, mod, _ in all_modules.values() + if mod is not None} =20 - error =3D False - for dep in deps.difference(modules): + # Collect all dependencies + all_deps =3D set() + for basename, mod, _ in all_modules.values(): + if mod is not None: + all_deps.update(mod['dep_names']) + + # Check for missing dependencies + missing =3D all_deps.difference(available) + for dep in missing: print(f"Dependency {dep} cannot be satisfied", file=3Dsys.stderr) - error =3D True =20 - if error: + if missing and not args.skip_missing_deps: exit(1) =20 + # When skipping missing deps, iteratively remove modules with + # unsatisfiable dependencies + if args.skip_missing_deps and missing: + changed =3D True + while changed: + changed =3D False + for modinfo, (basename, mod, skip_reason) in list(all_modules.= items()): + if mod is None: + continue + if not mod['dep_names'].issubset(available): + available.discard(basename) + all_modules[modinfo] =3D (basename, None, "missing_dep= s") + changed =3D True + + # generate output + print_pre() + for modinfo in args.modinfo: + (basename, mod, skip_reason) =3D all_modules[modinfo] + generate(modinfo, mod, skip_reason) + print_post() + if __name__ =3D=3D "__main__": main() --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854566; cv=none; d=zohomail.com; s=zohoarc; b=VXQbGx+zfTo67MCMzokGHfrfz0VgBMyufZrFbcp+/vGAYvcPqxjCzvi5Aqq+/cSdRTjkPLqtUlUQCzO5U4fetysHPYS3Q8Ab2I6OY8HkfSaJaIx7ipFKSYTlCv1UioEAB5BnRf9B6VDj63pZ6Q6zDGmIrcDxubVhaoqAcKlHCYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854566; 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=2klOYhoQ4fGAi4xB2sFPG+TEpv5+uqPlzGLBDNFYtXM=; b=NaVKg3XvKIK0BXWOzsuwlE4oedg1x/jYcAXvCESvdwAeu7JuZFx0FH5Z40WirAbzEbsbBos3ggX4K8nGYjHW4bR6qeWcaF8uGtnuRT4sA4pvnnCCpZWipMNYrOAPiKJr6tFAXD50H/3KfArQFpCG6qtQIjAUjdePOGFjSr/LLm8= 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 1771854566390676.1087979248866; Mon, 23 Feb 2026 05:49:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJJ-0001oP-Fu; Mon, 23 Feb 2026 08:49: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 1vuWIW-0000Sa-3c for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:29 -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 1vuWIS-00072Q-5l for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48: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-550-CJmoz9aUMaaZvfrBMS7DNw-1; Mon, 23 Feb 2026 08:48:20 -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 4CA5F180025E; Mon, 23 Feb 2026 13:48:19 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 989A730001BE; Mon, 23 Feb 2026 13:48:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854503; 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=2klOYhoQ4fGAi4xB2sFPG+TEpv5+uqPlzGLBDNFYtXM=; b=QowFK/35UtT3aiz62Rt7n0wuGcOuOyacdMtJRDOfHs8+5rYvR1icqFXPJ93akwXdKNkY14 KqZ870iVGqESRtEGf0lsfO8asd3uwEwKCh1wiWD1ww54OLAefYQuF1J/nNNOWaVZMh1OKT aexcyNMH8F0TRM/EFSCwed1sSk7BJvg= X-MC-Unique: CJmoz9aUMaaZvfrBMS7DNw-1 X-Mimecast-MFC-AGG-ID: CJmoz9aUMaaZvfrBMS7DNw_1771854499 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Subject: [PULL v3 17/85] util: add some extra stubs for qemu modules initialization Date: Mon, 23 Feb 2026 14:46:18 +0100 Message-ID: <20260223134731.2377432-18-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854566750158500 From: Marc-Andr=C3=A9 Lureau Avoid extra ifdef-ery when optionally supporting modules, as done in audio-test (and vl.c). Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- system/vl.c | 2 -- util/module.c | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/system/vl.c b/system/vl.c index aa9a1550417..3e341142a0c 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2889,10 +2889,8 @@ void qemu_init(int argc, char **argv) =20 os_setup_limits(); =20 -#ifdef CONFIG_MODULES module_init_info(qemu_modinfo); module_allow_arch(target_name()); -#endif =20 qemu_init_subsystems(); =20 diff --git a/util/module.c b/util/module.c index 1aa2079d013..09dc43f51eb 100644 --- a/util/module.c +++ b/util/module.c @@ -396,6 +396,9 @@ void qemu_load_module_for_opts(const char *group) =20 #else =20 +const QemuModinfo qemu_modinfo[] =3D {}; + +void module_init_info(const QemuModinfo *info) {} void module_allow_arch(const char *arch) {} void qemu_load_module_for_opts(const char *group) {} int module_load(const char *prefix, const char *name, Error **errp) { retu= rn 2; } --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854559; cv=none; d=zohomail.com; s=zohoarc; b=GfF6+fXn8YD+nYgYM965qeA1SJ8QfopEfvg6izyN2XqSxEBXaCCRkm5+8a6SVgCnOSQj7ATqN13DQR/DBVYHa5/gB+D5SlyV7nRBuVedoA1cdtO001WjI9rXQ5gvEHOa6JCxZiTdGflNnU89vqk0AeXNn93WNj+VtivtR6PuRT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854559; 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=pJuk4ChSh9AVrJiSUKyWmdUAakOuqgTvT75kzXiLvwc=; b=dt4euZAvUDjVpFXpXnUiCVBSAz4ze+ddfPkrTZpWpQEvKvPN+17QRNdi8wWryo87kyeiddJJWaRD5MJpVua/mMPBbGFMIRIcZKCDfwrsF+Va7jDBjgqFx0d83BjZsYQmnc2JMmuX43ZhJFVhBXx9+gGerUuMrRnDREx7NFuh/YU= 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 1771854559975346.030939514529; Mon, 23 Feb 2026 05:49:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWIy-00012j-L3; Mon, 23 Feb 2026 08:48:58 -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 1vuWIW-0000Sq-Ax for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:30 -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 1vuWIT-00072Y-Fx for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:28 -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-339-EKIjB6CbPwqerZqSmtwkbw-1; Mon, 23 Feb 2026 08:48:23 -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 46B201800265; Mon, 23 Feb 2026 13:48:22 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 206E71955F22; Mon, 23 Feb 2026 13:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854504; 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=pJuk4ChSh9AVrJiSUKyWmdUAakOuqgTvT75kzXiLvwc=; b=afneGewLnQbpbPx2pAJyEEuwpdKzrOPqql0m86uVhF5iu6ArxpeOJJMiY7qvszA0hNK8Y6 IayrMxQexR7JbeKrGHgzP7GaItwOy/qSusPs5PbcKlMO34nrrB3QFYreP56VW8Z4fJcOj6 Dtxao1M2xO45yR9TxgMXpZxjsg+2JcA= X-MC-Unique: EKIjB6CbPwqerZqSmtwkbw-1 X-Mimecast-MFC-AGG-ID: EKIjB6CbPwqerZqSmtwkbw_1771854502 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL v3 18/85] tests: start manual audio backend test Date: Mon, 23 Feb 2026 14:46:19 +0100 Message-ID: <20260223134731.2377432-19-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01 autolearn=no 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: 1771854560948158500 From: Marc-Andr=C3=A9 Lureau Start a simple test program that will exercise the QEMU audio APIs. It is meant to run manually for now, as it accesses the sound system and produces sound by default, and also runs for a few seconds. We may want to make it silent or use the "none" (noaudio) backend by default though, so it can run as part of the automated test suite. Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- MAINTAINERS | 1 + meson.build | 17 +- tests/audio/audio-stubs.c | 62 ++++ tests/audio/test-audio.c | 599 ++++++++++++++++++++++++++++++++++++++ audio/meson.build | 2 +- tests/audio/meson.build | 23 ++ tests/meson.build | 1 + ui/meson.build | 3 + 8 files changed, 702 insertions(+), 6 deletions(-) create mode 100644 tests/audio/audio-stubs.c create mode 100644 tests/audio/test-audio.c create mode 100644 tests/audio/meson.build diff --git a/MAINTAINERS b/MAINTAINERS index 4918f41ec45..233d2a5e71f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3036,6 +3036,7 @@ X: audio/sndioaudio.c X: audio/spiceaudio.c F: include/qemu/audio*.h F: qapi/audio.json +F: tests/audio/ =20 ALSA Audio backend M: Gerd Hoffmann diff --git a/meson.build b/meson.build index 17c4afdd45e..414c8ea7e28 100644 --- a/meson.build +++ b/meson.build @@ -3879,6 +3879,7 @@ target_modules +=3D { 'accel' : { 'qtest': qtest_modu= le_ss }} modinfo_collect =3D find_program('scripts/modinfo-collect.py') modinfo_generate =3D find_program('scripts/modinfo-generate.py') modinfo_files =3D [] +audio_modinfo_files =3D [] =20 block_mods =3D [] system_mods =3D [] @@ -3906,15 +3907,21 @@ foreach d, list : modules install: true, install_dir: qemu_moddir) if module_ss.sources() !=3D [] - modinfo_files +=3D custom_target(d + '-' + m + '.modinfo', - output: d + '-' + m + '.modinfo', - input: sl.extract_all_objects(recur= sive: true), - capture: true, - command: [modinfo_collect, '@INPUT@= ']) + modinfo =3D custom_target(d + '-' + m + '.modinfo', + output: d + '-' + m + '.modinfo', + input: sl.extract_all_objects(recursive: t= rue), + capture: true, + command: [modinfo_collect, '@INPUT@']) + modinfo_files +=3D modinfo + if d =3D=3D 'audio' + audio_modinfo_files +=3D modinfo + endif endif else if d =3D=3D 'block' block_ss.add_all(module_ss) + elif d =3D=3D 'audio' + audio_ss.add_all(module_ss) else system_ss.add_all(module_ss) endif diff --git a/tests/audio/audio-stubs.c b/tests/audio/audio-stubs.c new file mode 100644 index 00000000000..dd7f635d460 --- /dev/null +++ b/tests/audio/audio-stubs.c @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/* + * Stubs for audio test - provides missing functions for standalone audio = test + */ + +#include "qemu/osdep.h" +#include "qemu/dbus.h" +#include "ui/qemu-spice-module.h" +#include "ui/dbus-module.h" +#include "system/replay.h" +#include "system/runstate.h" + +int using_spice; +int using_dbus_display; + +struct QemuSpiceOps qemu_spice; + +GQuark dbus_display_error_quark(void) +{ + return g_quark_from_static_string("dbus-display-error-quark"); +} + +#ifdef WIN32 +/* from ui/dbus.h */ +bool +dbus_win32_import_socket(GDBusMethodInvocation *invocation, + GVariant *arg_listener, int *socket); + +bool +dbus_win32_import_socket(GDBusMethodInvocation *invocation, + GVariant *arg_listener, int *socket) +{ + return true; +} +#endif + +void replay_audio_in(size_t *recorded, st_sample *samples, + size_t *wpos, size_t size) +{ +} + +void replay_audio_out(size_t *played) +{ +} + +static int dummy_vmse; + +VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler = *cb, + void *opaque) +{ + return (VMChangeStateEntry *)&dummy_vmse; +} + +void qemu_del_vm_change_state_handler(VMChangeStateEntry *e) +{ +} + +bool runstate_is_running(void) +{ + return true; +} diff --git a/tests/audio/test-audio.c b/tests/audio/test-audio.c new file mode 100644 index 00000000000..edb4971972c --- /dev/null +++ b/tests/audio/test-audio.c @@ -0,0 +1,599 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include "qemu/osdep.h" +#include "qemu/config-file.h" +#include "qemu/cutils.h" +#include "qemu/help_option.h" +#include "qemu/module.h" +#include "qemu/main-loop.h" +#include "qemu/audio.h" +#include "qemu/log.h" +#include "qapi/error.h" +#include "trace/control.h" +#include "glib.h" + +#include "audio/audio_int.h" + +#include +#ifdef CONFIG_SDL +/* + * SDL insists on wrapping the main() function with its own implementation= on + * some platforms; it does so via a macro that renames our main function, = so + * must be #included here even with no SDL code called from this f= ile. + */ +#include +#endif + +#define SAMPLE_RATE 44100 +#define CHANNELS 2 +#define DURATION_SECS 2 +#define FREQUENCY 440.0 +#define BUFFER_FRAMES 1024 +#define TIMEOUT_SECS (DURATION_SECS + 1) + +/* Command-line options */ +static gchar *opt_audiodev; +static gchar *opt_trace; + +static GOptionEntry test_options[] =3D { + { "audiodev", 'a', 0, G_OPTION_ARG_STRING, &opt_audiodev, + "Audio device spec (e.g., none or pa,out.buffer-length=3D50000)", "D= EV" }, + { "trace", 'T', 0, G_OPTION_ARG_STRING, &opt_trace, + "Trace options (e.g., 'pw_*')", "TRACE" }, + { NULL } +}; + +#define TEST_AUDIODEV_ID "test" + +typedef struct TestSineState { + AudioBackend *be; + SWVoiceOut *voice; + int64_t total_frames; + int64_t frames_written; +} TestSineState; + +/* Default audio settings for tests */ +static const struct audsettings default_test_settings =3D { + .freq =3D SAMPLE_RATE, + .nchannels =3D CHANNELS, + .fmt =3D AUDIO_FORMAT_S16, + .endianness =3D 0, +}; + +static void dummy_audio_callback(void *opaque, int avail) +{ +} + +static AudioBackend *get_test_audio_backend(void) +{ + AudioBackend *be; + Error *err =3D NULL; + + if (opt_audiodev) { + be =3D audio_be_by_name(TEST_AUDIODEV_ID, &err); + } else { + be =3D audio_get_default_audio_be(&err); + } + + if (err) { + g_error("%s", error_get_pretty(err)); + error_free(err); + exit(1); + } + g_assert_nonnull(be); + return be; +} + +/* + * Helper functions for opening test voices with default settings. + * These reduce boilerplate in test functions. + */ +static SWVoiceOut *open_test_voice_out(AudioBackend *be, const char *name, + void *opaque, audio_callback_fn cb) +{ + struct audsettings as =3D default_test_settings; + SWVoiceOut *voice; + + voice =3D AUD_open_out(be, NULL, name, opaque, cb, &as); + g_assert_nonnull(voice); + return voice; +} + +static SWVoiceIn *open_test_voice_in(AudioBackend *be, const char *name, + void *opaque, audio_callback_fn cb) +{ + struct audsettings as =3D default_test_settings; + + return AUD_open_in(be, NULL, name, opaque, cb, &as); +} + +/* + * Generate 440Hz sine wave samples into buffer. + */ +static void generate_sine_samples(int16_t *buffer, int frames, + int64_t start_frame) +{ + for (int i =3D 0; i < frames; i++) { + double t =3D (double)(start_frame + i) / SAMPLE_RATE; + double sample =3D sin(2.0 * M_PI * FREQUENCY * t); + int16_t s =3D (int16_t)(sample * 32767.0); + + buffer[i * 2] =3D s; /* left channel */ + buffer[i * 2 + 1] =3D s; /* right channel */ + } +} + +static void test_sine_callback(void *opaque, int avail) +{ + TestSineState *s =3D opaque; + int16_t buffer[BUFFER_FRAMES * CHANNELS]; + int frames_remaining; + int frames_to_write; + size_t bytes_written; + + frames_remaining =3D s->total_frames - s->frames_written; + if (frames_remaining <=3D 0) { + return; + } + + frames_to_write =3D avail / (sizeof(int16_t) * CHANNELS); + frames_to_write =3D MIN(frames_to_write, BUFFER_FRAMES); + frames_to_write =3D MIN(frames_to_write, frames_remaining); + + generate_sine_samples(buffer, frames_to_write, s->frames_written); + + bytes_written =3D AUD_write(s->voice, buffer, + frames_to_write * sizeof(int16_t) * CHANNELS= ); + s->frames_written +=3D bytes_written / (sizeof(int16_t) * CHANNELS); +} + + +static void test_audio_out_sine_wave(void) +{ + TestSineState state =3D {0}; + int64_t start_time; + int64_t elapsed_ms; + + state.be =3D get_test_audio_backend(); + state.total_frames =3D SAMPLE_RATE * DURATION_SECS; + state.frames_written =3D 0; + + g_test_message("Opening audio output..."); + state.voice =3D open_test_voice_out(state.be, "test-sine", + &state, test_sine_callback); + + g_test_message("Playing 440Hz sine wave for %d seconds...", DURATION_S= ECS); + AUD_set_active_out(state.voice, true); + + /* + * Run the audio subsystem until all frames are written or timeout. + */ + start_time =3D g_get_monotonic_time(); + while (state.frames_written < state.total_frames) { + audio_run(state.be, "test"); + main_loop_wait(true); + + elapsed_ms =3D (g_get_monotonic_time() - start_time) / 1000; + if (elapsed_ms > TIMEOUT_SECS * 1000) { + g_test_message("Timeout waiting for audio to complete"); + break; + } + + g_usleep(G_USEC_PER_SEC / 100); /* 10ms */ + } + + g_test_message("Wrote %" PRId64 " frames (%.2f seconds)", + state.frames_written, + (double)state.frames_written / SAMPLE_RATE); + + g_assert_cmpint(state.frames_written, =3D=3D, state.total_frames); + + AUD_set_active_out(state.voice, false); + AUD_close_out(state.be, state.voice); +} + +static void test_audio_prio_list(void) +{ + g_autofree gchar *backends =3D NULL; + GString *str =3D g_string_new(NULL); + bool has_none =3D false; + + for (int i =3D 0; audio_prio_list[i]; i++) { + if (i > 0) { + g_string_append_c(str, ' '); + } + g_string_append(str, audio_prio_list[i]); + + if (g_strcmp0(audio_prio_list[i], "none") =3D=3D 0) { + has_none =3D true; + } + } + + backends =3D g_string_free(str, FALSE); + g_test_message("Available backends: %s", backends); + + /* The 'none' backend should always be available */ + g_assert_true(has_none); +} + +static void test_audio_out_active_state(void) +{ + AudioBackend *be; + SWVoiceOut *voice; + + be =3D get_test_audio_backend(); + voice =3D open_test_voice_out(be, "test-active", NULL, dummy_audio_cal= lback); + + g_assert_false(AUD_is_active_out(voice)); + + AUD_set_active_out(voice, true); + g_assert_true(AUD_is_active_out(voice)); + + AUD_set_active_out(voice, false); + g_assert_false(AUD_is_active_out(voice)); + + AUD_close_out(be, voice); +} + +static void test_audio_out_buffer_size(void) +{ + AudioBackend *be; + SWVoiceOut *voice; + int buffer_size; + + be =3D get_test_audio_backend(); + voice =3D open_test_voice_out(be, "test-buffer", NULL, dummy_audio_cal= lback); + + buffer_size =3D AUD_get_buffer_size_out(voice); + g_test_message("Buffer size: %d bytes", buffer_size); + g_assert_cmpint(buffer_size, >, 0); + + AUD_close_out(be, voice); + + g_assert_cmpint(AUD_get_buffer_size_out(NULL), =3D=3D, 0); +} + +static void test_audio_out_volume(void) +{ + AudioBackend *be; + SWVoiceOut *voice; + Volume vol; + + be =3D get_test_audio_backend(); + voice =3D open_test_voice_out(be, "test-volume", NULL, dummy_audio_cal= lback); + + vol =3D (Volume){ .mute =3D false, .channels =3D 2, .vol =3D {255, 255= } }; + AUD_set_volume_out(voice, &vol); + + vol =3D (Volume){ .mute =3D true, .channels =3D 2, .vol =3D {255, 255}= }; + AUD_set_volume_out(voice, &vol); + + vol =3D (Volume){ .mute =3D false, .channels =3D 2, .vol =3D {128, 128= } }; + AUD_set_volume_out(voice, &vol); + + AUD_close_out(be, voice); +} + +static void test_audio_in_active_state(void) +{ + AudioBackend *be; + SWVoiceIn *voice; + + be =3D get_test_audio_backend(); + voice =3D open_test_voice_in(be, "test-in-active", NULL, dummy_audio_c= allback); + if (!voice) { + g_test_skip("The backend may not support input"); + return; + } + + g_assert_false(AUD_is_active_in(voice)); + + AUD_set_active_in(voice, true); + g_assert_true(AUD_is_active_in(voice)); + + AUD_set_active_in(voice, false); + g_assert_false(AUD_is_active_in(voice)); + + AUD_close_in(be, voice); +} + +static void test_audio_in_volume(void) +{ + AudioBackend *be; + SWVoiceIn *voice; + Volume vol; + + be =3D get_test_audio_backend(); + voice =3D open_test_voice_in(be, "test-in-volume", NULL, dummy_audio_c= allback); + if (!voice) { + g_test_skip("The backend may not support input"); + return; + } + + vol =3D (Volume){ .mute =3D false, .channels =3D 2, .vol =3D {255, 255= } }; + AUD_set_volume_in(voice, &vol); + + vol =3D (Volume){ .mute =3D true, .channels =3D 2, .vol =3D {255, 255}= }; + AUD_set_volume_in(voice, &vol); + + AUD_close_in(be, voice); +} + + +/* Capture test state */ +#define CAPTURE_BUFFER_FRAMES (SAMPLE_RATE / 10) /* 100ms of audio */ +#define CAPTURE_BUFFER_SIZE (CAPTURE_BUFFER_FRAMES * CHANNELS * sizeof(i= nt16_t)) + +typedef struct TestCaptureState { + bool notify_called; + bool capture_called; + bool destroy_called; + audcnotification_e last_notify; + int16_t *captured_samples; + size_t captured_bytes; + size_t capture_buffer_size; +} TestCaptureState; + +static void test_capture_notify(void *opaque, audcnotification_e cmd) +{ + TestCaptureState *s =3D opaque; + s->notify_called =3D true; + s->last_notify =3D cmd; +} + +static void test_capture_capture(void *opaque, const void *buf, int size) +{ + TestCaptureState *s =3D opaque; + size_t bytes_to_copy; + + s->capture_called =3D true; + + if (!s->captured_samples || s->captured_bytes >=3D s->capture_buffer_s= ize) { + return; + } + + bytes_to_copy =3D MIN(size, s->capture_buffer_size - s->captured_bytes= ); + memcpy((uint8_t *)s->captured_samples + s->captured_bytes, buf, bytes_= to_copy); + s->captured_bytes +=3D bytes_to_copy; +} + +static void test_capture_destroy(void *opaque) +{ + TestCaptureState *s =3D opaque; + s->destroy_called =3D true; +} + +/* + * Compare captured audio with expected sine wave. + * Returns the number of matching samples (within tolerance). + */ +static int compare_sine_samples(const int16_t *captured, int frames, + int64_t start_frame, int tolerance) +{ + int matching =3D 0; + + for (int i =3D 0; i < frames; i++) { + double t =3D (double)(start_frame + i) / SAMPLE_RATE; + double sample =3D sin(2.0 * M_PI * FREQUENCY * t); + int16_t expected =3D (int16_t)(sample * 32767.0); + + /* Check left channel */ + if (abs(captured[i * 2] - expected) <=3D tolerance) { + matching++; + } + /* Check right channel */ + if (abs(captured[i * 2 + 1] - expected) <=3D tolerance) { + matching++; + } + } + + return matching; +} + +static void test_audio_capture(void) +{ + AudioBackend *be; + CaptureVoiceOut *cap; + SWVoiceOut *voice; + TestCaptureState state =3D {0}; + TestSineState sine_state =3D {0}; + struct audsettings as =3D default_test_settings; + struct audio_capture_ops ops =3D { + .notify =3D test_capture_notify, + .capture =3D test_capture_capture, + .destroy =3D test_capture_destroy, + }; + int64_t start_time; + int64_t elapsed_ms; + int captured_frames; + int matching_samples; + int total_samples; + double match_ratio; + + be =3D get_test_audio_backend(); + + state.captured_samples =3D g_malloc0(CAPTURE_BUFFER_SIZE); + state.captured_bytes =3D 0; + state.capture_buffer_size =3D CAPTURE_BUFFER_SIZE; + + cap =3D AUD_add_capture(be, &as, &ops, &state); + g_assert_nonnull(cap); + + sine_state.be =3D be; + sine_state.total_frames =3D CAPTURE_BUFFER_FRAMES; + sine_state.frames_written =3D 0; + + voice =3D open_test_voice_out(be, "test-capture-sine", + &sine_state, test_sine_callback); + sine_state.voice =3D voice; + + AUD_set_active_out(voice, true); + + start_time =3D g_get_monotonic_time(); + while (sine_state.frames_written < sine_state.total_frames || + state.captured_bytes < CAPTURE_BUFFER_SIZE) { + audio_run(be, "test-capture"); + main_loop_wait(true); + + elapsed_ms =3D (g_get_monotonic_time() - start_time) / 1000; + if (elapsed_ms > 1000) { /* 1 second timeout */ + break; + } + + g_usleep(G_USEC_PER_SEC / 1000); /* 1ms */ + } + + g_test_message("Wrote %" PRId64 " frames, captured %zu bytes", + sine_state.frames_written, state.captured_bytes); + + g_assert_true(state.capture_called); + g_assert_cmpuint(state.captured_bytes, >, 0); + + /* Compare captured data with expected sine wave */ + captured_frames =3D state.captured_bytes / (CHANNELS * sizeof(int16_t)= ); + if (captured_frames > 0) { + /* + * Allow some tolerance due to mixing/conversion. + * The tolerance accounts for potential rounding differences. + */ + matching_samples =3D compare_sine_samples(state.captured_samples, + captured_frames, 0, 100); + total_samples =3D captured_frames * CHANNELS; + match_ratio =3D (double)matching_samples / total_samples; + + g_test_message("Captured %d frames, %d/%d samples match (%.1f%%)", + captured_frames, matching_samples, total_samples, + match_ratio * 100.0); + + /* + * Expect at least 90% of samples to match within tolerance. + * Some variation is expected due to mixing engine processing. + */ + g_assert_cmpfloat(match_ratio, >=3D, 0.9); + } + + AUD_set_active_out(voice, false); + AUD_close_out(be, voice); + + AUD_del_capture(cap, &state); + g_assert_true(state.destroy_called); + + g_free(state.captured_samples); +} + +static void test_audio_null_handling(void) +{ + uint8_t buffer[64]; + + /* AUD_is_active_out/in(NULL) should return false */ + g_assert_false(AUD_is_active_out(NULL)); + g_assert_false(AUD_is_active_in(NULL)); + + /* AUD_get_buffer_size_out(NULL) should return 0 */ + g_assert_cmpint(AUD_get_buffer_size_out(NULL), =3D=3D, 0); + + /* AUD_write/read(NULL, ...) should return size (no-op) */ + g_assert_cmpuint(AUD_write(NULL, buffer, sizeof(buffer)), =3D=3D, + sizeof(buffer)); + g_assert_cmpuint(AUD_read(NULL, buffer, sizeof(buffer)), =3D=3D, + sizeof(buffer)); + + /* These should not crash */ + AUD_set_active_out(NULL, true); + AUD_set_active_out(NULL, false); + AUD_set_active_in(NULL, true); + AUD_set_active_in(NULL, false); +} + +static void test_audio_multiple_voices(void) +{ + AudioBackend *be; + SWVoiceOut *out1, *out2; + SWVoiceIn *in1; + + be =3D get_test_audio_backend(); + out1 =3D open_test_voice_out(be, "test-multi-out1", NULL, dummy_audio_= callback); + out2 =3D open_test_voice_out(be, "test-multi-out2", NULL, dummy_audio_= callback); + in1 =3D open_test_voice_in(be, "test-multi-in1", NULL, dummy_audio_cal= lback); + + AUD_set_active_out(out1, true); + AUD_set_active_out(out2, true); + AUD_set_active_in(in1, true); + + g_assert_true(AUD_is_active_out(out1)); + g_assert_true(AUD_is_active_out(out2)); + if (in1) { + g_assert_true(AUD_is_active_in(in1)); + } + + AUD_set_active_out(out1, false); + AUD_set_active_out(out2, false); + AUD_set_active_in(in1, false); + + AUD_close_in(be, in1); + AUD_close_out(be, out2); + AUD_close_out(be, out1); +} + +int main(int argc, char **argv) +{ + GOptionContext *context; + g_autoptr(GError) error =3D NULL; + g_autofree gchar *dir =3D NULL; + int ret; + + context =3D g_option_context_new("- QEMU audio test"); + g_option_context_add_main_entries(context, test_options, NULL); + + if (!g_option_context_parse(context, &argc, &argv, &error)) { + g_printerr("Option parsing failed: %s\n", error->message); + return 1; + } + g_option_context_free(context); + + g_test_init(&argc, &argv, NULL); + + module_call_init(MODULE_INIT_TRACE); + qemu_add_opts(&qemu_trace_opts); + if (opt_trace) { + trace_opt_parse(opt_trace); + qemu_set_log(LOG_TRACE, &error_fatal); + } + trace_init_backends(); + trace_init_file(); + + dir =3D g_test_build_filename(G_TEST_BUILT, "..", "..", NULL); + g_setenv("QEMU_MODULE_DIR", dir, true); + qemu_init_exec_dir(argv[0]); + module_call_init(MODULE_INIT_QOM); + module_init_info(qemu_modinfo); + + qemu_init_main_loop(&error_abort); + if (opt_audiodev) { + g_autofree gchar *spec =3D is_help_option(opt_audiodev) ? + opt_audiodev : g_strdup_printf("%s,id=3D%s", opt_audiodev, TES= T_AUDIODEV_ID); + audio_parse_option(spec); + } + audio_create_default_audiodevs(); + audio_init_audiodevs(); + + g_test_add_func("/audio/prio-list", test_audio_prio_list); + + g_test_add_func("/audio/out/active-state", test_audio_out_active_state= ); + g_test_add_func("/audio/out/sine-wave", test_audio_out_sine_wave); + g_test_add_func("/audio/out/buffer-size", test_audio_out_buffer_size); + g_test_add_func("/audio/out/volume", test_audio_out_volume); + g_test_add_func("/audio/out/capture", test_audio_capture); + + g_test_add_func("/audio/in/active-state", test_audio_in_active_state); + g_test_add_func("/audio/in/volume", test_audio_in_volume); + + g_test_add_func("/audio/null-handling", test_audio_null_handling); + g_test_add_func("/audio/multiple-voices", test_audio_multiple_voices); + + ret =3D g_test_run(); + + audio_cleanup(); + + return ret; +} diff --git a/audio/meson.build b/audio/meson.build index a5fec14fb3a..55ee0bfc865 100644 --- a/audio/meson.build +++ b/audio/meson.build @@ -32,7 +32,7 @@ endforeach if dbus_display module_ss =3D ss.source_set() module_ss.add(when: [gio, pixman], - if_true: [dbus_display1, files('dbusaudio.c')]) + if_true: [dbus_display1_h, files('dbusaudio.c')]) audio_modules +=3D {'dbus': module_ss} endif =20 diff --git a/tests/audio/meson.build b/tests/audio/meson.build new file mode 100644 index 00000000000..84754bde221 --- /dev/null +++ b/tests/audio/meson.build @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +if not have_system + subdir_done() +endif + +modinfo_dep =3D not_found +if enable_modules + modinfo_src =3D custom_target('modinfo.c', + output: 'modinfo.c', + input: audio_modinfo_files, + command: [modinfo_generate, '--skip-missin= g-deps', '@INPUT@'], + capture: true) + + modinfo_lib =3D static_library('modinfo.c', modinfo_src) + modinfo_dep =3D declare_dependency(link_with: modinfo_lib) +endif + +# manual audio test - not part of automated test suite +# as it relies on audio system +executable('test-audio', + sources: [files('test-audio.c', 'audio-stubs.c'), dbus_display1], + dependencies: [audio, qemuutil, modinfo_dep, gio, spice, sdl]) diff --git a/tests/meson.build b/tests/meson.build index 87861b28575..9ba04bbedd3 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -77,6 +77,7 @@ if 'CONFIG_TCG' in config_all_accel subdir('tcg/plugins') endif =20 +subdir('audio') subdir('unit') subdir('qapi-schema') subdir('qtest') diff --git a/ui/meson.build b/ui/meson.build index 6371422c460..69404bca71a 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -70,6 +70,7 @@ if opengl.found() ui_modules +=3D {'egl-headless' : egl_headless_ss} endif =20 +dbus_display1 =3D files() if dbus_display dbus_ss =3D ss.source_set() env =3D environment() @@ -88,6 +89,8 @@ if dbus_display '--interface-prefix', 'org.qemu.= ', '--c-namespace', 'QemuDBus', '--generate-c-code', '@BASENAME@= ']) + dbus_display1_h =3D declare_dependency(dependencies: [gio], + sources: dbus_display1[0]) dbus_ss.add(when: gio, if_true: [files( 'dbus-chardev.c', --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854614; cv=none; d=zohomail.com; s=zohoarc; b=QH9/Jd+Tyt1BTyEiet76PIKolil4W00JKMQm7OTlFw6j39x9+Ic8/2A4LMeB1GSneYQmuX3sFoyW2W+NCRM2Vpd/rKHJAY3GU0SgV1uD45jGGnVrpP5g8YL8fxu3XvN3MxU1Txncm6z4tN1z3fsEJ3uzBAcBJtVrsC3io8zNfJY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854614; 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=DfqZ6h7cKLR2svwZa0HiwkQaHr73PtF2978zuSWfcpI=; b=aLD5ZA6jTYjFvlnSZKwj5jIyXpCbxCkytTtBBlBuz5yyw8DqakTRRUtcuivWXAHLuNf9MvEKY5YhiPdXTPJzzb57XlFPjPoiTYXMb0beAiXy379OOeDDtrOsNR4Q+pq8KdOBWEh1x2f1N2sWGzah2kO3daq/mavgN6xNSuy+YUE= 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 1771854614299728.4341175945158; Mon, 23 Feb 2026 05:50:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJN-0002Gi-1Y; Mon, 23 Feb 2026 08:49:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWIb-0000dV-EE for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48: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 1vuWIY-00073C-GK for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:32 -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-92-MTmSn90RO1yH0MWjFm_xwg-1; Mon, 23 Feb 2026 08:48:26 -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 BA7AE1800365; Mon, 23 Feb 2026 13:48:24 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 384A01955D71; Mon, 23 Feb 2026 13:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854509; 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=DfqZ6h7cKLR2svwZa0HiwkQaHr73PtF2978zuSWfcpI=; b=LxU5vb3yL/nTCtgtj+E2AHGju4BeqAMQRtRRwmjNYQ7S9XY6pBxFwZe8t564YZ6GOSyU1p wGwLKuhVyQX0Mw7FbKj9/MmgARb7mCXRulZ6tA/SV5oraE97Oe5CKVOIx5t/9lj4fAcI1/ 1b6TCQKZ3Uv7iJw3S+Fb0TxCXfSsdtw= X-MC-Unique: MTmSn90RO1yH0MWjFm_xwg-1 X-Mimecast-MFC-AGG-ID: MTmSn90RO1yH0MWjFm_xwg_1771854504 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 19/85] audio: constify audsettings argument Date: Mon, 23 Feb 2026 14:46:20 +0100 Message-ID: <20260223134731.2377432-20-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854617159158500 From: Marc-Andr=C3=A9 Lureau It shouldn't be modified by the audio functions. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 2 +- audio/audio_template.h | 6 +++--- include/qemu/audio.h | 4 ++-- audio/audio.c | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 25de0e3f9cf..a6276375887 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -265,7 +265,7 @@ extern const char *audio_prio_list[]; =20 void audio_driver_register(audio_driver *drv); =20 -void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings = *as); +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); diff --git a/audio/audio_template.h b/audio/audio_template.h index 1ab3c47fd76..e69e6e74570 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -159,7 +159,7 @@ static int glue (audio_pcm_sw_init_, TYPE) ( SW *sw, HW *hw, const char *name, - struct audsettings *as + const struct audsettings *as ) { int err; @@ -426,7 +426,7 @@ static HW *glue(audio_pcm_hw_add_, TYPE)(AudioBackend *= s, struct audsettings *as static SW *glue(audio_pcm_create_voice_pair_, TYPE)( AudioBackend *s, const char *sw_name, - struct audsettings *as + const struct audsettings *as ) { SW *sw; @@ -491,7 +491,7 @@ SW *glue (AUD_open_, TYPE) ( const char *name, void *callback_opaque , audio_callback_fn callback_fn, - struct audsettings *as + const struct audsettings *as ) { AudioBackend *s =3D be; diff --git a/include/qemu/audio.h b/include/qemu/audio.h index a1a64ad340d..370e993f080 100644 --- a/include/qemu/audio.h +++ b/include/qemu/audio.h @@ -58,7 +58,7 @@ SWVoiceOut *AUD_open_out ( const char *name, void *callback_opaque, audio_callback_fn callback_fn, - struct audsettings *settings + const struct audsettings *settings ); =20 void AUD_close_out (AudioBackend *be, SWVoiceOut *sw); @@ -97,7 +97,7 @@ SWVoiceIn *AUD_open_in( const char *name, void *callback_opaque, audio_callback_fn callback_fn, - struct audsettings *settings + const struct audsettings *settings ); =20 void AUD_close_in(AudioBackend *be, SWVoiceIn *sw); diff --git a/audio/audio.c b/audio/audio.c index 68698b13e15..5dccb9b0a36 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -170,7 +170,7 @@ void AUD_log (const char *cap, const char *fmt, ...) va_end (ap); } =20 -static void audio_print_settings (struct audsettings *as) +static void audio_print_settings (const struct audsettings *as) { dolog ("frequency=3D%d nchannels=3D%d fmt=3D", as->freq, as->nchannels= ); =20 @@ -216,7 +216,7 @@ static void audio_print_settings (struct audsettings *a= s) AUD_log (NULL, "\n"); } =20 -static int audio_validate_settings (struct audsettings *as) +static int audio_validate_settings (const struct audsettings *as) { int invalid; =20 @@ -241,7 +241,7 @@ static int audio_validate_settings (struct audsettings = *as) return invalid ? -1 : 0; } =20 -static int audio_pcm_info_eq (struct audio_pcm_info *info, struct audsetti= ngs *as) +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; @@ -281,7 +281,7 @@ static int audio_pcm_info_eq (struct audio_pcm_info *in= fo, struct audsettings *a && info->swap_endianness =3D=3D (as->endianness !=3D HOST_BIG_ENDI= AN); } =20 -void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings = *as) +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; --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854699; cv=none; d=zohomail.com; s=zohoarc; b=JSftO2P7jY9K2xAaJ53WMkbJyXeM2LD6yluyj7G2WFPtzozTBB7oFZVhXrYtrd/EiBd75OM88kFLfpIDqMbU43A3R2SvoUSz67FV259DZ8DPs3TurBEYvjrP5oDaRw9HIeaO5qGvafzOS1TVxOHTCopJZPp4iZQmiHY782OC6Wg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854699; 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=6E7LBXbuAd2mWDdhOQp5nZ1S4M2r4p8d4uqj9EQhV+0=; b=OdRoP9HJZbOK6bSvJ6siHTdQGSioXcQkzP2m7twoJNDwk2EwXtFcQT7703TxXJoq1RKMJwHROBnDyXmQPCSXab2GAglO/1CMGi2LimF6ugQkcvXMerQamKkgSin9ayVq+2RkKlerqkWpNebw8xZhrIyc1melwR9IMN+xxtsNMCo= 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 17718546991321006.3618321089791; Mon, 23 Feb 2026 05:51:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWK4-0003NN-Ot; Mon, 23 Feb 2026 08:50: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 1vuWIh-0000f6-5E for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:46 -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 1vuWIb-00073M-4o for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:35 -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-547-55RuV58wPQ2d6ue56OxyPw-1; Mon, 23 Feb 2026 08:48: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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 04993195609D; Mon, 23 Feb 2026 13:48:27 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6E4371955D85; Mon, 23 Feb 2026 13:48:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854511; 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=6E7LBXbuAd2mWDdhOQp5nZ1S4M2r4p8d4uqj9EQhV+0=; b=ctXF7160eL+PuY+kBtE5KKEwFwpfcToceXJzFb2x+I6Uk6eOXVXB7pfK5ktr6cVEE/Z/KC iuAUTUkToSV1rClrcNnU6wr/A5wvvSdCh2XupD9xmiGEVceHQ4x4d/xnYqqGAlhleuiX6y W7Dj7NEiu6CKUpwsGtt/lGrL+C67r3I= X-MC-Unique: 55RuV58wPQ2d6ue56OxyPw-1 X-Mimecast-MFC-AGG-ID: 55RuV58wPQ2d6ue56OxyPw_1771854507 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Christian Schoenebeck Subject: [PULL v3 20/85] audio: introduce AudioMixengBackend Date: Mon, 23 Feb 2026 14:46:21 +0100 Message-ID: <20260223134731.2377432-21-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854699690158500 From: Marc-Andr=C3=A9 Lureau Introduce a sub-class for current "audio_driver" based implementations. Future AudioBackend implementations can do without it. Next cleanup will actually remove "audio_driver" struct altogether and make the subclass proper QOM objects. Public APIs still rely on backend being an AudioMixeng. They will assert() if not. This will be addressed later to allow other backends. Note that the initial naming proposed for this object was AudioDriver, however the semantics for "driver" is already overloaded and leads to confusion, in particular with the QAPI AudiodevDriver. The defining characteristic is of using QEMU's software mixing engine, so AudioMixengBackend. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 25 +++++--- audio/audio_template.h | 18 +++--- include/qemu/audio.h | 17 +++++- audio/alsaaudio.c | 2 +- audio/audio.c | 123 +++++++++++++++++++++++++++++---------- audio/dbusaudio.c | 8 +-- audio/ossaudio.c | 4 +- tests/audio/test-audio.c | 4 +- ui/dbus.c | 6 +- 9 files changed, 143 insertions(+), 64 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index a6276375887..06f5160e8df 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -61,7 +61,7 @@ struct audio_pcm_info { int swap_endianness; }; =20 -typedef struct AudioBackend AudioBackend; +typedef struct AudioMixengBackend AudioMixengBackend; typedef struct SWVoiceCap SWVoiceCap; =20 typedef struct STSampleBuffer { @@ -70,7 +70,7 @@ typedef struct STSampleBuffer { } STSampleBuffer; =20 typedef struct HWVoiceOut { - AudioBackend *s; + AudioMixengBackend *s; bool enabled; int poll_mode; bool pending_disable; @@ -90,7 +90,7 @@ typedef struct HWVoiceOut { } HWVoiceOut; =20 typedef struct HWVoiceIn { - AudioBackend *s; + AudioMixengBackend *s; bool enabled; int poll_mode; struct audio_pcm_info info; @@ -110,7 +110,7 @@ typedef struct HWVoiceIn { } HWVoiceIn; =20 struct SWVoiceOut { - AudioBackend *s; + AudioMixengBackend *s; struct audio_pcm_info info; t_sample *conv; STSampleBuffer resample_buf; @@ -126,7 +126,7 @@ struct SWVoiceOut { }; =20 struct SWVoiceIn { - AudioBackend *s; + AudioMixengBackend *s; bool active; struct audio_pcm_info info; void *rate; @@ -239,8 +239,12 @@ struct SWVoiceCap { QLIST_ENTRY (SWVoiceCap) entries; }; =20 -typedef struct AudioBackend { - Object parent; +struct AudioMixengBackendClass { + AudioBackendClass parent_class; +}; + +struct AudioMixengBackend { + AudioBackend parent_obj; =20 struct audio_driver *drv; Audiodev *dev; @@ -257,7 +261,7 @@ typedef struct AudioBackend { bool timer_running; uint64_t timer_last; VMChangeStateEntry *vmse; -} AudioBackend; +}; =20 extern const struct mixeng_volume nominal_volume; =20 @@ -270,7 +274,7 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *i= nfo, void *buf, int len); =20 int audio_bug (const char *funcname, int cond); =20 -void audio_run(AudioBackend *s, const char *msg); +void audio_run(AudioMixengBackend *s, const char *msg); =20 const char *audio_application_name(void); =20 @@ -323,4 +327,7 @@ void audio_create_pdos(Audiodev *dev); AudiodevPerDirectionOptions *audio_get_pdo_in(Audiodev *dev); AudiodevPerDirectionOptions *audio_get_pdo_out(Audiodev *dev); =20 +#define TYPE_AUDIO_MIXENG_BACKEND "audio-mixeng-backend" +OBJECT_DECLARE_TYPE(AudioMixengBackend, AudioMixengBackendClass, AUDIO_MIX= ENG_BACKEND) + #endif /* QEMU_AUDIO_INT_H */ diff --git a/audio/audio_template.h b/audio/audio_template.h index e69e6e74570..a1f78d8748b 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -36,7 +36,7 @@ #define HWBUF hw->conv_buf #endif =20 -static void glue(audio_init_nb_voices_, TYPE)(AudioBackend *s, +static void glue(audio_init_nb_voices_, TYPE)(AudioMixengBackend *s, struct audio_driver *drv, in= t min_voices) { int max_voices =3D glue (drv->max_voices_, TYPE); @@ -221,7 +221,7 @@ static void glue (audio_pcm_hw_del_sw_, TYPE) (SW *sw) static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) { HW *hw =3D *hwp; - AudioBackend *s =3D hw->s; + AudioMixengBackend *s =3D hw->s; =20 if (!hw->sw_head.lh_first) { #ifdef DAC @@ -236,12 +236,12 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) } } =20 -static HW *glue(audio_pcm_hw_find_any_, TYPE)(AudioBackend *s, HW *hw) +static HW *glue(audio_pcm_hw_find_any_, TYPE)(AudioMixengBackend *s, HW *h= w) { return hw ? hw->entries.le_next : glue (s->hw_head_, TYPE).lh_first; } =20 -static HW *glue(audio_pcm_hw_find_any_enabled_, TYPE)(AudioBackend *s, HW = *hw) +static HW *glue(audio_pcm_hw_find_any_enabled_, TYPE)(AudioMixengBackend *= s, HW *hw) { while ((hw =3D glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) { if (hw->enabled) { @@ -251,7 +251,7 @@ static HW *glue(audio_pcm_hw_find_any_enabled_, TYPE)(A= udioBackend *s, HW *hw) return NULL; } =20 -static HW *glue(audio_pcm_hw_find_specific_, TYPE)(AudioBackend *s, HW *hw, +static HW *glue(audio_pcm_hw_find_specific_, TYPE)(AudioMixengBackend *s, = HW *hw, struct audsettings *as) { while ((hw =3D glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) { @@ -262,7 +262,7 @@ static HW *glue(audio_pcm_hw_find_specific_, TYPE)(Audi= oBackend *s, HW *hw, return NULL; } =20 -static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioBackend *s, +static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMixengBackend *s, struct audsettings *as) { HW *hw; @@ -398,7 +398,7 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)= (Audiodev *dev) abort(); } =20 -static HW *glue(audio_pcm_hw_add_, TYPE)(AudioBackend *s, struct audsettin= gs *as) +static HW *glue(audio_pcm_hw_add_, TYPE)(AudioMixengBackend *s, struct aud= settings *as) { HW *hw; AudiodevPerDirectionOptions *pdo =3D glue(audio_get_pdo_, TYPE)(s->dev= ); @@ -424,7 +424,7 @@ static HW *glue(audio_pcm_hw_add_, TYPE)(AudioBackend *= s, struct audsettings *as } =20 static SW *glue(audio_pcm_create_voice_pair_, TYPE)( - AudioBackend *s, + AudioMixengBackend *s, const char *sw_name, const struct audsettings *as ) @@ -494,7 +494,7 @@ SW *glue (AUD_open_, TYPE) ( const struct audsettings *as ) { - AudioBackend *s =3D be; + AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(be); AudiodevPerDirectionOptions *pdo; =20 if (audio_bug(__func__, !be || !name || !callback_fn || !as)) { diff --git a/include/qemu/audio.h b/include/qemu/audio.h index 370e993f080..474d761f0be 100644 --- a/include/qemu/audio.h +++ b/include/qemu/audio.h @@ -44,11 +44,21 @@ typedef struct audsettings { typedef struct SWVoiceOut SWVoiceOut; typedef struct SWVoiceIn SWVoiceIn; =20 -struct AudioBackendClass { +typedef struct AudioBackend { + Object parent_obj; +} AudioBackend; + +typedef struct AudioBackendClass { ObjectClass parent_class; -}; =20 -typedef struct AudioBackend AudioBackend; + const char *(*get_id)(AudioBackend *be); +#ifdef CONFIG_GIO + bool (*set_dbus_server)(AudioBackend *be, + GDBusObjectManagerServer *manager, + bool p2p, + Error **errp); +#endif +} AudioBackendClass; =20 bool AUD_backend_check(AudioBackend **be, Error **errp); =20 @@ -125,6 +135,7 @@ AudioBackend *audio_be_by_name(const char *name, Error = **errp); AudioBackend *audio_get_default_audio_be(Error **errp); const char *audio_be_get_id(AudioBackend *be); #ifdef CONFIG_GIO +bool audio_be_can_set_dbus_server(AudioBackend *be); bool audio_be_set_dbus_server(AudioBackend *be, GDBusObjectManagerServer *server, bool p2p, diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 7d7da576dc9..814820e2864 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -41,7 +41,7 @@ struct pollhlp { struct pollfd *pfds; int count; int mask; - AudioBackend *s; + AudioMixengBackend *s; }; =20 typedef struct ALSAVoiceOut { diff --git a/audio/audio.c b/audio/audio.c index 5dccb9b0a36..75a7f694319 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -37,6 +37,7 @@ #include "qemu/log.h" #include "qemu/module.h" #include "qemu/help_option.h" +#include "qom/object.h" #include "system/system.h" #include "system/replay.h" #include "system/runstate.h" @@ -384,7 +385,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(AudioBackend *s, +static CaptureVoiceOut *audio_pcm_capture_find_specific(AudioMixengBackend= *s, struct audsettings= *as) { CaptureVoiceOut *cap; @@ -464,7 +465,7 @@ static void audio_detach_capture (HWVoiceOut *hw) =20 static int audio_attach_capture (HWVoiceOut *hw) { - AudioBackend *s =3D hw->s; + AudioMixengBackend *s =3D hw->s; CaptureVoiceOut *cap; =20 audio_detach_capture (hw); @@ -802,7 +803,7 @@ static void audio_pcm_print_info (const char *cap, stru= ct audio_pcm_info *info) /* * Timer */ -static int audio_is_timer_needed(AudioBackend *s) +static int audio_is_timer_needed(AudioMixengBackend *s) { HWVoiceIn *hwi =3D NULL; HWVoiceOut *hwo =3D NULL; @@ -820,7 +821,7 @@ static int audio_is_timer_needed(AudioBackend *s) return 0; } =20 -static void audio_reset_timer(AudioBackend *s) +static void audio_reset_timer(AudioMixengBackend *s) { if (audio_is_timer_needed(s)) { timer_mod_anticipate_ns(s->ts, @@ -842,7 +843,7 @@ static void audio_reset_timer(AudioBackend *s) static void audio_timer (void *opaque) { int64_t now, diff; - AudioBackend *s =3D opaque; + AudioMixengBackend *s =3D opaque; =20 now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); diff =3D now - s->timer_last; @@ -925,7 +926,7 @@ void AUD_set_active_out(SWVoiceOut *sw, bool on) =20 hw =3D sw->hw; if (sw->active !=3D on) { - AudioBackend *s =3D sw->s; + AudioMixengBackend *s =3D sw->s; SWVoiceOut *temp_sw; SWVoiceCap *sc; =20 @@ -973,7 +974,7 @@ void AUD_set_active_in(SWVoiceIn *sw, bool on) =20 hw =3D sw->hw; if (sw->active !=3D on) { - AudioBackend *s =3D sw->s; + AudioMixengBackend *s =3D sw->s; SWVoiceIn *temp_sw; =20 if (on) { @@ -1141,7 +1142,7 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, si= ze_t live) return clipped; } =20 -static void audio_run_out(AudioBackend *s) +static void audio_run_out(AudioMixengBackend *s) { HWVoiceOut *hw =3D NULL; SWVoiceOut *sw; @@ -1294,7 +1295,7 @@ static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, size= _t samples) return conv; } =20 -static void audio_run_in(AudioBackend *s) +static void audio_run_in(AudioMixengBackend *s) { HWVoiceIn *hw =3D NULL; =20 @@ -1341,7 +1342,7 @@ static void audio_run_in(AudioBackend *s) } } =20 -static void audio_run_capture(AudioBackend *s) +static void audio_run_capture(AudioMixengBackend *s) { CaptureVoiceOut *cap; =20 @@ -1388,7 +1389,7 @@ static void audio_run_capture(AudioBackend *s) } } =20 -void audio_run(AudioBackend *s, const char *msg) +void audio_run(AudioMixengBackend *s, const char *msg) { audio_run_out(s); audio_run_in(s); @@ -1561,8 +1562,8 @@ size_t audio_generic_read(HWVoiceIn *hw, void *buf, s= ize_t size) return total; } =20 -static bool audio_driver_init(AudioBackend *s, struct audio_driver *drv, - Audiodev *dev, Error **errp) +static bool audio_driver_do_init(AudioMixengBackend *s, struct audio_drive= r *drv, + Audiodev *dev, Error **errp) { s->drv_opaque =3D drv->init(dev, errp); if (!s->drv_opaque) { @@ -1594,7 +1595,7 @@ static bool audio_driver_init(AudioBackend *s, struct= audio_driver *drv, static void audio_vm_change_state_handler (void *opaque, bool running, RunState state) { - AudioBackend *s =3D opaque; + AudioMixengBackend *s =3D opaque; HWVoiceOut *hwo =3D NULL; HWVoiceIn *hwi =3D NULL; =20 @@ -1616,7 +1617,47 @@ static const VMStateDescription vmstate_audio; =20 static void audio_be_init(Object *obj) { - AudioBackend *s =3D AUDIO_BACKEND(obj); +} + +static void audio_be_finalize(Object *obj) +{ +} + +static const char *audio_mixeng_backend_get_id(AudioBackend *be) +{ + return AUDIO_MIXENG_BACKEND(be)->dev->id; +} + +#ifdef CONFIG_GIO +static bool audio_mixeng_backend_set_dbus_server(AudioBackend *be, + GDBusObjectManagerServer = *manager, + bool p2p, + Error **errp) +{ + AudioMixengBackend *d =3D AUDIO_MIXENG_BACKEND(be); + + if (!d->drv->set_dbus_server) { + return false; + } + + return d->drv->set_dbus_server(be, manager, p2p, errp); +} + +#endif + +static void audio_mixeng_backend_class_init(ObjectClass *klass, const void= *data) +{ + AudioBackendClass *be =3D AUDIO_BACKEND_CLASS(klass); + + be->get_id =3D audio_mixeng_backend_get_id; +#ifdef CONFIG_GIO + be->set_dbus_server =3D audio_mixeng_backend_set_dbus_server; +#endif +} + +static void audio_mixeng_backend_init(Object *obj) +{ + AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(obj); =20 QLIST_INIT(&s->hw_head_out); QLIST_INIT(&s->hw_head_in); @@ -1629,9 +1670,9 @@ static void audio_be_init(Object *obj) vmstate_register_any(NULL, &vmstate_audio, s); } =20 -static void audio_be_finalize(Object *obj) +static void audio_mixeng_backend_finalize(Object *obj) { - AudioBackend *s =3D AUDIO_BACKEND(obj); + AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(obj); HWVoiceOut *hwo, *hwon; HWVoiceIn *hwi, *hwin; =20 @@ -1747,10 +1788,10 @@ static AudioBackend *audio_init(Audiodev *dev, Erro= r **errp) { int done =3D 0; const char *drvname; - AudioBackend *s; + AudioMixengBackend *s; struct audio_driver *driver; =20 - s =3D AUDIO_BACKEND(object_new(TYPE_AUDIO_BACKEND)); + s =3D AUDIO_MIXENG_BACKEND(object_new(TYPE_AUDIO_MIXENG_BACKEND)); =20 if (dev) { /* -audiodev option */ @@ -1758,7 +1799,7 @@ static AudioBackend *audio_init(Audiodev *dev, Error = **errp) drvname =3D AudiodevDriver_str(dev->driver); driver =3D audio_driver_lookup(drvname); if (driver) { - done =3D audio_driver_init(s, driver, dev, errp); + done =3D audio_driver_do_init(s, driver, dev, errp); } else { error_setg(errp, "Unknown audio driver `%s'", drvname); } @@ -1778,7 +1819,7 @@ static AudioBackend *audio_init(Audiodev *dev, Error = **errp) g_free(e); drvname =3D AudiodevDriver_str(dev->driver); driver =3D audio_driver_lookup(drvname); - if (audio_driver_init(s, driver, dev, NULL)) { + if (audio_driver_do_init(s, driver, dev, NULL)) { break; } qapi_free_Audiodev(dev); @@ -1790,7 +1831,7 @@ static AudioBackend *audio_init(Audiodev *dev, Error = **errp) goto out; } object_unref(s); - return s; + return AUDIO_BACKEND(s); =20 out: object_unref(s); @@ -1829,12 +1870,13 @@ bool AUD_backend_check(AudioBackend **be, Error **e= rrp) static struct audio_pcm_ops capture_pcm_ops; =20 CaptureVoiceOut *AUD_add_capture( - AudioBackend *s, + AudioBackend *be, struct audsettings *as, struct audio_capture_ops *ops, void *cb_opaque ) { + AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(be); CaptureVoiceOut *cap; struct capture_callback *cb; =20 @@ -2225,27 +2267,37 @@ AudioBackend *audio_be_by_name(const char *name, Er= ror **errp) } =20 #ifdef CONFIG_GIO +bool audio_be_can_set_dbus_server(AudioBackend *be) +{ + /* + * TODO: + * AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + * return klass->set_dbus_server !=3D NULL; + */ + return AUDIO_MIXENG_BACKEND(be)->drv->set_dbus_server !=3D NULL; +} + bool audio_be_set_dbus_server(AudioBackend *be, GDBusObjectManagerServer *server, bool p2p, Error **errp) { - assert(be !=3D NULL); + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 - if (!be->drv->set_dbus_server) { - error_setg(errp, "Audiodev '%s' is not compatible with DBus", be->= dev->id); + if (!audio_be_can_set_dbus_server(be)) { + error_setg(errp, "Audiodev '%s' is not compatible with DBus", + audio_be_get_id(be)); return false; } =20 - return be->drv->set_dbus_server(be, server, p2p, errp); + return klass->set_dbus_server(be, server, p2p, errp); } #endif =20 const char *audio_be_get_id(AudioBackend *be) { if (be) { - assert(be->dev); - return be->dev->id; + return AUDIO_BACKEND_GET_CLASS(be)->get_id(be); } else { return ""; } @@ -2320,13 +2372,24 @@ static const TypeInfo audio_be_info =3D { .instance_size =3D sizeof(AudioBackend), .instance_init =3D audio_be_init, .instance_finalize =3D audio_be_finalize, - .abstract =3D false, /* TODO: subclass drivers and make it abstract */ + .abstract =3D true, .class_size =3D sizeof(AudioBackendClass), }; =20 +static const TypeInfo audio_mixeng_backend_info =3D { + .name =3D TYPE_AUDIO_MIXENG_BACKEND, + .parent =3D TYPE_AUDIO_BACKEND, + .instance_size =3D sizeof(AudioMixengBackend), + .instance_init =3D audio_mixeng_backend_init, + .instance_finalize =3D audio_mixeng_backend_finalize, + .class_size =3D sizeof(AudioMixengBackendClass), + .class_init =3D audio_mixeng_backend_class_init, +}; + static void register_types(void) { type_register_static(&audio_be_info); + type_register_static(&audio_mixeng_backend_info); } =20 type_init(register_types); diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index 1fe7c4ed647..96d4fa3f471 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -464,7 +464,7 @@ listener_in_vanished_cb(GDBusConnection *connection, } =20 static gboolean -dbus_audio_register_listener(AudioBackend *s, +dbus_audio_register_listener(AudioMixengBackend *s, GDBusMethodInvocation *invocation, #ifdef G_OS_UNIX GUnixFDList *fd_list, @@ -621,7 +621,7 @@ dbus_audio_register_listener(AudioBackend *s, } =20 static gboolean -dbus_audio_register_out_listener(AudioBackend *s, +dbus_audio_register_out_listener(AudioMixengBackend *s, GDBusMethodInvocation *invocation, #ifdef G_OS_UNIX GUnixFDList *fd_list, @@ -637,7 +637,7 @@ dbus_audio_register_out_listener(AudioBackend *s, } =20 static gboolean -dbus_audio_register_in_listener(AudioBackend *s, +dbus_audio_register_in_listener(AudioMixengBackend *s, GDBusMethodInvocation *invocation, #ifdef G_OS_UNIX GUnixFDList *fd_list, @@ -657,7 +657,7 @@ dbus_audio_set_server(AudioBackend *s, bool p2p, Error **errp) { - DBusAudio *da =3D s->drv_opaque; + DBusAudio *da =3D AUDIO_MIXENG_BACKEND(s)->drv_opaque; =20 g_assert(da); g_assert(!da->server); diff --git a/audio/ossaudio.c b/audio/ossaudio.c index c6cad47a015..6ad20ab1876 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -107,13 +107,13 @@ static void oss_anal_close (int *fdp) =20 static void oss_helper_poll_out (void *opaque) { - AudioBackend *s =3D opaque; + AudioMixengBackend *s =3D opaque; audio_run(s, "oss_poll_out"); } =20 static void oss_helper_poll_in (void *opaque) { - AudioBackend *s =3D opaque; + AudioMixengBackend *s =3D opaque; audio_run(s, "oss_poll_in"); } =20 diff --git a/tests/audio/test-audio.c b/tests/audio/test-audio.c index edb4971972c..66693f0fbfd 100644 --- a/tests/audio/test-audio.c +++ b/tests/audio/test-audio.c @@ -170,7 +170,7 @@ static void test_audio_out_sine_wave(void) */ start_time =3D g_get_monotonic_time(); while (state.frames_written < state.total_frames) { - audio_run(state.be, "test"); + audio_run(AUDIO_MIXENG_BACKEND(state.be), "test"); main_loop_wait(true); =20 elapsed_ms =3D (g_get_monotonic_time() - start_time) / 1000; @@ -432,7 +432,7 @@ static void test_audio_capture(void) start_time =3D g_get_monotonic_time(); while (sine_state.frames_written < sine_state.total_frames || state.captured_bytes < CAPTURE_BUFFER_SIZE) { - audio_run(be, "test-capture"); + audio_run(AUDIO_MIXENG_BACKEND(be), "test-capture"); main_loop_wait(true); =20 elapsed_ms =3D (g_get_monotonic_time() - start_time) / 1000; diff --git a/ui/dbus.c b/ui/dbus.c index 0be1931d208..905ee6fea71 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -221,8 +221,7 @@ dbus_display_complete(UserCreatable *uc, Error **errp) =20 { AudioBackend *audio_be =3D audio_get_default_audio_be(NULL); - - if (audio_be && !g_str_equal(audio_be->drv->name, "dbus")) { + if (audio_be && !audio_be_can_set_dbus_server(audio_be)) { audio_be =3D NULL; } if (dd->audiodev && *dd->audiodev) { @@ -231,8 +230,7 @@ dbus_display_complete(UserCreatable *uc, Error **errp) return; } } - if (audio_be && - !audio_be_set_dbus_server(audio_be, dd->server, dd->p2p, errp)= ) { + if (audio_be && !audio_be_set_dbus_server(audio_be, dd->server, dd= ->p2p, errp)) { return; } } --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854909; cv=none; d=zohomail.com; s=zohoarc; b=lsX3oJF73R6bD7buTHyC97nxeOx7L50GaI826Musp7kqtiSpAR++39yMziwRMT9Li9cBC1B7rJYgWWgRrSaEDZ13ZGElMx+fRWbdd/3juuvPJ3eEpYnazJIGz+qTBVjkgQgNJjp2rjGDwa6gmpYVex+7P7VvnKXEqMK+bsIXFkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854909; 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=bmLE4PI4NiS4bmYyzdcYckwaqWftpyyj3Q24H/oUE1E=; b=QoCELxmY5yeQfnYrNMF8UPKZydhr8bZt3+yQhZ7oM0ADroVQcy+CkWFtlgZpg7PSP0D82GZ5TpdixCzwM2sxp+ZpknAEWDHCiCIeBoRjXGEgGVn50p21dUS7I1ThiL3kBuxqyqyCWv7m9tbOVPDpnWs26QgdalOVImQw1XMSBgc= 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 1771854909569185.17027452494438; Mon, 23 Feb 2026 05:55:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJM-00029C-Sk; Mon, 23 Feb 2026 08:49: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 1vuWIh-0000f7-5l for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48: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 1vuWIb-00073U-Lb for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:35 -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-522-M7PI0Nz7PpytdP8CNbjpkQ-1; Mon, 23 Feb 2026 08:48:31 -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 7EAAD18005B7; Mon, 23 Feb 2026 13:48:30 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8ED7519560B4; Mon, 23 Feb 2026 13:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854512; 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=bmLE4PI4NiS4bmYyzdcYckwaqWftpyyj3Q24H/oUE1E=; b=WYlZZtGxmbRPxrbtdTWMzFEE/yOmqGVtmV25eCFkCBpSlJ7J/j+xnXzXgDuT+pm1DDjxj+ mqhzyYWLOAJsD6Fjlp6Ev/AftENEUFLwqqoBB5obAtZdkvMMNSqvSC0mLa5AwKq4tIFZsW oOOXKQAvhJA78dcqssyZbbpKmBv/8Wo= X-MC-Unique: M7PI0Nz7PpytdP8CNbjpkQ-1 X-Mimecast-MFC-AGG-ID: M7PI0Nz7PpytdP8CNbjpkQ_1771854510 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 21/85] audio: use DEFINE_TYPES Date: Mon, 23 Feb 2026 14:46:22 +0100 Message-ID: <20260223134731.2377432-22-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854910677158500 From: Marc-Andr=C3=A9 Lureau It's the "modern" way of registring the object TypeInfo. Suggested-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 75a7f694319..c4e4adec106 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -2366,30 +2366,25 @@ AudiodevList *qmp_query_audiodevs(Error **errp) return ret; } =20 -static const TypeInfo audio_be_info =3D { - .name =3D TYPE_AUDIO_BACKEND, - .parent =3D TYPE_OBJECT, - .instance_size =3D sizeof(AudioBackend), - .instance_init =3D audio_be_init, - .instance_finalize =3D audio_be_finalize, - .abstract =3D true, - .class_size =3D sizeof(AudioBackendClass), -}; - -static const TypeInfo audio_mixeng_backend_info =3D { - .name =3D TYPE_AUDIO_MIXENG_BACKEND, - .parent =3D TYPE_AUDIO_BACKEND, - .instance_size =3D sizeof(AudioMixengBackend), - .instance_init =3D audio_mixeng_backend_init, - .instance_finalize =3D audio_mixeng_backend_finalize, - .class_size =3D sizeof(AudioMixengBackendClass), - .class_init =3D audio_mixeng_backend_class_init, +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_BACKEND, + .parent =3D TYPE_OBJECT, + .instance_size =3D sizeof(AudioBackend), + .instance_init =3D audio_be_init, + .instance_finalize =3D audio_be_finalize, + .abstract =3D true, + .class_size =3D sizeof(AudioBackendClass), + }, + { + .name =3D TYPE_AUDIO_MIXENG_BACKEND, + .parent =3D TYPE_AUDIO_BACKEND, + .instance_size =3D sizeof(AudioMixengBackend), + .instance_init =3D audio_mixeng_backend_init, + .instance_finalize =3D audio_mixeng_backend_finalize, + .class_size =3D sizeof(AudioMixengBackendClass), + .class_init =3D audio_mixeng_backend_class_init, + } }; =20 -static void register_types(void) -{ - type_register_static(&audio_be_info); - type_register_static(&audio_mixeng_backend_info); -} - -type_init(register_types); +DEFINE_TYPES(audio_types) --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771855086; cv=none; d=zohomail.com; s=zohoarc; b=SMOGfYP5+8zY0PPM0n5aSJpK7zU4+kKyod+JY84gaCqGaTYZYjIpkupo3DTpt9VMo1o0nUhTNj6kJvC2N+mn2hm2rfToJPqKfmvOhblEgX4GOcmWny71ocOL+ASFDQ0yLgplABH2JO5W4chnsEUbnfpk82uSuapMfrsajlCr6uo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855086; 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=99d2Aunspa8tSdfszEIfDfTDk4GKioE/L+0EPViLRM0=; b=OsvY/k6pqNL2+3QIQnOas7QJmY/bRIr36G4XrEPzk8l7Ovv8PF/eAVEwMj1W30QPZsbPLm6SjS0M/AjEcAgYRS4JHYO4xJeoRijDzCqKKz5dzQENeVjblL7tyxXpeTvYG2hmNL0hMtRp15EtOa0JANqdLuvYbbnpi2TEf5jNhy8= 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 1771855086812704.4696419761932; Mon, 23 Feb 2026 05:58:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJz-0003KU-Pm; Mon, 23 Feb 2026 08:49:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWIk-0000iI-35 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:46 -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 1vuWIg-000744-V5 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:41 -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-629-y9WnFTt1PS-wFYyRPPMF-w-1; Mon, 23 Feb 2026 08:48:34 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 79D3F1955F44; Mon, 23 Feb 2026 13:48:33 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 905E41800465; Mon, 23 Feb 2026 13:48:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854517; 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=99d2Aunspa8tSdfszEIfDfTDk4GKioE/L+0EPViLRM0=; b=bt9+ZNIQLS+SG8+4hnQ1z+wXZydI1LyWAwYj+sLk5N3/n70+aIsnagsoD3NXIV3HMMn/Kw JZnYvEEZA/rUtS2VMcEYEdcrFsx0HJgq6ZWtwxBPWE73VQzs7UinXo5n39X33jihk6tLWK HDJbG5FOunid5dW9OMffHtZgG7/3tMQ= X-MC-Unique: y9WnFTt1PS-wFYyRPPMF-w-1 X-Mimecast-MFC-AGG-ID: y9WnFTt1PS-wFYyRPPMF-w_1771854513 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 22/85] audio: simplify audio_init() Date: Mon, 23 Feb 2026 14:46:23 +0100 Message-ID: <20260223134731.2377432-23-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855087655158500 From: Marc-Andr=C3=A9 Lureau Factorize looking up the driver in audio_driver_init() Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio.c | 66 ++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 37 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index c4e4adec106..10e32bcbb1a 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1562,11 +1562,18 @@ size_t audio_generic_read(HWVoiceIn *hw, void *buf,= size_t size) return total; } =20 -static bool audio_driver_do_init(AudioMixengBackend *s, struct audio_drive= r *drv, - Audiodev *dev, Error **errp) +static bool audio_driver_do_init(AudioMixengBackend *d, Error **errp) { - s->drv_opaque =3D drv->init(dev, errp); - if (!s->drv_opaque) { + const char *drvname =3D AudiodevDriver_str(d->dev->driver); + struct audio_driver *drv =3D audio_driver_lookup(drvname); + + if (!drv) { + error_setg(errp, "Unknown audio driver `%s'", drvname); + return false; + } + + d->drv_opaque =3D drv->init(d->dev, errp); + if (!d->drv_opaque) { return false; } =20 @@ -1579,14 +1586,14 @@ static bool audio_driver_do_init(AudioMixengBackend= *s, struct audio_driver *drv drv->pcm_ops->put_buffer_out =3D audio_generic_put_buffer_out; } =20 - audio_init_nb_voices_out(s, drv, 1); - audio_init_nb_voices_in(s, drv, 0); - s->drv =3D drv; + audio_init_nb_voices_out(d, drv, 1); + audio_init_nb_voices_in(d, drv, 0); + d->drv =3D drv; =20 - if (dev->timer_period <=3D 0) { - s->period_ticks =3D 1; + if (d->dev->timer_period <=3D 0) { + d->period_ticks =3D 1; } else { - s->period_ticks =3D dev->timer_period * (int64_t)SCALE_US; + d->period_ticks =3D d->dev->timer_period * (int64_t)SCALE_US; } =20 return true; @@ -1786,24 +1793,12 @@ void audio_create_default_audiodevs(void) */ static AudioBackend *audio_init(Audiodev *dev, Error **errp) { - int done =3D 0; - const char *drvname; - AudioMixengBackend *s; - struct audio_driver *driver; + AudioMixengBackend *d; =20 - s =3D AUDIO_MIXENG_BACKEND(object_new(TYPE_AUDIO_MIXENG_BACKEND)); - - if (dev) { - /* -audiodev option */ - s->dev =3D dev; - drvname =3D AudiodevDriver_str(dev->driver); - driver =3D audio_driver_lookup(drvname); - if (driver) { - done =3D audio_driver_do_init(s, driver, dev, errp); - } else { - error_setg(errp, "Unknown audio driver `%s'", drvname); - } - if (!done) { + d =3D AUDIO_MIXENG_BACKEND(object_new(TYPE_AUDIO_MIXENG_BACKEND)); + d->dev =3D dev; + if (d->dev) { + if (!audio_driver_do_init(d, errp)) { goto out; } } else { @@ -1814,27 +1809,24 @@ static AudioBackend *audio_init(Audiodev *dev, Erro= r **errp) error_setg(errp, "no default audio driver available"); goto out; } - s->dev =3D dev =3D e->dev; + d->dev =3D e->dev; QSIMPLEQ_REMOVE_HEAD(&default_audiodevs, next); g_free(e); - drvname =3D AudiodevDriver_str(dev->driver); - driver =3D audio_driver_lookup(drvname); - if (audio_driver_do_init(s, driver, dev, NULL)) { + if (audio_driver_do_init(d, NULL)) { break; } - qapi_free_Audiodev(dev); - s->dev =3D NULL; } } =20 - if (!object_property_try_add_child(get_audiodevs_root(), dev->id, OBJE= CT(s), errp)) { + if (!object_property_try_add_child(get_audiodevs_root(), + d->dev->id, OBJECT(d), errp)) { goto out; } - object_unref(s); - return AUDIO_BACKEND(s); + object_unref(d); + return AUDIO_BACKEND(d); =20 out: - object_unref(s); + object_unref(d); return NULL; } =20 --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854645; cv=none; d=zohomail.com; s=zohoarc; b=jfNVYSIjmMYWPbSe3snokfAyPZouK7RaWn/BQo1bJID3LPbsl51IPAPKzQ9UIgm7ggfFNs0U+y11ulS3YE6fWLJ50PAo2Pwj9C5VC5M17sln9De7+GvhVWBQ+tucxn6lKPV13D1USO00qTI68XIv+BjxdtofVZU3u+PA8wOAtE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854645; 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=6n0Nw4IjvpoGYNAliP9f9QdpiSJbuthryuT9oA6KUP4=; b=mRdgltJoDyFtyEV6szlXsdEm2P6aUZ+7NwCJ2259bjMw/cLiohYOq8GdC7+29oW8NGxLxsd4vTe86ZNiCt1hTGUByXp+gUmj/CatXH3HC7vLu5QvRrlH67fOvrKWXJpNW4X9P080U26KsiwnCVHsNYhTKUClCK61c85fNi2c6jE= 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 1771854645309584.9371798327326; Mon, 23 Feb 2026 05:50:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJO-0002PR-Co; Mon, 23 Feb 2026 08:49:22 -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 1vuWIl-0000io-CD for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48: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 1vuWIi-00074K-Sh for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:42 -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-84-Z60_gmZuNuOsHT6pMPTW8w-1; Mon, 23 Feb 2026 08:48:36 -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 0115F1800367; Mon, 23 Feb 2026 13:48:36 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 783111800465; Mon, 23 Feb 2026 13:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854520; 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=6n0Nw4IjvpoGYNAliP9f9QdpiSJbuthryuT9oA6KUP4=; b=ER+9pL45Hpyo9N+i6T4YUk7/DwYC/miDXvvvEn+8Q2+d0Utz5c8Ne9OyIwc9ZZ2NyWGeol Rw7HsCkJT4bsdVAvZAub2OWvLXlDvvlzeGE4YtsXayHmRTpjpn8CNBL2/NQTQfOn1EIc4M H8n9OkbIWM4ZU601oqPxZECN7kIBkuM= X-MC-Unique: Z60_gmZuNuOsHT6pMPTW8w-1 X-Mimecast-MFC-AGG-ID: Z60_gmZuNuOsHT6pMPTW8w_1771854516 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 23/85] audio: move object creation to audio_driver_init() Date: Mon, 23 Feb 2026 14:46:24 +0100 Message-ID: <20260223134731.2377432-24-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854647270158500 From: Marc-Andr=C3=A9 Lureau As we will allow other kind of AudioBackend objects to be instantiated, move the object allocation to a audio_driver_init() and rename it audio_be_new(). Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio.c | 65 +++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 10e32bcbb1a..3e1cd988852 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1562,19 +1562,24 @@ size_t audio_generic_read(HWVoiceIn *hw, void *buf,= size_t size) return total; } =20 -static bool audio_driver_do_init(AudioMixengBackend *d, Error **errp) +static AudioBackend *audio_be_new(Audiodev *dev, Error **errp) { - const char *drvname =3D AudiodevDriver_str(d->dev->driver); + const char *drvname =3D AudiodevDriver_str(dev->driver); struct audio_driver *drv =3D audio_driver_lookup(drvname); =20 if (!drv) { error_setg(errp, "Unknown audio driver `%s'", drvname); - return false; + qapi_free_Audiodev(dev); + return NULL; } =20 - d->drv_opaque =3D drv->init(d->dev, errp); - if (!d->drv_opaque) { - return false; + AudioMixengBackend *be =3D AUDIO_MIXENG_BACKEND(object_new(TYPE_AUDIO_= MIXENG_BACKEND)); + be->dev =3D dev; + + be->drv_opaque =3D drv->init(be->dev, errp); + if (!be->drv_opaque) { + object_unref(OBJECT(be)); + return NULL; } =20 if (!drv->pcm_ops->get_buffer_in) { @@ -1586,17 +1591,17 @@ static bool audio_driver_do_init(AudioMixengBackend= *d, Error **errp) drv->pcm_ops->put_buffer_out =3D audio_generic_put_buffer_out; } =20 - audio_init_nb_voices_out(d, drv, 1); - audio_init_nb_voices_in(d, drv, 0); - d->drv =3D drv; + audio_init_nb_voices_out(be, drv, 1); + audio_init_nb_voices_in(be, drv, 0); + be->drv =3D drv; =20 - if (d->dev->timer_period <=3D 0) { - d->period_ticks =3D 1; + if (be->dev->timer_period <=3D 0) { + be->period_ticks =3D 1; } else { - d->period_ticks =3D d->dev->timer_period * (int64_t)SCALE_US; + be->period_ticks =3D be->dev->timer_period * (int64_t)SCALE_US; } =20 - return true; + return AUDIO_BACKEND(be); } =20 static void audio_vm_change_state_handler (void *opaque, bool running, @@ -1793,41 +1798,39 @@ void audio_create_default_audiodevs(void) */ static AudioBackend *audio_init(Audiodev *dev, Error **errp) { - AudioMixengBackend *d; + AudioBackend *be; =20 - d =3D AUDIO_MIXENG_BACKEND(object_new(TYPE_AUDIO_MIXENG_BACKEND)); - d->dev =3D dev; - if (d->dev) { - if (!audio_driver_do_init(d, errp)) { - goto out; + if (dev) { + be =3D audio_be_new(dev, errp); + if (!be) { + return NULL; } } else { assert(!default_audio_be); for (;;) { AudiodevListEntry *e =3D QSIMPLEQ_FIRST(&default_audiodevs); + if (!e) { error_setg(errp, "no default audio driver available"); - goto out; + return NULL; } - d->dev =3D e->dev; + dev =3D e->dev; QSIMPLEQ_REMOVE_HEAD(&default_audiodevs, next); g_free(e); - if (audio_driver_do_init(d, NULL)) { + be =3D audio_be_new(dev, NULL); + if (be) { break; } } } =20 if (!object_property_try_add_child(get_audiodevs_root(), - d->dev->id, OBJECT(d), errp)) { - goto out; + audio_be_get_id(be), OBJECT(be), er= rp)) { + object_unref(be); + return NULL; } - object_unref(d); - return AUDIO_BACKEND(d); - -out: - object_unref(d); - return NULL; + object_unref(be); + return be; } =20 AudioBackend *audio_get_default_audio_be(Error **errp) @@ -2183,7 +2186,7 @@ void audio_init_audiodevs(void) AudiodevListEntry *e; =20 QSIMPLEQ_FOREACH(e, &audiodevs, next) { - audio_init(e->dev, &error_fatal); + audio_init(QAPI_CLONE(Audiodev, e->dev), &error_fatal); } } =20 --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771855407; cv=none; d=zohomail.com; s=zohoarc; b=oA3s7umsTLQO6FcP3KzprdJXYdZelWSXESZRbIILb1sSf8imWRUyZ8Ej7PMxkqnKnSGy8nl3h0TITa/oAB3xJIiASWyk03wkjl8+oJh10bLaf3KKrC4UJQUUCndAq82kX605Vf0djBOFTWzwXIk40WLMiz2PIhnwWwIGbzVx0E4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855407; 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=8fGV94VVX3seSWRJwyKsFhWxzUn+0ErA9KzpBi1fBXU=; b=RDg880OYMR0iwkYcY8fgePZtHF7ULxrlo9hZf6zptHnnOq3tEs8AOuj+Y+ONV8ULLcOdHCcCnr84vAnj8TER8FLpiOuFFYORPwDeMi3mzDu8Q2B97SQLGXHBnf+cUlwdzBVugkNij2plWz0/k/OIe/kmPJzgzOyZrIHtbApCV2Q= 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 1771855407708338.2773457337055; Mon, 23 Feb 2026 06:03:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWNh-0003Ws-BG; Mon, 23 Feb 2026 08:53:49 -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 1vuWIq-0000jq-KI for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:51 -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 1vuWIn-00075A-H9 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:48 -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-122-JiHd3qQCPhSxsw5cusVtsg-1; Mon, 23 Feb 2026 08:48: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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A6C2B1955F29; Mon, 23 Feb 2026 13:48:39 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3F2F01955D85; Mon, 23 Feb 2026 13:48:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854524; 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=8fGV94VVX3seSWRJwyKsFhWxzUn+0ErA9KzpBi1fBXU=; b=Wm3kiuEmqDArOFeyhYrknafn10mpHh13rvbaG1azlM/5Jdf3piEjWCUFIoxuIpsGvTrf/H ThkbZ0VCfTMga55PGQwyyPsNLEFv7SREp6OabdPpgvrufTqYMgWdtCzowFN97n6Bir2RYf KxE4GqJJG/cZhIvNPcTUQz7BO+Uf/eI= X-MC-Unique: JiHd3qQCPhSxsw5cusVtsg-1 X-Mimecast-MFC-AGG-ID: JiHd3qQCPhSxsw5cusVtsg_1771854520 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Thomas Huth , Alexandre Ratchov Subject: [PULL v3 24/85] audio: add QOM module-objects for each backend Date: Mon, 23 Feb 2026 14:46:25 +0100 Message-ID: <20260223134731.2377432-25-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855408733158500 From: Marc-Andr=C3=A9 Lureau This will allow to use QOM and the dynamic object module loading. The changes are done systematically, introducing an empty instance structure that will later be filled by state with further refactoring. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki Reviewed-by: Mark Cave-Ayland --- audio/audio_int.h | 2 ++ audio/alsaaudio.c | 27 +++++++++++++++++++++++++++ audio/dbusaudio.c | 26 ++++++++++++++++++++++++++ audio/dsoundaudio.c | 26 ++++++++++++++++++++++++++ audio/jackaudio.c | 26 ++++++++++++++++++++++++++ audio/noaudio.c | 26 ++++++++++++++++++++++++++ audio/ossaudio.c | 26 ++++++++++++++++++++++++++ audio/paaudio.c | 26 ++++++++++++++++++++++++++ audio/pwaudio.c | 26 ++++++++++++++++++++++++++ audio/sdlaudio.c | 26 ++++++++++++++++++++++++++ audio/sndioaudio.c | 26 ++++++++++++++++++++++++++ audio/spiceaudio.c | 26 ++++++++++++++++++++++++++ audio/wavaudio.c | 26 ++++++++++++++++++++++++++ audio/coreaudio.m | 26 ++++++++++++++++++++++++++ 14 files changed, 341 insertions(+) diff --git a/audio/audio_int.h b/audio/audio_int.h index 06f5160e8df..29f5864be69 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -241,6 +241,8 @@ struct SWVoiceCap { =20 struct AudioMixengBackendClass { AudioBackendClass parent_class; + + audio_driver *driver; }; =20 struct AudioMixengBackend { diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 814820e2864..ecc22d7c8f9 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -27,6 +27,7 @@ #include "qemu/main-loop.h" #include "qemu/module.h" #include "qemu/audio.h" +#include "qom/object.h" #include "trace.h" =20 #pragma GCC diagnostic ignored "-Waddress" @@ -36,6 +37,22 @@ =20 #define DEBUG_ALSA 0 =20 +#define TYPE_AUDIO_ALSA "audio-alsa" +OBJECT_DECLARE_SIMPLE_TYPE(AudioALSA, AUDIO_ALSA) + +struct AudioALSA { + AudioMixengBackend parent_obj; +}; + +static struct audio_driver alsa_audio_driver; + +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; @@ -945,8 +962,18 @@ static struct audio_driver alsa_audio_driver =3D { .voice_size_in =3D sizeof (ALSAVoiceIn) }; =20 +static const TypeInfo audio_alsa_info =3D { + .name =3D TYPE_AUDIO_ALSA, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioALSA), + .class_init =3D audio_alsa_class_init, +}; + + static void register_audio_alsa(void) { audio_driver_register(&alsa_audio_driver); + type_register_static(&audio_alsa_info); } type_init(register_audio_alsa); +module_obj(TYPE_AUDIO_ALSA); diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index 96d4fa3f471..4d62de6d72c 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -26,6 +26,7 @@ #include "qemu/error-report.h" #include "qemu/module.h" #include "qemu/dbus.h" +#include "qom/object.h" =20 #ifdef G_OS_UNIX #include @@ -44,6 +45,22 @@ =20 #define DBUS_DEFAULT_AUDIO_NSAMPLES 480 =20 +#define TYPE_AUDIO_DBUS "audio-dbus" +OBJECT_DECLARE_SIMPLE_TYPE(AudioDbus, AUDIO_DBUS) + +struct AudioDbus { + AudioMixengBackend parent_obj; +}; + +static struct audio_driver dbus_audio_driver; + +static void audio_dbus_class_init(ObjectClass *klass, const void *data) +{ + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + k->driver =3D &dbus_audio_driver; +} + typedef struct DBusAudio { Audiodev *dev; GDBusObjectManagerServer *server; @@ -711,10 +728,19 @@ static struct audio_driver dbus_audio_driver =3D { .voice_size_in =3D sizeof(DBusVoiceIn) }; =20 +static const TypeInfo audio_dbus_info =3D { + .name =3D TYPE_AUDIO_DBUS, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioDbus), + .class_init =3D audio_dbus_class_init, +}; + static void register_audio_dbus(void) { audio_driver_register(&dbus_audio_driver); + type_register_static(&audio_dbus_info); } type_init(register_audio_dbus); =20 module_dep("ui-dbus") +module_obj(TYPE_AUDIO_DBUS) diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 7a03d1dad86..91c83dec742 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -33,6 +33,7 @@ #include "audio_int.h" #include "qemu/module.h" #include "qapi/error.h" +#include "qom/object.h" =20 #include #include @@ -41,6 +42,22 @@ =20 #include "audio_win_int.h" =20 +#define TYPE_AUDIO_DSOUND "audio-dsound" +OBJECT_DECLARE_SIMPLE_TYPE(AudioDsound, AUDIO_DSOUND) + +struct AudioDsound { + AudioMixengBackend parent_obj; +}; + +static struct audio_driver dsound_audio_driver; + +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 { @@ -694,8 +711,17 @@ static struct audio_driver dsound_audio_driver =3D { .voice_size_in =3D sizeof (DSoundVoiceIn) }; =20 +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, +}; + static void register_audio_dsound(void) { audio_driver_register(&dsound_audio_driver); + type_register_static(&audio_dsound_info); } type_init(register_audio_dsound); +module_obj(TYPE_AUDIO_DSOUND); diff --git a/audio/jackaudio.c b/audio/jackaudio.c index 7a3fcaedbae..7ed2e91fcc8 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -27,6 +27,7 @@ #include "qemu/atomic.h" #include "qemu/main-loop.h" #include "qemu/audio.h" +#include "qom/object.h" =20 #define AUDIO_CAP "jack" #include "audio_int.h" @@ -34,6 +35,22 @@ #include #include =20 +#define TYPE_AUDIO_JACK "audio-jack" +OBJECT_DECLARE_SIMPLE_TYPE(AudioJack, AUDIO_JACK) + +struct AudioJack { + AudioMixengBackend parent_obj; +}; + +static struct audio_driver jack_driver; + +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 { @@ -691,10 +708,18 @@ static void qjack_info(const char *msg) dolog("I: %s\n", msg); } =20 +static const TypeInfo audio_jack_info =3D { + .name =3D TYPE_AUDIO_JACK, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioJack), + .class_init =3D audio_jack_class_init, +}; + static void register_audio_jack(void) { qemu_mutex_init(&qjack_shutdown_lock); audio_driver_register(&jack_driver); + type_register_static(&audio_jack_info); #if !defined(WIN32) && defined(CONFIG_PTHREAD_SETNAME_NP_W_TID) jack_set_thread_creator(qjack_thread_creator); #endif @@ -702,3 +727,4 @@ static void register_audio_jack(void) jack_set_info_function(qjack_info); } type_init(register_audio_jack); +module_obj(TYPE_AUDIO_JACK); diff --git a/audio/noaudio.c b/audio/noaudio.c index 4ed9d2156c5..b3305480013 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -25,10 +25,27 @@ #include "qemu/osdep.h" #include "qemu/module.h" #include "qemu/audio.h" +#include "qom/object.h" =20 #define AUDIO_CAP "noaudio" #include "audio_int.h" =20 +#define TYPE_AUDIO_NONE "audio-none" +OBJECT_DECLARE_SIMPLE_TYPE(AudioNone, AUDIO_NONE) + +struct AudioNone { + AudioMixengBackend parent_obj; +}; + +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; @@ -138,8 +155,17 @@ static struct audio_driver no_audio_driver =3D { .voice_size_in =3D sizeof (NoVoiceIn) }; =20 +static const TypeInfo audio_none_info =3D { + .name =3D TYPE_AUDIO_NONE, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioNone), + .class_init =3D audio_none_class_init, +}; + static void register_audio_none(void) { audio_driver_register(&no_audio_driver); + type_register_static(&audio_none_info); } type_init(register_audio_none); +module_obj(TYPE_AUDIO_NONE); diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 6ad20ab1876..9697f4a0beb 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -30,11 +30,28 @@ #include "qemu/host-utils.h" #include "qapi/error.h" #include "qemu/audio.h" +#include "qom/object.h" #include "trace.h" =20 #define AUDIO_CAP "oss" #include "audio_int.h" =20 +#define TYPE_AUDIO_OSS "audio-oss" +OBJECT_DECLARE_SIMPLE_TYPE(AudioOss, AUDIO_OSS) + +struct AudioOss { + AudioMixengBackend parent_obj; +}; + +static struct audio_driver oss_audio_driver; + +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 @@ -772,8 +789,17 @@ static struct audio_driver oss_audio_driver =3D { .voice_size_in =3D sizeof (OSSVoiceIn) }; =20 +static const TypeInfo audio_oss_info =3D { + .name =3D TYPE_AUDIO_OSS, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioOss), + .class_init =3D audio_oss_class_init, +}; + static void register_audio_oss(void) { audio_driver_register(&oss_audio_driver); + type_register_static(&audio_oss_info); } type_init(register_audio_oss); +module_obj(TYPE_AUDIO_OSS); diff --git a/audio/paaudio.c b/audio/paaudio.c index 0c06a397195..707a6d2fb23 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -4,12 +4,29 @@ #include "qemu/module.h" #include "qemu/audio.h" #include "qapi/error.h" +#include "qom/object.h" =20 #include =20 #define AUDIO_CAP "pulseaudio" #include "audio_int.h" =20 +#define TYPE_AUDIO_PA "audio-pa" +OBJECT_DECLARE_SIMPLE_TYPE(AudioPa, AUDIO_PA) + +struct AudioPa { + AudioMixengBackend parent_obj; +}; + +static struct audio_driver pa_audio_driver; + +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; @@ -931,8 +948,17 @@ static struct audio_driver pa_audio_driver =3D { .voice_size_in =3D sizeof (PAVoiceIn), }; =20 +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, +}; + static void register_audio_pa(void) { audio_driver_register(&pa_audio_driver); + type_register_static(&audio_pa_info); } type_init(register_audio_pa); +module_obj(TYPE_AUDIO_PA); diff --git a/audio/pwaudio.c b/audio/pwaudio.c index 30f717ccacf..31f8899d1ed 100644 --- a/audio/pwaudio.c +++ b/audio/pwaudio.c @@ -13,6 +13,7 @@ #include "qemu/audio.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "qom/object.h" #include #include #include @@ -27,6 +28,22 @@ =20 #include "audio_int.h" =20 +#define TYPE_AUDIO_PW "audio-pipewire" +OBJECT_DECLARE_SIMPLE_TYPE(AudioPw, AUDIO_PW) + +struct AudioPw { + AudioMixengBackend parent_obj; +}; + +static struct audio_driver pw_audio_driver; + +static void audio_pw_class_init(ObjectClass *klass, const void *data) +{ + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + k->driver =3D &pw_audio_driver; +} + typedef struct pwvolume { uint32_t channels; float values[SPA_AUDIO_MAX_CHANNELS]; @@ -847,10 +864,19 @@ static struct audio_driver pw_audio_driver =3D { .voice_size_in =3D sizeof(PWVoiceIn), }; =20 +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, +}; + static void register_audio_pw(void) { audio_driver_register(&pw_audio_driver); + type_register_static(&audio_pw_info); } =20 type_init(register_audio_pw); +module_obj(TYPE_AUDIO_PW); diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 707110973ac..5841e131cc0 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -28,6 +28,7 @@ #include "qemu/module.h" #include "qapi/error.h" #include "qemu/audio.h" +#include "qom/object.h" =20 #ifndef _WIN32 #ifdef __sun__ @@ -40,6 +41,22 @@ #define AUDIO_CAP "sdl" #include "audio_int.h" =20 +#define TYPE_AUDIO_SDL "audio-sdl" +OBJECT_DECLARE_SIMPLE_TYPE(AudioSdl, AUDIO_SDL) + +struct AudioSdl { + AudioMixengBackend parent_obj; +}; + +static struct audio_driver sdl_audio_driver; + +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; @@ -491,8 +508,17 @@ static struct audio_driver sdl_audio_driver =3D { .voice_size_in =3D sizeof(SDLVoiceIn), }; =20 +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, +}; + static void register_audio_sdl(void) { audio_driver_register(&sdl_audio_driver); + type_register_static(&audio_sdl_info); } type_init(register_audio_sdl); +module_obj(TYPE_AUDIO_SDL); diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c index 8197b8b0b47..7f388b498f6 100644 --- a/audio/sndioaudio.c +++ b/audio/sndioaudio.c @@ -20,10 +20,27 @@ #include "qemu/main-loop.h" #include "qemu/audio.h" #include "trace.h" +#include "qom/object.h" =20 #define AUDIO_CAP "sndio" #include "audio_int.h" =20 +#define TYPE_AUDIO_SNDIO "audio-sndio" +OBJECT_DECLARE_SIMPLE_TYPE(AudioSndio, AUDIO_SNDIO) + +struct AudioSndio { + AudioMixengBackend parent_obj; +}; + +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; +} + /* default latency in microseconds if no option is set */ #define SNDIO_LATENCY_US 50000 =20 @@ -555,9 +572,18 @@ static struct audio_driver sndio_audio_driver =3D { .voice_size_in =3D sizeof(SndioVoice) }; =20 +static const TypeInfo audio_sndio_info =3D { + .name =3D TYPE_AUDIO_SNDIO, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioSndio), + .class_init =3D audio_sndio_class_init, +}; + static void register_audio_sndio(void) { audio_driver_register(&sndio_audio_driver); + type_register_static(&audio_sndio_info); } =20 type_init(register_audio_sndio); +module_obj(TYPE_AUDIO_SNDIO); diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 7db2d1f0dfd..d0bcc0836ad 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -24,11 +24,28 @@ #include "qemu/timer.h" #include "qapi/error.h" #include "ui/qemu-spice.h" +#include "qom/object.h" =20 #define AUDIO_CAP "spice" #include "qemu/audio.h" #include "audio_int.h" =20 +#define TYPE_AUDIO_SPICE "audio-spice" +OBJECT_DECLARE_SIMPLE_TYPE(AudioSpice, AUDIO_SPICE) + +struct AudioSpice { + AudioMixengBackend parent_obj; +}; + +static struct audio_driver spice_audio_driver; + +static void audio_spice_class_init(ObjectClass *klass, const void *data) +{ + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + 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 @@ -325,10 +342,19 @@ static struct audio_driver spice_audio_driver =3D { .voice_size_in =3D sizeof (SpiceVoiceIn), }; =20 +static const TypeInfo audio_spice_info =3D { + .name =3D TYPE_AUDIO_SPICE, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioSpice), + .class_init =3D audio_spice_class_init, +}; + static void register_audio_spice(void) { audio_driver_register(&spice_audio_driver); + type_register_static(&audio_spice_info); } type_init(register_audio_spice); +module_obj(TYPE_AUDIO_SPICE); =20 module_dep("ui-spice-core"); diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 46460a5d573..00cf110ecd7 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -25,10 +25,27 @@ #include "qemu/osdep.h" #include "qemu/module.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" +OBJECT_DECLARE_SIMPLE_TYPE(AudioWav, AUDIO_WAV) + +struct AudioWav { + AudioMixengBackend parent_obj; +}; + +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; @@ -214,8 +231,17 @@ static struct audio_driver wav_audio_driver =3D { .voice_size_in =3D 0 }; =20 +static const TypeInfo audio_wav_info =3D { + .name =3D TYPE_AUDIO_WAV, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioWav), + .class_init =3D audio_wav_class_init, +}; + static void register_audio_wav(void) { audio_driver_register(&wav_audio_driver); + type_register_static(&audio_wav_info); } type_init(register_audio_wav); +module_obj(TYPE_AUDIO_WAV); diff --git a/audio/coreaudio.m b/audio/coreaudio.m index 997017a1e96..61333e9f2f9 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -29,10 +29,27 @@ #include "qemu/main-loop.h" #include "qemu/module.h" #include "qemu/audio.h" +#include "qom/object.h" =20 #define AUDIO_CAP "coreaudio" #include "audio_int.h" =20 +#define TYPE_AUDIO_COREAUDIO "audio-coreaudio" +OBJECT_DECLARE_SIMPLE_TYPE(AudioCoreaudio, AUDIO_COREAUDIO) + +struct AudioCoreaudio { + AudioMixengBackend parent_obj; +}; + +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; @@ -673,8 +690,17 @@ static void coreaudio_audio_fini (void *opaque) .voice_size_in =3D 0 }; =20 +static const TypeInfo audio_coreaudio_info =3D { + .name =3D TYPE_AUDIO_COREAUDIO, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioCoreaudio), + .class_init =3D audio_coreaudio_class_init, +}; + static void register_audio_coreaudio(void) { audio_driver_register(&coreaudio_audio_driver); + type_register_static(&audio_coreaudio_info); } type_init(register_audio_coreaudio); +module_obj(TYPE_AUDIO_COREAUDIO); --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854635; cv=none; d=zohomail.com; s=zohoarc; b=mfWOD8DcEb8IPLfAzFsZpScC/vpFr3iJQLPO7Vv3RsAo/fVbLvKD3rLenIYG4TUQGDMKeOs3DCIT03CQSmDCZq/rTLHSCiDnN5p/MV47VUj/6POpRmuEWQTJvy6V6IqtQGs48P+FPaL4BPXFWs4I81IhBVE4l/hZfFp0R1zhXG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854635; 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=JO/doYJMTA5GIVakdVk4YUijhqPrKYqGCmICdVQo/SA=; b=XTEOxrpZ3cFwwjno/juJUF9bgi4sco3mS0IGX4vwvsIdZ6FQCN2MfwhOjVfnexnBPVd8yrCY87tHP2A9fLWh26odWDITtXF3qVHjX/RcSmYPEXJzZZCYLHeIgTFuMJRNegJa8fb4Dayp1Kub4h5fL97zSBVVyeY8azp2D4OXYmw= 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 1771854635883946.9001174288024; Mon, 23 Feb 2026 05:50:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJp-0003I5-Eq; Mon, 23 Feb 2026 08:49:49 -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 1vuWIp-0000jp-FZ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:51 -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 1vuWIm-000752-V9 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:46 -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-350-Xs7Uq5qENOiCqDXKONkVVQ-1; Mon, 23 Feb 2026 08:48:43 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1F38A1956053; Mon, 23 Feb 2026 13:48:42 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9A8251800465; Mon, 23 Feb 2026 13:48:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854524; 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=JO/doYJMTA5GIVakdVk4YUijhqPrKYqGCmICdVQo/SA=; b=SPe1UMrJM0ZdUAtvyfDibPinV2gxkAYB1YSvJqk4idVPlxHAAPTadhJ+c6mAgT8sEeZ0jE z3OZdmcTXURVlhzZ8Wr8yNsvDTM6JrwOqXutH3XOLYjMZI3nEIYvnAXcPL9ILCkpxhO00s 7DeRCYPUyeeIa4cYFjrIYj4BATwOU3Y= X-MC-Unique: Xs7Uq5qENOiCqDXKONkVVQ-1 X-Mimecast-MFC-AGG-ID: Xs7Uq5qENOiCqDXKONkVVQ_1771854522 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 25/85] audio: remove set_dbus_server from audio_driver Date: Mon, 23 Feb 2026 14:46:26 +0100 Message-ID: <20260223134731.2377432-26-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854637232158500 From: Marc-Andr=C3=A9 Lureau Use the QOM class vtable only instead. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 10 ---------- audio/audio.c | 29 +++-------------------------- audio/dbusaudio.c | 17 +++++++++-------- 3 files changed, 12 insertions(+), 44 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 29f5864be69..0b97c8edee3 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -33,10 +33,6 @@ #include "qemu/audio-capture.h" #include "mixeng.h" =20 -#ifdef CONFIG_GIO -#include -#endif - void G_GNUC_PRINTF(2, 0) AUD_vlog(const char *cap, const char *fmt, va_list ap); =20 @@ -145,12 +141,6 @@ struct audio_driver { const char *name; void *(*init) (Audiodev *, Error **); void (*fini) (void *); -#ifdef CONFIG_GIO - bool (*set_dbus_server)(AudioBackend *be, - GDBusObjectManagerServer *manager, - bool p2p, - Error **errp); -#endif struct audio_pcm_ops *pcm_ops; int max_voices_out; int max_voices_in; diff --git a/audio/audio.c b/audio/audio.c index 3e1cd988852..5d0f5ad2145 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1640,31 +1640,11 @@ static const char *audio_mixeng_backend_get_id(Audi= oBackend *be) return AUDIO_MIXENG_BACKEND(be)->dev->id; } =20 -#ifdef CONFIG_GIO -static bool audio_mixeng_backend_set_dbus_server(AudioBackend *be, - GDBusObjectManagerServer = *manager, - bool p2p, - Error **errp) -{ - AudioMixengBackend *d =3D AUDIO_MIXENG_BACKEND(be); - - if (!d->drv->set_dbus_server) { - return false; - } - - return d->drv->set_dbus_server(be, manager, p2p, errp); -} - -#endif - static void audio_mixeng_backend_class_init(ObjectClass *klass, const void= *data) { AudioBackendClass *be =3D AUDIO_BACKEND_CLASS(klass); =20 be->get_id =3D audio_mixeng_backend_get_id; -#ifdef CONFIG_GIO - be->set_dbus_server =3D audio_mixeng_backend_set_dbus_server; -#endif } =20 static void audio_mixeng_backend_init(Object *obj) @@ -2264,12 +2244,9 @@ AudioBackend *audio_be_by_name(const char *name, Err= or **errp) #ifdef CONFIG_GIO bool audio_be_can_set_dbus_server(AudioBackend *be) { - /* - * TODO: - * AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - * return klass->set_dbus_server !=3D NULL; - */ - return AUDIO_MIXENG_BACKEND(be)->drv->set_dbus_server !=3D NULL; + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->set_dbus_server !=3D NULL; } =20 bool audio_be_set_dbus_server(AudioBackend *be, diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index 4d62de6d72c..5a5752b8f33 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -54,13 +54,6 @@ struct AudioDbus { =20 static struct audio_driver dbus_audio_driver; =20 -static void audio_dbus_class_init(ObjectClass *klass, const void *data) -{ - AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); - - k->driver =3D &dbus_audio_driver; -} - typedef struct DBusAudio { Audiodev *dev; GDBusObjectManagerServer *server; @@ -720,7 +713,6 @@ static struct audio_driver dbus_audio_driver =3D { .name =3D "dbus", .init =3D dbus_audio_init, .fini =3D dbus_audio_fini, - .set_dbus_server =3D dbus_audio_set_server, .pcm_ops =3D &dbus_pcm_ops, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, @@ -728,6 +720,15 @@ static struct audio_driver dbus_audio_driver =3D { .voice_size_in =3D sizeof(DBusVoiceIn) }; =20 +static void audio_dbus_class_init(ObjectClass *klass, const void *data) +{ + AudioBackendClass *b =3D AUDIO_BACKEND_CLASS(klass); + AudioMixengBackendClass *k =3D AUDIO_MIXENG_BACKEND_CLASS(klass); + + b->set_dbus_server =3D dbus_audio_set_server; + k->driver =3D &dbus_audio_driver; +} + static const TypeInfo audio_dbus_info =3D { .name =3D TYPE_AUDIO_DBUS, .parent =3D TYPE_AUDIO_MIXENG_BACKEND, --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854786; cv=none; d=zohomail.com; s=zohoarc; b=lXwzJBx5wixaK58HFvQIZC/yA3BEuRT91rNAhrOZC8WyxsmfXF86Dfniyoh+rBD/Lq1RKfp9xSR1GjdLmhucws9UqDAVk2/NaE7eEDIyGQFXLQsbCXeHU7mhewh11x+j2gAV6mC93/cUfwTnCtN1x4pbEEiDufN8gUJuhLY9H94= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854786; 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=6GhijycHKeebI32O4PhP+DIZaklxb5TcF/ISqeLI/T0=; b=Ep0JdsKrOajAyyCEhjV/cUW7ATZfw9RkniF5u1QpVg9rhjddaY48pxJuhAwEf246/fMpc+LFbC7h+noWdrbvvLG5ktWJwpFdhGER83rRw0vQ5bnr9PndT91t4UwDJBA/RTQ/+Hhef0Ojs5shN5tlokZiAxOBP9UZMDIjiCqcCSI= 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 1771854786245615.629307356039; Mon, 23 Feb 2026 05:53:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWK7-0003p5-Cq; Mon, 23 Feb 2026 08:50:07 -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 1vuWIs-0000n0-WC for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:51 -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 1vuWIr-00075n-EW for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:50 -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-574-NPpNhE_JO8qtGR1Biz_kDw-1; Mon, 23 Feb 2026 08:48:45 -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 B1D2619560AA; Mon, 23 Feb 2026 13:48:44 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CF53F1800351; Mon, 23 Feb 2026 13:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854528; 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=6GhijycHKeebI32O4PhP+DIZaklxb5TcF/ISqeLI/T0=; b=HYrG9ulqqxWybB2pHrroAR6P3lOEHoRNBi+zMlk74ezHEXBVkYf9oIo/107sIvhdaLHBRs +TA4WOaHnjDxIkzRhDtImNnJkCZrH1SPgkB6JPmaudP5imvdrKRp/iCjkEy/+oD2QpudwW jMWK5zfkidJKLWXUB0NRHDmk3sQL/w0= X-MC-Unique: NPpNhE_JO8qtGR1Biz_kDw-1 X-Mimecast-MFC-AGG-ID: NPpNhE_JO8qtGR1Biz_kDw_1771854524 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 26/85] audio: lookup "audio-" object types, and realize them Date: Mon, 23 Feb 2026 14:46:27 +0100 Message-ID: <20260223134731.2377432-27-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854788074158500 From: Marc-Andr=C3=A9 Lureau Now "audio_driver" is a detail implementation of AudioMixengBackend and not required to implement an AudioBackend. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qemu/audio.h | 1 + audio/audio.c | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/include/qemu/audio.h b/include/qemu/audio.h index 474d761f0be..1eeead2a722 100644 --- a/include/qemu/audio.h +++ b/include/qemu/audio.h @@ -51,6 +51,7 @@ typedef struct AudioBackend { typedef struct AudioBackendClass { ObjectClass parent_class; =20 + bool (*realize)(AudioBackend *be, Audiodev *dev, Error **errp); const char *(*get_id)(AudioBackend *be); #ifdef CONFIG_GIO bool (*set_dbus_server)(AudioBackend *be, diff --git a/audio/audio.c b/audio/audio.c index 5d0f5ad2145..72949fe27f5 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1562,24 +1562,16 @@ size_t audio_generic_read(HWVoiceIn *hw, void *buf,= size_t size) return total; } =20 -static AudioBackend *audio_be_new(Audiodev *dev, Error **errp) +static bool audio_mixeng_backend_realize(AudioBackend *abe, + Audiodev *dev, Error **errp) { - const char *drvname =3D AudiodevDriver_str(dev->driver); - struct audio_driver *drv =3D audio_driver_lookup(drvname); + AudioMixengBackend *be =3D AUDIO_MIXENG_BACKEND(abe); + audio_driver *drv =3D AUDIO_MIXENG_BACKEND_GET_CLASS(be)->driver; =20 - if (!drv) { - error_setg(errp, "Unknown audio driver `%s'", drvname); - qapi_free_Audiodev(dev); - return NULL; - } - - AudioMixengBackend *be =3D AUDIO_MIXENG_BACKEND(object_new(TYPE_AUDIO_= MIXENG_BACKEND)); be->dev =3D dev; - be->drv_opaque =3D drv->init(be->dev, errp); if (!be->drv_opaque) { - object_unref(OBJECT(be)); - return NULL; + return false; } =20 if (!drv->pcm_ops->get_buffer_in) { @@ -1601,7 +1593,26 @@ static AudioBackend *audio_be_new(Audiodev *dev, Err= or **errp) be->period_ticks =3D be->dev->timer_period * (int64_t)SCALE_US; } =20 - return AUDIO_BACKEND(be); + return true; +} + +static AudioBackend *audio_be_new(Audiodev *dev, Error **errp) +{ + const char *drvname =3D AudiodevDriver_str(dev->driver); + g_autofree char *type =3D g_strconcat("audio-", drvname, NULL); + AudioBackend *be =3D AUDIO_BACKEND(object_new(type)); + + if (!be) { + error_setg(errp, "Unknown audio driver `%s'", drvname); + return NULL; + } + + if (!AUDIO_BACKEND_GET_CLASS(be)->realize(be, dev, errp)) { + object_unref(OBJECT(be)); + return NULL; + } + + return be; } =20 static void audio_vm_change_state_handler (void *opaque, bool running, @@ -1644,6 +1655,7 @@ static void audio_mixeng_backend_class_init(ObjectCla= ss *klass, const void *data { AudioBackendClass *be =3D AUDIO_BACKEND_CLASS(klass); =20 + be->realize =3D audio_mixeng_backend_realize; be->get_id =3D audio_mixeng_backend_get_id; } =20 --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854753; cv=none; d=zohomail.com; s=zohoarc; b=B8XGK3F1e4PJF5UQQPr4EvWs0AjtYGuLCFuA15ZvfveDsWuKusOc7OFdCs26TtFwo81yNWUI20jUrH+v8AD4zvhjl2iiXuPIR5tYU4+WOknPs1zv4BBpPsnN7IsfkhLGzL4BmUREkVHbxj/1dsx8ptWEpxaNPapbMFYdidcGJXw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854753; 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=7HCB0tFd+ANmIO7FPb3+hIVZQ6tqCMrMKL5pZLTa81o=; b=CqpQeeXTT2OskQASdV93kq2xRn0t4KXz8NOQ6CzrKu7AtjlM5ui5c/LwF7M+34y3KVOtgu5MHA1OrYHWBwrOxIfxw7PnXcbJQwzkujfT6aJQCKN/upcXHjLM1WhZtQsocxiWMx92OhacopWiMZrr4AwXo2in2VZSwoxDbb2Z58c= 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 1771854753555361.4419122032182; Mon, 23 Feb 2026 05:52:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWK8-0003qg-0D; Mon, 23 Feb 2026 08:50: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 1vuWIy-00016Z-Br for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:56 -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 1vuWIw-00076N-AG for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:55 -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-377-GiA1s5N3PqCr7PLW8q9gDw-1; Mon, 23 Feb 2026 08:48:49 -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 3CBCB1956072; Mon, 23 Feb 2026 13:48:48 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0F56F30001BE; Mon, 23 Feb 2026 13:48:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854533; 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=7HCB0tFd+ANmIO7FPb3+hIVZQ6tqCMrMKL5pZLTa81o=; b=ZT9XdHWW1/SFrarmZEhJyE9/eQHCn/Q/+np0j8pk45omUm1keTXwH3GjNAh9Co61nc/Lvt 4zxkd8iAA9xhbLaQqX1J+6l9OdN+MzzFwgiJdMsEunzaHoDDURZnBbuZjtNTdoDQZZUWT9 rrhw7ago2piYWHIfUgcvUpre1z7IiDU= X-MC-Unique: GiA1s5N3PqCr7PLW8q9gDw-1 X-Mimecast-MFC-AGG-ID: GiA1s5N3PqCr7PLW8q9gDw_1771854528 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Thomas Huth , Alexandre Ratchov Subject: [PULL v3 27/85] audio: drop audio driver registration Date: Mon, 23 Feb 2026 14:46:28 +0100 Message-ID: <20260223134731.2377432-28-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854755184158500 From: Marc-Andr=C3=A9 Lureau module_object_class_by_name() handles loading the module providing the requested object. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki Reviewed-by: Mark Cave-Ayland --- audio/audio_int.h | 2 -- audio/alsaaudio.c | 1 - audio/audio.c | 43 +++++++++++++------------------------------ 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, 13 insertions(+), 45 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 0b97c8edee3..446ba1d52c6 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -259,8 +259,6 @@ extern const struct mixeng_volume nominal_volume; =20 extern const char *audio_prio_list[]; =20 -void audio_driver_register(audio_driver *drv); - 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 diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index ecc22d7c8f9..7200777ad82 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -972,7 +972,6 @@ static const TypeInfo audio_alsa_info =3D { =20 static void register_audio_alsa(void) { - audio_driver_register(&alsa_audio_driver); type_register_static(&audio_alsa_info); } type_init(register_audio_alsa); diff --git a/audio/audio.c b/audio/audio.c index 72949fe27f5..16edc57e5f0 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -68,40 +68,21 @@ const char *audio_prio_list[] =3D { NULL }; =20 -static QLIST_HEAD(, audio_driver) audio_drivers; static AudiodevListHead audiodevs =3D QSIMPLEQ_HEAD_INITIALIZER(audiodevs); static AudiodevListHead default_audiodevs =3D QSIMPLEQ_HEAD_INITIALIZER(default_audiodevs); =20 - -void audio_driver_register(audio_driver *drv) -{ - QLIST_INSERT_HEAD(&audio_drivers, drv, next); -} - -static audio_driver *audio_driver_lookup(const char *name) +static AudioBackendClass *audio_be_class_by_name(const char *name) { - struct audio_driver *d; - Error *local_err =3D NULL; - int rv; + g_autofree char *tname =3D g_strconcat("audio-", name, NULL); + ObjectClass *oc =3D module_object_class_by_name(tname); =20 - QLIST_FOREACH(d, &audio_drivers, next) { - if (strcmp(name, d->name) =3D=3D 0) { - return d; - } - } - rv =3D audio_module_load(name, &local_err); - if (rv > 0) { - QLIST_FOREACH(d, &audio_drivers, next) { - if (strcmp(name, d->name) =3D=3D 0) { - return d; - } - } - } else if (rv < 0) { - error_report_err(local_err); + if (!oc || !object_class_dynamic_cast(oc, TYPE_AUDIO_BACKEND)) { + return NULL; } - return NULL; + + return AUDIO_BACKEND_CLASS(oc); } =20 static AudioBackend *default_audio_be; @@ -1764,7 +1745,7 @@ static const VMStateDescription vmstate_audio =3D { void audio_create_default_audiodevs(void) { for (int i =3D 0; audio_prio_list[i]; i++) { - if (audio_driver_lookup(audio_prio_list[i])) { + if (audio_be_class_by_name(audio_prio_list[i]) !=3D NULL) { QDict *dict =3D qdict_new(); Audiodev *dev =3D NULL; Visitor *v; @@ -2129,9 +2110,11 @@ void audio_help(void) printf("Available audio drivers:\n"); =20 for (i =3D 0; i < AUDIODEV_DRIVER__MAX; i++) { - audio_driver *driver =3D audio_driver_lookup(AudiodevDriver_str(i)= ); - if (driver) { - printf("%s\n", driver->name); + const char *name =3D AudiodevDriver_str(i); + AudioBackendClass *be =3D audio_be_class_by_name(name); + + if (be) { + printf("%s\n", name); } } } diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index 5a5752b8f33..48c9078d80e 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -738,7 +738,6 @@ static const TypeInfo audio_dbus_info =3D { =20 static void register_audio_dbus(void) { - audio_driver_register(&dbus_audio_driver); type_register_static(&audio_dbus_info); } type_init(register_audio_dbus); diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 91c83dec742..6d213899660 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -720,7 +720,6 @@ static const TypeInfo audio_dsound_info =3D { =20 static void register_audio_dsound(void) { - audio_driver_register(&dsound_audio_driver); type_register_static(&audio_dsound_info); } type_init(register_audio_dsound); diff --git a/audio/jackaudio.c b/audio/jackaudio.c index 7ed2e91fcc8..bfce4cb0b4c 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -718,7 +718,6 @@ static const TypeInfo audio_jack_info =3D { static void register_audio_jack(void) { qemu_mutex_init(&qjack_shutdown_lock); - audio_driver_register(&jack_driver); type_register_static(&audio_jack_info); #if !defined(WIN32) && defined(CONFIG_PTHREAD_SETNAME_NP_W_TID) jack_set_thread_creator(qjack_thread_creator); diff --git a/audio/noaudio.c b/audio/noaudio.c index b3305480013..8b5ebd71bf6 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -164,7 +164,6 @@ static const TypeInfo audio_none_info =3D { =20 static void register_audio_none(void) { - audio_driver_register(&no_audio_driver); type_register_static(&audio_none_info); } type_init(register_audio_none); diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 9697f4a0beb..b8e26b17ed7 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -798,7 +798,6 @@ static const TypeInfo audio_oss_info =3D { =20 static void register_audio_oss(void) { - audio_driver_register(&oss_audio_driver); type_register_static(&audio_oss_info); } type_init(register_audio_oss); diff --git a/audio/paaudio.c b/audio/paaudio.c index 707a6d2fb23..adaeb2af807 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -957,7 +957,6 @@ static const TypeInfo audio_pa_info =3D { =20 static void register_audio_pa(void) { - audio_driver_register(&pa_audio_driver); type_register_static(&audio_pa_info); } type_init(register_audio_pa); diff --git a/audio/pwaudio.c b/audio/pwaudio.c index 31f8899d1ed..facd166052c 100644 --- a/audio/pwaudio.c +++ b/audio/pwaudio.c @@ -874,7 +874,6 @@ static const TypeInfo audio_pw_info =3D { static void register_audio_pw(void) { - audio_driver_register(&pw_audio_driver); type_register_static(&audio_pw_info); } =20 diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 5841e131cc0..c00f1366d17 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -517,7 +517,6 @@ static const TypeInfo audio_sdl_info =3D { =20 static void register_audio_sdl(void) { - audio_driver_register(&sdl_audio_driver); type_register_static(&audio_sdl_info); } type_init(register_audio_sdl); diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c index 7f388b498f6..c8310b1fa37 100644 --- a/audio/sndioaudio.c +++ b/audio/sndioaudio.c @@ -581,7 +581,6 @@ static const TypeInfo audio_sndio_info =3D { =20 static void register_audio_sndio(void) { - audio_driver_register(&sndio_audio_driver); type_register_static(&audio_sndio_info); } =20 diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index d0bcc0836ad..d1bb318b6b7 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -351,7 +351,6 @@ static const TypeInfo audio_spice_info =3D { =20 static void register_audio_spice(void) { - audio_driver_register(&spice_audio_driver); type_register_static(&audio_spice_info); } type_init(register_audio_spice); diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 00cf110ecd7..12d4108ffad 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -240,7 +240,6 @@ static const TypeInfo audio_wav_info =3D { =20 static void register_audio_wav(void) { - audio_driver_register(&wav_audio_driver); type_register_static(&audio_wav_info); } type_init(register_audio_wav); diff --git a/audio/coreaudio.m b/audio/coreaudio.m index 61333e9f2f9..5efd16df7c4 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -699,7 +699,6 @@ static void coreaudio_audio_fini (void *opaque) =20 static void register_audio_coreaudio(void) { - audio_driver_register(&coreaudio_audio_driver); type_register_static(&audio_coreaudio_info); } type_init(register_audio_coreaudio); --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854708; cv=none; d=zohomail.com; s=zohoarc; b=E0lIJ/XiPk9GU8FIXmdpMa5zwJLoe+pRki0BwVNK3vp7P7xc6qggSUs176JimLj0CaH1QYMzof9ASFlHaUKXVwMKtiAJu3aWclfVBLxePdTyTIVnkRSDIzuj1NDwnqgYTwl1VeRWunn8vwpNilhTbOfqkBTnRYo1Z3k3ha6MKOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854708; 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=e/lNqekkU0zmaz129+ZTshYIgpbjYvVcZpX5WuE9OxM=; b=goJjfWQi0E726W5PMxz8v97Esd7C2M90lkDi5gxvn6/NSDbE/1FLrxiv7lBKxf9gjbuufOJWM+aKZV4F5sOwq5IULDacP6zMR+s+3n+ASaPL8SzqjAxDN6Ulu4JLhIujB8AZ+3BqL8VhlPV//ZJkWX6p6uDkkTdsUaa6HeURWVA= 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 1771854708701119.00743919834281; Mon, 23 Feb 2026 05:51:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWK5-0003fm-Sa; Mon, 23 Feb 2026 08:50: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 1vuWIy-00016c-EJ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48:56 -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 1vuWIx-00076c-49 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:48: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-275-EEaincpzM7SePq1pQG-jyQ-1; Mon, 23 Feb 2026 08:48: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 D307D180057E; Mon, 23 Feb 2026 13:48:50 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 539491955F22; Mon, 23 Feb 2026 13:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854534; 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=e/lNqekkU0zmaz129+ZTshYIgpbjYvVcZpX5WuE9OxM=; b=QYQ6GHVXltBLl7dILtzoZcHN10r2xHagWaV3KGR5fzvAjGOqFexYU3Z0JWdT5Cgu+4euNQ PSYSkdVcAb3fpzBKoALMjtNSubti8+FSiCi848Be/Jw9KZzyQA5YFby7JY/9eXXhuwwkaM zgRX3foDhqRcQ4Au76y4iWQzgMhKC5I= X-MC-Unique: EEaincpzM7SePq1pQG-jyQ-1 X-Mimecast-MFC-AGG-ID: EEaincpzM7SePq1pQG-jyQ_1771854530 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v3 28/85] module: remove audio module support Date: Mon, 23 Feb 2026 14:46:29 +0100 Message-ID: <20260223134731.2377432-29-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854709540158500 From: Marc-Andr=C3=A9 Lureau It relies on dynamic object loading support instead. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qemu/module.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/qemu/module.h b/include/qemu/module.h index c37ce74b16f..9885ac9afb3 100644 --- a/include/qemu/module.h +++ b/include/qemu/module.h @@ -63,7 +63,6 @@ typedef enum { #define migration_init(function) module_init(function, MODULE_INIT_MIGRATI= ON) #define block_module_load(lib, errp) module_load("block-", lib, errp) #define ui_module_load(lib, errp) module_load("ui-", lib, errp) -#define audio_module_load(lib, errp) module_load("audio-", lib, errp) =20 void register_module_init(void (*fn)(void), module_init_type type); void register_dso_module_init(void (*fn)(void), module_init_type type); @@ -78,7 +77,7 @@ void module_call_init(module_init_type type); * - get_relocated_path(CONFIG_QEMU_MODDIR); * - /var/run/qemu/${version_dir} * - * prefix: a subsystem prefix, or the empty string ("audio-", ...,= "") + * prefix: a subsystem prefix, or the empty string ("ui-", ..., "") * name: name of the module * errp: error to set in case the module is found, but load fail= ed. * --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854800; cv=none; d=zohomail.com; s=zohoarc; b=YAFBTXQPjE4/sBwCgrzzbLr5LCjfrpz/L5gz5n5Vetznjp0l35NXKc9OYvjb9SvQ9HYomc80RaDvSXIwwA8CLcira3upDZ/3uXdKn5PMflEfaCZaKxxctDX/mKY18q1HCe5axmP9aBQsfcgtpoIYZ5nIfUeUssS570g1K5j2JYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854800; 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=7dYNOcoBCKFkN0Cn3daTveXayiCg4/lNSqFq1tQwUuA=; b=aGCBIxITSPlLz3coDns2N43ek07TDBsK/g1KF4uuPBN456AcWq8ahtq5qXUl05FwvQ/p+3ZMOH5W4i6NWaFnxveBAXmDV7CArNg3qdj47I6SscojBNRBv/qb04KhsnTHvSB7PsgeQcZ158iYrt4oYO7TAjuNQI8oPyCf7gIGYNw= 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 1771854800295426.2417971504361; Mon, 23 Feb 2026 05:53:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWK9-0003xx-Iy; Mon, 23 Feb 2026 08:50:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWJ4-0001FX-EW for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:04 -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 1vuWJ2-000778-5I for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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-692-r1A83dWKPemAMMfBO5MJ4Q-1; Mon, 23 Feb 2026 08:48:55 -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 8C9EC19560A1; Mon, 23 Feb 2026 13:48:53 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C49561955F22; Mon, 23 Feb 2026 13:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854538; 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=7dYNOcoBCKFkN0Cn3daTveXayiCg4/lNSqFq1tQwUuA=; b=YiAHepyQ8ib8eJ8VOSd51miyxFO4HSzkX/1JK3ndzhmE7POyhQrxoS6X2NI6g4F1Wl+JDO H5LU+59OgEBoNQPhzdbYlErNCgO+Ycb4m56zRJuuOvzCqjnMM8vwRy9TbF5agScwp87Dq/ nvfjtNwLIiOgcOtBComNZELgveSU3aE= X-MC-Unique: r1A83dWKPemAMMfBO5MJ4Q-1 X-Mimecast-MFC-AGG-ID: r1A83dWKPemAMMfBO5MJ4Q_1771854534 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Thomas Huth , Alexandre Ratchov Subject: [PULL v3 29/85] audio: replace type_init() with DEFINE_TYPES Date: Mon, 23 Feb 2026 14:46:30 +0100 Message-ID: <20260223134731.2377432-30-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854803122158500 From: Marc-Andr=C3=A9 Lureau Use the convenience macro to register types. Note that jack backend was using the type registration to initialize some globals. Use a ctor function instead. Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/alsaaudio.c | 19 ++++++++----------- audio/dbusaudio.c | 18 ++++++++---------- audio/dsoundaudio.c | 18 ++++++++---------- audio/jackaudio.c | 18 ++++++++++-------- audio/noaudio.c | 18 ++++++++---------- audio/ossaudio.c | 18 ++++++++---------- audio/paaudio.c | 18 ++++++++---------- audio/pwaudio.c | 20 ++++++++------------ audio/sdlaudio.c | 18 ++++++++---------- audio/sndioaudio.c | 19 ++++++++----------- audio/spiceaudio.c | 18 ++++++++---------- audio/wavaudio.c | 18 ++++++++---------- audio/coreaudio.m | 18 ++++++++---------- 13 files changed, 106 insertions(+), 132 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 7200777ad82..ae1cec6a36e 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -962,17 +962,14 @@ static struct audio_driver alsa_audio_driver =3D { .voice_size_in =3D sizeof (ALSAVoiceIn) }; =20 -static const TypeInfo audio_alsa_info =3D { - .name =3D TYPE_AUDIO_ALSA, - .parent =3D TYPE_AUDIO_MIXENG_BACKEND, - .instance_size =3D sizeof(AudioALSA), - .class_init =3D audio_alsa_class_init, +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_ALSA, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioALSA), + .class_init =3D audio_alsa_class_init, + }, }; =20 - -static void register_audio_alsa(void) -{ - type_register_static(&audio_alsa_info); -} -type_init(register_audio_alsa); +DEFINE_TYPES(audio_types) module_obj(TYPE_AUDIO_ALSA); diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index 48c9078d80e..269db7877b6 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -729,18 +729,16 @@ static void audio_dbus_class_init(ObjectClass *klass,= const void *data) k->driver =3D &dbus_audio_driver; } =20 -static const TypeInfo audio_dbus_info =3D { - .name =3D TYPE_AUDIO_DBUS, - .parent =3D TYPE_AUDIO_MIXENG_BACKEND, - .instance_size =3D sizeof(AudioDbus), - .class_init =3D audio_dbus_class_init, +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_DBUS, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioDbus), + .class_init =3D audio_dbus_class_init, + }, }; =20 -static void register_audio_dbus(void) -{ - type_register_static(&audio_dbus_info); -} -type_init(register_audio_dbus); +DEFINE_TYPES(audio_types) =20 module_dep("ui-dbus") module_obj(TYPE_AUDIO_DBUS) diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 6d213899660..462d09e02af 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -711,16 +711,14 @@ static struct audio_driver dsound_audio_driver =3D { .voice_size_in =3D sizeof (DSoundVoiceIn) }; =20 -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, +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_DSOUND, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioDsound), + .class_init =3D audio_dsound_class_init, + }, }; =20 -static void register_audio_dsound(void) -{ - type_register_static(&audio_dsound_info); -} -type_init(register_audio_dsound); +DEFINE_TYPES(audio_types) module_obj(TYPE_AUDIO_DSOUND); diff --git a/audio/jackaudio.c b/audio/jackaudio.c index bfce4cb0b4c..972b158f023 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -708,22 +708,24 @@ static void qjack_info(const char *msg) dolog("I: %s\n", msg); } =20 -static const TypeInfo audio_jack_info =3D { - .name =3D TYPE_AUDIO_JACK, - .parent =3D TYPE_AUDIO_MIXENG_BACKEND, - .instance_size =3D sizeof(AudioJack), - .class_init =3D audio_jack_class_init, +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_JACK, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioJack), + .class_init =3D audio_jack_class_init, + }, }; =20 -static void register_audio_jack(void) +static void __attribute__((__constructor__)) audio_jack_init(void) { qemu_mutex_init(&qjack_shutdown_lock); - type_register_static(&audio_jack_info); #if !defined(WIN32) && defined(CONFIG_PTHREAD_SETNAME_NP_W_TID) jack_set_thread_creator(qjack_thread_creator); #endif jack_set_error_function(qjack_error); jack_set_info_function(qjack_info); } -type_init(register_audio_jack); + +DEFINE_TYPES(audio_types) module_obj(TYPE_AUDIO_JACK); diff --git a/audio/noaudio.c b/audio/noaudio.c index 8b5ebd71bf6..65679b8b13d 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -155,16 +155,14 @@ static struct audio_driver no_audio_driver =3D { .voice_size_in =3D sizeof (NoVoiceIn) }; =20 -static const TypeInfo audio_none_info =3D { - .name =3D TYPE_AUDIO_NONE, - .parent =3D TYPE_AUDIO_MIXENG_BACKEND, - .instance_size =3D sizeof(AudioNone), - .class_init =3D audio_none_class_init, +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_NONE, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioNone), + .class_init =3D audio_none_class_init, + }, }; =20 -static void register_audio_none(void) -{ - type_register_static(&audio_none_info); -} -type_init(register_audio_none); +DEFINE_TYPES(audio_types) module_obj(TYPE_AUDIO_NONE); diff --git a/audio/ossaudio.c b/audio/ossaudio.c index b8e26b17ed7..f64c564e345 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -789,16 +789,14 @@ static struct audio_driver oss_audio_driver =3D { .voice_size_in =3D sizeof (OSSVoiceIn) }; =20 -static const TypeInfo audio_oss_info =3D { - .name =3D TYPE_AUDIO_OSS, - .parent =3D TYPE_AUDIO_MIXENG_BACKEND, - .instance_size =3D sizeof(AudioOss), - .class_init =3D audio_oss_class_init, +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_OSS, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioOss), + .class_init =3D audio_oss_class_init, + }, }; =20 -static void register_audio_oss(void) -{ - type_register_static(&audio_oss_info); -} -type_init(register_audio_oss); +DEFINE_TYPES(audio_types) module_obj(TYPE_AUDIO_OSS); diff --git a/audio/paaudio.c b/audio/paaudio.c index adaeb2af807..331da4f2ed6 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -948,16 +948,14 @@ static struct audio_driver pa_audio_driver =3D { .voice_size_in =3D sizeof (PAVoiceIn), }; =20 -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, +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_PA, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioPa), + .class_init =3D audio_pa_class_init, + }, }; =20 -static void register_audio_pa(void) -{ - type_register_static(&audio_pa_info); -} -type_init(register_audio_pa); +DEFINE_TYPES(audio_types) module_obj(TYPE_AUDIO_PA); diff --git a/audio/pwaudio.c b/audio/pwaudio.c index facd166052c..3b524dfea5a 100644 --- a/audio/pwaudio.c +++ b/audio/pwaudio.c @@ -864,18 +864,14 @@ static struct audio_driver pw_audio_driver =3D { .voice_size_in =3D sizeof(PWVoiceIn), }; =20 -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, +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_PW, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioPw), + .class_init =3D audio_pw_class_init, + }, }; =20 -static void -register_audio_pw(void) -{ - type_register_static(&audio_pw_info); -} - -type_init(register_audio_pw); +DEFINE_TYPES(audio_types) module_obj(TYPE_AUDIO_PW); diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index c00f1366d17..a60b1629da0 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -508,16 +508,14 @@ static struct audio_driver sdl_audio_driver =3D { .voice_size_in =3D sizeof(SDLVoiceIn), }; =20 -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, +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_SDL, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioSdl), + .class_init =3D audio_sdl_class_init, + }, }; =20 -static void register_audio_sdl(void) -{ - type_register_static(&audio_sdl_info); -} -type_init(register_audio_sdl); +DEFINE_TYPES(audio_types) module_obj(TYPE_AUDIO_SDL); diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c index c8310b1fa37..2a9ae42992b 100644 --- a/audio/sndioaudio.c +++ b/audio/sndioaudio.c @@ -572,17 +572,14 @@ static struct audio_driver sndio_audio_driver =3D { .voice_size_in =3D sizeof(SndioVoice) }; =20 -static const TypeInfo audio_sndio_info =3D { - .name =3D TYPE_AUDIO_SNDIO, - .parent =3D TYPE_AUDIO_MIXENG_BACKEND, - .instance_size =3D sizeof(AudioSndio), - .class_init =3D audio_sndio_class_init, +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_SNDIO, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioSndio), + .class_init =3D audio_sndio_class_init, + }, }; =20 -static void register_audio_sndio(void) -{ - type_register_static(&audio_sndio_info); -} - -type_init(register_audio_sndio); +DEFINE_TYPES(audio_types) module_obj(TYPE_AUDIO_SNDIO); diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index d1bb318b6b7..ad7cb69673b 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -342,18 +342,16 @@ static struct audio_driver spice_audio_driver =3D { .voice_size_in =3D sizeof (SpiceVoiceIn), }; =20 -static const TypeInfo audio_spice_info =3D { - .name =3D TYPE_AUDIO_SPICE, - .parent =3D TYPE_AUDIO_MIXENG_BACKEND, - .instance_size =3D sizeof(AudioSpice), - .class_init =3D audio_spice_class_init, +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_SPICE, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioSpice), + .class_init =3D audio_spice_class_init, + }, }; =20 -static void register_audio_spice(void) -{ - type_register_static(&audio_spice_info); -} -type_init(register_audio_spice); +DEFINE_TYPES(audio_types) module_obj(TYPE_AUDIO_SPICE); =20 module_dep("ui-spice-core"); diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 12d4108ffad..cd2ceffd42b 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -231,16 +231,14 @@ static struct audio_driver wav_audio_driver =3D { .voice_size_in =3D 0 }; =20 -static const TypeInfo audio_wav_info =3D { - .name =3D TYPE_AUDIO_WAV, - .parent =3D TYPE_AUDIO_MIXENG_BACKEND, - .instance_size =3D sizeof(AudioWav), - .class_init =3D audio_wav_class_init, +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_WAV, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioWav), + .class_init =3D audio_wav_class_init, + } }; =20 -static void register_audio_wav(void) -{ - type_register_static(&audio_wav_info); -} -type_init(register_audio_wav); +DEFINE_TYPES(audio_types) module_obj(TYPE_AUDIO_WAV); diff --git a/audio/coreaudio.m b/audio/coreaudio.m index 5efd16df7c4..862cb9dd9b0 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -690,16 +690,14 @@ static void coreaudio_audio_fini (void *opaque) .voice_size_in =3D 0 }; =20 -static const TypeInfo audio_coreaudio_info =3D { - .name =3D TYPE_AUDIO_COREAUDIO, - .parent =3D TYPE_AUDIO_MIXENG_BACKEND, - .instance_size =3D sizeof(AudioCoreaudio), - .class_init =3D audio_coreaudio_class_init, +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_COREAUDIO, + .parent =3D TYPE_AUDIO_MIXENG_BACKEND, + .instance_size =3D sizeof(AudioCoreaudio), + .class_init =3D audio_coreaudio_class_init, + }, }; =20 -static void register_audio_coreaudio(void) -{ - type_register_static(&audio_coreaudio_info); -} -type_init(register_audio_coreaudio); +DEFINE_TYPES(audio_types) module_obj(TYPE_AUDIO_COREAUDIO); --=20 2.53.0 From nobody Sun Apr 12 02:50:02 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=1771854962; cv=none; d=zohomail.com; s=zohoarc; b=A1T1psIWCpXRaOgbY6J4hR59J2wmQN5Hk+VjVuYoBQsqM3gGkRJXfB4Y/IGPEVZ4Azf6gG5z1DzvjJeuBxilG1AIjGBlgwhrvtHSDmSmD6vngAXOveGiBZdxe7c0b/fHJ7wL0qWKamX1M/8Y6D2MO/ovAwnJkHHVY3QsZ4MzpG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854962; 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=TqhGjBY+mC3y4OSdljPQ85F3Z7Hx6fbG+VByjEnt370=; b=KytKIgPD4Skvhz3oqx+3LYyIyObvrpGVF6a8uJnfM4rsggd2y/OrO676UmFjqdiGainP66OglhHAtEq7gFTp+H4r8Qes1YBlMur//JH3EDocmu+jwZIZlrM2IhbViniAaJbKWJcaYkFq6IAdB8D1qOssx3b6F2F4DvUmKqoUkIY= 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 1771854962835418.6167023881617; Mon, 23 Feb 2026 05:56:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJz-0003Jn-2s; Mon, 23 Feb 2026 08:49:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWJ2-0001Dq-JK for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:04 -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 1vuWJ1-000775-8K for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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-633-1xFkVo6XNyGhITzt5xtmuQ-1; Mon, 23 Feb 2026 08:48: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 84A91195608D; Mon, 23 Feb 2026 13:48:56 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8A0A719560A2; Mon, 23 Feb 2026 13:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854538; 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=TqhGjBY+mC3y4OSdljPQ85F3Z7Hx6fbG+VByjEnt370=; b=TmNOtAdetsFOBp17v8PitxF0r6vAX9ckI9YvA2ujE/MSuhZ7mLJf1FOOrP/RPak+aWlctT WOpZcDksxpVNXApjhxwMED7vPkEZRmL7wvxVKlTKHYdRiXODtubJ+sT/toKGogHgSEdTSH QikJvgH/JnjXB11/z9xohgBxT71X1YQ= X-MC-Unique: 1xFkVo6XNyGhITzt5xtmuQ-1 X-Mimecast-MFC-AGG-ID: 1xFkVo6XNyGhITzt5xtmuQ_1771854536 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 30/85] audio: keep a strong reference on the backend Date: Mon, 23 Feb 2026 14:46:31 +0100 Message-ID: <20260223134731.2377432-31-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854962965158500 From: Marc-Andr=C3=A9 Lureau Since we are going to convert audio_driver-based backends, we need to properly handle reference counting to allow for a different order of class finalization (for example, pulse class before base driver class). Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_template.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index a1f78d8748b..512abbfe22f 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -231,6 +231,7 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) glue(hw->pcm_ops->fini_, TYPE) (hw); glue(s->nb_hw_voices_, TYPE) +=3D 1; glue(audio_pcm_hw_free_resources_ , TYPE) (hw); + object_unref(hw->s); g_free(hw); *hwp =3D NULL; } @@ -287,7 +288,7 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMixen= gBackend *s, * is guaranteed to be !=3D 0. See the audio_init_nb_voices_* function= s. */ hw =3D g_malloc0(glue(drv->voice_size_, TYPE)); - hw->s =3D s; + hw->s =3D AUDIO_MIXENG_BACKEND(object_ref(s)); hw->pcm_ops =3D drv->pcm_ops; =20 QLIST_INIT (&hw->sw_head); @@ -335,6 +336,7 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioMixen= gBackend *s, err1: glue (hw->pcm_ops->fini_, TYPE) (hw); err0: + object_unref(hw->s); g_free (hw); return NULL; } @@ -441,7 +443,7 @@ static SW *glue(audio_pcm_create_voice_pair_, TYPE)( } =20 sw =3D g_new0(SW, 1); - sw->s =3D s; + sw->s =3D AUDIO_MIXENG_BACKEND(object_ref(s)); =20 hw =3D glue(audio_pcm_hw_add_, TYPE)(s, &hw_as); if (!hw) { @@ -461,6 +463,7 @@ err2: glue (audio_pcm_hw_del_sw_, TYPE) (sw); glue (audio_pcm_hw_gc_, TYPE) (&hw); err1: + object_unref(sw->s); g_free(sw); return NULL; } @@ -470,6 +473,8 @@ static void glue (audio_close_, TYPE) (SW *sw) glue (audio_pcm_sw_fini_, TYPE) (sw); glue (audio_pcm_hw_del_sw_, TYPE) (sw); glue (audio_pcm_hw_gc_, TYPE) (&sw->hw); + + object_unref(sw->s); g_free (sw); } =20 --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771855031; cv=none; d=zohomail.com; s=zohoarc; b=ma+QxwyHwvl6lSGGzn7IPhdPvqeI9kGN4DMgjGJr5WMNGyEt2TKHm6a8RSK1xlYeR/prfxbTWFCyGb7jLuTFFb0bWmuwxQKKIchIN/QLECafjnRd4X1vWtd5oFpCEOVjEbt/vekldM5XpeyBEsWTXqrHILxt6xQU6Az7s3czJBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855031; 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=7QlxcLRDQ69PV90o9Mn4CbxaLjwkLmtdD5/P7jjtqnc=; b=KdltYuLv/nuvoFSHkfSlFHyU8rYGul6x6GWlxhFjK5R1dJ1vYwDz34PT6U5Meauk6UvZBbr95Rz607ERFgIndCTYQDCj4OlOiqqBu3HO2SSrLL1aT+npxubn56+25j4n1QXt8jROPOObqNKPXUFWUs+gIwn6rOJcE867mJSxXzQ= 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 17718550312101018.967886835095; Mon, 23 Feb 2026 05:57:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWKB-000476-JX; Mon, 23 Feb 2026 08:50: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 1vuWJ8-0001Ki-B2 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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 1vuWJ6-000782-Nq for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:05 -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-137-QJhWrvCHMiGrJvu6Qr7f_w-1; Mon, 23 Feb 2026 08:48:59 -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 EBCA61800352; Mon, 23 Feb 2026 13:48:58 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3A34A19560A2; Mon, 23 Feb 2026 13:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854544; 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=7QlxcLRDQ69PV90o9Mn4CbxaLjwkLmtdD5/P7jjtqnc=; b=AffsHp0kqZNFJGgfs+LlqQSjgXXrF0SIP6a7vAy5VHiwwwDyc8KiRCa16EST7FZlVFihdl H1veIxUng6jtHZXK4Dszp/EepGNkdveZ9ELUH4DcwqQC9Y+9Bby4/U/o3GyNlVtZAJC4vz T0rSGoTH+8MQLS+1BvzvgQjzzexyk10= X-MC-Unique: QJhWrvCHMiGrJvu6Qr7f_w-1 X-Mimecast-MFC-AGG-ID: QJhWrvCHMiGrJvu6Qr7f_w_1771854539 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 31/85] audio: make list type declaration private Date: Mon, 23 Feb 2026 14:46:32 +0100 Message-ID: <20260223134731.2377432-32-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855033342158500 From: Marc-Andr=C3=A9 Lureau No need to share in a common header. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 7 ------- audio/audio.c | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 446ba1d52c6..08d07b17557 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -306,13 +306,6 @@ static inline size_t audio_ring_posb(size_t pos, size_= t dist, size_t len) #define ldebug(fmt, ...) (void)0 #endif =20 -typedef struct AudiodevListEntry { - Audiodev *dev; - QSIMPLEQ_ENTRY(AudiodevListEntry) next; -} AudiodevListEntry; - -typedef QSIMPLEQ_HEAD(, AudiodevListEntry) AudiodevListHead; - void audio_create_pdos(Audiodev *dev); AudiodevPerDirectionOptions *audio_get_pdo_in(Audiodev *dev); AudiodevPerDirectionOptions *audio_get_pdo_out(Audiodev *dev); diff --git a/audio/audio.c b/audio/audio.c index 16edc57e5f0..d8a54548274 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -68,6 +68,13 @@ const char *audio_prio_list[] =3D { NULL }; =20 +typedef struct AudiodevListEntry { + Audiodev *dev; + QSIMPLEQ_ENTRY(AudiodevListEntry) next; +} AudiodevListEntry; + +typedef QSIMPLEQ_HEAD(, AudiodevListEntry) AudiodevListHead; + static AudiodevListHead audiodevs =3D QSIMPLEQ_HEAD_INITIALIZER(audiodevs); static AudiodevListHead default_audiodevs =3D --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771855563; cv=none; d=zohomail.com; s=zohoarc; b=YRXUKrpnbjEI5tsqfMwm8bUfAoqPFMWVX7ThB2V1+OTzQDRCgZFyAwOyVDr3foNunbAsMrLlHVqpsgnvYwCUi1SqDoAbcLxuEC+5yBg+gtSNcIzJwtiuuthhh4pDU/lUTjw8Y98QMkNj+MxkT5Ws8Fbd/9WqU4jkml85+XVLufM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855563; 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=fUSdMSZXOTAiBsKu/r1t/9mAav7xqoPHM1t6Qx58oss=; b=CQzKtwJvu1+23CWmadno1KRC8UE9cQfbTgpOtVesnxGku7o/8Yrh27Mt6pZjGe1RdxyNjVE6GEx47z3c0+B9qLPdQp1lHyH4sAPvO/Xns3Hg9YDPS9c8LZFcPTX+jkNL/v0dyvbL7lmrmJ8p2OR6Kn2CHlv9HTNckEfSHPK2xLM= 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 1771855563606616.311267822784; Mon, 23 Feb 2026 06:06:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJz-0003K2-Lt; Mon, 23 Feb 2026 08:49:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWJA-0001RM-OW for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:11 -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 1vuWJ9-00078K-Ez for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:08 -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-288-axr9uJr3PgqD7IMsffRiFQ-1; Mon, 23 Feb 2026 08:49:02 -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 997C5195608F; Mon, 23 Feb 2026 13:49:01 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 02A48180066A; Mon, 23 Feb 2026 13:49:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854545; 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=fUSdMSZXOTAiBsKu/r1t/9mAav7xqoPHM1t6Qx58oss=; b=YdXuuvYYKSLP7iD/1cEV2mo4Dh/HPlSvygiJHJX2iRy5yXgsJ2Rh79ramj0JYCUycTYXxf 2Y35QIu1LJbPJO3Sloaa6CNk2Nl6kiwGF9/DyGhDoOpzIP8tsFZSOOvZ3ockvs5ZLN3VMJ IPxV0Zvy3sbu+k2iBdTkANzQ0PRA3Zo= X-MC-Unique: axr9uJr3PgqD7IMsffRiFQ-1 X-Mimecast-MFC-AGG-ID: axr9uJr3PgqD7IMsffRiFQ_1771854541 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 32/85] audio: make create_pdos() private Date: Mon, 23 Feb 2026 14:46:33 +0100 Message-ID: <20260223134731.2377432-33-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855565386158500 From: Marc-Andr=C3=A9 Lureau Clean up. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 1 - audio/audio.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index 08d07b17557..e1f9fa333ba 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -306,7 +306,6 @@ static inline size_t audio_ring_posb(size_t pos, size_t= dist, size_t len) #define ldebug(fmt, ...) (void)0 #endif =20 -void audio_create_pdos(Audiodev *dev); AudiodevPerDirectionOptions *audio_get_pdo_in(Audiodev *dev); AudiodevPerDirectionOptions *audio_get_pdo_out(Audiodev *dev); =20 diff --git a/audio/audio.c b/audio/audio.c index d8a54548274..1fa63ee0421 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1990,7 +1990,7 @@ void AUD_set_volume_in(SWVoiceIn *sw, Volume *vol) } } =20 -void audio_create_pdos(Audiodev *dev) +static void audio_create_pdos(Audiodev *dev) { switch (dev->driver) { #define CASE(DRIVER, driver, pdo_name) \ --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771854835; cv=none; d=zohomail.com; s=zohoarc; b=UoBV6638Q3wnoXIz2eCv5UtPZnb/oRL0MWSufD2AC5m6bHe5Z0EMQvlIOzSvbVFP3TFgrJGLCL5x1LjPiM02tUEhFtkwau7Rv4A15jtW8rz/p5AxUkfeQYGiFKhL2LhbpAEWJkFqUPxGhpSqVbqXzkFoV+4oo2ccdnHNwVa/b7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854835; 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=Jpet2QkO3YlzQfYSfDPOd1CVsnkxJoKnqMXiSPFSPJA=; b=SzE/jJatEdsQ28+RGX39n4lS4Vwkxk3ZDubrAkQkF/VFn1Ysc8DjPVVH/jABuwACp+XzIXDJ7xufp0kdrngwogP8f0481qkX2KfjA1gy5TLoBQ5JH5iwuQtK6hHzXYoFy9U3qEzPSLmSN3/jbsb7+rstf5vbdBWWYmHPJv0wsIg= 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 1771854835762790.9811178867129; Mon, 23 Feb 2026 05:53:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWJO-0002QX-GZ; Mon, 23 Feb 2026 08:49:22 -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 1vuWJE-0001Ud-OM for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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 1vuWJC-00078l-TW for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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-519-UauFlspDMG23hi5Ns43MeA-1; Mon, 23 Feb 2026 08:49:05 -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 3E1ED19560AE; Mon, 23 Feb 2026 13:49:04 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 891D519560A2; Mon, 23 Feb 2026 13:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854548; 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=Jpet2QkO3YlzQfYSfDPOd1CVsnkxJoKnqMXiSPFSPJA=; b=N1leg60Za2bA0FEUbNRC7FY6rXpqeO4D8LvZM58xuAMYsgm7wBisCf/HktSrUIZjXZnZgU l6auHumqVnsvBvssmo2nlaPdcgAO07JE8gGMGADcPkajb+K1SSJGt3Ho48+BOvV9RHQH0Y EQVjhXbWrfm4vJcqsscBAxKTgXs7wD8= X-MC-Unique: UauFlspDMG23hi5Ns43MeA-1 X-Mimecast-MFC-AGG-ID: UauFlspDMG23hi5Ns43MeA_1771854544 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , John Snow , Cleber Rosa Subject: [PULL v3 33/85] replay: remove dependency on audio/ Date: Mon, 23 Feb 2026 14:46:34 +0100 Message-ID: <20260223134731.2377432-34-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854836440158500 From: Marc-Andr=C3=A9 Lureau The replay infrastructure shouldn't depend on internals of audio/. (st_sample is an internal implementation detail and could be different) Let audio drive the audio samples recording/replaying. Notice also we don't need to save & restore the internal ring "wpos", all replay should care about is the number of samples and the samples. Bump the replay version. Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 5 ++++ include/qemu/audio.h | 5 ---- include/system/replay.h | 11 +++++++-- replay/replay-internal.h | 2 ++ audio/audio.c | 23 ++++++++++++++++-- replay/replay-audio.c | 51 +++++++++++++++++++++++---------------- replay/replay.c | 2 +- replay/stubs-system.c | 8 +++++- tests/audio/audio-stubs.c | 13 +++++++--- scripts/replay-dump.py | 8 +++++- 10 files changed, 92 insertions(+), 36 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index e1f9fa333ba..250fd45238d 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -309,6 +309,11 @@ static inline size_t audio_ring_posb(size_t pos, size_= t dist, size_t len) AudiodevPerDirectionOptions *audio_get_pdo_in(Audiodev *dev); AudiodevPerDirectionOptions *audio_get_pdo_out(Audiodev *dev); =20 +void audio_sample_to_uint64(const st_sample *sample, int pos, + uint64_t *left, uint64_t *right); +void audio_sample_from_uint64(st_sample *sample, int pos, + uint64_t left, uint64_t right); + #define TYPE_AUDIO_MIXENG_BACKEND "audio-mixeng-backend" OBJECT_DECLARE_TYPE(AudioMixengBackend, AudioMixengBackendClass, AUDIO_MIX= ENG_BACKEND) =20 diff --git a/include/qemu/audio.h b/include/qemu/audio.h index 1eeead2a722..03ce9adbc88 100644 --- a/include/qemu/audio.h +++ b/include/qemu/audio.h @@ -120,11 +120,6 @@ void audio_cleanup(void); =20 typedef struct st_sample st_sample; =20 -void audio_sample_to_uint64(const st_sample *sample, int pos, - uint64_t *left, uint64_t *right); -void audio_sample_from_uint64(st_sample *sample, int pos, - uint64_t left, uint64_t right); - void audio_add_audiodev(Audiodev *audio); void audio_add_default_audiodev(Audiodev *dev, Error **errp); void audio_parse_option(const char *opt); diff --git a/include/system/replay.h b/include/system/replay.h index f8715ca9feb..19fb6dbb396 100644 --- a/include/system/replay.h +++ b/include/system/replay.h @@ -165,8 +165,15 @@ void replay_net_packet_event(ReplayNetState *rns, unsi= gned flags, =20 /*! Saves/restores number of played samples of audio out operation. */ void replay_audio_out(size_t *played); -/*! Saves/restores recorded samples of audio in operation. */ -void replay_audio_in(size_t *recorded, st_sample *samples, size_t *wpos, s= ize_t size); +/* + * Start saves/restores recorded samples of audio in operation. + * Must be called before replay_audio_in_sample_lr(). + */ +void replay_audio_in_start(size_t *recorded); +/* Saves/restores recorded samples. */ +void replay_audio_in_sample_lr(uint64_t *left, uint64_t *right); +/* Finish saves/restores recorded samples. */ +void replay_audio_in_finish(void); =20 /* VM state operations */ =20 diff --git a/replay/replay-internal.h b/replay/replay-internal.h index 75249b76936..643b357da12 100644 --- a/replay/replay-internal.h +++ b/replay/replay-internal.h @@ -85,6 +85,7 @@ enum ReplayEvents { * @file_offset: offset into replay log at replay snapshot * @block_request_id: current serialised block request id * @read_event_id: current async read event id + * @n_audio_samples: expected audio samples */ typedef struct ReplayState { int64_t cached_clock[REPLAY_CLOCK_COUNT]; @@ -96,6 +97,7 @@ typedef struct ReplayState { uint64_t file_offset; uint64_t block_request_id; uint64_t read_event_id; + size_t n_audio_samples; } ReplayState; extern ReplayState replay_state; =20 diff --git a/audio/audio.c b/audio/audio.c index 1fa63ee0421..3e16b719399 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1301,13 +1301,32 @@ static void audio_run_in(AudioMixengBackend *s) while ((hw =3D audio_pcm_hw_find_any_enabled_in(s, hw))) { SWVoiceIn *sw; size_t captured =3D 0, min; + int pos; =20 if (replay_mode !=3D REPLAY_MODE_PLAY) { captured =3D audio_pcm_hw_run_in( hw, hw->conv_buf.size - audio_pcm_hw_get_live_in(hw)); } - replay_audio_in(&captured, hw->conv_buf.buffer, &hw->conv_buf.pos, - hw->conv_buf.size); + + replay_audio_in_start(&captured); + assert(captured <=3D hw->conv_buf.size); + if (replay_mode =3D=3D REPLAY_MODE_PLAY) { + hw->conv_buf.pos =3D (hw->conv_buf.pos + captured) % hw->conv_= buf.size; + } + for (pos =3D (hw->conv_buf.pos - captured + hw->conv_buf.size) % h= w->conv_buf.size; + pos !=3D hw->conv_buf.pos; + pos =3D (pos + 1) % hw->conv_buf.size) { + uint64_t left, right; + + if (replay_mode =3D=3D REPLAY_MODE_RECORD) { + audio_sample_to_uint64(hw->conv_buf.buffer, pos, &left= , &right); + } + replay_audio_in_sample_lr(&left, &right); + if (replay_mode =3D=3D REPLAY_MODE_PLAY) { + audio_sample_from_uint64(hw->conv_buf.buffer, pos, lef= t, right); + } + } + replay_audio_in_finish(); =20 min =3D audio_pcm_hw_find_min_in (hw); hw->total_samples_captured +=3D captured - min; diff --git a/replay/replay-audio.c b/replay/replay-audio.c index 1b614f41379..7d20ae9110c 100644 --- a/replay/replay-audio.c +++ b/replay/replay-audio.c @@ -13,7 +13,6 @@ #include "qemu/error-report.h" #include "system/replay.h" #include "replay-internal.h" -#include "qemu/audio.h" =20 void replay_audio_out(size_t *played) { @@ -35,38 +34,48 @@ void replay_audio_out(size_t *played) } } =20 -void replay_audio_in(size_t *recorded, st_sample *samples, size_t *wpos, s= ize_t size) +void replay_audio_in_start(size_t *nsamples) { - int pos; - uint64_t left, right; if (replay_mode =3D=3D REPLAY_MODE_RECORD) { g_assert(replay_mutex_locked()); replay_save_instructions(); replay_put_event(EVENT_AUDIO_IN); - replay_put_qword(*recorded); - replay_put_qword(*wpos); - for (pos =3D (*wpos - *recorded + size) % size ; pos !=3D *wpos - ; pos =3D (pos + 1) % size) { - audio_sample_to_uint64(samples, pos, &left, &right); - replay_put_qword(left); - replay_put_qword(right); - } + replay_put_qword(*nsamples); + replay_state.n_audio_samples =3D *nsamples; } else if (replay_mode =3D=3D REPLAY_MODE_PLAY) { g_assert(replay_mutex_locked()); replay_account_executed_instructions(); if (replay_next_event_is(EVENT_AUDIO_IN)) { - *recorded =3D replay_get_qword(); - *wpos =3D replay_get_qword(); - for (pos =3D (*wpos - *recorded + size) % size ; pos !=3D *wpos - ; pos =3D (pos + 1) % size) { - left =3D replay_get_qword(); - right =3D replay_get_qword(); - audio_sample_from_uint64(samples, pos, left, right); - } - replay_finish_event(); + *nsamples =3D replay_get_qword(); + replay_state.n_audio_samples =3D *nsamples; } else { error_report("Missing audio in event in the replay log"); abort(); } } } + +void replay_audio_in_sample_lr(uint64_t *left, uint64_t *right) +{ + if (replay_mode =3D=3D REPLAY_MODE_RECORD) { + replay_put_qword(*left); + replay_put_qword(*right); + } else if (replay_mode =3D=3D REPLAY_MODE_PLAY) { + *left =3D replay_get_qword(); + *right =3D replay_get_qword(); + } else { + return; + } + + assert(replay_state.n_audio_samples > 0); + replay_state.n_audio_samples--; +} + +void replay_audio_in_finish(void) +{ + assert(replay_state.n_audio_samples =3D=3D 0); + + if (replay_mode =3D=3D REPLAY_MODE_PLAY) { + replay_finish_event(); + } +} diff --git a/replay/replay.c b/replay/replay.c index b2121788c1d..2e5c6fa82ea 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -22,7 +22,7 @@ =20 /* Current version of the replay mechanism. Increase it when file format changes. */ -#define REPLAY_VERSION 0xe0200c +#define REPLAY_VERSION 0xe0200d /* Size of replay log header */ #define HEADER_SIZE (sizeof(uint32_t) + sizeof(uint64_t)) =20 diff --git a/replay/stubs-system.c b/replay/stubs-system.c index 7f85764936f..b2c52bc4043 100644 --- a/replay/stubs-system.c +++ b/replay/stubs-system.c @@ -15,7 +15,13 @@ void replay_input_sync_event(void) void replay_add_blocker(const char *feature) { } -void replay_audio_in(size_t *recorded, st_sample *samples, size_t *wpos, s= ize_t size) +void replay_audio_in_start(size_t *nsamples) +{ +} +void replay_audio_in_sample_lr(uint64_t *left, uint64_t *right) +{ +} +void replay_audio_in_finish(void) { } void replay_audio_out(size_t *played) diff --git a/tests/audio/audio-stubs.c b/tests/audio/audio-stubs.c index dd7f635d460..2c19dfa7d6b 100644 --- a/tests/audio/audio-stubs.c +++ b/tests/audio/audio-stubs.c @@ -35,12 +35,19 @@ dbus_win32_import_socket(GDBusMethodInvocation *invocat= ion, } #endif =20 -void replay_audio_in(size_t *recorded, st_sample *samples, - size_t *wpos, size_t size) +void replay_audio_out(size_t *played) { } =20 -void replay_audio_out(size_t *played) +void replay_audio_in_start(size_t *nsamples) +{ +} + +void replay_audio_in_sample_lr(uint64_t *left, uint64_t *right) +{ +} + +void replay_audio_in_finish(void) { } =20 diff --git a/scripts/replay-dump.py b/scripts/replay-dump.py index 097636570dd..081aaa36c5e 100755 --- a/scripts/replay-dump.py +++ b/scripts/replay-dump.py @@ -395,6 +395,9 @@ def decode_end(eid, name, dumpfile): Decoder(39, "EVENT_END", decode_end), ] =20 +# EVENT_AUDIO_IN has changed +v13_event_table =3D v12_event_table + def parse_arguments(): "Grab arguments for script" parser =3D argparse.ArgumentParser() @@ -413,7 +416,10 @@ def decode_file(filename): # see REPLAY_VERSION print("HEADER: version 0x%x" % (version)) =20 - if version =3D=3D 0xe0200c: + if version =3D=3D 0xe0200d: + event_decode_table =3D v13_event_table + replay_state.checkpoint_start =3D 30 + elif version =3D=3D 0xe0200c: event_decode_table =3D v12_event_table replay_state.checkpoint_start =3D 30 elif version =3D=3D 0xe02007: --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771855073; cv=none; d=zohomail.com; s=zohoarc; b=aIpRugvt57aQKSjLo2/9qWEjTsX1tQkdugtvN0AQ6O3S/XVB8wwuvnlT7PCJqh8txshfLy25NdRlDNiLhh38Q3QR2SkRY8GDxlobCavXbnWWMSPKcIQG67wkNSq7OYOelKt7/o6YRzGR6pd5yH0OnEiuFTH9qOenEfqQ88liJJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855073; 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=Y1fz33nakZxHifVKcY+106tbLEA/1o7Z0hvw4rwmDaM=; b=WqYNE2tPWayPHJzZGe9zsjuPe3gDJRNC2F6dBMYe/OlcGgSwWCXeNxw2IbMXfDrU6VjG9mdGOOQX3mvhBd/RqmyF0yhcpHBxgcUYQa5cXBDV91N/EonLypFfzEwkuf/4hzPfsEpQTSd/1l3Gxj6Xa1QUyGpT5KcaDmqTgCMCUuE= 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 1771855073126540.562624337103; Mon, 23 Feb 2026 05:57:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWKB-00046V-Ik; Mon, 23 Feb 2026 08:50: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 1vuWJM-0002Gm-U6 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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 1vuWJI-00079U-CQ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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-389-6Bxwzn3KP_C13MIpPfsnZw-1; Mon, 23 Feb 2026 08:49:09 -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 1F98418002DE; Mon, 23 Feb 2026 13:49:08 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 64E711800361; Mon, 23 Feb 2026 13:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854555; 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=Y1fz33nakZxHifVKcY+106tbLEA/1o7Z0hvw4rwmDaM=; b=L+5nN0gmI+Az3M7y86wdciRHVMJ8pw6FVFunupDuljjP4rfbr5lVF+zG/4Ju/0eBUSTZNm O24854w4YGi+Q023lKez6soT41Goo0QsAtcOCnfIWd7BE5gotdIottyDnsc7HUKhSch9n3 LAtO6NNseTp5pkNvo8ygDp2uxSgJi4Q= X-MC-Unique: 6Bxwzn3KP_C13MIpPfsnZw-1 X-Mimecast-MFC-AGG-ID: 6Bxwzn3KP_C13MIpPfsnZw_1771854548 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Laurent Vivier , Manos Pitsidianakis , "Michael S. Tsirkin" , Alistair Francis , "Edgar E. Iglesias" , qemu-arm@nongnu.org (open list:Xilinx ZynqMP and...) Subject: [PULL v3 34/85] audio: make all the backend-specific APIs take the be Date: Mon, 23 Feb 2026 14:46:35 +0100 Message-ID: <20260223134731.2377432-35-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01 autolearn=no 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: 1771855073606158500 From: Marc-Andr=C3=A9 Lureau This will allow to dispatch to different implementations next. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_template.h | 2 +- include/qemu/audio-capture.h | 9 ++-- include/qemu/audio.h | 34 ++++++++------- audio/audio.c | 18 ++++---- audio/wavcapture.c | 7 ++- hw/audio/ac97.c | 24 +++++------ hw/audio/adlib.c | 9 ++-- hw/audio/asc.c | 16 +++---- hw/audio/cs4231a.c | 16 +++---- hw/audio/es1370.c | 12 +++--- hw/audio/gus.c | 9 ++-- hw/audio/hda-codec.c | 20 +++++---- hw/audio/lm4549.c | 12 +++--- hw/audio/pcspk.c | 4 +- hw/audio/sb16.c | 14 +++--- hw/audio/via-ac97.c | 14 +++--- hw/audio/virtio-snd.c | 14 +++--- hw/audio/wm8750.c | 24 +++++------ hw/display/xlnx_dp.c | 10 ++--- hw/usb/dev-audio.c | 12 +++--- tests/audio/test-audio.c | 83 ++++++++++++++++++------------------ ui/vnc.c | 2 +- 22 files changed, 192 insertions(+), 173 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index 512abbfe22f..33f2ff432eb 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -569,7 +569,7 @@ SW *glue (AUD_open_, TYPE) ( return NULL; } =20 -bool glue(AUD_is_active_, TYPE)(SW *sw) +bool glue(AUD_is_active_, TYPE)(AudioBackend *be, SW *sw) { return sw ? sw->active : 0; } diff --git a/include/qemu/audio-capture.h b/include/qemu/audio-capture.h index a07412db857..f500b0a7f8c 100644 --- a/include/qemu/audio-capture.h +++ b/include/qemu/audio-capture.h @@ -36,8 +36,11 @@ CaptureVoiceOut *AUD_add_capture( AudioBackend *be, struct audsettings *as, struct audio_capture_ops *ops, - void *opaque - ); -void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque); + void *opaque); + +void AUD_del_capture( + AudioBackend *be, + CaptureVoiceOut *cap, + void *cb_opaque); =20 #endif /* QEMU_AUDIO_CAPTURE_H */ diff --git a/include/qemu/audio.h b/include/qemu/audio.h index 03ce9adbc88..e87708e3d1e 100644 --- a/include/qemu/audio.h +++ b/include/qemu/audio.h @@ -63,7 +63,7 @@ typedef struct AudioBackendClass { =20 bool AUD_backend_check(AudioBackend **be, Error **errp); =20 -SWVoiceOut *AUD_open_out ( +SWVoiceOut *AUD_open_out( AudioBackend *be, SWVoiceOut *sw, const char *name, @@ -72,11 +72,11 @@ SWVoiceOut *AUD_open_out ( const struct audsettings *settings ); =20 -void AUD_close_out (AudioBackend *be, SWVoiceOut *sw); -size_t AUD_write (SWVoiceOut *sw, void *pcm_buf, size_t size); -int AUD_get_buffer_size_out (SWVoiceOut *sw); -void AUD_set_active_out(SWVoiceOut *sw, bool on); -bool AUD_is_active_out(SWVoiceOut *sw); +void AUD_close_out(AudioBackend *be, SWVoiceOut *sw); +size_t AUD_write(AudioBackend *be, SWVoiceOut *sw, void *pcm_buf, size_t s= ize); +int AUD_get_buffer_size_out(AudioBackend *be, SWVoiceOut *sw); +void AUD_set_active_out(AudioBackend *be, SWVoiceOut *sw, bool on); +bool AUD_is_active_out(AudioBackend *be, SWVoiceOut *sw); =20 #define AUDIO_MAX_CHANNELS 16 typedef struct Volume { @@ -85,19 +85,23 @@ typedef struct Volume { uint8_t vol[AUDIO_MAX_CHANNELS]; } Volume; =20 -void AUD_set_volume_out(SWVoiceOut *sw, Volume *vol); -void AUD_set_volume_in(SWVoiceIn *sw, Volume *vol); +void AUD_set_volume_out(AudioBackend *be, SWVoiceOut *sw, Volume *vol); +void AUD_set_volume_in(AudioBackend *be, SWVoiceIn *sw, Volume *vol); =20 static inline void -AUD_set_volume_out_lr(SWVoiceOut *sw, bool mut, uint8_t lvol, uint8_t rvol= ) { - AUD_set_volume_out(sw, &(Volume) { +AUD_set_volume_out_lr(AudioBackend *be, SWVoiceOut *sw, + bool mut, uint8_t lvol, uint8_t rvol) +{ + AUD_set_volume_out(be, sw, &(Volume) { .mute =3D mut, .channels =3D 2, .vol =3D { lvol, rvol } }); } =20 static inline void -AUD_set_volume_in_lr(SWVoiceIn *sw, bool mut, uint8_t lvol, uint8_t rvol) { - AUD_set_volume_in(sw, &(Volume) { +AUD_set_volume_in_lr(AudioBackend *be, SWVoiceIn *sw, + bool mut, uint8_t lvol, uint8_t rvol) +{ + AUD_set_volume_in(be, sw, &(Volume) { .mute =3D mut, .channels =3D 2, .vol =3D { lvol, rvol } }); } @@ -112,9 +116,9 @@ SWVoiceIn *AUD_open_in( ); =20 void AUD_close_in(AudioBackend *be, SWVoiceIn *sw); -size_t AUD_read (SWVoiceIn *sw, void *pcm_buf, size_t size); -void AUD_set_active_in(SWVoiceIn *sw, bool on); -bool AUD_is_active_in(SWVoiceIn *sw); +size_t AUD_read(AudioBackend *be, SWVoiceIn *sw, void *pcm_buf, size_t siz= e); +void AUD_set_active_in(AudioBackend *be, SWVoiceIn *sw, bool on); +bool AUD_is_active_in(AudioBackend *be, SWVoiceIn *sw); =20 void audio_cleanup(void); =20 diff --git a/audio/audio.c b/audio/audio.c index 3e16b719399..320035c0484 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -847,7 +847,7 @@ static void audio_timer (void *opaque) /* * Public API */ -size_t AUD_write(SWVoiceOut *sw, void *buf, size_t size) +size_t AUD_write(AudioBackend *be, SWVoiceOut *sw, void *buf, size_t size) { HWVoiceOut *hw; =20 @@ -869,7 +869,7 @@ size_t AUD_write(SWVoiceOut *sw, void *buf, size_t size) } } =20 -size_t AUD_read(SWVoiceIn *sw, void *buf, size_t size) +size_t AUD_read(AudioBackend *be, SWVoiceIn *sw, void *buf, size_t size) { HWVoiceIn *hw; =20 @@ -891,7 +891,7 @@ size_t AUD_read(SWVoiceIn *sw, void *buf, size_t size) } } =20 -int AUD_get_buffer_size_out(SWVoiceOut *sw) +int AUD_get_buffer_size_out(AudioBackend *be, SWVoiceOut *sw) { if (!sw) { return 0; @@ -904,7 +904,7 @@ int AUD_get_buffer_size_out(SWVoiceOut *sw) return sw->hw->samples * sw->hw->info.bytes_per_frame; } =20 -void AUD_set_active_out(SWVoiceOut *sw, bool on) +void AUD_set_active_out(AudioBackend *be, SWVoiceOut *sw, bool on) { HWVoiceOut *hw; =20 @@ -952,7 +952,7 @@ void AUD_set_active_out(SWVoiceOut *sw, bool on) } } =20 -void AUD_set_active_in(SWVoiceIn *sw, bool on) +void AUD_set_active_in(AudioBackend *be, SWVoiceIn *sw, bool on) { HWVoiceIn *hw; =20 @@ -997,7 +997,7 @@ void AUD_set_active_in(SWVoiceIn *sw, bool on) } } =20 -static size_t audio_get_avail (SWVoiceIn *sw) +static size_t audio_get_avail(SWVoiceIn *sw) { size_t live; =20 @@ -1938,7 +1938,7 @@ CaptureVoiceOut *AUD_add_capture( return cap; } =20 -void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque) +void AUD_del_capture(AudioBackend *be, CaptureVoiceOut *cap, void *cb_opaq= ue) { struct capture_callback *cb; =20 @@ -1977,7 +1977,7 @@ void AUD_del_capture (CaptureVoiceOut *cap, void *cb_= opaque) } } =20 -void AUD_set_volume_out(SWVoiceOut *sw, Volume *vol) +void AUD_set_volume_out(AudioBackend *be, SWVoiceOut *sw, Volume *vol) { if (sw) { HWVoiceOut *hw =3D sw->hw; @@ -1993,7 +1993,7 @@ void AUD_set_volume_out(SWVoiceOut *sw, Volume *vol) } } =20 -void AUD_set_volume_in(SWVoiceIn *sw, Volume *vol) +void AUD_set_volume_in(AudioBackend *be, SWVoiceIn *sw, Volume *vol) { if (sw) { HWVoiceIn *hw =3D sw->hw; diff --git a/audio/wavcapture.c b/audio/wavcapture.c index b33a38ff45b..2950ceaf242 100644 --- a/audio/wavcapture.c +++ b/audio/wavcapture.c @@ -1,4 +1,5 @@ #include "qemu/osdep.h" +#include "qemu/audio.h" #include "qemu/qemu-print.h" #include "qemu/error-report.h" #include "audio_int.h" @@ -10,6 +11,7 @@ typedef struct { int freq; int bits; int nchannels; + AudioBackend *audio_be; CaptureVoiceOut *cap; } WAVState; =20 @@ -84,7 +86,7 @@ static void wav_capture_destroy (void *opaque) { WAVState *wav =3D opaque; =20 - AUD_del_capture (wav->cap, wav); + AUD_del_capture(wav->audio_be, wav->cap, wav); g_free (wav); } =20 @@ -159,6 +161,7 @@ int wav_start_capture(AudioBackend *state, CaptureState= *s, const char *path, return -1; } =20 + wav->audio_be =3D state; wav->path =3D g_strdup (path); wav->bits =3D bits; wav->nchannels =3D nchannels; @@ -169,7 +172,7 @@ int wav_start_capture(AudioBackend *state, CaptureState= *s, const char *path, goto error_free; } =20 - cap =3D AUD_add_capture(state, &as, &ops, wav); + cap =3D AUD_add_capture(wav->audio_be, &as, &ops, wav); if (!cap) { error_report("Failed to add audio capture"); goto error_free; diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index 0694f0adf9c..65a4141b8af 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -246,15 +246,15 @@ static void voice_set_active(AC97LinkState *s, int bm= _index, int on) { switch (bm_index) { case PI_INDEX: - AUD_set_active_in(s->voice_pi, on); + AUD_set_active_in(s->audio_be, s->voice_pi, on); break; =20 case PO_INDEX: - AUD_set_active_out(s->voice_po, on); + AUD_set_active_out(s->audio_be, s->voice_po, on); break; =20 case MC_INDEX: - AUD_set_active_in(s->voice_mc, on); + AUD_set_active_in(s->audio_be, s->voice_mc, on); break; =20 default: @@ -378,15 +378,15 @@ static void reset_voices(AC97LinkState *s, uint8_t ac= tive[LAST_INDEX]) =20 freq =3D mixer_load(s, AC97_PCM_LR_ADC_Rate); open_voice(s, PI_INDEX, freq); - AUD_set_active_in(s->voice_pi, active[PI_INDEX]); + AUD_set_active_in(s->audio_be, s->voice_pi, active[PI_INDEX]); =20 freq =3D mixer_load(s, AC97_PCM_Front_DAC_Rate); open_voice(s, PO_INDEX, freq); - AUD_set_active_out(s->voice_po, active[PO_INDEX]); + AUD_set_active_out(s->audio_be, s->voice_po, active[PO_INDEX]); =20 freq =3D mixer_load(s, AC97_MIC_ADC_Rate); open_voice(s, MC_INDEX, freq); - AUD_set_active_in(s->voice_mc, active[MC_INDEX]); + AUD_set_active_in(s->audio_be, s->voice_mc, active[MC_INDEX]); } =20 static void get_volume(uint16_t vol, uint16_t mask, int inverse, @@ -416,7 +416,7 @@ static void update_combined_volume_out(AC97LinkState *s) lvol =3D (lvol * plvol) / 255; rvol =3D (rvol * prvol) / 255; =20 - AUD_set_volume_out_lr(s->voice_po, mute, lvol, rvol); + AUD_set_volume_out_lr(s->audio_be, s->voice_po, mute, lvol, rvol); } =20 static void update_volume_in(AC97LinkState *s) @@ -427,7 +427,7 @@ static void update_volume_in(AC97LinkState *s) get_volume(mixer_load(s, AC97_Record_Gain_Mute), 0x0f, 0, &mute, &lvol, &rvol); =20 - AUD_set_volume_in_lr(s->voice_pi, mute, lvol, rvol); + AUD_set_volume_in_lr(s->audio_be, s->voice_pi, mute, lvol, rvol); } =20 static void set_volume(AC97LinkState *s, int index, uint32_t val) @@ -904,7 +904,7 @@ static int write_audio(AC97LinkState *s, AC97BusMasterR= egs *r, int copied; to_copy =3D MIN(temp, sizeof(tmpbuf)); pci_dma_read(&s->dev, addr, tmpbuf, to_copy); - copied =3D AUD_write(s->voice_po, tmpbuf, to_copy); + copied =3D AUD_write(s->audio_be, s->voice_po, tmpbuf, to_copy); dolog("write_audio max=3D%x to_copy=3D%x copied=3D%x", max, to_copy, copied); if (!copied) { @@ -948,7 +948,7 @@ static void write_bup(AC97LinkState *s, int elapsed) while (elapsed) { int temp =3D MIN(elapsed, sizeof(s->silence)); while (temp) { - int copied =3D AUD_write(s->voice_po, s->silence, temp); + int copied =3D AUD_write(s->audio_be, s->voice_po, s->silence,= temp); if (!copied) { return; } @@ -978,7 +978,7 @@ static int read_audio(AC97LinkState *s, AC97BusMasterRe= gs *r, while (temp) { int acquired; to_copy =3D MIN(temp, sizeof(tmpbuf)); - acquired =3D AUD_read(voice, tmpbuf, to_copy); + acquired =3D AUD_read(s->audio_be, voice, tmpbuf, to_copy); if (!acquired) { *stop =3D 1; break; @@ -1275,7 +1275,7 @@ static void ac97_realize(PCIDevice *dev, Error **errp) AC97LinkState *s =3D AC97(dev); uint8_t *c =3D s->dev.config; =20 - if (!AUD_backend_check (&s->audio_be, errp)) { + if (!AUD_backend_check(&s->audio_be, errp)) { return; } =20 diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index f79654627f5..dd5d9cf6772 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -95,7 +95,7 @@ static void adlib_write(void *opaque, uint32_t nport, uin= t32_t val) int a =3D nport & 3; =20 s->active =3D 1; - AUD_set_active_out (s->voice, 1); + AUD_set_active_out(s->audio_be, s->voice, 1); =20 adlib_kill_timers (s); =20 @@ -143,7 +143,8 @@ static int write_audio (AdlibState *s, int samples) int nbytes, wbytes, wsampl; =20 nbytes =3D samples << SHIFT; - wbytes =3D AUD_write ( + wbytes =3D AUD_write( + s->audio_be, s->voice, s->mixbuf + (pos << (SHIFT - 1)), nbytes @@ -255,7 +256,7 @@ static void adlib_realizefn (DeviceState *dev, Error **= errp) as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D HOST_BIG_ENDIAN; =20 - s->voice =3D AUD_open_out ( + s->voice =3D AUD_open_out( s->audio_be, s->voice, "adlib", @@ -269,7 +270,7 @@ static void adlib_realizefn (DeviceState *dev, Error **= errp) return; } =20 - s->samples =3D AUD_get_buffer_size_out (s->voice) >> SHIFT; + s->samples =3D AUD_get_buffer_size_out(s->audio_be, s->voice) >> SHIFT; s->mixbuf =3D g_malloc0 (s->samples << SHIFT); =20 adlib_portio_list[0].offset =3D s->port; diff --git a/hw/audio/asc.c b/hw/audio/asc.c index a934c2e82c0..43cd51939a3 100644 --- a/hw/audio/asc.c +++ b/hw/audio/asc.c @@ -355,12 +355,12 @@ static void asc_out_cb(void *opaque, int free_b) * loop because the FIFO has run out of data, and the driver * reuses the stale content in its circular audio buffer. */ - AUD_write(s->voice, s->silentbuf, samples << s->shift); + AUD_write(s->audio_be, s->voice, s->silentbuf, samples << s->s= hift); } return; } =20 - AUD_write(s->voice, s->mixbuf, generated << s->shift); + AUD_write(s->audio_be, s->voice, s->mixbuf, generated << s->shift); } =20 static uint64_t asc_fifo_read(void *opaque, hwaddr addr, @@ -470,9 +470,9 @@ static void asc_write(void *opaque, hwaddr addr, uint64= _t value, asc_fifo_reset(&s->fifos[1]); asc_lower_irq(s); if (value !=3D 0) { - AUD_set_active_out(s->voice, 1); + AUD_set_active_out(s->audio_be, s->voice, 1); } else { - AUD_set_active_out(s->voice, 0); + AUD_set_active_out(s->audio_be, s->voice, 0); } } break; @@ -489,7 +489,7 @@ static void asc_write(void *opaque, hwaddr addr, uint64= _t value, { int vol =3D (value & 0xe0); =20 - AUD_set_volume_out_lr(s->voice, 0, vol, vol); + AUD_set_volume_out_lr(s->audio_be, s->voice, 0, vol, vol); break; } } @@ -545,7 +545,7 @@ static int asc_post_load(void *opaque, int version) ASCState *s =3D ASC(opaque); =20 if (s->regs[ASC_MODE] !=3D 0) { - AUD_set_active_out(s->voice, 1); + AUD_set_active_out(s->audio_be, s->voice, 1); } =20 return 0; @@ -614,7 +614,7 @@ static void asc_reset_hold(Object *obj, ResetType type) { ASCState *s =3D ASC(obj); =20 - AUD_set_active_out(s->voice, 0); + AUD_set_active_out(s->audio_be, s->voice, 0); =20 memset(s->regs, 0, sizeof(s->regs)); asc_fifo_reset(&s->fifos[0]); @@ -658,7 +658,7 @@ static void asc_realize(DeviceState *dev, Error **errp) } =20 s->shift =3D 1; - s->samples =3D AUD_get_buffer_size_out(s->voice) >> s->shift; + s->samples =3D AUD_get_buffer_size_out(s->audio_be, s->voice) >> s->sh= ift; s->mixbuf =3D g_malloc0(s->samples << s->shift); =20 s->silentbuf =3D g_malloc(s->samples << s->shift); diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c index 7489cf42b7d..3b8ed092fe4 100644 --- a/hw/audio/cs4231a.c +++ b/hw/audio/cs4231a.c @@ -327,7 +327,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) goto error; } =20 - s->voice =3D AUD_open_out ( + s->voice =3D AUD_open_out( s->audio_be, s->voice, "cs4231a", @@ -339,7 +339,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) if (s->dregs[Interface_Configuration] & PEN) { if (!s->dma_running) { k->hold_DREQ(s->isa_dma, s->dma); - AUD_set_active_out (s->voice, 1); + AUD_set_active_out(s->audio_be, s->voice, 1); s->transferred =3D 0; } s->dma_running =3D 1; @@ -347,7 +347,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) else { if (s->dma_running) { k->release_DREQ(s->isa_dma, s->dma); - AUD_set_active_out (s->voice, 0); + AUD_set_active_out(s->audio_be, s->voice, 0); } s->dma_running =3D 0; } @@ -356,7 +356,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) error: if (s->dma_running) { k->release_DREQ(s->isa_dma, s->dma); - AUD_set_active_out (s->voice, 0); + AUD_set_active_out(s->audio_be, s->voice, 0); } } =20 @@ -465,7 +465,7 @@ static void cs_write (void *opaque, hwaddr addr, if (s->dma_running) { IsaDmaClass *k =3D ISADMA_GET_CLASS(s->isa_dma); k->release_DREQ(s->isa_dma, s->dma); - AUD_set_active_out (s->voice, 0); + AUD_set_active_out(s->audio_be, s->voice, 0); s->dma_running =3D 0; } } @@ -551,11 +551,11 @@ static int cs_write_audio (CSState *s, int nchan, int= dma_pos, =20 for (i =3D 0; i < copied; ++i) linbuf[i] =3D s->tab[tmpbuf[i]]; - copied =3D AUD_write (s->voice, linbuf, copied << 1); + copied =3D AUD_write(s->audio_be, s->voice, linbuf, copied << = 1); copied >>=3D 1; } else { - copied =3D AUD_write (s->voice, tmpbuf, copied); + copied =3D AUD_write(s->audio_be, s->voice, tmpbuf, copied); } =20 temp -=3D copied; @@ -614,7 +614,7 @@ static int cs4231a_pre_load (void *opaque) if (s->dma_running) { IsaDmaClass *k =3D ISADMA_GET_CLASS(s->isa_dma); k->release_DREQ(s->isa_dma, s->dma); - AUD_set_active_out (s->voice, 0); + AUD_set_active_out(s->audio_be, s->voice, 0); } s->dma_running =3D 0; return 0; diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 566f93f1eae..44b204730b5 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -411,7 +411,7 @@ static void es1370_update_voices (ES1370State *s, uint3= 2_t ctl, uint32_t sctl) =20 if (i =3D=3D ADC_CHANNEL) { s->adc_voice =3D - AUD_open_in ( + AUD_open_in( s->audio_be, s->adc_voice, "es1370.adc", @@ -421,7 +421,7 @@ static void es1370_update_voices (ES1370State *s, uint3= 2_t ctl, uint32_t sctl) ); } else { s->dac_voice[i] =3D - AUD_open_out ( + AUD_open_out( s->audio_be, s->dac_voice[i], i ? "es1370.dac2" : "es1370.dac1", @@ -438,9 +438,9 @@ static void es1370_update_voices (ES1370State *s, uint3= 2_t ctl, uint32_t sctl) int on =3D (ctl & b->ctl_en) && !(sctl & b->sctl_pause); =20 if (i =3D=3D ADC_CHANNEL) { - AUD_set_active_in (s->adc_voice, on); + AUD_set_active_in(s->audio_be, s->adc_voice, on); } else { - AUD_set_active_out (s->dac_voice[i], on); + AUD_set_active_out(s->audio_be, s->dac_voice[i], on); } } } @@ -627,7 +627,7 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, int acquired, to_copy; =20 to_copy =3D MIN(to_transfer, sizeof(tmpbuf)); - acquired =3D AUD_read (s->adc_voice, tmpbuf, to_copy); + acquired =3D AUD_read(s->audio_be, s->adc_voice, tmpbuf, to_co= py); if (!acquired) { break; } @@ -646,7 +646,7 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, =20 to_copy =3D MIN(to_transfer, sizeof(tmpbuf)); pci_dma_read (&s->dev, addr, tmpbuf, to_copy); - copied =3D AUD_write (voice, tmpbuf, to_copy); + copied =3D AUD_write(s->audio_be, voice, tmpbuf, to_copy); if (!copied) { break; } diff --git a/hw/audio/gus.c b/hw/audio/gus.c index 69ddc419191..1ede1c4a51d 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -87,7 +87,8 @@ static int write_audio (GUSState *s, int samples) int nbytes, wbytes, wsampl; =20 nbytes =3D samples << s->shift; - wbytes =3D AUD_write ( + wbytes =3D AUD_write( + s->audio_be, s->voice, s->mixbuf + (pos << (s->shift - 1)), nbytes @@ -257,7 +258,7 @@ static void gus_realizefn (DeviceState *dev, Error **er= rp) as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D HOST_BIG_ENDIAN; =20 - s->voice =3D AUD_open_out ( + s->voice =3D AUD_open_out( s->audio_be, NULL, "gus", @@ -272,7 +273,7 @@ static void gus_realizefn (DeviceState *dev, Error **er= rp) } =20 s->shift =3D 2; - s->samples =3D AUD_get_buffer_size_out (s->voice) >> s->shift; + s->samples =3D AUD_get_buffer_size_out(s->audio_be, s->voice) >> s->sh= ift; s->mixbuf =3D g_malloc0 (s->samples << s->shift); =20 isa_register_portio_list(d, &s->portio_list1, s->port, @@ -287,7 +288,7 @@ static void gus_realizefn (DeviceState *dev, Error **er= rp) s->emu.opaque =3D s; s->pic =3D isa_bus_get_irq(bus, s->emu.gusirq); =20 - AUD_set_active_out (s->voice, 1); + AUD_set_active_out(s->audio_be, s->voice, 1); } =20 static const Property gus_properties[] =3D { diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index 6445d227594..0373d2f7271 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -275,7 +275,8 @@ static void hda_audio_input_cb(void *opaque, int avail) while (to_transfer) { uint32_t start =3D (uint32_t) (wpos & B_MASK); uint32_t chunk =3D (uint32_t) MIN(B_SIZE - start, to_transfer); - uint32_t read =3D AUD_read(st->voice.in, st->buf + start, chunk); + uint32_t read =3D AUD_read(st->state->audio_be, st->voice.in, + st->buf + start, chunk); wpos +=3D read; to_transfer -=3D read; st->wpos +=3D read; @@ -354,7 +355,8 @@ static void hda_audio_output_cb(void *opaque, int avail) while (to_transfer) { uint32_t start =3D (uint32_t) (rpos & B_MASK); uint32_t chunk =3D (uint32_t) MIN(B_SIZE - start, to_transfer); - uint32_t written =3D AUD_write(st->voice.out, st->buf + start, chu= nk); + uint32_t written =3D AUD_write(st->state->audio_be, st->voice.out, + st->buf + start, chunk); rpos +=3D written; to_transfer -=3D written; st->rpos +=3D written; @@ -375,7 +377,8 @@ static void hda_audio_compat_input_cb(void *opaque, int= avail) =20 while (avail - recv >=3D sizeof(st->compat_buf)) { if (st->compat_bpos !=3D sizeof(st->compat_buf)) { - len =3D AUD_read(st->voice.in, st->compat_buf + st->compat_bpo= s, + len =3D AUD_read(st->state->audio_be, st->voice.in, + st->compat_buf + st->compat_bpos, sizeof(st->compat_buf) - st->compat_bpos); st->compat_bpos +=3D len; recv +=3D len; @@ -408,7 +411,8 @@ static void hda_audio_compat_output_cb(void *opaque, in= t avail) } st->compat_bpos =3D 0; } - len =3D AUD_write(st->voice.out, st->compat_buf + st->compat_bpos, + len =3D AUD_write(st->state->audio_be, st->voice.out, + st->compat_buf + st->compat_bpos, sizeof(st->compat_buf) - st->compat_bpos); st->compat_bpos +=3D len; sent +=3D len; @@ -440,9 +444,9 @@ static void hda_audio_set_running(HDAAudioStream *st, b= ool running) } } if (st->output) { - AUD_set_active_out(st->voice.out, st->running); + AUD_set_active_out(st->state->audio_be, st->voice.out, st->running= ); } else { - AUD_set_active_in(st->voice.in, st->running); + AUD_set_active_in(st->state->audio_be, st->voice.in, st->running); } } =20 @@ -466,9 +470,9 @@ static void hda_audio_set_amp(HDAAudioStream *st) return; } if (st->output) { - AUD_set_volume_out_lr(st->voice.out, muted, left, right); + AUD_set_volume_out_lr(st->state->audio_be, st->voice.out, muted, l= eft, right); } else { - AUD_set_volume_in_lr(st->voice.in, muted, left, right); + AUD_set_volume_in_lr(st->state->audio_be, st->voice.in, muted, lef= t, right); } } =20 diff --git a/hw/audio/lm4549.c b/hw/audio/lm4549.c index f85226d1ac5..b875e83d454 100644 --- a/hw/audio/lm4549.c +++ b/hw/audio/lm4549.c @@ -101,11 +101,11 @@ static void lm4549_audio_transfer(lm4549_state *s) uint32_t i; =20 /* Activate the voice */ - AUD_set_active_out(s->voice, 1); + AUD_set_active_out(s->audio_be, s->voice, 1); s->voice_is_active =3D 1; =20 /* Try to write the buffer content */ - written_bytes =3D AUD_write(s->voice, s->buffer, + written_bytes =3D AUD_write(s->audio_be, s->voice, s->buffer, s->buffer_level * sizeof(uint16_t)); written_samples =3D written_bytes >> 1; =20 @@ -129,14 +129,14 @@ static void lm4549_audio_out_callback(void *opaque, i= nt free) static uint32_t prev_buffer_level; =20 #ifdef LM4549_DEBUG - int size =3D AUD_get_buffer_size_out(s->voice); + int size =3D AUD_get_buffer_size_out(s->audio_be, s->voice); DPRINTF("audio_out_callback size =3D %i free =3D %i\n", size, free); #endif =20 /* Detect that no data are consumed =3D> disable the voice */ if (s->buffer_level =3D=3D prev_buffer_level) { - AUD_set_active_out(s->voice, 0); + AUD_set_active_out(s->audio_be, s->voice, 0); s->voice_is_active =3D 0; } prev_buffer_level =3D s->buffer_level; @@ -285,7 +285,7 @@ static int lm4549_post_load(void *opaque, int version_i= d) =20 /* Request data */ if (s->voice_is_active =3D=3D 1) { - lm4549_audio_out_callback(s, AUD_get_buffer_size_out(s->voice)); + lm4549_audio_out_callback(s, AUD_get_buffer_size_out(s->audio_be, = s->voice)); } =20 return 0; @@ -323,7 +323,7 @@ void lm4549_init(lm4549_state *s, lm4549_callback data_= req_cb, void* opaque, &as ); =20 - AUD_set_volume_out_lr(s->voice, 0, 255, 255); + AUD_set_volume_out_lr(s->audio_be, s->voice, 0, 255, 255); =20 s->voice_is_active =3D 0; =20 diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index 0b01544941c..07ebfcfccf6 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -105,7 +105,7 @@ static void pcspk_callback(void *opaque, int free) =20 while (free > 0) { n =3D MIN(s->samples - s->play_pos, (unsigned int)free); - n =3D AUD_write(s->voice, &s->sample_buf[s->play_pos], n); + n =3D AUD_write(s->audio_be, s->voice, &s->sample_buf[s->play_pos]= , n); if (!n) break; s->play_pos =3D (s->play_pos + n) % s->samples; @@ -163,7 +163,7 @@ static void pcspk_io_write(void *opaque, hwaddr addr, u= int64_t val, if (s->voice) { if (gate) /* restart */ s->play_pos =3D 0; - AUD_set_active_out(s->voice, gate & s->data_on); + AUD_set_active_out(s->audio_be, s->voice, gate & s->data_on); } } =20 diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index 3c5beb9dfa3..da0c33ea41b 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -185,11 +185,11 @@ static void control (SB16State *s, int hold) =20 if (hold) { k->hold_DREQ(isa_dma, dma); - AUD_set_active_out (s->voice, 1); + AUD_set_active_out(s->audio_be, s->voice, 1); } else { k->release_DREQ(isa_dma, dma); - AUD_set_active_out (s->voice, 0); + AUD_set_active_out(s->audio_be, s->voice, 0); } } =20 @@ -215,7 +215,7 @@ static void continue_dma8 (SB16State *s) as.fmt =3D s->fmt; as.endianness =3D 0; =20 - s->voice =3D AUD_open_out ( + s->voice =3D AUD_open_out( s->audio_be, s->voice, "sb16", @@ -378,7 +378,7 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8_t= d0, int dma_len) as.fmt =3D s->fmt; as.endianness =3D 0; =20 - s->voice =3D AUD_open_out ( + s->voice =3D AUD_open_out( s->audio_be, s->voice, "sb16", @@ -879,7 +879,7 @@ static void legacy_reset (SB16State *s) as.fmt =3D AUDIO_FORMAT_U8; as.endianness =3D 0; =20 - s->voice =3D AUD_open_out ( + s->voice =3D AUD_open_out( s->audio_be, s->voice, "sb16", @@ -1196,7 +1196,7 @@ static int write_audio (SB16State *s, int nchan, int = dma_pos, } =20 copied =3D k->read_memory(isa_dma, nchan, tmpbuf, dma_pos, to_copy= ); - copied =3D AUD_write (s->voice, tmpbuf, copied); + copied =3D AUD_write(s->audio_be, s->voice, tmpbuf, copied); =20 temp -=3D copied; dma_pos =3D (dma_pos + copied) % dma_len; @@ -1302,7 +1302,7 @@ static int sb16_post_load (void *opaque, int version_= id) as.fmt =3D s->fmt; as.endianness =3D 0; =20 - s->voice =3D AUD_open_out ( + s->voice =3D AUD_open_out( s->audio_be, s->voice, "sb16", diff --git a/hw/audio/via-ac97.c b/hw/audio/via-ac97.c index 019d2968534..5b344d7a0fc 100644 --- a/hw/audio/via-ac97.c +++ b/hw/audio/via-ac97.c @@ -53,7 +53,7 @@ static void codec_volume_set_out(ViaAC97State *s) rvol /=3D 255; mute =3D CODEC_REG(s, AC97_Master_Volume_Mute) >> MUTE_SHIFT; mute |=3D CODEC_REG(s, AC97_PCM_Out_Volume_Mute) >> MUTE_SHIFT; - AUD_set_volume_out_lr(s->vo, mute, lvol, rvol); + AUD_set_volume_out_lr(s->audio_be, s->vo, mute, lvol, rvol); } =20 static void codec_reset(ViaAC97State *s) @@ -189,7 +189,7 @@ static void out_cb(void *opaque, int avail) while (temp) { to_copy =3D MIN(temp, sizeof(tmpbuf)); pci_dma_read(&s->dev, c->addr, tmpbuf, to_copy); - copied =3D AUD_write(s->vo, tmpbuf, to_copy); + copied =3D AUD_write(s->audio_be, s->vo, tmpbuf, to_copy); if (!copied) { stop =3D true; break; @@ -208,7 +208,7 @@ static void out_cb(void *opaque, int avail) c->stat |=3D STAT_PAUSED; } else { c->stat &=3D ~STAT_ACTIVE; - AUD_set_active_out(s->vo, 0); + AUD_set_active_out(s->audio_be, s->vo, 0); } if (c->type & STAT_EOL) { via_isa_set_irq(&s->dev, 0, 1); @@ -317,20 +317,20 @@ static void sgd_write(void *opaque, hwaddr addr, uint= 64_t val, unsigned size) break; case 1: if (val & CNTL_START) { - AUD_set_active_out(s->vo, 1); + AUD_set_active_out(s->audio_be, s->vo, 1); s->aur.stat =3D STAT_ACTIVE; } if (val & CNTL_TERM) { - AUD_set_active_out(s->vo, 0); + AUD_set_active_out(s->audio_be, s->vo, 0); s->aur.stat &=3D ~(STAT_ACTIVE | STAT_PAUSED); s->aur.clen =3D 0; } if (val & CNTL_PAUSE) { - AUD_set_active_out(s->vo, 0); + AUD_set_active_out(s->audio_be, s->vo, 0); s->aur.stat &=3D ~STAT_ACTIVE; s->aur.stat |=3D STAT_PAUSED; } else if (!(val & CNTL_PAUSE) && (s->aur.stat & STAT_PAUSED)) { - AUD_set_active_out(s->vo, 1); + AUD_set_active_out(s->audio_be, s->vo, 1); s->aur.stat |=3D STAT_ACTIVE; s->aur.stat &=3D ~STAT_PAUSED; } diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index d5d430ad654..7cbfd164893 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -475,7 +475,7 @@ static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s, = uint32_t stream_id) stream, virtio_snd_pcm_out_cb, &as); - AUD_set_volume_out_lr(stream->voice.out, 0, 255, 255); + AUD_set_volume_out_lr(s->audio_be, stream->voice.out, 0, 255, 255); } else { stream->voice.in =3D AUD_open_in(s->audio_be, stream->voice.in, @@ -483,7 +483,7 @@ static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s, = uint32_t stream_id) stream, virtio_snd_pcm_in_cb, &as); - AUD_set_volume_in_lr(stream->voice.in, 0, 255, 255); + AUD_set_volume_in_lr(s->audio_be, stream->voice.in, 0, 255, 255); } =20 return cpu_to_le32(VIRTIO_SND_S_OK); @@ -573,9 +573,9 @@ static void virtio_snd_handle_pcm_start_stop(VirtIOSoun= d *s, stream->active =3D start; } if (stream->info.direction =3D=3D VIRTIO_SND_D_OUTPUT) { - AUD_set_active_out(stream->voice.out, start); + AUD_set_active_out(s->audio_be, stream->voice.out, start); } else { - AUD_set_active_in(stream->voice.in, start); + AUD_set_active_in(s->audio_be, stream->voice.in, start); } } else { error_report("Invalid stream id: %"PRIu32, stream_id); @@ -1177,7 +1177,8 @@ static void virtio_snd_pcm_out_cb(void *data, int ava= ilable) buffer->populated =3D true; } for (;;) { - size =3D AUD_write(stream->voice.out, + size =3D AUD_write(stream->s->audio_be, + stream->voice.out, buffer->data + buffer->offset, MIN(buffer->size, available)); assert(size <=3D MIN(buffer->size, available)); @@ -1279,7 +1280,8 @@ static void virtio_snd_pcm_in_cb(void *data, int avai= lable) to_read =3D stream->params.period_bytes - buffer->size; to_read =3D MIN(to_read, available); to_read =3D MIN(to_read, max_size - buffer->size); - size =3D AUD_read(stream->voice.in, + size =3D AUD_read(stream->s->audio_be, + stream->voice.in, buffer->data + buffer->size, to_read); if (!size) { diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c index 336fb6d20bd..bc347fe5376 100644 --- a/hw/audio/wm8750.c +++ b/hw/audio/wm8750.c @@ -72,7 +72,7 @@ static inline void wm8750_in_load(WM8750State *s) if (s->idx_in + s->req_in <=3D sizeof(s->data_in)) return; s->idx_in =3D MAX(0, (int) sizeof(s->data_in) - s->req_in); - AUD_read(*s->in[0], s->data_in + s->idx_in, + AUD_read(s->audio_be, *s->in[0], s->data_in + s->idx_in, sizeof(s->data_in) - s->idx_in); } =20 @@ -80,7 +80,7 @@ static inline void wm8750_out_flush(WM8750State *s) { int sent =3D 0; while (sent < s->idx_out) - sent +=3D AUD_write(*s->out[0], s->data_out + sent, s->idx_out - s= ent) + sent +=3D AUD_write(s->audio_be, *s->out[0], s->data_out + sent, s= ->idx_out - sent) ?: s->idx_out; s->idx_out =3D 0; } @@ -145,30 +145,30 @@ static void wm8750_vol_update(WM8750State *s) { /* FIXME: multiply all volumes by s->invol[2], s->invol[3] */ =20 - AUD_set_volume_in_lr(s->adc_voice[0], s->mute, + AUD_set_volume_in_lr(s->audio_be, s->adc_voice[0], s->mute, s->inmute[0] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[0]), s->inmute[1] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[1])= ); - AUD_set_volume_in_lr(s->adc_voice[1], s->mute, + AUD_set_volume_in_lr(s->audio_be, s->adc_voice[1], s->mute, s->inmute[0] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[0]), s->inmute[1] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[1])= ); - AUD_set_volume_in_lr(s->adc_voice[2], s->mute, + AUD_set_volume_in_lr(s->audio_be, s->adc_voice[2], s->mute, s->inmute[0] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[0]), s->inmute[1] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[1])= ); =20 /* FIXME: multiply all volumes by s->outvol[0], s->outvol[1] */ =20 /* Speaker: LOUT2VOL ROUT2VOL */ - AUD_set_volume_out_lr(s->dac_voice[0], s->mute, + AUD_set_volume_out_lr(s->audio_be, s->dac_voice[0], s->mute, s->outmute[0] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[= 4]), s->outmute[1] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[= 5])); =20 /* Headphone: LOUT1VOL ROUT1VOL */ - AUD_set_volume_out_lr(s->dac_voice[1], s->mute, + AUD_set_volume_out_lr(s->audio_be, s->dac_voice[1], s->mute, s->outmute[0] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[= 2]), s->outmute[1] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[= 3])); =20 /* MONOOUT: MONOVOL MONOVOL */ - AUD_set_volume_out_lr(s->dac_voice[2], s->mute, + AUD_set_volume_out_lr(s->audio_be, s->dac_voice[2], s->mute, s->outmute[0] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[= 6]), s->outmute[1] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[= 6])); } @@ -182,9 +182,9 @@ static void wm8750_set_format(WM8750State *s) wm8750_out_flush(s); =20 if (s->in[0] && *s->in[0]) - AUD_set_active_in(*s->in[0], 0); + AUD_set_active_in(s->audio_be, *s->in[0], 0); if (s->out[0] && *s->out[0]) - AUD_set_active_out(*s->out[0], 0); + AUD_set_active_out(s->audio_be, *s->out[0], 0); =20 for (i =3D 0; i < IN_PORT_N; i ++) if (s->adc_voice[i]) { @@ -235,9 +235,9 @@ static void wm8750_set_format(WM8750State *s) * for mixing or combining paths to different ports, so we * connect both channels to where the left channel is routed. */ if (s->in[0] && *s->in[0]) - AUD_set_active_in(*s->in[0], 1); + AUD_set_active_in(s->audio_be, *s->in[0], 1); if (s->out[0] && *s->out[0]) - AUD_set_active_out(*s->out[0], 1); + AUD_set_active_out(s->audio_be, *s->out[0], 1); } =20 static void wm8750_clk_update(WM8750State *s, int ext) diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c index a24e95f0a73..deda7efe15d 100644 --- a/hw/display/xlnx_dp.c +++ b/hw/display/xlnx_dp.c @@ -331,7 +331,7 @@ static inline void xlnx_dp_audio_activate(XlnxDPState *= s) { bool activated =3D ((s->core_registers[DP_TX_AUDIO_CONTROL] & DP_TX_AUD_CTRL) !=3D 0); - AUD_set_active_out(s->amixer_output_stream, activated); + AUD_set_active_out(s->audio_be, s->amixer_output_stream, activated); xlnx_dpdma_set_host_data_location(s->dpdma, DP_AUDIO_DMA_CHANNEL(0), &s->audio_buffer_0); xlnx_dpdma_set_host_data_location(s->dpdma, DP_AUDIO_DMA_CHANNEL(1), @@ -401,7 +401,7 @@ static void xlnx_dp_audio_callback(void *opaque, int av= ail) /* Send the buffer through the audio. */ if (s->byte_left <=3D MAX_QEMU_BUFFER_SIZE) { if (s->byte_left !=3D 0) { - written =3D AUD_write(s->amixer_output_stream, + written =3D AUD_write(s->audio_be, s->amixer_output_stream, &s->out_buffer[s->data_ptr], s->byte_left); } else { int len_to_copy; @@ -413,12 +413,12 @@ static void xlnx_dp_audio_callback(void *opaque, int = avail) while (avail) { len_to_copy =3D MIN(AUD_CHBUF_MAX_DEPTH, avail); memset(s->out_buffer, 0, len_to_copy); - avail -=3D AUD_write(s->amixer_output_stream, s->out_buffe= r, + avail -=3D AUD_write(s->audio_be, s->amixer_output_stream,= s->out_buffer, len_to_copy); } } } else { - written =3D AUD_write(s->amixer_output_stream, + written =3D AUD_write(s->audio_be, s->amixer_output_stream, &s->out_buffer[s->data_ptr], MAX_QEMU_BUFFER_S= IZE); } s->byte_left -=3D written; @@ -1401,7 +1401,7 @@ static void xlnx_dp_realize(DeviceState *dev, Error *= *errp) s, xlnx_dp_audio_callback, &as); - AUD_set_volume_out_lr(s->amixer_output_stream, 0, 255, 255); + AUD_set_volume_out_lr(s->audio_be, s->amixer_output_stream, 0, 255, 25= 5); xlnx_dp_audio_activate(s); s->vblank =3D ptimer_init(vblank_hit, s, DP_VBLANK_PTIMER_POLICY); ptimer_transaction_begin(s->vblank); diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c index dfda2dccc04..0f36587fc6f 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -669,7 +669,7 @@ static void output_callback(void *opaque, int avail) return; } =20 - written =3D AUD_write(s->out.voice, data, len); + written =3D AUD_write(s->audio_be, s->out.voice, data, len); avail -=3D written; s->out.buf.cons +=3D written; =20 @@ -683,7 +683,7 @@ static int usb_audio_set_output_altset(USBAudioState *s= , int altset) { switch (altset) { case ALTSET_OFF: - AUD_set_active_out(s->out.voice, false); + AUD_set_active_out(s->audio_be, s->out.voice, false); break; case ALTSET_STEREO: case ALTSET_51: @@ -692,7 +692,7 @@ static int usb_audio_set_output_altset(USBAudioState *s= , int altset) usb_audio_reinit(USB_DEVICE(s), altset_channels[altset]); } streambuf_init(&s->out.buf, s->buffer, s->out.channels); - AUD_set_active_out(s->out.voice, true); + AUD_set_active_out(s->audio_be, s->out.voice, true); break; default: return -1; @@ -805,7 +805,7 @@ static int usb_audio_set_control(USBAudioState *s, uint= 8_t attrib, } fprintf(stderr, "\n"); } - AUD_set_volume_out(s->out.voice, &s->out.vol); + AUD_set_volume_out(s->audio_be, s->out.voice, &s->out.vol); } =20 return ret; @@ -980,8 +980,8 @@ static void usb_audio_reinit(USBDevice *dev, unsigned c= hannels) =20 s->out.voice =3D AUD_open_out(s->audio_be, s->out.voice, TYPE_USB_AUDI= O, s, output_callback, &s->out.as); - AUD_set_volume_out(s->out.voice, &s->out.vol); - AUD_set_active_out(s->out.voice, 0); + AUD_set_volume_out(s->audio_be, s->out.voice, &s->out.vol); + AUD_set_active_out(s->audio_be, s->out.voice, 0); } =20 static const VMStateDescription vmstate_usb_audio =3D { diff --git a/tests/audio/test-audio.c b/tests/audio/test-audio.c index 66693f0fbfd..6c182ee7c60 100644 --- a/tests/audio/test-audio.c +++ b/tests/audio/test-audio.c @@ -142,7 +142,7 @@ static void test_sine_callback(void *opaque, int avail) =20 generate_sine_samples(buffer, frames_to_write, s->frames_written); =20 - bytes_written =3D AUD_write(s->voice, buffer, + bytes_written =3D AUD_write(s->be, s->voice, buffer, frames_to_write * sizeof(int16_t) * CHANNELS= ); s->frames_written +=3D bytes_written / (sizeof(int16_t) * CHANNELS); } @@ -163,7 +163,7 @@ static void test_audio_out_sine_wave(void) &state, test_sine_callback); =20 g_test_message("Playing 440Hz sine wave for %d seconds...", DURATION_S= ECS); - AUD_set_active_out(state.voice, true); + AUD_set_active_out(state.be, state.voice, true); =20 /* * Run the audio subsystem until all frames are written or timeout. @@ -188,7 +188,7 @@ static void test_audio_out_sine_wave(void) =20 g_assert_cmpint(state.frames_written, =3D=3D, state.total_frames); =20 - AUD_set_active_out(state.voice, false); + AUD_set_active_out(state.be, state.voice, false); AUD_close_out(state.be, state.voice); } =20 @@ -224,13 +224,13 @@ static void test_audio_out_active_state(void) be =3D get_test_audio_backend(); voice =3D open_test_voice_out(be, "test-active", NULL, dummy_audio_cal= lback); =20 - g_assert_false(AUD_is_active_out(voice)); + g_assert_false(AUD_is_active_out(be, voice)); =20 - AUD_set_active_out(voice, true); - g_assert_true(AUD_is_active_out(voice)); + AUD_set_active_out(be, voice, true); + g_assert_true(AUD_is_active_out(be, voice)); =20 - AUD_set_active_out(voice, false); - g_assert_false(AUD_is_active_out(voice)); + AUD_set_active_out(be, voice, false); + g_assert_false(AUD_is_active_out(be, voice)); =20 AUD_close_out(be, voice); } @@ -244,13 +244,13 @@ static void test_audio_out_buffer_size(void) be =3D get_test_audio_backend(); voice =3D open_test_voice_out(be, "test-buffer", NULL, dummy_audio_cal= lback); =20 - buffer_size =3D AUD_get_buffer_size_out(voice); + buffer_size =3D AUD_get_buffer_size_out(be, voice); g_test_message("Buffer size: %d bytes", buffer_size); g_assert_cmpint(buffer_size, >, 0); =20 AUD_close_out(be, voice); =20 - g_assert_cmpint(AUD_get_buffer_size_out(NULL), =3D=3D, 0); + g_assert_cmpint(AUD_get_buffer_size_out(NULL, NULL), =3D=3D, 0); } =20 static void test_audio_out_volume(void) @@ -263,13 +263,13 @@ static void test_audio_out_volume(void) voice =3D open_test_voice_out(be, "test-volume", NULL, dummy_audio_cal= lback); =20 vol =3D (Volume){ .mute =3D false, .channels =3D 2, .vol =3D {255, 255= } }; - AUD_set_volume_out(voice, &vol); + AUD_set_volume_out(be, voice, &vol); =20 vol =3D (Volume){ .mute =3D true, .channels =3D 2, .vol =3D {255, 255}= }; - AUD_set_volume_out(voice, &vol); + AUD_set_volume_out(be, voice, &vol); =20 vol =3D (Volume){ .mute =3D false, .channels =3D 2, .vol =3D {128, 128= } }; - AUD_set_volume_out(voice, &vol); + AUD_set_volume_out(be, voice, &vol); =20 AUD_close_out(be, voice); } @@ -286,13 +286,13 @@ static void test_audio_in_active_state(void) return; } =20 - g_assert_false(AUD_is_active_in(voice)); + g_assert_false(AUD_is_active_in(be, voice)); =20 - AUD_set_active_in(voice, true); - g_assert_true(AUD_is_active_in(voice)); + AUD_set_active_in(be, voice, true); + g_assert_true(AUD_is_active_in(be, voice)); =20 - AUD_set_active_in(voice, false); - g_assert_false(AUD_is_active_in(voice)); + AUD_set_active_in(be, voice, false); + g_assert_false(AUD_is_active_in(be, voice)); =20 AUD_close_in(be, voice); } @@ -311,10 +311,10 @@ static void test_audio_in_volume(void) } =20 vol =3D (Volume){ .mute =3D false, .channels =3D 2, .vol =3D {255, 255= } }; - AUD_set_volume_in(voice, &vol); + AUD_set_volume_in(be, voice, &vol); =20 vol =3D (Volume){ .mute =3D true, .channels =3D 2, .vol =3D {255, 255}= }; - AUD_set_volume_in(voice, &vol); + AUD_set_volume_in(be, voice, &vol); =20 AUD_close_in(be, voice); } @@ -427,7 +427,7 @@ static void test_audio_capture(void) &sine_state, test_sine_callback); sine_state.voice =3D voice; =20 - AUD_set_active_out(voice, true); + AUD_set_active_out(be, voice, true); =20 start_time =3D g_get_monotonic_time(); while (sine_state.frames_written < sine_state.total_frames || @@ -472,10 +472,10 @@ static void test_audio_capture(void) g_assert_cmpfloat(match_ratio, >=3D, 0.9); } =20 - AUD_set_active_out(voice, false); + AUD_set_active_out(be, voice, false); AUD_close_out(be, voice); =20 - AUD_del_capture(cap, &state); + AUD_del_capture(be, cap, &state); g_assert_true(state.destroy_called); =20 g_free(state.captured_samples); @@ -483,26 +483,27 @@ static void test_audio_capture(void) =20 static void test_audio_null_handling(void) { + AudioBackend *be =3D get_test_audio_backend(); uint8_t buffer[64]; =20 /* AUD_is_active_out/in(NULL) should return false */ - g_assert_false(AUD_is_active_out(NULL)); - g_assert_false(AUD_is_active_in(NULL)); + g_assert_false(AUD_is_active_out(be, NULL)); + g_assert_false(AUD_is_active_in(be, NULL)); =20 /* AUD_get_buffer_size_out(NULL) should return 0 */ - g_assert_cmpint(AUD_get_buffer_size_out(NULL), =3D=3D, 0); + g_assert_cmpint(AUD_get_buffer_size_out(be, NULL), =3D=3D, 0); =20 /* AUD_write/read(NULL, ...) should return size (no-op) */ - g_assert_cmpuint(AUD_write(NULL, buffer, sizeof(buffer)), =3D=3D, + g_assert_cmpuint(AUD_write(be, NULL, buffer, sizeof(buffer)), =3D=3D, sizeof(buffer)); - g_assert_cmpuint(AUD_read(NULL, buffer, sizeof(buffer)), =3D=3D, + g_assert_cmpuint(AUD_read(be, NULL, buffer, sizeof(buffer)), =3D=3D, sizeof(buffer)); =20 /* These should not crash */ - AUD_set_active_out(NULL, true); - AUD_set_active_out(NULL, false); - AUD_set_active_in(NULL, true); - AUD_set_active_in(NULL, false); + AUD_set_active_out(be, NULL, true); + AUD_set_active_out(be, NULL, false); + AUD_set_active_in(be, NULL, true); + AUD_set_active_in(be, NULL, false); } =20 static void test_audio_multiple_voices(void) @@ -516,19 +517,19 @@ static void test_audio_multiple_voices(void) out2 =3D open_test_voice_out(be, "test-multi-out2", NULL, dummy_audio_= callback); in1 =3D open_test_voice_in(be, "test-multi-in1", NULL, dummy_audio_cal= lback); =20 - AUD_set_active_out(out1, true); - AUD_set_active_out(out2, true); - AUD_set_active_in(in1, true); + AUD_set_active_out(be, out1, true); + AUD_set_active_out(be, out2, true); + AUD_set_active_in(be, in1, true); =20 - g_assert_true(AUD_is_active_out(out1)); - g_assert_true(AUD_is_active_out(out2)); + g_assert_true(AUD_is_active_out(be, out1)); + g_assert_true(AUD_is_active_out(be, out2)); if (in1) { - g_assert_true(AUD_is_active_in(in1)); + g_assert_true(AUD_is_active_in(be, in1)); } =20 - AUD_set_active_out(out1, false); - AUD_set_active_out(out2, false); - AUD_set_active_in(in1, false); + AUD_set_active_out(be, out1, false); + AUD_set_active_out(be, out2, false); + AUD_set_active_in(be, in1, false); =20 AUD_close_in(be, in1); AUD_close_out(be, out2); diff --git a/ui/vnc.c b/ui/vnc.c index a61a4f937d6..c142d9fc7c0 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1289,7 +1289,7 @@ static void audio_add(VncState *vs) static void audio_del(VncState *vs) { if (vs->audio_cap) { - AUD_del_capture(vs->audio_cap, vs); + AUD_del_capture(vs->vd->audio_be, vs->audio_cap, vs); vs->audio_cap =3D NULL; } } --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771855506; cv=none; d=zohomail.com; s=zohoarc; b=c67GetvxAg/L7JJp6ZBvynMJgLlognRk81AITs+A7JpcZ0ikJ7r2yoi9zCqFoOZ5usVtBgd1k9va7O4b2o1RKModJXf5lvQ3ZoeBmOYrGFVyl34crMv9D9J1ioJd8ixkghlH8+OFUF0hKQKPMmJkJz7LOR1PUQvn93iG8XkfKno= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855506; 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=1g/F5PtdIz9SgI7wPwsefeu+goB4d1MjontlE0ZmifI=; b=Q5x4iCOprwvwb3EM8DKEfsHYtJPAGKOcTMkewT0PF6g1Lge4QGnD/xpoHUvBKavcJXEYBJ/pbn6Ff3RjvbvBp/QIhHyee0yLXWXoZ+ZMlM59MGo6Naxn5H/A0jrD0v70Ye9fak7odqxnDgxrjlCL9W4RE8Wc3qGxPXtWnDg9ZbE= 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 1771855506053492.4817544065369; Mon, 23 Feb 2026 06:05:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWK0-0003LA-T5; Mon, 23 Feb 2026 08:50: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 1vuWJK-00020l-RR for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:18 -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 1vuWJH-00079J-Er for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:18 -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-615-jmeNkWTzPrizyNA-mYMoow-1; Mon, 23 Feb 2026 08:49:11 -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 90C05180059B; Mon, 23 Feb 2026 13:49:10 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 119FF1800351; Mon, 23 Feb 2026 13:49:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854554; 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=1g/F5PtdIz9SgI7wPwsefeu+goB4d1MjontlE0ZmifI=; b=XNU38FekOb6Gf2kvoX53CmWVih+LUif5twNf/EQEFxBVbcSeYRffE0wG9ZyMUTjIIGS/AA tx/3gqBQYS9ivRc33BhrMH/pgiWAHFC7OEFaa4k5ZxMAYto3u6v8C1z6Y7ZV0ibg6Mw20Y bylQpA6aA/44GOhu6AfMZOrEV1JAy24= X-MC-Unique: jmeNkWTzPrizyNA-mYMoow-1 X-Mimecast-MFC-AGG-ID: jmeNkWTzPrizyNA-mYMoow_1771854550 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 35/85] audio: make AudioBackend truly abstract Date: Mon, 23 Feb 2026 14:46:36 +0100 Message-ID: <20260223134731.2377432-36-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855507197158500 From: Marc-Andr=C3=A9 Lureau Add virtual methods to be implemented by concrete classes, like AudioMixengBackendClass. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_template.h | 9 +- include/qemu/audio-capture.h | 13 --- include/qemu/audio.h | 58 +++++++++-- audio/audio.c | 187 ++++++++++++++++++++++++++++++++--- 4 files changed, 227 insertions(+), 40 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index 33f2ff432eb..a7733f9e1d9 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -478,7 +478,7 @@ static void glue (audio_close_, TYPE) (SW *sw) g_free (sw); } =20 -void glue(AUD_close_, TYPE)(AudioBackend *be, SW *sw) +static void glue(audio_mixeng_backend_close_, TYPE)(AudioBackend *be, SW *= sw) { if (sw) { if (audio_bug(__func__, !be)) { @@ -490,14 +490,13 @@ void glue(AUD_close_, TYPE)(AudioBackend *be, SW *sw) } } =20 -SW *glue (AUD_open_, TYPE) ( +static SW *glue(audio_mixeng_backend_open_, TYPE) ( AudioBackend *be, SW *sw, const char *name, void *callback_opaque , audio_callback_fn callback_fn, - const struct audsettings *as - ) + const struct audsettings *as) { AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(be); AudiodevPerDirectionOptions *pdo; @@ -569,7 +568,7 @@ SW *glue (AUD_open_, TYPE) ( return NULL; } =20 -bool glue(AUD_is_active_, TYPE)(AudioBackend *be, SW *sw) +static bool glue(audio_mixeng_backend_is_active_, TYPE)(AudioBackend *be, = SW *sw) { return sw ? sw->active : 0; } diff --git a/include/qemu/audio-capture.h b/include/qemu/audio-capture.h index f500b0a7f8c..5bfbdd02985 100644 --- a/include/qemu/audio-capture.h +++ b/include/qemu/audio-capture.h @@ -8,19 +8,6 @@ =20 #include "audio.h" =20 -typedef struct CaptureVoiceOut CaptureVoiceOut; - -typedef enum { - AUD_CNOTIFY_ENABLE, - AUD_CNOTIFY_DISABLE -} audcnotification_e; - -struct audio_capture_ops { - void (*notify) (void *opaque, audcnotification_e cmd); - void (*capture) (void *opaque, const void *buf, int size); - void (*destroy) (void *opaque); -}; - struct capture_ops { void (*info) (void *opaque); void (*destroy) (void *opaque); diff --git a/include/qemu/audio.h b/include/qemu/audio.h index e87708e3d1e..4fae48886ba 100644 --- a/include/qemu/audio.h +++ b/include/qemu/audio.h @@ -43,6 +43,25 @@ typedef struct audsettings { =20 typedef struct SWVoiceOut SWVoiceOut; typedef struct SWVoiceIn SWVoiceIn; +typedef struct CaptureVoiceOut CaptureVoiceOut; + +typedef enum { + AUD_CNOTIFY_ENABLE, + AUD_CNOTIFY_DISABLE +} audcnotification_e; + +struct audio_capture_ops { + void (*notify) (void *opaque, audcnotification_e cmd); + void (*capture) (void *opaque, const void *buf, int size); + void (*destroy) (void *opaque); +}; + +#define AUDIO_MAX_CHANNELS 16 +typedef struct Volume { + bool mute; + int channels; + uint8_t vol[AUDIO_MAX_CHANNELS]; +} Volume; =20 typedef struct AudioBackend { Object parent_obj; @@ -53,6 +72,35 @@ typedef struct AudioBackendClass { =20 bool (*realize)(AudioBackend *be, Audiodev *dev, Error **errp); const char *(*get_id)(AudioBackend *be); + SWVoiceOut *(*open_out)(AudioBackend *be, + SWVoiceOut *sw, + const char *name, + void *callback_opaque, + audio_callback_fn callback_fn, + const struct audsettings *as); + SWVoiceIn *(*open_in)(AudioBackend *be, + SWVoiceIn *sw, + const char *name, + void *callback_opaque, + audio_callback_fn callback_fn, + const struct audsettings *as); + void (*close_out)(AudioBackend *be, SWVoiceOut *sw); + void (*close_in)(AudioBackend *be, SWVoiceIn *sw); + bool (*is_active_out)(AudioBackend *be, SWVoiceOut *sw); + bool (*is_active_in)(AudioBackend *be, SWVoiceIn *sw); + void (*set_active_out)(AudioBackend *be, SWVoiceOut *sw, bool on); + void (*set_active_in)(AudioBackend *be, SWVoiceIn *sw, bool on); + void (*set_volume_out)(AudioBackend *be, SWVoiceOut *sw, Volume *vol); + void (*set_volume_in)(AudioBackend *be, SWVoiceIn *sw, Volume *vol); + size_t (*write)(AudioBackend *be, SWVoiceOut *sw, void *buf, size_t si= ze); + 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, + void *cb_opaque); + void (*del_capture)(AudioBackend *be, CaptureVoiceOut *cap, void *cb_o= paque); + #ifdef CONFIG_GIO bool (*set_dbus_server)(AudioBackend *be, GDBusObjectManagerServer *manager, @@ -69,8 +117,7 @@ SWVoiceOut *AUD_open_out( const char *name, void *callback_opaque, audio_callback_fn callback_fn, - const struct audsettings *settings - ); + const struct audsettings *settings); =20 void AUD_close_out(AudioBackend *be, SWVoiceOut *sw); size_t AUD_write(AudioBackend *be, SWVoiceOut *sw, void *pcm_buf, size_t s= ize); @@ -78,13 +125,6 @@ int AUD_get_buffer_size_out(AudioBackend *be, SWVoiceO= ut *sw); void AUD_set_active_out(AudioBackend *be, SWVoiceOut *sw, bool on); bool AUD_is_active_out(AudioBackend *be, SWVoiceOut *sw); =20 -#define AUDIO_MAX_CHANNELS 16 -typedef struct Volume { - bool mute; - int channels; - uint8_t vol[AUDIO_MAX_CHANNELS]; -} Volume; - void AUD_set_volume_out(AudioBackend *be, SWVoiceOut *sw, Volume *vol); void AUD_set_volume_in(AudioBackend *be, SWVoiceIn *sw, Volume *vol); =20 diff --git a/audio/audio.c b/audio/audio.c index 320035c0484..32b2b882f80 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -847,7 +847,8 @@ static void audio_timer (void *opaque) /* * Public API */ -size_t AUD_write(AudioBackend *be, SWVoiceOut *sw, void *buf, size_t size) +static size_t audio_mixeng_backend_write(AudioBackend *be, SWVoiceOut *sw, + void *buf, size_t size) { HWVoiceOut *hw; =20 @@ -858,7 +859,7 @@ size_t AUD_write(AudioBackend *be, SWVoiceOut *sw, void= *buf, size_t size) hw =3D sw->hw; =20 if (!hw->enabled) { - dolog ("Writing to disabled voice %s\n", SW_NAME (sw)); + dolog("Writing to disabled voice %s\n", SW_NAME(sw)); return 0; } =20 @@ -869,7 +870,15 @@ size_t AUD_write(AudioBackend *be, SWVoiceOut *sw, voi= d *buf, size_t size) } } =20 -size_t AUD_read(AudioBackend *be, SWVoiceIn *sw, void *buf, size_t size) +size_t AUD_write(AudioBackend *be, SWVoiceOut *sw, void *buf, size_t size) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->write(be, sw, buf, size); +} + +static size_t audio_mixeng_backend_read(AudioBackend *be, SWVoiceIn *sw, + void *buf, size_t size) { HWVoiceIn *hw; =20 @@ -880,7 +889,7 @@ size_t AUD_read(AudioBackend *be, SWVoiceIn *sw, void *= buf, size_t size) hw =3D sw->hw; =20 if (!hw->enabled) { - dolog ("Reading from disabled voice %s\n", SW_NAME (sw)); + dolog("Reading from disabled voice %s\n", SW_NAME(sw)); return 0; } =20 @@ -889,9 +898,17 @@ size_t AUD_read(AudioBackend *be, SWVoiceIn *sw, void = *buf, size_t size) } else { return hw->pcm_ops->read(hw, buf, size); } + } =20 -int AUD_get_buffer_size_out(AudioBackend *be, SWVoiceOut *sw) +size_t AUD_read(AudioBackend *be, SWVoiceIn *sw, void *buf, size_t size) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->read(be, sw, buf, size); +} + +static int audio_mixeng_backend_get_buffer_size_out(AudioBackend *be, SWVo= iceOut *sw) { if (!sw) { return 0; @@ -904,7 +921,15 @@ int AUD_get_buffer_size_out(AudioBackend *be, SWVoiceO= ut *sw) return sw->hw->samples * sw->hw->info.bytes_per_frame; } =20 -void AUD_set_active_out(AudioBackend *be, SWVoiceOut *sw, bool on) +int AUD_get_buffer_size_out(AudioBackend *be, SWVoiceOut *sw) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->get_buffer_size_out(be, sw); +} + +static void audio_mixeng_backend_set_active_out(AudioBackend *be, SWVoiceO= ut *sw, + bool on) { HWVoiceOut *hw; =20 @@ -950,9 +975,17 @@ void AUD_set_active_out(AudioBackend *be, SWVoiceOut *= sw, bool on) } sw->active =3D on; } + } =20 -void AUD_set_active_in(AudioBackend *be, SWVoiceIn *sw, bool on) +void AUD_set_active_out(AudioBackend *be, SWVoiceOut *sw, bool on) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->set_active_out(be, sw, on); +} + +static void audio_mixeng_backend_set_active_in(AudioBackend *be, SWVoiceIn= *sw, bool on) { HWVoiceIn *hw; =20 @@ -997,6 +1030,13 @@ void AUD_set_active_in(AudioBackend *be, SWVoiceIn *s= w, bool on) } } =20 +void AUD_set_active_in(AudioBackend *be, SWVoiceIn *sw, bool on) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->set_active_in(be, sw, on); +} + static size_t audio_get_avail(SWVoiceIn *sw) { size_t live; @@ -1658,12 +1698,97 @@ static const char *audio_mixeng_backend_get_id(Audi= oBackend *be) return AUDIO_MIXENG_BACKEND(be)->dev->id; } =20 +static CaptureVoiceOut *audio_mixeng_backend_add_capture( + AudioBackend *be, + struct audsettings *as, + struct audio_capture_ops *ops, + void *cb_opaque); + +static void audio_mixeng_backend_del_capture( + AudioBackend *be, + CaptureVoiceOut *cap, + void *cb_opaque); + +static void audio_mixeng_backend_set_volume_out(AudioBackend *be, SWVoiceO= ut *sw, + Volume *vol); +static void audio_mixeng_backend_set_volume_in(AudioBackend *be, SWVoiceIn= *sw, + Volume *vol); + +SWVoiceOut *AUD_open_out( + AudioBackend *be, + SWVoiceOut *sw, + const char *name, + void *callback_opaque, + audio_callback_fn callback_fn, + const struct audsettings *as) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->open_out(be, sw, name, callback_opaque, callback_fn, as); +} + +SWVoiceIn *AUD_open_in( + AudioBackend *be, + SWVoiceIn *sw, + const char *name, + void *callback_opaque, + audio_callback_fn callback_fn, + const struct audsettings *as) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->open_in(be, sw, name, callback_opaque, callback_fn, as); +} + +void AUD_close_out(AudioBackend *be, SWVoiceOut *sw) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->close_out(be, sw); +} + +void AUD_close_in(AudioBackend *be, SWVoiceIn *sw) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->close_in(be, sw); +} + +bool AUD_is_active_out(AudioBackend *be, SWVoiceOut *sw) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->is_active_out(be, sw); +} + +bool AUD_is_active_in(AudioBackend *be, SWVoiceIn *sw) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->is_active_in(be, sw); +} + static void audio_mixeng_backend_class_init(ObjectClass *klass, const void= *data) { AudioBackendClass *be =3D AUDIO_BACKEND_CLASS(klass); =20 be->realize =3D audio_mixeng_backend_realize; be->get_id =3D audio_mixeng_backend_get_id; + be->open_in =3D audio_mixeng_backend_open_in; + be->open_out =3D audio_mixeng_backend_open_out; + be->close_in =3D audio_mixeng_backend_close_in; + be->close_out =3D audio_mixeng_backend_close_out; + be->is_active_out =3D audio_mixeng_backend_is_active_out; + be->is_active_in =3D audio_mixeng_backend_is_active_in; + be->set_active_out =3D audio_mixeng_backend_set_active_out; + be->set_active_in =3D audio_mixeng_backend_set_active_in; + be->set_volume_out =3D audio_mixeng_backend_set_volume_out; + be->set_volume_in =3D audio_mixeng_backend_set_volume_in; + be->read =3D audio_mixeng_backend_read; + be->write =3D audio_mixeng_backend_write; + be->get_buffer_size_out =3D audio_mixeng_backend_get_buffer_size_out; + be->add_capture =3D audio_mixeng_backend_add_capture; + be->del_capture =3D audio_mixeng_backend_del_capture; } =20 static void audio_mixeng_backend_init(Object *obj) @@ -1863,12 +1988,11 @@ bool AUD_backend_check(AudioBackend **be, Error **e= rrp) =20 static struct audio_pcm_ops capture_pcm_ops; =20 -CaptureVoiceOut *AUD_add_capture( +static CaptureVoiceOut *audio_mixeng_backend_add_capture( AudioBackend *be, struct audsettings *as, struct audio_capture_ops *ops, - void *cb_opaque - ) + void *cb_opaque) { AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(be); CaptureVoiceOut *cap; @@ -1938,7 +2062,21 @@ CaptureVoiceOut *AUD_add_capture( return cap; } =20 -void AUD_del_capture(AudioBackend *be, CaptureVoiceOut *cap, void *cb_opaq= ue) +CaptureVoiceOut *AUD_add_capture( + AudioBackend *be, + struct audsettings *as, + struct audio_capture_ops *ops, + void *cb_opaque) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->add_capture(be, as, ops, cb_opaque); +} + +static void audio_mixeng_backend_del_capture( + AudioBackend *be, + CaptureVoiceOut *cap, + void *cb_opaque) { struct capture_callback *cb; =20 @@ -1977,7 +2115,15 @@ void AUD_del_capture(AudioBackend *be, CaptureVoiceO= ut *cap, void *cb_opaque) } } =20 -void AUD_set_volume_out(AudioBackend *be, SWVoiceOut *sw, Volume *vol) +void AUD_del_capture(AudioBackend *be, CaptureVoiceOut *cap, void *cb_opaq= ue) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + klass->del_capture(be, cap, cb_opaque); +} + +static void audio_mixeng_backend_set_volume_out(AudioBackend *be, SWVoiceO= ut *sw, + Volume *vol) { if (sw) { HWVoiceOut *hw =3D sw->hw; @@ -1993,7 +2139,15 @@ void AUD_set_volume_out(AudioBackend *be, SWVoiceOut= *sw, Volume *vol) } } =20 -void AUD_set_volume_in(AudioBackend *be, SWVoiceIn *sw, Volume *vol) +void AUD_set_volume_out(AudioBackend *be, SWVoiceOut *sw, Volume *vol) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + klass->set_volume_out(be, sw, vol); +} + +static void audio_mixeng_backend_set_volume_in(AudioBackend *be, SWVoiceIn= *sw, + Volume *vol) { if (sw) { HWVoiceIn *hw =3D sw->hw; @@ -2009,6 +2163,13 @@ void AUD_set_volume_in(AudioBackend *be, SWVoiceIn *= sw, Volume *vol) } } =20 +void AUD_set_volume_in(AudioBackend *be, SWVoiceIn *sw, Volume *vol) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + klass->set_volume_in(be, sw, vol); +} + static void audio_create_pdos(Audiodev *dev) { switch (dev->driver) { --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771855452; cv=none; d=zohomail.com; s=zohoarc; b=mnUriFzizAIm2jF0o68GGP594CG+jnkNh7vdwAkg4V2TxuIRJQNZtMwLG8qu8UeRQw+mmxa3bBzis9Z3kmkOUM8VN6bx42dN61E0mreXwLUs1P0H2MnkA3NXhk6MSWbXle65ku3oPudMrswBJR2ZZp7jeoKRtIGSBPnaeWlC22U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855452; 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=mb5pHzNfJSpKQ6uJQFjOza9G7rq7AO5807bWCHM3ZPc=; b=PC6U+862pWpe1r8v717UfYkWsVkEmEOj7hEmbTCcnlNiA58G0ZzVtGjUCYkDJf9scm+AP1tdu5II9q68Msv9RFXs0QrGqztCIDTCIXM6M7DLdASGahrkLk9+FDExoK3jtAUrJMPUoZVVMrHcfzJmkE+ZPIH/dOMny7LR2JshSf8= 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 1771855452014341.2989187011375; Mon, 23 Feb 2026 06:04:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWKA-00041U-FH; Mon, 23 Feb 2026 08:50: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 1vuWJK-00021q-TI for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:18 -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 1vuWJH-00079N-O1 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:18 -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-336-x2DH4Fy_MdaUwf2CTh_U5Q-1; Mon, 23 Feb 2026 08:49:13 -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 CC7A81955F0E; Mon, 23 Feb 2026 13:49:12 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4A63E1800668; Mon, 23 Feb 2026 13:49:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854555; 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=mb5pHzNfJSpKQ6uJQFjOza9G7rq7AO5807bWCHM3ZPc=; b=EJ7BIDYc+dNR1dXqJ2cL12VavhcCuPEm678DveTsDzRSq0EpgRRwIlct+wFoo0jJAZvxxk C47E2kRzTdJg1DlSC4dWJTDujgzQ4XjT40yRSLqshPLq7NCHbUnPg5gR0swxZ5w/2i6K/1 Dyd2J5ZQlaULZalvR+Pg3YRx+EyCiJE= X-MC-Unique: x2DH4Fy_MdaUwf2CTh_U5Q-1 X-Mimecast-MFC-AGG-ID: x2DH4Fy_MdaUwf2CTh_U5Q_1771854552 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 36/85] audio: split AudioBackend Date: Mon, 23 Feb 2026 14:46:37 +0100 Message-ID: <20260223134731.2377432-37-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855452760158501 From: Marc-Andr=C3=A9 Lureau Code clean-up, to allow building bare abstract class separately. The original file is MIT-licensed. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qemu/audio.h | 2 + audio/audio-be.c | 206 ++++++++++++++++++++++++++++++++++++++++++ audio/audio.c | 209 +------------------------------------------ audio/meson.build | 1 + 4 files changed, 211 insertions(+), 207 deletions(-) create mode 100644 audio/audio-be.c diff --git a/include/qemu/audio.h b/include/qemu/audio.h index 4fae48886ba..9f85c6316a8 100644 --- a/include/qemu/audio.h +++ b/include/qemu/audio.h @@ -111,6 +111,8 @@ typedef struct AudioBackendClass { =20 bool AUD_backend_check(AudioBackend **be, Error **errp); =20 +AudioBackend *audio_be_new(Audiodev *dev, Error **errp); + SWVoiceOut *AUD_open_out( AudioBackend *be, SWVoiceOut *sw, diff --git a/audio/audio-be.c b/audio/audio-be.c new file mode 100644 index 00000000000..51fb124026a --- /dev/null +++ b/audio/audio-be.c @@ -0,0 +1,206 @@ +/* SPDX-License-Identifier: MIT */ + +#include "qemu/osdep.h" +#include "qemu/audio.h" +#include "qemu/audio-capture.h" +#include "qapi/error.h" + +bool AUD_backend_check(AudioBackend **be, Error **errp) +{ + assert(be !=3D NULL); + + if (!*be) { + *be =3D audio_get_default_audio_be(errp); + if (!*be) { + return false; + } + } + + return true; +} + +SWVoiceIn *AUD_open_in( + AudioBackend *be, + SWVoiceIn *sw, + const char *name, + void *callback_opaque, + audio_callback_fn callback_fn, + const struct audsettings *as) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->open_in(be, sw, name, callback_opaque, callback_fn, as); +} + +SWVoiceOut *AUD_open_out( + AudioBackend *be, + SWVoiceOut *sw, + const char *name, + void *callback_opaque, + audio_callback_fn callback_fn, + const struct audsettings *as) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->open_out(be, sw, name, callback_opaque, callback_fn, as); +} + +void AUD_close_out(AudioBackend *be, SWVoiceOut *sw) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->close_out(be, sw); +} + +void AUD_close_in(AudioBackend *be, SWVoiceIn *sw) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->close_in(be, sw); +} + +bool AUD_is_active_out(AudioBackend *be, SWVoiceOut *sw) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->is_active_out(be, sw); +} + +bool AUD_is_active_in(AudioBackend *be, SWVoiceIn *sw) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->is_active_in(be, sw); +} + +size_t AUD_write(AudioBackend *be, SWVoiceOut *sw, void *buf, size_t size) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->write(be, sw, buf, size); +} + +size_t AUD_read(AudioBackend *be, SWVoiceIn *sw, void *buf, size_t size) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->read(be, sw, buf, size); +} + +int AUD_get_buffer_size_out(AudioBackend *be, SWVoiceOut *sw) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->get_buffer_size_out(be, sw); +} + +void AUD_set_active_out(AudioBackend *be, SWVoiceOut *sw, bool on) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->set_active_out(be, sw, on); +} + +void AUD_set_active_in(AudioBackend *be, SWVoiceIn *sw, bool on) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->set_active_in(be, sw, on); +} + +void AUD_set_volume_out(AudioBackend *be, SWVoiceOut *sw, Volume *vol) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + klass->set_volume_out(be, sw, vol); +} + +void AUD_set_volume_in(AudioBackend *be, SWVoiceIn *sw, Volume *vol) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + klass->set_volume_in(be, sw, vol); +} + +CaptureVoiceOut *AUD_add_capture( + AudioBackend *be, + struct audsettings *as, + struct audio_capture_ops *ops, + void *cb_opaque) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->add_capture(be, as, ops, cb_opaque); +} + +void AUD_del_capture(AudioBackend *be, CaptureVoiceOut *cap, void *cb_opaq= ue) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + klass->del_capture(be, cap, cb_opaque); +} + +#ifdef CONFIG_GIO +bool audio_be_can_set_dbus_server(AudioBackend *be) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + return klass->set_dbus_server !=3D NULL; +} + +bool audio_be_set_dbus_server(AudioBackend *be, + GDBusObjectManagerServer *server, + bool p2p, + Error **errp) +{ + AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); + + if (!audio_be_can_set_dbus_server(be)) { + error_setg(errp, "Audiodev '%s' is not compatible with DBus", + audio_be_get_id(be)); + return false; + } + + return klass->set_dbus_server(be, server, p2p, errp); +} +#endif + +const char *audio_be_get_id(AudioBackend *be) +{ + if (be) { + return AUDIO_BACKEND_GET_CLASS(be)->get_id(be); + } else { + return ""; + } +} + +AudioBackend *audio_be_new(Audiodev *dev, Error **errp) +{ + const char *drvname =3D AudiodevDriver_str(dev->driver); + g_autofree char *type =3D g_strconcat("audio-", drvname, NULL); + AudioBackend *be =3D AUDIO_BACKEND(object_new(type)); + + if (!be) { + error_setg(errp, "Unknown audio driver `%s'", drvname); + return NULL; + } + + if (!AUDIO_BACKEND_GET_CLASS(be)->realize(be, dev, errp)) { + object_unref(OBJECT(be)); + return NULL; + } + + return be; +} + +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_BACKEND, + .parent =3D TYPE_OBJECT, + .instance_size =3D sizeof(AudioBackend), + .abstract =3D true, + .class_size =3D sizeof(AudioBackendClass), + }, +}; + +DEFINE_TYPES(audio_types) diff --git a/audio/audio.c b/audio/audio.c index 32b2b882f80..22e55ac9758 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -870,15 +870,8 @@ static size_t audio_mixeng_backend_write(AudioBackend = *be, SWVoiceOut *sw, } } =20 -size_t AUD_write(AudioBackend *be, SWVoiceOut *sw, void *buf, size_t size) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - return klass->write(be, sw, buf, size); -} - -static size_t audio_mixeng_backend_read(AudioBackend *be, SWVoiceIn *sw, - void *buf, size_t size) +static size_t audio_mixeng_backend_read(AudioBackend *be, + SWVoiceIn *sw, void *buf, size_t s= ize) { HWVoiceIn *hw; =20 @@ -901,13 +894,6 @@ static size_t audio_mixeng_backend_read(AudioBackend *= be, SWVoiceIn *sw, =20 } =20 -size_t AUD_read(AudioBackend *be, SWVoiceIn *sw, void *buf, size_t size) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - return klass->read(be, sw, buf, size); -} - static int audio_mixeng_backend_get_buffer_size_out(AudioBackend *be, SWVo= iceOut *sw) { if (!sw) { @@ -921,13 +907,6 @@ static int audio_mixeng_backend_get_buffer_size_out(Au= dioBackend *be, SWVoiceOut return sw->hw->samples * sw->hw->info.bytes_per_frame; } =20 -int AUD_get_buffer_size_out(AudioBackend *be, SWVoiceOut *sw) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - return klass->get_buffer_size_out(be, sw); -} - static void audio_mixeng_backend_set_active_out(AudioBackend *be, SWVoiceO= ut *sw, bool on) { @@ -978,13 +957,6 @@ static void audio_mixeng_backend_set_active_out(AudioB= ackend *be, SWVoiceOut *sw =20 } =20 -void AUD_set_active_out(AudioBackend *be, SWVoiceOut *sw, bool on) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - return klass->set_active_out(be, sw, on); -} - static void audio_mixeng_backend_set_active_in(AudioBackend *be, SWVoiceIn= *sw, bool on) { HWVoiceIn *hw; @@ -1030,13 +1002,6 @@ static void audio_mixeng_backend_set_active_in(Audio= Backend *be, SWVoiceIn *sw, } } =20 -void AUD_set_active_in(AudioBackend *be, SWVoiceIn *sw, bool on) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - return klass->set_active_in(be, sw, on); -} - static size_t audio_get_avail(SWVoiceIn *sw) { size_t live; @@ -1643,25 +1608,6 @@ static bool audio_mixeng_backend_realize(AudioBacken= d *abe, return true; } =20 -static AudioBackend *audio_be_new(Audiodev *dev, Error **errp) -{ - const char *drvname =3D AudiodevDriver_str(dev->driver); - g_autofree char *type =3D g_strconcat("audio-", drvname, NULL); - AudioBackend *be =3D AUDIO_BACKEND(object_new(type)); - - if (!be) { - error_setg(errp, "Unknown audio driver `%s'", drvname); - return NULL; - } - - if (!AUDIO_BACKEND_GET_CLASS(be)->realize(be, dev, errp)) { - object_unref(OBJECT(be)); - return NULL; - } - - return be; -} - static void audio_vm_change_state_handler (void *opaque, bool running, RunState state) { @@ -1685,14 +1631,6 @@ static void audio_vm_change_state_handler (void *opa= que, bool running, =20 static const VMStateDescription vmstate_audio; =20 -static void audio_be_init(Object *obj) -{ -} - -static void audio_be_finalize(Object *obj) -{ -} - static const char *audio_mixeng_backend_get_id(AudioBackend *be) { return AUDIO_MIXENG_BACKEND(be)->dev->id; @@ -1714,60 +1652,6 @@ static void audio_mixeng_backend_set_volume_out(Audi= oBackend *be, SWVoiceOut *sw static void audio_mixeng_backend_set_volume_in(AudioBackend *be, SWVoiceIn= *sw, Volume *vol); =20 -SWVoiceOut *AUD_open_out( - AudioBackend *be, - SWVoiceOut *sw, - const char *name, - void *callback_opaque, - audio_callback_fn callback_fn, - const struct audsettings *as) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - return klass->open_out(be, sw, name, callback_opaque, callback_fn, as); -} - -SWVoiceIn *AUD_open_in( - AudioBackend *be, - SWVoiceIn *sw, - const char *name, - void *callback_opaque, - audio_callback_fn callback_fn, - const struct audsettings *as) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - return klass->open_in(be, sw, name, callback_opaque, callback_fn, as); -} - -void AUD_close_out(AudioBackend *be, SWVoiceOut *sw) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - return klass->close_out(be, sw); -} - -void AUD_close_in(AudioBackend *be, SWVoiceIn *sw) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - return klass->close_in(be, sw); -} - -bool AUD_is_active_out(AudioBackend *be, SWVoiceOut *sw) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - return klass->is_active_out(be, sw); -} - -bool AUD_is_active_in(AudioBackend *be, SWVoiceIn *sw) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - return klass->is_active_in(be, sw); -} - static void audio_mixeng_backend_class_init(ObjectClass *klass, const void= *data) { AudioBackendClass *be =3D AUDIO_BACKEND_CLASS(klass); @@ -1972,20 +1856,6 @@ AudioBackend *audio_get_default_audio_be(Error **err= p) return default_audio_be; } =20 -bool AUD_backend_check(AudioBackend **be, Error **errp) -{ - assert(be !=3D NULL); - - if (!*be) { - *be =3D audio_get_default_audio_be(errp); - if (!*be) { - return false; - } - } - - return true; -} - static struct audio_pcm_ops capture_pcm_ops; =20 static CaptureVoiceOut *audio_mixeng_backend_add_capture( @@ -2062,17 +1932,6 @@ static CaptureVoiceOut *audio_mixeng_backend_add_cap= ture( return cap; } =20 -CaptureVoiceOut *AUD_add_capture( - AudioBackend *be, - struct audsettings *as, - struct audio_capture_ops *ops, - void *cb_opaque) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - return klass->add_capture(be, as, ops, cb_opaque); -} - static void audio_mixeng_backend_del_capture( AudioBackend *be, CaptureVoiceOut *cap, @@ -2115,13 +1974,6 @@ static void audio_mixeng_backend_del_capture( } } =20 -void AUD_del_capture(AudioBackend *be, CaptureVoiceOut *cap, void *cb_opaq= ue) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - klass->del_capture(be, cap, cb_opaque); -} - static void audio_mixeng_backend_set_volume_out(AudioBackend *be, SWVoiceO= ut *sw, Volume *vol) { @@ -2139,13 +1991,6 @@ static void audio_mixeng_backend_set_volume_out(Audi= oBackend *be, SWVoiceOut *sw } } =20 -void AUD_set_volume_out(AudioBackend *be, SWVoiceOut *sw, Volume *vol) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - klass->set_volume_out(be, sw, vol); -} - static void audio_mixeng_backend_set_volume_in(AudioBackend *be, SWVoiceIn= *sw, Volume *vol) { @@ -2163,13 +2008,6 @@ static void audio_mixeng_backend_set_volume_in(Audio= Backend *be, SWVoiceIn *sw, } } =20 -void AUD_set_volume_in(AudioBackend *be, SWVoiceIn *sw, Volume *vol) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - klass->set_volume_in(be, sw, vol); -} - static void audio_create_pdos(Audiodev *dev) { switch (dev->driver) { @@ -2423,40 +2261,6 @@ AudioBackend *audio_be_by_name(const char *name, Err= or **errp) } } =20 -#ifdef CONFIG_GIO -bool audio_be_can_set_dbus_server(AudioBackend *be) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - return klass->set_dbus_server !=3D NULL; -} - -bool audio_be_set_dbus_server(AudioBackend *be, - GDBusObjectManagerServer *server, - bool p2p, - Error **errp) -{ - AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); - - if (!audio_be_can_set_dbus_server(be)) { - error_setg(errp, "Audiodev '%s' is not compatible with DBus", - audio_be_get_id(be)); - return false; - } - - return klass->set_dbus_server(be, server, p2p, errp); -} -#endif - -const char *audio_be_get_id(AudioBackend *be) -{ - if (be) { - return AUDIO_BACKEND_GET_CLASS(be)->get_id(be); - } else { - return ""; - } -} - const char *audio_application_name(void) { const char *vm_name; @@ -2521,15 +2325,6 @@ AudiodevList *qmp_query_audiodevs(Error **errp) } =20 static const TypeInfo audio_types[] =3D { - { - .name =3D TYPE_AUDIO_BACKEND, - .parent =3D TYPE_OBJECT, - .instance_size =3D sizeof(AudioBackend), - .instance_init =3D audio_be_init, - .instance_finalize =3D audio_be_finalize, - .abstract =3D true, - .class_size =3D sizeof(AudioBackendClass), - }, { .name =3D TYPE_AUDIO_MIXENG_BACKEND, .parent =3D TYPE_AUDIO_BACKEND, diff --git a/audio/meson.build b/audio/meson.build index 55ee0bfc865..17f58369c20 100644 --- a/audio/meson.build +++ b/audio/meson.build @@ -1,6 +1,7 @@ audio_ss =3D ss.source_set() audio_ss.add(files( 'audio.c', + 'audio-be.c', 'mixeng.c', 'noaudio.c', 'wavaudio.c', --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771854699; cv=none; d=zohomail.com; s=zohoarc; b=F2Fab9CICtdpm+kDjM5xv1XPzM2jCDas81MSTiD5wItVbE9VXJtwJ6udg9g4e3chs2390FFPr15Lzsnbl97qrLe5AAWkc+l2f6cs6j/OcDDbjSd3AC6+WdsHyfXp1UN34i+fRAB06krqSU7rNhlnn3teGPZFNl1KmGrZ3aM1UjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854699; 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=MCg2g/2oH8wKYlwMvTOyiseagpFo2oj70c69vVyAAOc=; b=SofAlrY++IkCckx6YEZaFjmz6DEoJgXAindDN+ba68tIFsRNksnwApvsnwDGxFCGOnb6UiPh5uZm8knirXUScnybivMriZDyINKCVm7VNju5tEyPHN3o7TLkcKofTPRizIaJxK8HVR3JWi0eD+Sp5aETGa6ybMNVeUHq7eeVs0U= 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 1771854699082450.8117811094844; Mon, 23 Feb 2026 05:51:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWL2-00065Q-RD; Mon, 23 Feb 2026 08:51: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 1vuWJT-0002xE-Fp for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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 1vuWJN-0007A7-RA for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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-610-kqirEmfzMDKLAipPBWh1_A-1; Mon, 23 Feb 2026 08:49:17 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 05038180057E; Mon, 23 Feb 2026 13:49:16 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E112F1800370; Mon, 23 Feb 2026 13:49:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854561; 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=MCg2g/2oH8wKYlwMvTOyiseagpFo2oj70c69vVyAAOc=; b=EYRqPEwyxzPdvplsHNbLlDwWW00dI3xtb0HTOJnmRywrNPICEv2lAL4B1oTxoYysj2pnAL 5a5U4l+ZNFqLLOEs2FM5j0wALtvL/+FtjvymI2cOYWgvxBWIQcycMzgpku3v8uZCThGeOT qpw5rO3IwHU8O/Lk/aXR5gM0a5NDNmM= X-MC-Unique: kqirEmfzMDKLAipPBWh1_A-1 X-Mimecast-MFC-AGG-ID: kqirEmfzMDKLAipPBWh1_A_1771854556 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Laurent Vivier , "Michael S. Tsirkin" , Manos Pitsidianakis , Alistair Francis , "Edgar E. Iglesias" , qemu-arm@nongnu.org (open list:Xilinx ZynqMP and...) Subject: [PULL v3 37/85] audio: AUD_ -> audio_be_ Date: Mon, 23 Feb 2026 14:46:38 +0100 Message-ID: <20260223134731.2377432-38-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01 autolearn=no 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: 1771854699695158500 From: Marc-Andr=C3=A9 Lureau Use the associate AudioBackend prefix for readability. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_template.h | 4 +- include/qemu/audio-capture.h | 4 +- include/qemu/audio.h | 43 +++++++------ audio/audio-be.c | 32 +++++----- audio/wavcapture.c | 4 +- hw/audio/ac97.c | 42 ++++++------- hw/audio/adlib.c | 10 +-- hw/audio/asc.c | 20 +++--- hw/audio/cs4231a.c | 18 +++--- hw/audio/es1370.c | 26 ++++---- hw/audio/gus.c | 10 +-- hw/audio/hda-codec.c | 40 ++++++------ hw/audio/lm4549.c | 20 +++--- hw/audio/pcspk.c | 8 +-- hw/audio/sb16.c | 22 +++---- hw/audio/via-ac97.c | 20 +++--- hw/audio/virtio-snd.c | 40 ++++++------ hw/audio/wm8750.c | 43 ++++++------- hw/display/xlnx_dp.c | 16 ++--- hw/usb/dev-audio.c | 18 +++--- tests/audio/test-audio.c | 116 +++++++++++++++++------------------ ui/vnc.c | 4 +- 22 files changed, 281 insertions(+), 279 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index a7733f9e1d9..77a70d6e56a 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -527,7 +527,7 @@ static SW *glue(audio_mixeng_backend_open_, TYPE) ( } =20 if (!pdo->fixed_settings && sw) { - glue(AUD_close_, TYPE)(be, sw); + glue(audio_be_close_, TYPE)(be, sw); sw =3D NULL; } =20 @@ -564,7 +564,7 @@ static SW *glue(audio_mixeng_backend_open_, TYPE) ( return sw; =20 fail: - glue(AUD_close_, TYPE)(be, sw); + glue(audio_be_close_, TYPE)(be, sw); return NULL; } =20 diff --git a/include/qemu/audio-capture.h b/include/qemu/audio-capture.h index 5bfbdd02985..d7998232243 100644 --- a/include/qemu/audio-capture.h +++ b/include/qemu/audio-capture.h @@ -19,13 +19,13 @@ typedef struct CaptureState { QLIST_ENTRY(CaptureState) entries; } CaptureState; =20 -CaptureVoiceOut *AUD_add_capture( +CaptureVoiceOut *audio_be_add_capture( AudioBackend *be, struct audsettings *as, struct audio_capture_ops *ops, void *opaque); =20 -void AUD_del_capture( +void audio_be_del_capture( AudioBackend *be, CaptureVoiceOut *cap, void *cb_opaque); diff --git a/include/qemu/audio.h b/include/qemu/audio.h index 9f85c6316a8..42f97f732a6 100644 --- a/include/qemu/audio.h +++ b/include/qemu/audio.h @@ -109,11 +109,11 @@ typedef struct AudioBackendClass { #endif } AudioBackendClass; =20 -bool AUD_backend_check(AudioBackend **be, Error **errp); +bool audio_be_check(AudioBackend **be, Error **errp); =20 AudioBackend *audio_be_new(Audiodev *dev, Error **errp); =20 -SWVoiceOut *AUD_open_out( +SWVoiceOut *audio_be_open_out( AudioBackend *be, SWVoiceOut *sw, const char *name, @@ -121,34 +121,33 @@ SWVoiceOut *AUD_open_out( audio_callback_fn callback_fn, const struct audsettings *settings); =20 -void AUD_close_out(AudioBackend *be, SWVoiceOut *sw); -size_t AUD_write(AudioBackend *be, SWVoiceOut *sw, void *pcm_buf, size_t s= ize); -int AUD_get_buffer_size_out(AudioBackend *be, SWVoiceOut *sw); -void AUD_set_active_out(AudioBackend *be, SWVoiceOut *sw, bool on); -bool AUD_is_active_out(AudioBackend *be, SWVoiceOut *sw); +void audio_be_close_out(AudioBackend *be, SWVoiceOut *sw); +size_t audio_be_write(AudioBackend *be, SWVoiceOut *sw, void *pcm_buf, siz= e_t size); +int audio_be_get_buffer_size_out(AudioBackend *be, SWVoiceOut *sw); +void audio_be_set_active_out(AudioBackend *be, SWVoiceOut *sw, bool on); +bool audio_be_is_active_out(AudioBackend *be, SWVoiceOut *sw); =20 -void AUD_set_volume_out(AudioBackend *be, SWVoiceOut *sw, Volume *vol); -void AUD_set_volume_in(AudioBackend *be, SWVoiceIn *sw, Volume *vol); + +void audio_be_set_volume_out(AudioBackend *be, SWVoiceOut *sw, Volume *vol= ); +void audio_be_set_volume_in(AudioBackend *be, SWVoiceIn *sw, Volume *vol); =20 static inline void -AUD_set_volume_out_lr(AudioBackend *be, SWVoiceOut *sw, - bool mut, uint8_t lvol, uint8_t rvol) -{ - AUD_set_volume_out(be, sw, &(Volume) { +audio_be_set_volume_out_lr(AudioBackend *be, SWVoiceOut *sw, + bool mut, uint8_t lvol, uint8_t rvol) { + audio_be_set_volume_out(be, sw, &(Volume) { .mute =3D mut, .channels =3D 2, .vol =3D { lvol, rvol } }); } =20 static inline void -AUD_set_volume_in_lr(AudioBackend *be, SWVoiceIn *sw, - bool mut, uint8_t lvol, uint8_t rvol) -{ - AUD_set_volume_in(be, sw, &(Volume) { +audio_be_set_volume_in_lr(AudioBackend *be, SWVoiceIn *sw, + bool mut, uint8_t lvol, uint8_t rvol) { + audio_be_set_volume_in(be, sw, &(Volume) { .mute =3D mut, .channels =3D 2, .vol =3D { lvol, rvol } }); } =20 -SWVoiceIn *AUD_open_in( +SWVoiceIn *audio_be_open_in( AudioBackend *be, SWVoiceIn *sw, const char *name, @@ -157,10 +156,10 @@ SWVoiceIn *AUD_open_in( const struct audsettings *settings ); =20 -void AUD_close_in(AudioBackend *be, SWVoiceIn *sw); -size_t AUD_read(AudioBackend *be, SWVoiceIn *sw, void *pcm_buf, size_t siz= e); -void AUD_set_active_in(AudioBackend *be, SWVoiceIn *sw, bool on); -bool AUD_is_active_in(AudioBackend *be, SWVoiceIn *sw); +void audio_be_close_in(AudioBackend *be, SWVoiceIn *sw); +size_t audio_be_read(AudioBackend *be, SWVoiceIn *sw, void *pcm_buf, size_= t size); +void audio_be_set_active_in(AudioBackend *be, SWVoiceIn *sw, bool on); +bool audio_be_is_active_in(AudioBackend *be, SWVoiceIn *sw); =20 void audio_cleanup(void); =20 diff --git a/audio/audio-be.c b/audio/audio-be.c index 51fb124026a..4d3b1e2bafd 100644 --- a/audio/audio-be.c +++ b/audio/audio-be.c @@ -5,7 +5,7 @@ #include "qemu/audio-capture.h" #include "qapi/error.h" =20 -bool AUD_backend_check(AudioBackend **be, Error **errp) +bool audio_be_check(AudioBackend **be, Error **errp) { assert(be !=3D NULL); =20 @@ -19,7 +19,7 @@ bool AUD_backend_check(AudioBackend **be, Error **errp) return true; } =20 -SWVoiceIn *AUD_open_in( +SWVoiceIn *audio_be_open_in( AudioBackend *be, SWVoiceIn *sw, const char *name, @@ -32,7 +32,7 @@ SWVoiceIn *AUD_open_in( return klass->open_in(be, sw, name, callback_opaque, callback_fn, as); } =20 -SWVoiceOut *AUD_open_out( +SWVoiceOut *audio_be_open_out( AudioBackend *be, SWVoiceOut *sw, const char *name, @@ -45,84 +45,84 @@ SWVoiceOut *AUD_open_out( return klass->open_out(be, sw, name, callback_opaque, callback_fn, as); } =20 -void AUD_close_out(AudioBackend *be, SWVoiceOut *sw) +void audio_be_close_out(AudioBackend *be, SWVoiceOut *sw) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 return klass->close_out(be, sw); } =20 -void AUD_close_in(AudioBackend *be, SWVoiceIn *sw) +void audio_be_close_in(AudioBackend *be, SWVoiceIn *sw) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 return klass->close_in(be, sw); } =20 -bool AUD_is_active_out(AudioBackend *be, SWVoiceOut *sw) +bool audio_be_is_active_out(AudioBackend *be, SWVoiceOut *sw) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 return klass->is_active_out(be, sw); } =20 -bool AUD_is_active_in(AudioBackend *be, SWVoiceIn *sw) +bool audio_be_is_active_in(AudioBackend *be, SWVoiceIn *sw) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 return klass->is_active_in(be, sw); } =20 -size_t AUD_write(AudioBackend *be, SWVoiceOut *sw, void *buf, size_t size) +size_t audio_be_write(AudioBackend *be, SWVoiceOut *sw, void *buf, size_t = size) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 return klass->write(be, sw, buf, size); } =20 -size_t AUD_read(AudioBackend *be, SWVoiceIn *sw, void *buf, size_t size) +size_t audio_be_read(AudioBackend *be, SWVoiceIn *sw, void *buf, size_t si= ze) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 return klass->read(be, sw, buf, size); } =20 -int AUD_get_buffer_size_out(AudioBackend *be, SWVoiceOut *sw) +int audio_be_get_buffer_size_out(AudioBackend *be, SWVoiceOut *sw) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 return klass->get_buffer_size_out(be, sw); } =20 -void AUD_set_active_out(AudioBackend *be, SWVoiceOut *sw, bool on) +void audio_be_set_active_out(AudioBackend *be, SWVoiceOut *sw, bool on) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 return klass->set_active_out(be, sw, on); } =20 -void AUD_set_active_in(AudioBackend *be, SWVoiceIn *sw, bool on) +void audio_be_set_active_in(AudioBackend *be, SWVoiceIn *sw, bool on) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 return klass->set_active_in(be, sw, on); } =20 -void AUD_set_volume_out(AudioBackend *be, SWVoiceOut *sw, Volume *vol) +void audio_be_set_volume_out(AudioBackend *be, SWVoiceOut *sw, Volume *vol) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 klass->set_volume_out(be, sw, vol); } =20 -void AUD_set_volume_in(AudioBackend *be, SWVoiceIn *sw, Volume *vol) +void audio_be_set_volume_in(AudioBackend *be, SWVoiceIn *sw, Volume *vol) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 klass->set_volume_in(be, sw, vol); } =20 -CaptureVoiceOut *AUD_add_capture( +CaptureVoiceOut *audio_be_add_capture( AudioBackend *be, struct audsettings *as, struct audio_capture_ops *ops, @@ -133,7 +133,7 @@ CaptureVoiceOut *AUD_add_capture( return klass->add_capture(be, as, ops, cb_opaque); } =20 -void AUD_del_capture(AudioBackend *be, CaptureVoiceOut *cap, void *cb_opaq= ue) +void audio_be_del_capture(AudioBackend *be, CaptureVoiceOut *cap, void *cb= _opaque) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 diff --git a/audio/wavcapture.c b/audio/wavcapture.c index 2950ceaf242..69aa91e35f6 100644 --- a/audio/wavcapture.c +++ b/audio/wavcapture.c @@ -86,7 +86,7 @@ static void wav_capture_destroy (void *opaque) { WAVState *wav =3D opaque; =20 - AUD_del_capture(wav->audio_be, wav->cap, wav); + audio_be_del_capture(wav->audio_be, wav->cap, wav); g_free (wav); } =20 @@ -172,7 +172,7 @@ int wav_start_capture(AudioBackend *state, CaptureState= *s, const char *path, goto error_free; } =20 - cap =3D AUD_add_capture(wav->audio_be, &as, &ops, wav); + cap =3D audio_be_add_capture(wav->audio_be, &as, &ops, wav); if (!cap) { error_report("Failed to add audio capture"); goto error_free; diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index 65a4141b8af..5d442b7e067 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -246,15 +246,15 @@ static void voice_set_active(AC97LinkState *s, int bm= _index, int on) { switch (bm_index) { case PI_INDEX: - AUD_set_active_in(s->audio_be, s->voice_pi, on); + audio_be_set_active_in(s->audio_be, s->voice_pi, on); break; =20 case PO_INDEX: - AUD_set_active_out(s->audio_be, s->voice_po, on); + audio_be_set_active_out(s->audio_be, s->voice_po, on); break; =20 case MC_INDEX: - AUD_set_active_in(s->audio_be, s->voice_mc, on); + audio_be_set_active_in(s->audio_be, s->voice_mc, on); break; =20 default: @@ -319,7 +319,7 @@ static void open_voice(AC97LinkState *s, int index, int= freq) s->invalid_freq[index] =3D 0; switch (index) { case PI_INDEX: - s->voice_pi =3D AUD_open_in( + s->voice_pi =3D audio_be_open_in( s->audio_be, s->voice_pi, "ac97.pi", @@ -330,7 +330,7 @@ static void open_voice(AC97LinkState *s, int index, int= freq) break; =20 case PO_INDEX: - s->voice_po =3D AUD_open_out( + s->voice_po =3D audio_be_open_out( s->audio_be, s->voice_po, "ac97.po", @@ -341,7 +341,7 @@ static void open_voice(AC97LinkState *s, int index, int= freq) break; =20 case MC_INDEX: - s->voice_mc =3D AUD_open_in( + s->voice_mc =3D audio_be_open_in( s->audio_be, s->voice_mc, "ac97.mc", @@ -355,17 +355,17 @@ static void open_voice(AC97LinkState *s, int index, i= nt freq) s->invalid_freq[index] =3D freq; switch (index) { case PI_INDEX: - AUD_close_in(s->audio_be, s->voice_pi); + audio_be_close_in(s->audio_be, s->voice_pi); s->voice_pi =3D NULL; break; =20 case PO_INDEX: - AUD_close_out(s->audio_be, s->voice_po); + audio_be_close_out(s->audio_be, s->voice_po); s->voice_po =3D NULL; break; =20 case MC_INDEX: - AUD_close_in(s->audio_be, s->voice_mc); + audio_be_close_in(s->audio_be, s->voice_mc); s->voice_mc =3D NULL; break; } @@ -378,15 +378,15 @@ static void reset_voices(AC97LinkState *s, uint8_t ac= tive[LAST_INDEX]) =20 freq =3D mixer_load(s, AC97_PCM_LR_ADC_Rate); open_voice(s, PI_INDEX, freq); - AUD_set_active_in(s->audio_be, s->voice_pi, active[PI_INDEX]); + audio_be_set_active_in(s->audio_be, s->voice_pi, active[PI_INDEX]); =20 freq =3D mixer_load(s, AC97_PCM_Front_DAC_Rate); open_voice(s, PO_INDEX, freq); - AUD_set_active_out(s->audio_be, s->voice_po, active[PO_INDEX]); + audio_be_set_active_out(s->audio_be, s->voice_po, active[PO_INDEX]); =20 freq =3D mixer_load(s, AC97_MIC_ADC_Rate); open_voice(s, MC_INDEX, freq); - AUD_set_active_in(s->audio_be, s->voice_mc, active[MC_INDEX]); + audio_be_set_active_in(s->audio_be, s->voice_mc, active[MC_INDEX]); } =20 static void get_volume(uint16_t vol, uint16_t mask, int inverse, @@ -416,7 +416,7 @@ static void update_combined_volume_out(AC97LinkState *s) lvol =3D (lvol * plvol) / 255; rvol =3D (rvol * prvol) / 255; =20 - AUD_set_volume_out_lr(s->audio_be, s->voice_po, mute, lvol, rvol); + audio_be_set_volume_out_lr(s->audio_be, s->voice_po, mute, lvol, rvol); } =20 static void update_volume_in(AC97LinkState *s) @@ -427,7 +427,7 @@ static void update_volume_in(AC97LinkState *s) get_volume(mixer_load(s, AC97_Record_Gain_Mute), 0x0f, 0, &mute, &lvol, &rvol); =20 - AUD_set_volume_in_lr(s->audio_be, s->voice_pi, mute, lvol, rvol); + audio_be_set_volume_in_lr(s->audio_be, s->voice_pi, mute, lvol, rvol); } =20 static void set_volume(AC97LinkState *s, int index, uint32_t val) @@ -904,7 +904,7 @@ static int write_audio(AC97LinkState *s, AC97BusMasterR= egs *r, int copied; to_copy =3D MIN(temp, sizeof(tmpbuf)); pci_dma_read(&s->dev, addr, tmpbuf, to_copy); - copied =3D AUD_write(s->audio_be, s->voice_po, tmpbuf, to_copy); + copied =3D audio_be_write(s->audio_be, s->voice_po, tmpbuf, to_cop= y); dolog("write_audio max=3D%x to_copy=3D%x copied=3D%x", max, to_copy, copied); if (!copied) { @@ -948,7 +948,7 @@ static void write_bup(AC97LinkState *s, int elapsed) while (elapsed) { int temp =3D MIN(elapsed, sizeof(s->silence)); while (temp) { - int copied =3D AUD_write(s->audio_be, s->voice_po, s->silence,= temp); + int copied =3D audio_be_write(s->audio_be, s->voice_po, s->sil= ence, temp); if (!copied) { return; } @@ -978,7 +978,7 @@ static int read_audio(AC97LinkState *s, AC97BusMasterRe= gs *r, while (temp) { int acquired; to_copy =3D MIN(temp, sizeof(tmpbuf)); - acquired =3D AUD_read(s->audio_be, voice, tmpbuf, to_copy); + acquired =3D audio_be_read(s->audio_be, voice, tmpbuf, to_copy); if (!acquired) { *stop =3D 1; break; @@ -1275,7 +1275,7 @@ static void ac97_realize(PCIDevice *dev, Error **errp) AC97LinkState *s =3D AC97(dev); uint8_t *c =3D s->dev.config; =20 - if (!AUD_backend_check(&s->audio_be, errp)) { + if (!audio_be_check(&s->audio_be, errp)) { return; } =20 @@ -1301,9 +1301,9 @@ static void ac97_exit(PCIDevice *dev) { AC97LinkState *s =3D AC97(dev); =20 - AUD_close_in(s->audio_be, s->voice_pi); - AUD_close_out(s->audio_be, s->voice_po); - AUD_close_in(s->audio_be, s->voice_mc); + audio_be_close_in(s->audio_be, s->voice_pi); + audio_be_close_out(s->audio_be, s->voice_po); + audio_be_close_in(s->audio_be, s->voice_mc); } =20 static const Property ac97_properties[] =3D { diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index dd5d9cf6772..ce17e21d5fd 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -95,7 +95,7 @@ static void adlib_write(void *opaque, uint32_t nport, uin= t32_t val) int a =3D nport & 3; =20 s->active =3D 1; - AUD_set_active_out(s->audio_be, s->voice, 1); + audio_be_set_active_out(s->audio_be, s->voice, 1); =20 adlib_kill_timers (s); =20 @@ -143,7 +143,7 @@ static int write_audio (AdlibState *s, int samples) int nbytes, wbytes, wsampl; =20 nbytes =3D samples << SHIFT; - wbytes =3D AUD_write( + wbytes =3D audio_be_write( s->audio_be, s->voice, s->mixbuf + (pos << (SHIFT - 1)), @@ -237,7 +237,7 @@ static void adlib_realizefn (DeviceState *dev, Error **= errp) AdlibState *s =3D ADLIB(dev); struct audsettings as; =20 - if (!AUD_backend_check(&s->audio_be, errp)) { + if (!audio_be_check(&s->audio_be, errp)) { return; } =20 @@ -256,7 +256,7 @@ static void adlib_realizefn (DeviceState *dev, Error **= errp) as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D HOST_BIG_ENDIAN; =20 - s->voice =3D AUD_open_out( + s->voice =3D audio_be_open_out( s->audio_be, s->voice, "adlib", @@ -270,7 +270,7 @@ static void adlib_realizefn (DeviceState *dev, Error **= errp) return; } =20 - s->samples =3D AUD_get_buffer_size_out(s->audio_be, s->voice) >> SHIFT; + s->samples =3D audio_be_get_buffer_size_out(s->audio_be, s->voice) >> = SHIFT; s->mixbuf =3D g_malloc0 (s->samples << SHIFT); =20 adlib_portio_list[0].offset =3D s->port; diff --git a/hw/audio/asc.c b/hw/audio/asc.c index 43cd51939a3..35c7b5750d6 100644 --- a/hw/audio/asc.c +++ b/hw/audio/asc.c @@ -355,12 +355,12 @@ static void asc_out_cb(void *opaque, int free_b) * loop because the FIFO has run out of data, and the driver * reuses the stale content in its circular audio buffer. */ - AUD_write(s->audio_be, s->voice, s->silentbuf, samples << s->s= hift); + audio_be_write(s->audio_be, s->voice, s->silentbuf, samples <<= s->shift); } return; } =20 - AUD_write(s->audio_be, s->voice, s->mixbuf, generated << s->shift); + audio_be_write(s->audio_be, s->voice, s->mixbuf, generated << s->shift= ); } =20 static uint64_t asc_fifo_read(void *opaque, hwaddr addr, @@ -470,9 +470,9 @@ static void asc_write(void *opaque, hwaddr addr, uint64= _t value, asc_fifo_reset(&s->fifos[1]); asc_lower_irq(s); if (value !=3D 0) { - AUD_set_active_out(s->audio_be, s->voice, 1); + audio_be_set_active_out(s->audio_be, s->voice, 1); } else { - AUD_set_active_out(s->audio_be, s->voice, 0); + audio_be_set_active_out(s->audio_be, s->voice, 0); } } break; @@ -489,7 +489,7 @@ static void asc_write(void *opaque, hwaddr addr, uint64= _t value, { int vol =3D (value & 0xe0); =20 - AUD_set_volume_out_lr(s->audio_be, s->voice, 0, vol, vol); + audio_be_set_volume_out_lr(s->audio_be, s->voice, 0, vol, vol); break; } } @@ -545,7 +545,7 @@ static int asc_post_load(void *opaque, int version) ASCState *s =3D ASC(opaque); =20 if (s->regs[ASC_MODE] !=3D 0) { - AUD_set_active_out(s->audio_be, s->voice, 1); + audio_be_set_active_out(s->audio_be, s->voice, 1); } =20 return 0; @@ -614,7 +614,7 @@ static void asc_reset_hold(Object *obj, ResetType type) { ASCState *s =3D ASC(obj); =20 - AUD_set_active_out(s->audio_be, s->voice, 0); + audio_be_set_active_out(s->audio_be, s->voice, 0); =20 memset(s->regs, 0, sizeof(s->regs)); asc_fifo_reset(&s->fifos[0]); @@ -641,7 +641,7 @@ static void asc_realize(DeviceState *dev, Error **errp) ASCState *s =3D ASC(dev); struct audsettings as; =20 - if (!AUD_backend_check(&s->audio_be, errp)) { + if (!audio_be_check(&s->audio_be, errp)) { return; } =20 @@ -650,7 +650,7 @@ static void asc_realize(DeviceState *dev, Error **errp) as.fmt =3D AUDIO_FORMAT_U8; as.endianness =3D HOST_BIG_ENDIAN; =20 - s->voice =3D AUD_open_out(s->audio_be, s->voice, "asc.out", s, asc_out= _cb, + s->voice =3D audio_be_open_out(s->audio_be, s->voice, "asc.out", s, as= c_out_cb, &as); if (!s->voice) { error_setg(errp, "Initializing audio stream failed"); @@ -658,7 +658,7 @@ static void asc_realize(DeviceState *dev, Error **errp) } =20 s->shift =3D 1; - s->samples =3D AUD_get_buffer_size_out(s->audio_be, s->voice) >> s->sh= ift; + s->samples =3D audio_be_get_buffer_size_out(s->audio_be, s->voice) >> = s->shift; s->mixbuf =3D g_malloc0(s->samples << s->shift); =20 s->silentbuf =3D g_malloc(s->samples << s->shift); diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c index 3b8ed092fe4..e6cae9c988e 100644 --- a/hw/audio/cs4231a.c +++ b/hw/audio/cs4231a.c @@ -327,7 +327,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) goto error; } =20 - s->voice =3D AUD_open_out( + s->voice =3D audio_be_open_out( s->audio_be, s->voice, "cs4231a", @@ -339,7 +339,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) if (s->dregs[Interface_Configuration] & PEN) { if (!s->dma_running) { k->hold_DREQ(s->isa_dma, s->dma); - AUD_set_active_out(s->audio_be, s->voice, 1); + audio_be_set_active_out(s->audio_be, s->voice, 1); s->transferred =3D 0; } s->dma_running =3D 1; @@ -347,7 +347,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) else { if (s->dma_running) { k->release_DREQ(s->isa_dma, s->dma); - AUD_set_active_out(s->audio_be, s->voice, 0); + audio_be_set_active_out(s->audio_be, s->voice, 0); } s->dma_running =3D 0; } @@ -356,7 +356,7 @@ static void cs_reset_voices (CSState *s, uint32_t val) error: if (s->dma_running) { k->release_DREQ(s->isa_dma, s->dma); - AUD_set_active_out(s->audio_be, s->voice, 0); + audio_be_set_active_out(s->audio_be, s->voice, 0); } } =20 @@ -465,7 +465,7 @@ static void cs_write (void *opaque, hwaddr addr, if (s->dma_running) { IsaDmaClass *k =3D ISADMA_GET_CLASS(s->isa_dma); k->release_DREQ(s->isa_dma, s->dma); - AUD_set_active_out(s->audio_be, s->voice, 0); + audio_be_set_active_out(s->audio_be, s->voice, 0); s->dma_running =3D 0; } } @@ -551,11 +551,11 @@ static int cs_write_audio (CSState *s, int nchan, int= dma_pos, =20 for (i =3D 0; i < copied; ++i) linbuf[i] =3D s->tab[tmpbuf[i]]; - copied =3D AUD_write(s->audio_be, s->voice, linbuf, copied << = 1); + copied =3D audio_be_write(s->audio_be, s->voice, linbuf, copie= d << 1); copied >>=3D 1; } else { - copied =3D AUD_write(s->audio_be, s->voice, tmpbuf, copied); + copied =3D audio_be_write(s->audio_be, s->voice, tmpbuf, copie= d); } =20 temp -=3D copied; @@ -614,7 +614,7 @@ static int cs4231a_pre_load (void *opaque) if (s->dma_running) { IsaDmaClass *k =3D ISADMA_GET_CLASS(s->isa_dma); k->release_DREQ(s->isa_dma, s->dma); - AUD_set_active_out(s->audio_be, s->voice, 0); + audio_be_set_active_out(s->audio_be, s->voice, 0); } s->dma_running =3D 0; return 0; @@ -678,7 +678,7 @@ static void cs4231a_realizefn (DeviceState *dev, Error = **errp) return; } =20 - if (!AUD_backend_check(&s->audio_be, errp)) { + if (!audio_be_check(&s->audio_be, errp)) { return; } =20 diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 44b204730b5..e1658393c6a 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -330,10 +330,10 @@ static void es1370_reset (ES1370State *s) d->scount =3D 0; d->leftover =3D 0; if (i =3D=3D ADC_CHANNEL) { - AUD_close_in(s->audio_be, s->adc_voice); + audio_be_close_in(s->audio_be, s->adc_voice); s->adc_voice =3D NULL; } else { - AUD_close_out(s->audio_be, s->dac_voice[i]); + audio_be_close_out(s->audio_be, s->dac_voice[i]); s->dac_voice[i] =3D NULL; } } @@ -411,7 +411,7 @@ static void es1370_update_voices (ES1370State *s, uint3= 2_t ctl, uint32_t sctl) =20 if (i =3D=3D ADC_CHANNEL) { s->adc_voice =3D - AUD_open_in( + audio_be_open_in( s->audio_be, s->adc_voice, "es1370.adc", @@ -421,7 +421,7 @@ static void es1370_update_voices (ES1370State *s, uint3= 2_t ctl, uint32_t sctl) ); } else { s->dac_voice[i] =3D - AUD_open_out( + audio_be_open_out( s->audio_be, s->dac_voice[i], i ? "es1370.dac2" : "es1370.dac1", @@ -438,9 +438,9 @@ static void es1370_update_voices (ES1370State *s, uint3= 2_t ctl, uint32_t sctl) int on =3D (ctl & b->ctl_en) && !(sctl & b->sctl_pause); =20 if (i =3D=3D ADC_CHANNEL) { - AUD_set_active_in(s->audio_be, s->adc_voice, on); + audio_be_set_active_in(s->audio_be, s->adc_voice, on); } else { - AUD_set_active_out(s->audio_be, s->dac_voice[i], on); + audio_be_set_active_out(s->audio_be, s->dac_voice[i], on); } } } @@ -627,7 +627,7 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, int acquired, to_copy; =20 to_copy =3D MIN(to_transfer, sizeof(tmpbuf)); - acquired =3D AUD_read(s->audio_be, s->adc_voice, tmpbuf, to_co= py); + acquired =3D audio_be_read(s->audio_be, s->adc_voice, tmpbuf, = to_copy); if (!acquired) { break; } @@ -646,7 +646,7 @@ static void es1370_transfer_audio (ES1370State *s, stru= ct chan *d, int loop_sel, =20 to_copy =3D MIN(to_transfer, sizeof(tmpbuf)); pci_dma_read (&s->dev, addr, tmpbuf, to_copy); - copied =3D AUD_write(s->audio_be, voice, tmpbuf, to_copy); + copied =3D audio_be_write(s->audio_be, voice, tmpbuf, to_copy); if (!copied) { break; } @@ -784,12 +784,12 @@ static int es1370_post_load (void *opaque, int versio= n_id) for (i =3D 0; i < NB_CHANNELS; ++i) { if (i =3D=3D ADC_CHANNEL) { if (s->adc_voice) { - AUD_close_in(s->audio_be, s->adc_voice); + audio_be_close_in(s->audio_be, s->adc_voice); s->adc_voice =3D NULL; } } else { if (s->dac_voice[i]) { - AUD_close_out(s->audio_be, s->dac_voice[i]); + audio_be_close_out(s->audio_be, s->dac_voice[i]); s->dac_voice[i] =3D NULL; } } @@ -833,7 +833,7 @@ static void es1370_realize(PCIDevice *dev, Error **errp) ES1370State *s =3D ES1370(dev); uint8_t *c =3D s->dev.config; =20 - if (!AUD_backend_check(&s->audio_be, errp)) { + if (!audio_be_check(&s->audio_be, errp)) { return; } =20 @@ -861,10 +861,10 @@ static void es1370_exit(PCIDevice *dev) int i; =20 for (i =3D 0; i < 2; ++i) { - AUD_close_out(s->audio_be, s->dac_voice[i]); + audio_be_close_out(s->audio_be, s->dac_voice[i]); } =20 - AUD_close_in(s->audio_be, s->adc_voice); + audio_be_close_in(s->audio_be, s->adc_voice); } =20 static const Property es1370_properties[] =3D { diff --git a/hw/audio/gus.c b/hw/audio/gus.c index 1ede1c4a51d..5c2a34c09d2 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -87,7 +87,7 @@ static int write_audio (GUSState *s, int samples) int nbytes, wbytes, wsampl; =20 nbytes =3D samples << s->shift; - wbytes =3D AUD_write( + wbytes =3D audio_be_write( s->audio_be, s->voice, s->mixbuf + (pos << (s->shift - 1)), @@ -243,7 +243,7 @@ static void gus_realizefn (DeviceState *dev, Error **er= rp) IsaDmaClass *k; struct audsettings as; =20 - if (!AUD_backend_check(&s->audio_be, errp)) { + if (!audio_be_check(&s->audio_be, errp)) { return; } =20 @@ -258,7 +258,7 @@ static void gus_realizefn (DeviceState *dev, Error **er= rp) as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D HOST_BIG_ENDIAN; =20 - s->voice =3D AUD_open_out( + s->voice =3D audio_be_open_out( s->audio_be, NULL, "gus", @@ -273,7 +273,7 @@ static void gus_realizefn (DeviceState *dev, Error **er= rp) } =20 s->shift =3D 2; - s->samples =3D AUD_get_buffer_size_out(s->audio_be, s->voice) >> s->sh= ift; + s->samples =3D audio_be_get_buffer_size_out(s->audio_be, s->voice) >> = s->shift; s->mixbuf =3D g_malloc0 (s->samples << s->shift); =20 isa_register_portio_list(d, &s->portio_list1, s->port, @@ -288,7 +288,7 @@ static void gus_realizefn (DeviceState *dev, Error **er= rp) s->emu.opaque =3D s; s->pic =3D isa_bus_get_irq(bus, s->emu.gusirq); =20 - AUD_set_active_out(s->audio_be, s->voice, 1); + audio_be_set_active_out(s->audio_be, s->voice, 1); } =20 static const Property gus_properties[] =3D { diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index 0373d2f7271..984029a8db1 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -275,8 +275,8 @@ static void hda_audio_input_cb(void *opaque, int avail) while (to_transfer) { uint32_t start =3D (uint32_t) (wpos & B_MASK); uint32_t chunk =3D (uint32_t) MIN(B_SIZE - start, to_transfer); - uint32_t read =3D AUD_read(st->state->audio_be, st->voice.in, - st->buf + start, chunk); + uint32_t read =3D audio_be_read(st->state->audio_be, st->voice.in, + st->buf + start, chunk); wpos +=3D read; to_transfer -=3D read; st->wpos +=3D read; @@ -355,8 +355,8 @@ static void hda_audio_output_cb(void *opaque, int avail) while (to_transfer) { uint32_t start =3D (uint32_t) (rpos & B_MASK); uint32_t chunk =3D (uint32_t) MIN(B_SIZE - start, to_transfer); - uint32_t written =3D AUD_write(st->state->audio_be, st->voice.out, - st->buf + start, chunk); + uint32_t written =3D audio_be_write(st->state->audio_be, st->voice= .out, + st->buf + start, chunk); rpos +=3D written; to_transfer -=3D written; st->rpos +=3D written; @@ -377,9 +377,9 @@ static void hda_audio_compat_input_cb(void *opaque, int= avail) =20 while (avail - recv >=3D sizeof(st->compat_buf)) { if (st->compat_bpos !=3D sizeof(st->compat_buf)) { - len =3D AUD_read(st->state->audio_be, st->voice.in, - st->compat_buf + st->compat_bpos, - sizeof(st->compat_buf) - st->compat_bpos); + len =3D audio_be_read(st->state->audio_be, st->voice.in, + st->compat_buf + st->compat_bpos, + sizeof(st->compat_buf) - st->compat_bpos); st->compat_bpos +=3D len; recv +=3D len; if (st->compat_bpos !=3D sizeof(st->compat_buf)) { @@ -411,9 +411,9 @@ static void hda_audio_compat_output_cb(void *opaque, in= t avail) } st->compat_bpos =3D 0; } - len =3D AUD_write(st->state->audio_be, st->voice.out, - st->compat_buf + st->compat_bpos, - sizeof(st->compat_buf) - st->compat_bpos); + len =3D audio_be_write(st->state->audio_be, st->voice.out, + st->compat_buf + st->compat_bpos, + sizeof(st->compat_buf) - st->compat_bpos); st->compat_bpos +=3D len; sent +=3D len; if (st->compat_bpos !=3D sizeof(st->compat_buf)) { @@ -444,9 +444,9 @@ static void hda_audio_set_running(HDAAudioStream *st, b= ool running) } } if (st->output) { - AUD_set_active_out(st->state->audio_be, st->voice.out, st->running= ); + audio_be_set_active_out(st->state->audio_be, st->voice.out, st->ru= nning); } else { - AUD_set_active_in(st->state->audio_be, st->voice.in, st->running); + audio_be_set_active_in(st->state->audio_be, st->voice.in, st->runn= ing); } } =20 @@ -470,9 +470,11 @@ static void hda_audio_set_amp(HDAAudioStream *st) return; } if (st->output) { - AUD_set_volume_out_lr(st->state->audio_be, st->voice.out, muted, l= eft, right); + audio_be_set_volume_out_lr(st->state->audio_be, st->voice.out, + muted, left, right); } else { - AUD_set_volume_in_lr(st->state->audio_be, st->voice.in, muted, lef= t, right); + audio_be_set_volume_in_lr(st->state->audio_be, st->voice.in, + muted, left, right); } } =20 @@ -495,7 +497,7 @@ static void hda_audio_setup(HDAAudioStream *st) } else { cb =3D hda_audio_compat_output_cb; } - st->voice.out =3D AUD_open_out(st->state->audio_be, st->voice.out, + st->voice.out =3D audio_be_open_out(st->state->audio_be, st->voice= .out, st->node->name, st, cb, &st->as); } else { if (use_timer) { @@ -504,7 +506,7 @@ static void hda_audio_setup(HDAAudioStream *st) } else { cb =3D hda_audio_compat_input_cb; } - st->voice.in =3D AUD_open_in(st->state->audio_be, st->voice.in, + st->voice.in =3D audio_be_open_in(st->state->audio_be, st->voice.i= n, st->node->name, st, cb, &st->as); } } @@ -700,7 +702,7 @@ static void hda_audio_init(HDACodecDevice *hda, const desc_param *param; uint32_t i, type; =20 - if (!AUD_backend_check(&a->audio_be, errp)) { + if (!audio_be_check(&a->audio_be, errp)) { return; } =20 @@ -758,9 +760,9 @@ static void hda_audio_exit(HDACodecDevice *hda) } timer_free(st->buft); if (st->output) { - AUD_close_out(a->audio_be, st->voice.out); + audio_be_close_out(a->audio_be, st->voice.out); } else { - AUD_close_in(a->audio_be, st->voice.in); + audio_be_close_in(a->audio_be, st->voice.in); } } } diff --git a/hw/audio/lm4549.c b/hw/audio/lm4549.c index b875e83d454..14e15a844ba 100644 --- a/hw/audio/lm4549.c +++ b/hw/audio/lm4549.c @@ -101,11 +101,11 @@ static void lm4549_audio_transfer(lm4549_state *s) uint32_t i; =20 /* Activate the voice */ - AUD_set_active_out(s->audio_be, s->voice, 1); + audio_be_set_active_out(s->audio_be, s->voice, 1); s->voice_is_active =3D 1; =20 /* Try to write the buffer content */ - written_bytes =3D AUD_write(s->audio_be, s->voice, s->buffer, + written_bytes =3D audio_be_write(s->audio_be, s->voice, s->buffer, s->buffer_level * sizeof(uint16_t)); written_samples =3D written_bytes >> 1; =20 @@ -129,14 +129,14 @@ static void lm4549_audio_out_callback(void *opaque, i= nt free) static uint32_t prev_buffer_level; =20 #ifdef LM4549_DEBUG - int size =3D AUD_get_buffer_size_out(s->audio_be, s->voice); + int size =3D audio_be_get_buffer_size_out(s->audio_be, s->voice); DPRINTF("audio_out_callback size =3D %i free =3D %i\n", size, free); #endif =20 /* Detect that no data are consumed =3D> disable the voice */ if (s->buffer_level =3D=3D prev_buffer_level) { - AUD_set_active_out(s->audio_be, s->voice, 0); + audio_be_set_active_out(s->audio_be, s->voice, 0); s->voice_is_active =3D 0; } prev_buffer_level =3D s->buffer_level; @@ -204,7 +204,7 @@ void lm4549_write(lm4549_state *s, as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D 0; =20 - s->voice =3D AUD_open_out( + s->voice =3D audio_be_open_out( s->audio_be, s->voice, "lm4549.out", @@ -274,7 +274,7 @@ static int lm4549_post_load(void *opaque, int version_i= d) as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D 0; =20 - s->voice =3D AUD_open_out( + s->voice =3D audio_be_open_out( s->audio_be, s->voice, "lm4549.out", @@ -285,7 +285,7 @@ static int lm4549_post_load(void *opaque, int version_i= d) =20 /* Request data */ if (s->voice_is_active =3D=3D 1) { - lm4549_audio_out_callback(s, AUD_get_buffer_size_out(s->audio_be, = s->voice)); + lm4549_audio_out_callback(s, audio_be_get_buffer_size_out(s->audio= _be, s->voice)); } =20 return 0; @@ -297,7 +297,7 @@ void lm4549_init(lm4549_state *s, lm4549_callback data_= req_cb, void* opaque, struct audsettings as; =20 /* Register an audio card */ - if (!AUD_backend_check(&s->audio_be, errp)) { + if (!audio_be_check(&s->audio_be, errp)) { return; } =20 @@ -314,7 +314,7 @@ void lm4549_init(lm4549_state *s, lm4549_callback data_= req_cb, void* opaque, as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D 0; =20 - s->voice =3D AUD_open_out( + s->voice =3D audio_be_open_out( s->audio_be, s->voice, "lm4549.out", @@ -323,7 +323,7 @@ void lm4549_init(lm4549_state *s, lm4549_callback data_= req_cb, void* opaque, &as ); =20 - AUD_set_volume_out_lr(s->audio_be, s->voice, 0, 255, 255); + audio_be_set_volume_out_lr(s->audio_be, s->voice, 0, 255, 255); =20 s->voice_is_active =3D 0; =20 diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index 07ebfcfccf6..6b826507ce3 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -105,7 +105,7 @@ static void pcspk_callback(void *opaque, int free) =20 while (free > 0) { n =3D MIN(s->samples - s->play_pos, (unsigned int)free); - n =3D AUD_write(s->audio_be, s->voice, &s->sample_buf[s->play_pos]= , n); + n =3D audio_be_write(s->audio_be, s->voice, &s->sample_buf[s->play= _pos], n); if (!n) break; s->play_pos =3D (s->play_pos + n) % s->samples; @@ -122,7 +122,7 @@ static int pcspk_audio_init(PCSpkState *s) return 0; } =20 - s->voice =3D AUD_open_out(s->audio_be, s->voice, s_spk, s, pcspk_callb= ack, &as); + s->voice =3D audio_be_open_out(s->audio_be, s->voice, s_spk, s, pcspk_= callback, &as); if (!s->voice) { error_report("pcspk: Could not open voice"); return -1; @@ -163,7 +163,7 @@ static void pcspk_io_write(void *opaque, hwaddr addr, u= int64_t val, if (s->voice) { if (gate) /* restart */ s->play_pos =3D 0; - AUD_set_active_out(s->audio_be, s->voice, gate & s->data_on); + audio_be_set_active_out(s->audio_be, s->voice, gate & s->data_on); } } =20 @@ -195,7 +195,7 @@ static void pcspk_realizefn(DeviceState *dev, Error **e= rrp) =20 isa_register_ioport(isadev, &s->ioport, s->iobase); =20 - if (s->audio_be && AUD_backend_check(&s->audio_be, errp)) { + if (s->audio_be && audio_be_check(&s->audio_be, errp)) { pcspk_audio_init(s); return; } diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index da0c33ea41b..c8fc7df8b44 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -171,7 +171,7 @@ static void log_dsp (SB16State *dsp) static void speaker (SB16State *s, int on) { s->speaker =3D on; - /* AUD_enable (s->voice, on); */ + /* audio_be_enable (s->voice, on); */ } =20 static void control (SB16State *s, int hold) @@ -185,11 +185,11 @@ static void control (SB16State *s, int hold) =20 if (hold) { k->hold_DREQ(isa_dma, dma); - AUD_set_active_out(s->audio_be, s->voice, 1); + audio_be_set_active_out(s->audio_be, s->voice, 1); } else { k->release_DREQ(isa_dma, dma); - AUD_set_active_out(s->audio_be, s->voice, 0); + audio_be_set_active_out(s->audio_be, s->voice, 0); } } =20 @@ -215,7 +215,7 @@ static void continue_dma8 (SB16State *s) as.fmt =3D s->fmt; as.endianness =3D 0; =20 - s->voice =3D AUD_open_out( + s->voice =3D audio_be_open_out( s->audio_be, s->voice, "sb16", @@ -378,7 +378,7 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8_t= d0, int dma_len) as.fmt =3D s->fmt; as.endianness =3D 0; =20 - s->voice =3D AUD_open_out( + s->voice =3D audio_be_open_out( s->audio_be, s->voice, "sb16", @@ -879,7 +879,7 @@ static void legacy_reset (SB16State *s) as.fmt =3D AUDIO_FORMAT_U8; as.endianness =3D 0; =20 - s->voice =3D AUD_open_out( + s->voice =3D audio_be_open_out( s->audio_be, s->voice, "sb16", @@ -889,7 +889,7 @@ static void legacy_reset (SB16State *s) ); =20 /* Not sure about that... */ - /* AUD_set_active_out (s->voice, 1); */ + /* audio_be_set_active_out (s->voice, 1); */ } =20 static void reset (SB16State *s) @@ -1196,7 +1196,7 @@ static int write_audio (SB16State *s, int nchan, int = dma_pos, } =20 copied =3D k->read_memory(isa_dma, nchan, tmpbuf, dma_pos, to_copy= ); - copied =3D AUD_write(s->audio_be, s->voice, tmpbuf, copied); + copied =3D audio_be_write(s->audio_be, s->voice, tmpbuf, copied); =20 temp -=3D copied; dma_pos =3D (dma_pos + copied) % dma_len; @@ -1287,7 +1287,7 @@ static int sb16_post_load (void *opaque, int version_= id) SB16State *s =3D opaque; =20 if (s->voice) { - AUD_close_out(s->audio_be, s->voice); + audio_be_close_out(s->audio_be, s->voice); s->voice =3D NULL; } =20 @@ -1302,7 +1302,7 @@ static int sb16_post_load (void *opaque, int version_= id) as.fmt =3D s->fmt; as.endianness =3D 0; =20 - s->voice =3D AUD_open_out( + s->voice =3D audio_be_open_out( s->audio_be, s->voice, "sb16", @@ -1401,7 +1401,7 @@ static void sb16_realizefn (DeviceState *dev, Error *= *errp) SB16State *s =3D SB16 (dev); IsaDmaClass *k; =20 - if (!AUD_backend_check(&s->audio_be, errp)) { + if (!audio_be_check(&s->audio_be, errp)) { return; } =20 diff --git a/hw/audio/via-ac97.c b/hw/audio/via-ac97.c index 5b344d7a0fc..84d137b41a3 100644 --- a/hw/audio/via-ac97.c +++ b/hw/audio/via-ac97.c @@ -53,7 +53,7 @@ static void codec_volume_set_out(ViaAC97State *s) rvol /=3D 255; mute =3D CODEC_REG(s, AC97_Master_Volume_Mute) >> MUTE_SHIFT; mute |=3D CODEC_REG(s, AC97_PCM_Out_Volume_Mute) >> MUTE_SHIFT; - AUD_set_volume_out_lr(s->audio_be, s->vo, mute, lvol, rvol); + audio_be_set_volume_out_lr(s->audio_be, s->vo, mute, lvol, rvol); } =20 static void codec_reset(ViaAC97State *s) @@ -189,7 +189,7 @@ static void out_cb(void *opaque, int avail) while (temp) { to_copy =3D MIN(temp, sizeof(tmpbuf)); pci_dma_read(&s->dev, c->addr, tmpbuf, to_copy); - copied =3D AUD_write(s->audio_be, s->vo, tmpbuf, to_copy); + copied =3D audio_be_write(s->audio_be, s->vo, tmpbuf, to_copy); if (!copied) { stop =3D true; break; @@ -208,7 +208,7 @@ static void out_cb(void *opaque, int avail) c->stat |=3D STAT_PAUSED; } else { c->stat &=3D ~STAT_ACTIVE; - AUD_set_active_out(s->audio_be, s->vo, 0); + audio_be_set_active_out(s->audio_be, s->vo, 0); } if (c->type & STAT_EOL) { via_isa_set_irq(&s->dev, 0, 1); @@ -239,7 +239,7 @@ static void open_voice_out(ViaAC97State *s) .fmt =3D s->aur.type & BIT(5) ? AUDIO_FORMAT_S16 : AUDIO_FORMAT_S8, .endianness =3D 0, }; - s->vo =3D AUD_open_out(s->audio_be, s->vo, "via-ac97.out", s, out_cb, = &as); + s->vo =3D audio_be_open_out(s->audio_be, s->vo, "via-ac97.out", s, out= _cb, &as); } =20 static uint64_t sgd_read(void *opaque, hwaddr addr, unsigned size) @@ -317,20 +317,20 @@ static void sgd_write(void *opaque, hwaddr addr, uint= 64_t val, unsigned size) break; case 1: if (val & CNTL_START) { - AUD_set_active_out(s->audio_be, s->vo, 1); + audio_be_set_active_out(s->audio_be, s->vo, 1); s->aur.stat =3D STAT_ACTIVE; } if (val & CNTL_TERM) { - AUD_set_active_out(s->audio_be, s->vo, 0); + audio_be_set_active_out(s->audio_be, s->vo, 0); s->aur.stat &=3D ~(STAT_ACTIVE | STAT_PAUSED); s->aur.clen =3D 0; } if (val & CNTL_PAUSE) { - AUD_set_active_out(s->audio_be, s->vo, 0); + audio_be_set_active_out(s->audio_be, s->vo, 0); s->aur.stat &=3D ~STAT_ACTIVE; s->aur.stat |=3D STAT_PAUSED; } else if (!(val & CNTL_PAUSE) && (s->aur.stat & STAT_PAUSED)) { - AUD_set_active_out(s->audio_be, s->vo, 1); + audio_be_set_active_out(s->audio_be, s->vo, 1); s->aur.stat |=3D STAT_ACTIVE; s->aur.stat &=3D ~STAT_PAUSED; } @@ -426,7 +426,7 @@ static void via_ac97_realize(PCIDevice *pci_dev, Error = **errp) ViaAC97State *s =3D VIA_AC97(pci_dev); Object *o =3D OBJECT(s); =20 - if (!AUD_backend_check(&s->audio_be, errp)) { + if (!audio_be_check(&s->audio_be, errp)) { return; } =20 @@ -455,7 +455,7 @@ static void via_ac97_exit(PCIDevice *dev) { ViaAC97State *s =3D VIA_AC97(dev); =20 - AUD_close_out(s->audio_be, s->vo); + audio_be_close_out(s->audio_be, s->vo); } =20 static const Property via_ac97_properties[] =3D { diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index 7cbfd164893..ca44fa372f2 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -402,10 +402,10 @@ static void virtio_snd_pcm_close(VirtIOSoundPCMStream= *stream) if (stream) { virtio_snd_pcm_flush(stream); if (stream->info.direction =3D=3D VIRTIO_SND_D_OUTPUT) { - AUD_close_out(stream->pcm->snd->audio_be, stream->voice.out); + audio_be_close_out(stream->pcm->snd->audio_be, stream->voice.o= ut); stream->voice.out =3D NULL; } else if (stream->info.direction =3D=3D VIRTIO_SND_D_INPUT) { - AUD_close_in(stream->pcm->snd->audio_be, stream->voice.in); + audio_be_close_in(stream->pcm->snd->audio_be, stream->voice.in= ); stream->voice.in =3D NULL; } } @@ -469,21 +469,21 @@ static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s= , uint32_t stream_id) stream->as =3D as; =20 if (stream->info.direction =3D=3D VIRTIO_SND_D_OUTPUT) { - stream->voice.out =3D AUD_open_out(s->audio_be, + stream->voice.out =3D audio_be_open_out(s->audio_be, stream->voice.out, "virtio-sound.out", stream, virtio_snd_pcm_out_cb, &as); - AUD_set_volume_out_lr(s->audio_be, stream->voice.out, 0, 255, 255); + audio_be_set_volume_out_lr(s->audio_be, stream->voice.out, 0, 255,= 255); } else { - stream->voice.in =3D AUD_open_in(s->audio_be, + stream->voice.in =3D audio_be_open_in(s->audio_be, stream->voice.in, "virtio-sound.in", stream, virtio_snd_pcm_in_cb, &as); - AUD_set_volume_in_lr(s->audio_be, stream->voice.in, 0, 255, 255); + audio_be_set_volume_in_lr(s->audio_be, stream->voice.in, 0, 255, 2= 55); } =20 return cpu_to_le32(VIRTIO_SND_S_OK); @@ -573,9 +573,9 @@ static void virtio_snd_handle_pcm_start_stop(VirtIOSoun= d *s, stream->active =3D start; } if (stream->info.direction =3D=3D VIRTIO_SND_D_OUTPUT) { - AUD_set_active_out(s->audio_be, stream->voice.out, start); + audio_be_set_active_out(s->audio_be, stream->voice.out, start); } else { - AUD_set_active_in(s->audio_be, stream->voice.in, start); + audio_be_set_active_in(s->audio_be, stream->voice.in, start); } } else { error_report("Invalid stream id: %"PRIu32, stream_id); @@ -1057,7 +1057,7 @@ static void virtio_snd_realize(DeviceState *dev, Erro= r **errp) return; } =20 - if (!AUD_backend_check(&vsnd->audio_be, errp)) { + if (!audio_be_check(&vsnd->audio_be, errp)) { return; } =20 @@ -1146,10 +1146,10 @@ static inline void return_tx_buffer(VirtIOSoundPCMS= tream *stream, } =20 /* - * AUD_* output callback. + * audio_be_* output callback. * * @data: VirtIOSoundPCMStream stream - * @available: number of bytes that can be written with AUD_write() + * @available: number of bytes that can be written with audio_be_write() */ static void virtio_snd_pcm_out_cb(void *data, int available) { @@ -1164,7 +1164,7 @@ static void virtio_snd_pcm_out_cb(void *data, int ava= ilable) return; } if (!stream->active) { - /* Stream has stopped, so do not perform AUD_write. */ + /* Stream has stopped, so do not perform audio_be_write. */ return_tx_buffer(stream, buffer); continue; } @@ -1177,7 +1177,7 @@ static void virtio_snd_pcm_out_cb(void *data, int ava= ilable) buffer->populated =3D true; } for (;;) { - size =3D AUD_write(stream->s->audio_be, + size =3D audio_be_write(stream->s->audio_be, stream->voice.out, buffer->data + buffer->offset, MIN(buffer->size, available)); @@ -1242,10 +1242,10 @@ static inline void return_rx_buffer(VirtIOSoundPCMS= tream *stream, =20 =20 /* - * AUD_* input callback. + * audio_be_* input callback. * * @data: VirtIOSoundPCMStream stream - * @available: number of bytes that can be read with AUD_read() + * @available: number of bytes that can be read with audio_be_read() */ static void virtio_snd_pcm_in_cb(void *data, int available) { @@ -1260,7 +1260,7 @@ static void virtio_snd_pcm_in_cb(void *data, int avai= lable) return; } if (!stream->active) { - /* Stream has stopped, so do not perform AUD_read. */ + /* Stream has stopped, so do not perform audio_be_read. */ return_rx_buffer(stream, buffer); continue; } @@ -1280,10 +1280,10 @@ static void virtio_snd_pcm_in_cb(void *data, int av= ailable) to_read =3D stream->params.period_bytes - buffer->size; to_read =3D MIN(to_read, available); to_read =3D MIN(to_read, max_size - buffer->size); - size =3D AUD_read(stream->s->audio_be, - stream->voice.in, - buffer->data + buffer->size, - to_read); + size =3D audio_be_read(stream->s->audio_be, + stream->voice.in, + buffer->data + buffer->size, + to_read); if (!size) { available =3D 0; break; diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c index bc347fe5376..2a286515b14 100644 --- a/hw/audio/wm8750.c +++ b/hw/audio/wm8750.c @@ -72,7 +72,7 @@ static inline void wm8750_in_load(WM8750State *s) if (s->idx_in + s->req_in <=3D sizeof(s->data_in)) return; s->idx_in =3D MAX(0, (int) sizeof(s->data_in) - s->req_in); - AUD_read(s->audio_be, *s->in[0], s->data_in + s->idx_in, + audio_be_read(s->audio_be, *s->in[0], s->data_in + s->idx_in, sizeof(s->data_in) - s->idx_in); } =20 @@ -80,7 +80,8 @@ static inline void wm8750_out_flush(WM8750State *s) { int sent =3D 0; while (sent < s->idx_out) - sent +=3D AUD_write(s->audio_be, *s->out[0], s->data_out + sent, s= ->idx_out - sent) + sent +=3D audio_be_write(s->audio_be, *s->out[0], + s->data_out + sent, s->idx_out - sent) ?: s->idx_out; s->idx_out =3D 0; } @@ -145,30 +146,30 @@ static void wm8750_vol_update(WM8750State *s) { /* FIXME: multiply all volumes by s->invol[2], s->invol[3] */ =20 - AUD_set_volume_in_lr(s->audio_be, s->adc_voice[0], s->mute, + audio_be_set_volume_in_lr(s->audio_be, s->adc_voice[0], s->mute, s->inmute[0] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[0]), s->inmute[1] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[1])= ); - AUD_set_volume_in_lr(s->audio_be, s->adc_voice[1], s->mute, + audio_be_set_volume_in_lr(s->audio_be, s->adc_voice[1], s->mute, s->inmute[0] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[0]), s->inmute[1] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[1])= ); - AUD_set_volume_in_lr(s->audio_be, s->adc_voice[2], s->mute, + audio_be_set_volume_in_lr(s->audio_be, s->adc_voice[2], s->mute, s->inmute[0] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[0]), s->inmute[1] ? 0 : WM8750_INVOL_TRANSFORM(s->invol[1])= ); =20 /* FIXME: multiply all volumes by s->outvol[0], s->outvol[1] */ =20 /* Speaker: LOUT2VOL ROUT2VOL */ - AUD_set_volume_out_lr(s->audio_be, s->dac_voice[0], s->mute, + audio_be_set_volume_out_lr(s->audio_be, s->dac_voice[0], s->mute, s->outmute[0] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[= 4]), s->outmute[1] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[= 5])); =20 /* Headphone: LOUT1VOL ROUT1VOL */ - AUD_set_volume_out_lr(s->audio_be, s->dac_voice[1], s->mute, + audio_be_set_volume_out_lr(s->audio_be, s->dac_voice[1], s->mute, s->outmute[0] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[= 2]), s->outmute[1] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[= 3])); =20 /* MONOOUT: MONOVOL MONOVOL */ - AUD_set_volume_out_lr(s->audio_be, s->dac_voice[2], s->mute, + audio_be_set_volume_out_lr(s->audio_be, s->dac_voice[2], s->mute, s->outmute[0] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[= 6]), s->outmute[1] ? 0 : WM8750_OUTVOL_TRANSFORM(s->outvol[= 6])); } @@ -182,18 +183,18 @@ static void wm8750_set_format(WM8750State *s) wm8750_out_flush(s); =20 if (s->in[0] && *s->in[0]) - AUD_set_active_in(s->audio_be, *s->in[0], 0); + audio_be_set_active_in(s->audio_be, *s->in[0], 0); if (s->out[0] && *s->out[0]) - AUD_set_active_out(s->audio_be, *s->out[0], 0); + audio_be_set_active_out(s->audio_be, *s->out[0], 0); =20 for (i =3D 0; i < IN_PORT_N; i ++) if (s->adc_voice[i]) { - AUD_close_in(s->audio_be, s->adc_voice[i]); + audio_be_close_in(s->audio_be, s->adc_voice[i]); s->adc_voice[i] =3D NULL; } for (i =3D 0; i < OUT_PORT_N; i ++) if (s->dac_voice[i]) { - AUD_close_out(s->audio_be, s->dac_voice[i]); + audio_be_close_out(s->audio_be, s->dac_voice[i]); s->dac_voice[i] =3D NULL; } =20 @@ -206,11 +207,11 @@ static void wm8750_set_format(WM8750State *s) in_fmt.freq =3D s->adc_hz; in_fmt.fmt =3D AUDIO_FORMAT_S16; =20 - s->adc_voice[0] =3D AUD_open_in(s->audio_be, s->adc_voice[0], + s->adc_voice[0] =3D audio_be_open_in(s->audio_be, s->adc_voice[0], CODEC ".input1", s, wm8750_audio_in_cb, &in_fmt); - s->adc_voice[1] =3D AUD_open_in(s->audio_be, s->adc_voice[1], + s->adc_voice[1] =3D audio_be_open_in(s->audio_be, s->adc_voice[1], CODEC ".input2", s, wm8750_audio_in_cb, &in_fmt); - s->adc_voice[2] =3D AUD_open_in(s->audio_be, s->adc_voice[2], + s->adc_voice[2] =3D audio_be_open_in(s->audio_be, s->adc_voice[2], CODEC ".input3", s, wm8750_audio_in_cb, &in_fmt); =20 /* Setup output */ @@ -219,12 +220,12 @@ static void wm8750_set_format(WM8750State *s) out_fmt.freq =3D s->dac_hz; out_fmt.fmt =3D AUDIO_FORMAT_S16; =20 - s->dac_voice[0] =3D AUD_open_out(s->audio_be, s->dac_voice[0], + s->dac_voice[0] =3D audio_be_open_out(s->audio_be, s->dac_voice[0], CODEC ".speaker", s, wm8750_audio_out_cb, &out_fmt); - s->dac_voice[1] =3D AUD_open_out(s->audio_be, s->dac_voice[1], + s->dac_voice[1] =3D audio_be_open_out(s->audio_be, s->dac_voice[1], CODEC ".headphone", s, wm8750_audio_out_cb, &out_fmt); /* MONOMIX is also in stereo for simplicity */ - s->dac_voice[2] =3D AUD_open_out(s->audio_be, s->dac_voice[2], + s->dac_voice[2] =3D audio_be_open_out(s->audio_be, s->dac_voice[2], CODEC ".monomix", s, wm8750_audio_out_cb, &out_fmt); /* no sense emulating OUT3 which is a mix of other outputs */ =20 @@ -235,9 +236,9 @@ static void wm8750_set_format(WM8750State *s) * for mixing or combining paths to different ports, so we * connect both channels to where the left channel is routed. */ if (s->in[0] && *s->in[0]) - AUD_set_active_in(s->audio_be, *s->in[0], 1); + audio_be_set_active_in(s->audio_be, *s->in[0], 1); if (s->out[0] && *s->out[0]) - AUD_set_active_out(s->audio_be, *s->out[0], 1); + audio_be_set_active_out(s->audio_be, *s->out[0], 1); } =20 static void wm8750_clk_update(WM8750State *s, int ext) @@ -624,7 +625,7 @@ static void wm8750_realize(DeviceState *dev, Error **er= rp) { WM8750State *s =3D WM8750(dev); =20 - if (!AUD_backend_check(&s->audio_be, errp)) { + if (!audio_be_check(&s->audio_be, errp)) { return; } =20 diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c index deda7efe15d..9aa4709b411 100644 --- a/hw/display/xlnx_dp.c +++ b/hw/display/xlnx_dp.c @@ -331,7 +331,7 @@ static inline void xlnx_dp_audio_activate(XlnxDPState *= s) { bool activated =3D ((s->core_registers[DP_TX_AUDIO_CONTROL] & DP_TX_AUD_CTRL) !=3D 0); - AUD_set_active_out(s->audio_be, s->amixer_output_stream, activated); + audio_be_set_active_out(s->audio_be, s->amixer_output_stream, activate= d); xlnx_dpdma_set_host_data_location(s->dpdma, DP_AUDIO_DMA_CHANNEL(0), &s->audio_buffer_0); xlnx_dpdma_set_host_data_location(s->dpdma, DP_AUDIO_DMA_CHANNEL(1), @@ -401,7 +401,7 @@ static void xlnx_dp_audio_callback(void *opaque, int av= ail) /* Send the buffer through the audio. */ if (s->byte_left <=3D MAX_QEMU_BUFFER_SIZE) { if (s->byte_left !=3D 0) { - written =3D AUD_write(s->audio_be, s->amixer_output_stream, + written =3D audio_be_write(s->audio_be, s->amixer_output_strea= m, &s->out_buffer[s->data_ptr], s->byte_left); } else { int len_to_copy; @@ -413,12 +413,12 @@ static void xlnx_dp_audio_callback(void *opaque, int = avail) while (avail) { len_to_copy =3D MIN(AUD_CHBUF_MAX_DEPTH, avail); memset(s->out_buffer, 0, len_to_copy); - avail -=3D AUD_write(s->audio_be, s->amixer_output_stream,= s->out_buffer, - len_to_copy); + avail -=3D audio_be_write(s->audio_be, s->amixer_output_st= ream, + s->out_buffer, len_to_copy); } } } else { - written =3D AUD_write(s->audio_be, s->amixer_output_stream, + written =3D audio_be_write(s->audio_be, s->amixer_output_stream, &s->out_buffer[s->data_ptr], MAX_QEMU_BUFFER_S= IZE); } s->byte_left -=3D written; @@ -1373,7 +1373,7 @@ static void xlnx_dp_realize(DeviceState *dev, Error *= *errp) DisplaySurface *surface; struct audsettings as; =20 - if (!AUD_backend_check(&s->audio_be, errp)) { + if (!audio_be_check(&s->audio_be, errp)) { return; } =20 @@ -1395,13 +1395,13 @@ static void xlnx_dp_realize(DeviceState *dev, Error= **errp) as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D 0; =20 - s->amixer_output_stream =3D AUD_open_out(s->audio_be, + s->amixer_output_stream =3D audio_be_open_out(s->audio_be, s->amixer_output_stream, "xlnx_dp.audio.out", s, xlnx_dp_audio_callback, &as); - AUD_set_volume_out_lr(s->audio_be, s->amixer_output_stream, 0, 255, 25= 5); + audio_be_set_volume_out_lr(s->audio_be, s->amixer_output_stream, 0, 25= 5, 255); xlnx_dp_audio_activate(s); s->vblank =3D ptimer_init(vblank_hit, s, DP_VBLANK_PTIMER_POLICY); ptimer_transaction_begin(s->vblank); diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c index 0f36587fc6f..7b758718c12 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -669,7 +669,7 @@ static void output_callback(void *opaque, int avail) return; } =20 - written =3D AUD_write(s->audio_be, s->out.voice, data, len); + written =3D audio_be_write(s->audio_be, s->out.voice, data, len); avail -=3D written; s->out.buf.cons +=3D written; =20 @@ -683,7 +683,7 @@ static int usb_audio_set_output_altset(USBAudioState *s= , int altset) { switch (altset) { case ALTSET_OFF: - AUD_set_active_out(s->audio_be, s->out.voice, false); + audio_be_set_active_out(s->audio_be, s->out.voice, false); break; case ALTSET_STEREO: case ALTSET_51: @@ -692,7 +692,7 @@ static int usb_audio_set_output_altset(USBAudioState *s= , int altset) usb_audio_reinit(USB_DEVICE(s), altset_channels[altset]); } streambuf_init(&s->out.buf, s->buffer, s->out.channels); - AUD_set_active_out(s->audio_be, s->out.voice, true); + audio_be_set_active_out(s->audio_be, s->out.voice, true); break; default: return -1; @@ -805,7 +805,7 @@ static int usb_audio_set_control(USBAudioState *s, uint= 8_t attrib, } fprintf(stderr, "\n"); } - AUD_set_volume_out(s->audio_be, s->out.voice, &s->out.vol); + audio_be_set_volume_out(s->audio_be, s->out.voice, &s->out.vol); } =20 return ret; @@ -931,7 +931,7 @@ static void usb_audio_unrealize(USBDevice *dev) } =20 usb_audio_set_output_altset(s, ALTSET_OFF); - AUD_close_out(s->audio_be, s->out.voice); + audio_be_close_out(s->audio_be, s->out.voice); =20 streambuf_fini(&s->out.buf); } @@ -941,7 +941,7 @@ static void usb_audio_realize(USBDevice *dev, Error **e= rrp) USBAudioState *s =3D USB_AUDIO(dev); int i; =20 - if (!AUD_backend_check(&s->audio_be, errp)) { + if (!audio_be_check(&s->audio_be, errp)) { return; } =20 @@ -978,10 +978,10 @@ static void usb_audio_reinit(USBDevice *dev, unsigned= channels) s->out.as.endianness =3D 0; streambuf_init(&s->out.buf, s->buffer, s->out.channels); =20 - s->out.voice =3D AUD_open_out(s->audio_be, s->out.voice, TYPE_USB_AUDI= O, + s->out.voice =3D audio_be_open_out(s->audio_be, s->out.voice, TYPE_USB= _AUDIO, s, output_callback, &s->out.as); - AUD_set_volume_out(s->audio_be, s->out.voice, &s->out.vol); - AUD_set_active_out(s->audio_be, s->out.voice, 0); + audio_be_set_volume_out(s->audio_be, s->out.voice, &s->out.vol); + audio_be_set_active_out(s->audio_be, s->out.voice, 0); } =20 static const VMStateDescription vmstate_usb_audio =3D { diff --git a/tests/audio/test-audio.c b/tests/audio/test-audio.c index 6c182ee7c60..1827c084ac8 100644 --- a/tests/audio/test-audio.c +++ b/tests/audio/test-audio.c @@ -94,7 +94,7 @@ static SWVoiceOut *open_test_voice_out(AudioBackend *be, = const char *name, struct audsettings as =3D default_test_settings; SWVoiceOut *voice; =20 - voice =3D AUD_open_out(be, NULL, name, opaque, cb, &as); + voice =3D audio_be_open_out(be, NULL, name, opaque, cb, &as); g_assert_nonnull(voice); return voice; } @@ -104,7 +104,7 @@ static SWVoiceIn *open_test_voice_in(AudioBackend *be, = const char *name, { struct audsettings as =3D default_test_settings; =20 - return AUD_open_in(be, NULL, name, opaque, cb, &as); + return audio_be_open_in(be, NULL, name, opaque, cb, &as); } =20 /* @@ -142,8 +142,8 @@ static void test_sine_callback(void *opaque, int avail) =20 generate_sine_samples(buffer, frames_to_write, s->frames_written); =20 - bytes_written =3D AUD_write(s->be, s->voice, buffer, - frames_to_write * sizeof(int16_t) * CHANNELS= ); + bytes_written =3D audio_be_write(s->be, s->voice, buffer, + frames_to_write * sizeof(int16_t) * CHA= NNELS); s->frames_written +=3D bytes_written / (sizeof(int16_t) * CHANNELS); } =20 @@ -163,7 +163,7 @@ static void test_audio_out_sine_wave(void) &state, test_sine_callback); =20 g_test_message("Playing 440Hz sine wave for %d seconds...", DURATION_S= ECS); - AUD_set_active_out(state.be, state.voice, true); + audio_be_set_active_out(state.be, state.voice, true); =20 /* * Run the audio subsystem until all frames are written or timeout. @@ -188,8 +188,8 @@ static void test_audio_out_sine_wave(void) =20 g_assert_cmpint(state.frames_written, =3D=3D, state.total_frames); =20 - AUD_set_active_out(state.be, state.voice, false); - AUD_close_out(state.be, state.voice); + audio_be_set_active_out(state.be, state.voice, false); + audio_be_close_out(state.be, state.voice); } =20 static void test_audio_prio_list(void) @@ -224,15 +224,15 @@ static void test_audio_out_active_state(void) be =3D get_test_audio_backend(); voice =3D open_test_voice_out(be, "test-active", NULL, dummy_audio_cal= lback); =20 - g_assert_false(AUD_is_active_out(be, voice)); + g_assert_false(audio_be_is_active_out(be, voice)); =20 - AUD_set_active_out(be, voice, true); - g_assert_true(AUD_is_active_out(be, voice)); + audio_be_set_active_out(be, voice, true); + g_assert_true(audio_be_is_active_out(be, voice)); =20 - AUD_set_active_out(be, voice, false); - g_assert_false(AUD_is_active_out(be, voice)); + audio_be_set_active_out(be, voice, false); + g_assert_false(audio_be_is_active_out(be, voice)); =20 - AUD_close_out(be, voice); + audio_be_close_out(be, voice); } =20 static void test_audio_out_buffer_size(void) @@ -244,13 +244,13 @@ static void test_audio_out_buffer_size(void) be =3D get_test_audio_backend(); voice =3D open_test_voice_out(be, "test-buffer", NULL, dummy_audio_cal= lback); =20 - buffer_size =3D AUD_get_buffer_size_out(be, voice); + buffer_size =3D audio_be_get_buffer_size_out(be, voice); g_test_message("Buffer size: %d bytes", buffer_size); g_assert_cmpint(buffer_size, >, 0); =20 - AUD_close_out(be, voice); + audio_be_close_out(be, voice); =20 - g_assert_cmpint(AUD_get_buffer_size_out(NULL, NULL), =3D=3D, 0); + g_assert_cmpint(audio_be_get_buffer_size_out(be, NULL), =3D=3D, 0); } =20 static void test_audio_out_volume(void) @@ -263,15 +263,15 @@ static void test_audio_out_volume(void) voice =3D open_test_voice_out(be, "test-volume", NULL, dummy_audio_cal= lback); =20 vol =3D (Volume){ .mute =3D false, .channels =3D 2, .vol =3D {255, 255= } }; - AUD_set_volume_out(be, voice, &vol); + audio_be_set_volume_out(be, voice, &vol); =20 vol =3D (Volume){ .mute =3D true, .channels =3D 2, .vol =3D {255, 255}= }; - AUD_set_volume_out(be, voice, &vol); + audio_be_set_volume_out(be, voice, &vol); =20 vol =3D (Volume){ .mute =3D false, .channels =3D 2, .vol =3D {128, 128= } }; - AUD_set_volume_out(be, voice, &vol); + audio_be_set_volume_out(be, voice, &vol); =20 - AUD_close_out(be, voice); + audio_be_close_out(be, voice); } =20 static void test_audio_in_active_state(void) @@ -286,15 +286,15 @@ static void test_audio_in_active_state(void) return; } =20 - g_assert_false(AUD_is_active_in(be, voice)); + g_assert_false(audio_be_is_active_in(be, voice)); =20 - AUD_set_active_in(be, voice, true); - g_assert_true(AUD_is_active_in(be, voice)); + audio_be_set_active_in(be, voice, true); + g_assert_true(audio_be_is_active_in(be, voice)); =20 - AUD_set_active_in(be, voice, false); - g_assert_false(AUD_is_active_in(be, voice)); + audio_be_set_active_in(be, voice, false); + g_assert_false(audio_be_is_active_in(be, voice)); =20 - AUD_close_in(be, voice); + audio_be_close_in(be, voice); } =20 static void test_audio_in_volume(void) @@ -311,12 +311,12 @@ static void test_audio_in_volume(void) } =20 vol =3D (Volume){ .mute =3D false, .channels =3D 2, .vol =3D {255, 255= } }; - AUD_set_volume_in(be, voice, &vol); + audio_be_set_volume_in(be, voice, &vol); =20 vol =3D (Volume){ .mute =3D true, .channels =3D 2, .vol =3D {255, 255}= }; - AUD_set_volume_in(be, voice, &vol); + audio_be_set_volume_in(be, voice, &vol); =20 - AUD_close_in(be, voice); + audio_be_close_in(be, voice); } =20 =20 @@ -416,7 +416,7 @@ static void test_audio_capture(void) state.captured_bytes =3D 0; state.capture_buffer_size =3D CAPTURE_BUFFER_SIZE; =20 - cap =3D AUD_add_capture(be, &as, &ops, &state); + cap =3D audio_be_add_capture(be, &as, &ops, &state); g_assert_nonnull(cap); =20 sine_state.be =3D be; @@ -427,7 +427,7 @@ static void test_audio_capture(void) &sine_state, test_sine_callback); sine_state.voice =3D voice; =20 - AUD_set_active_out(be, voice, true); + audio_be_set_active_out(be, voice, true); =20 start_time =3D g_get_monotonic_time(); while (sine_state.frames_written < sine_state.total_frames || @@ -472,10 +472,10 @@ static void test_audio_capture(void) g_assert_cmpfloat(match_ratio, >=3D, 0.9); } =20 - AUD_set_active_out(be, voice, false); - AUD_close_out(be, voice); + audio_be_set_active_out(be, voice, false); + audio_be_close_out(be, voice); =20 - AUD_del_capture(be, cap, &state); + audio_be_del_capture(be, cap, &state); g_assert_true(state.destroy_called); =20 g_free(state.captured_samples); @@ -486,24 +486,24 @@ static void test_audio_null_handling(void) AudioBackend *be =3D get_test_audio_backend(); uint8_t buffer[64]; =20 - /* AUD_is_active_out/in(NULL) should return false */ - g_assert_false(AUD_is_active_out(be, NULL)); - g_assert_false(AUD_is_active_in(be, NULL)); + /* audio_be_is_active_out/in(NULL) should return false */ + g_assert_false(audio_be_is_active_out(be, NULL)); + g_assert_false(audio_be_is_active_in(be, NULL)); =20 - /* AUD_get_buffer_size_out(NULL) should return 0 */ - g_assert_cmpint(AUD_get_buffer_size_out(be, NULL), =3D=3D, 0); + /* audio_be_get_buffer_size_out(NULL) should return 0 */ + g_assert_cmpint(audio_be_get_buffer_size_out(be, NULL), =3D=3D, 0); =20 - /* AUD_write/read(NULL, ...) should return size (no-op) */ - g_assert_cmpuint(AUD_write(be, NULL, buffer, sizeof(buffer)), =3D=3D, + /* audio_be_write/read(NULL, ...) should return size (no-op) */ + g_assert_cmpuint(audio_be_write(be, NULL, buffer, sizeof(buffer)), =3D= =3D, sizeof(buffer)); - g_assert_cmpuint(AUD_read(be, NULL, buffer, sizeof(buffer)), =3D=3D, + g_assert_cmpuint(audio_be_read(be, NULL, buffer, sizeof(buffer)), =3D= =3D, sizeof(buffer)); =20 /* These should not crash */ - AUD_set_active_out(be, NULL, true); - AUD_set_active_out(be, NULL, false); - AUD_set_active_in(be, NULL, true); - AUD_set_active_in(be, NULL, false); + audio_be_set_active_out(be, NULL, true); + audio_be_set_active_out(be, NULL, false); + audio_be_set_active_in(be, NULL, true); + audio_be_set_active_in(be, NULL, false); } =20 static void test_audio_multiple_voices(void) @@ -517,23 +517,23 @@ static void test_audio_multiple_voices(void) out2 =3D open_test_voice_out(be, "test-multi-out2", NULL, dummy_audio_= callback); in1 =3D open_test_voice_in(be, "test-multi-in1", NULL, dummy_audio_cal= lback); =20 - AUD_set_active_out(be, out1, true); - AUD_set_active_out(be, out2, true); - AUD_set_active_in(be, in1, true); + audio_be_set_active_out(be, out1, true); + audio_be_set_active_out(be, out2, true); + audio_be_set_active_in(be, in1, true); =20 - g_assert_true(AUD_is_active_out(be, out1)); - g_assert_true(AUD_is_active_out(be, out2)); + g_assert_true(audio_be_is_active_out(be, out1)); + g_assert_true(audio_be_is_active_out(be, out2)); if (in1) { - g_assert_true(AUD_is_active_in(be, in1)); + g_assert_true(audio_be_is_active_in(be, in1)); } =20 - AUD_set_active_out(be, out1, false); - AUD_set_active_out(be, out2, false); - AUD_set_active_in(be, in1, false); + audio_be_set_active_out(be, out1, false); + audio_be_set_active_out(be, out2, false); + audio_be_set_active_in(be, in1, false); =20 - AUD_close_in(be, in1); - AUD_close_out(be, out2); - AUD_close_out(be, out1); + audio_be_close_in(be, in1); + audio_be_close_out(be, out2); + audio_be_close_out(be, out1); } =20 int main(int argc, char **argv) diff --git a/ui/vnc.c b/ui/vnc.c index c142d9fc7c0..d56fe2c180e 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1280,7 +1280,7 @@ static void audio_add(VncState *vs) ops.destroy =3D audio_capture_destroy; ops.capture =3D audio_capture; =20 - vs->audio_cap =3D AUD_add_capture(vs->vd->audio_be, &vs->as, &ops, vs); + vs->audio_cap =3D audio_be_add_capture(vs->vd->audio_be, &vs->as, &ops= , vs); if (!vs->audio_cap) { error_report("Failed to add audio capture"); } @@ -1289,7 +1289,7 @@ static void audio_add(VncState *vs) static void audio_del(VncState *vs) { if (vs->audio_cap) { - AUD_del_capture(vs->vd->audio_be, vs->audio_cap, vs); + audio_be_del_capture(vs->vd->audio_be, vs->audio_cap, vs); vs->audio_cap =3D NULL; } } --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771854925; cv=none; d=zohomail.com; s=zohoarc; b=cqHXMbO7D6yku4PR1DGuv0DDiwf9CoyRXPoj+0N8LC163L6slahIDAAlWoIvw3Xb6lpZ9sSnvWfYhjN2yRE5WGPTcR9rmZ9Lyk/4fXO9p3XFHYk322Nn38tEiAr3T5tLEF6YWAXSJ8hKNuTwL0oUpiuNuO4whYAI2BCWSdr/oVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854925; 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=gk8z/yPZc780qIB6Fxp7tinO/ilEaeihoI2LilPTyNQ=; b=D6YhvYm/BaD7rV8KeDPjHcuoxviqZk/wgf1iWCuWba2u/ZaGX5UPy12IkMAmOFBVKqskYL5Xe/wg6ErbCbwqdj4sYY+NUBIY7kRF8AXkNBRgBLWVKJ13LiF/47c99izDgRHSSfHeMQivEZOWiBZMSrPpozaL03TNBk7j6uw21Gk= 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 1771854925744102.80629049987886; Mon, 23 Feb 2026 05:55:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWLG-0006J1-Mx; Mon, 23 Feb 2026 08:51:23 -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 1vuWJW-00036l-SC for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:34 -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 1vuWJR-0007AS-36 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:27 -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-383-tmsrrQ9NNJa-GUO_K0UmNw-1; Mon, 23 Feb 2026 08:49:19 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6F656180025E; Mon, 23 Feb 2026 13:49:18 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A04AF1800668; Mon, 23 Feb 2026 13:49:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854562; 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=gk8z/yPZc780qIB6Fxp7tinO/ilEaeihoI2LilPTyNQ=; b=Xiqzqh2XmnFElCQwus8R3b6pI0aY47dtyv0g4Gj5uzYFthgauwpPvjOOeGW2Q9HnOMVDLh 1y4/RHMdsGGqT155mgmN+K9ksoLdkuEW7Nnu2OS6ZzqrTDRBHzOf759+5NpXfiD4blZn+o iLhLB8aJKbIW/8JxiQy/QKUeMtU265g= X-MC-Unique: tmsrrQ9NNJa-GUO_K0UmNw-1 X-Mimecast-MFC-AGG-ID: tmsrrQ9NNJa-GUO_K0UmNw_1771854558 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 38/85] audio-be: add common pre-conditions Date: Mon, 23 Feb 2026 14:46:39 +0100 Message-ID: <20260223134731.2377432-39-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854926853158500 From: Marc-Andr=C3=A9 Lureau assert() on valid values, and handle acceptable NULL arguments gracefully. Note audio_driver_write() and audio_driver_read() used to return size (with a "XXX: Consider options") when sw was NULL. Imho, it is more correct to not pretend to have read/written anything by default in the AudioBackend base abstract class. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio-be.c | 61 ++++++++++++++++++++++++++++++++++++++++ tests/audio/test-audio.c | 8 ++---- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/audio/audio-be.c b/audio/audio-be.c index 4d3b1e2bafd..719dd8cac12 100644 --- a/audio/audio-be.c +++ b/audio/audio-be.c @@ -29,6 +29,10 @@ SWVoiceIn *audio_be_open_in( { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + assert(name !=3D NULL); + assert(callback_fn !=3D NULL); + assert(as !=3D NULL); + return klass->open_in(be, sw, name, callback_opaque, callback_fn, as); } =20 @@ -42,6 +46,10 @@ SWVoiceOut *audio_be_open_out( { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + assert(name !=3D NULL); + assert(callback_fn !=3D NULL); + assert(as !=3D NULL); + return klass->open_out(be, sw, name, callback_opaque, callback_fn, as); } =20 @@ -49,6 +57,10 @@ void audio_be_close_out(AudioBackend *be, SWVoiceOut *sw) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + if (!sw) { + return; + } + return klass->close_out(be, sw); } =20 @@ -56,6 +68,10 @@ void audio_be_close_in(AudioBackend *be, SWVoiceIn *sw) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + if (!sw) { + return; + } + return klass->close_in(be, sw); } =20 @@ -63,6 +79,10 @@ bool audio_be_is_active_out(AudioBackend *be, SWVoiceOut= *sw) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + if (!sw) { + return false; + } + return klass->is_active_out(be, sw); } =20 @@ -70,6 +90,10 @@ bool audio_be_is_active_in(AudioBackend *be, SWVoiceIn *= sw) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + if (!sw) { + return false; + } + return klass->is_active_in(be, sw); } =20 @@ -77,6 +101,10 @@ size_t audio_be_write(AudioBackend *be, SWVoiceOut *sw,= void *buf, size_t size) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + if (!sw) { + return 0; + } + return klass->write(be, sw, buf, size); } =20 @@ -84,6 +112,10 @@ size_t audio_be_read(AudioBackend *be, SWVoiceIn *sw, v= oid *buf, size_t size) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + if (!sw) { + return 0; + } + return klass->read(be, sw, buf, size); } =20 @@ -91,6 +123,10 @@ int audio_be_get_buffer_size_out(AudioBackend *be, SWVo= iceOut *sw) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + if (!sw) { + return 0; + } + return klass->get_buffer_size_out(be, sw); } =20 @@ -98,6 +134,10 @@ void audio_be_set_active_out(AudioBackend *be, SWVoiceO= ut *sw, bool on) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + if (!sw) { + return; + } + return klass->set_active_out(be, sw, on); } =20 @@ -105,6 +145,10 @@ void audio_be_set_active_in(AudioBackend *be, SWVoiceI= n *sw, bool on) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + if (!sw) { + return; + } + return klass->set_active_in(be, sw, on); } =20 @@ -112,6 +156,10 @@ void audio_be_set_volume_out(AudioBackend *be, SWVoice= Out *sw, Volume *vol) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + if (!sw) { + return; + } + klass->set_volume_out(be, sw, vol); } =20 @@ -119,6 +167,10 @@ void audio_be_set_volume_in(AudioBackend *be, SWVoiceI= n *sw, Volume *vol) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + if (!sw) { + return; + } + klass->set_volume_in(be, sw, vol); } =20 @@ -130,6 +182,9 @@ CaptureVoiceOut *audio_be_add_capture( { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + assert(as !=3D NULL); + assert(ops !=3D NULL); + return klass->add_capture(be, as, ops, cb_opaque); } =20 @@ -137,6 +192,10 @@ void audio_be_del_capture(AudioBackend *be, CaptureVoi= ceOut *cap, void *cb_opaqu { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + if (!cap) { + return; + } + klass->del_capture(be, cap, cb_opaque); } =20 @@ -155,6 +214,8 @@ bool audio_be_set_dbus_server(AudioBackend *be, { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + assert(server !=3D NULL); + if (!audio_be_can_set_dbus_server(be)) { error_setg(errp, "Audiodev '%s' is not compatible with DBus", audio_be_get_id(be)); diff --git a/tests/audio/test-audio.c b/tests/audio/test-audio.c index 1827c084ac8..90d96ae0575 100644 --- a/tests/audio/test-audio.c +++ b/tests/audio/test-audio.c @@ -493,11 +493,9 @@ static void test_audio_null_handling(void) /* audio_be_get_buffer_size_out(NULL) should return 0 */ g_assert_cmpint(audio_be_get_buffer_size_out(be, NULL), =3D=3D, 0); =20 - /* audio_be_write/read(NULL, ...) should return size (no-op) */ - g_assert_cmpuint(audio_be_write(be, NULL, buffer, sizeof(buffer)), =3D= =3D, - sizeof(buffer)); - g_assert_cmpuint(audio_be_read(be, NULL, buffer, sizeof(buffer)), =3D= =3D, - sizeof(buffer)); + /* audio_be_write/read(NULL, ...) should return 0 */ + g_assert_cmpuint(audio_be_write(be, NULL, buffer, sizeof(buffer)), =3D= =3D, 0); + g_assert_cmpuint(audio_be_read(be, NULL, buffer, sizeof(buffer)), =3D= =3D, 0); =20 /* These should not crash */ audio_be_set_active_out(be, NULL, true); --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771855033; cv=none; d=zohomail.com; s=zohoarc; b=S3CRPSe4awLml8k4+OPdCOymMsyw8Z0B1VsjLMZLuVgznaitzDnyieb4VVyFxmexDZmfuCSSp+/AGpJ3Twwj8ovVZHdSfjnFAxqbIOWw2KR3R+DIsfijdISkv8rjoF+CdzyOc9sw/D11RT6qZ6Isho5jKmXwQqpTF/4CP/E93SE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855033; 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=vCretvQY97NryFYO0+50I2FBpo2YmwF0r5vmz6Zo5bQ=; b=Pf3q4jfgcYE2H4ULKLVlvEvrQJTvGuJh55zhXI6b8kM6peTNOcXwMrT0Xvasp05GfX8jcIij2Sg6XufwzisIssxy6C6xnjq2dHC7ozGj9yQCU12jlHxBNXWKX0EchQgR2UBB68CzyKsOZlmkyNnIpblhFQDjqMa3I/P/7ENaypU= 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 1771855033204992.4619964417548; Mon, 23 Feb 2026 05:57:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWKO-00055G-9v; Mon, 23 Feb 2026 08:50: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 1vuWJW-00036v-0T for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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 1vuWJT-0007BR-EN for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:28 -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-22-GPsisPnpPlueFB8uszBEkA-1; Mon, 23 Feb 2026 08:49:22 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 477F21800605; Mon, 23 Feb 2026 13:49:21 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5DABE1955F22; Mon, 23 Feb 2026 13:49:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854566; 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=vCretvQY97NryFYO0+50I2FBpo2YmwF0r5vmz6Zo5bQ=; b=R+A73JYTu41IpkDp7uW/g4Pals1ygZ6sI16FEpxYQdGWwU1DvZdZowBEce6eC86ouY9v/X +1W3K9Q0/kawO6x4YApf9ptLxbyo6yrrisV81ZuprEqrfk+L3khg6r2rvVeEZWKczDg+Vz gZ1KgYixpzbaFtaSobj4sjDlU2OykEk= X-MC-Unique: GPsisPnpPlueFB8uszBEkA-1 X-Mimecast-MFC-AGG-ID: GPsisPnpPlueFB8uszBEkA_1771854561 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 39/85] audio-be: add some state trace for debugging Date: Mon, 23 Feb 2026 14:46:40 +0100 Message-ID: <20260223134731.2377432-40-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855035375158500 From: Marc-Andr=C3=A9 Lureau Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio-be.c | 5 +++++ audio/trace-events | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/audio/audio-be.c b/audio/audio-be.c index 719dd8cac12..3203bb80e05 100644 --- a/audio/audio-be.c +++ b/audio/audio-be.c @@ -4,6 +4,7 @@ #include "qemu/audio.h" #include "qemu/audio-capture.h" #include "qapi/error.h" +#include "trace.h" =20 bool audio_be_check(AudioBackend **be, Error **errp) { @@ -134,6 +135,8 @@ void audio_be_set_active_out(AudioBackend *be, SWVoiceO= ut *sw, bool on) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + trace_audio_be_set_active_out(sw, on); + if (!sw) { return; } @@ -145,6 +148,8 @@ void audio_be_set_active_in(AudioBackend *be, SWVoiceIn= *sw, bool on) { AudioBackendClass *klass =3D AUDIO_BACKEND_GET_CLASS(be); =20 + trace_audio_be_set_active_in(sw, on); + if (!sw) { return; } diff --git a/audio/trace-events b/audio/trace-events index 7e3f1593c81..f7f639d9605 100644 --- a/audio/trace-events +++ b/audio/trace-events @@ -26,6 +26,10 @@ pw_vol(const char *ret) "set volume: %s" pw_period(uint64_t quantum, uint32_t rate) "period =3D%" PRIu64 "/%u" pw_audio_init(void) "Initialize PipeWire context" =20 +# audio-be.c +audio_be_set_active_in(void *sw, bool on) "sw=3D%p, on=3D%d" +audio_be_set_active_out(void *sw, bool on) "sw=3D%p, on=3D%d" + # audio.c audio_timer_start(int interval) "interval %d ms" audio_timer_stop(void) "" --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771854787; cv=none; d=zohomail.com; s=zohoarc; b=dspaP7XpndmKF2q2da7t+1JPmfHruWx6TnChqKXsFVIm3mhScje7C2zibdoi98LEtUcr7qR386AlIZhBGJuew9H9LNLrIfS9du9mMWvse5gdd4SHr4qX3LvWQbxSisNznSJVLwzLQB8r9f6i8UWesrCpLHJXEAgKey3s7ETJgc8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854787; 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=FbXBj1Q8ejooAfIcT/fbAguEL3illTubPKvY0IyZL2E=; b=WnbRwsLSXLv8NKJpOAjsXu9gclQ3VV+93UU+rKkkFk0IupUjzm3Qh9KZg0yn53/J1lQMjwA6vHdPnXZjJJsWrFSwVW9idSHapjpc6bAFlaqnSrOitKnwtnz8vqJfnBnqmlN3b+aeHYMMJWgYsVejhwFt/XlBf+YpiU7VW2QEqIw= 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 1771854787501209.73832676730558; Mon, 23 Feb 2026 05:53:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWMR-0008O2-SM; Mon, 23 Feb 2026 08:52:31 -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 1vuWJa-0003FL-IW for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWJU-0007C0-Tt for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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-527-MmpBBEFANMm2OTNnsZzFhw-1; Mon, 23 Feb 2026 08:49:25 -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 E5F3F1956062; Mon, 23 Feb 2026 13:49:24 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 151473000C26; Mon, 23 Feb 2026 13:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854567; 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=FbXBj1Q8ejooAfIcT/fbAguEL3illTubPKvY0IyZL2E=; b=a3Xq9A7HTqCDIorwto01fkwMB0kY4AkR+MqhEYUE0IXHny7sB+d3QHcvYfOe6rmu5dbkp3 MfqNbnKxgiRsh58yaQNDMzGCVzO3X0ZBz/feKcSZmIbNkjENGxMdi8edUJWd/+IOEuGt3G a57qoq0PnsrkoGks8vDPv9CT65N3lPY= X-MC-Unique: MmpBBEFANMm2OTNnsZzFhw-1 X-Mimecast-MFC-AGG-ID: MmpBBEFANMm2OTNnsZzFhw_1771854565 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 40/85] audio: split AudioMixengBackend code in audio-mixeng-be.c Date: Mon, 23 Feb 2026 14:46:41 +0100 Message-ID: <20260223134731.2377432-41-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854788251158500 From: Marc-Andr=C3=A9 Lureau Allow to build the audio/ base classes without the resampling/mixing/queuing code. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 2 - include/qemu/audio.h | 2 + audio/audio-be.c | 2 + audio/audio-mixeng-be.c | 1976 ++++++++++++++++++++++++++++++++++ audio/audio.c | 2223 ++++----------------------------------- audio/meson.build | 1 + 6 files changed, 2158 insertions(+), 2048 deletions(-) create mode 100644 audio/audio-mixeng-be.c diff --git a/audio/audio_int.h b/audio/audio_int.h index 250fd45238d..6ecd75c4fbf 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -266,8 +266,6 @@ int audio_bug (const char *funcname, int cond); =20 void audio_run(AudioMixengBackend *s, const char *msg); =20 -const char *audio_application_name(void); - typedef struct RateCtl { int64_t start_ticks; int64_t bytes_sent; diff --git a/include/qemu/audio.h b/include/qemu/audio.h index 42f97f732a6..dfe247ab8c4 100644 --- a/include/qemu/audio.h +++ b/include/qemu/audio.h @@ -183,6 +183,8 @@ bool audio_be_set_dbus_server(AudioBackend *be, Error **errp); #endif =20 +const char *audio_application_name(void); + #define DEFINE_AUDIO_PROPERTIES(_s, _f) \ DEFINE_PROP_AUDIODEV("audiodev", _s, _f) =20 diff --git a/audio/audio-be.c b/audio/audio-be.c index 3203bb80e05..8094a3196c7 100644 --- a/audio/audio-be.c +++ b/audio/audio-be.c @@ -5,6 +5,7 @@ #include "qemu/audio-capture.h" #include "qapi/error.h" #include "trace.h" +#include "qapi-types-audio.h" =20 bool audio_be_check(AudioBackend **be, Error **errp) { @@ -248,6 +249,7 @@ AudioBackend *audio_be_new(Audiodev *dev, Error **errp) =20 if (!be) { error_setg(errp, "Unknown audio driver `%s'", drvname); + qapi_free_Audiodev(dev); return NULL; } =20 diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c new file mode 100644 index 00000000000..f906c84bf7c --- /dev/null +++ b/audio/audio-mixeng-be.c @@ -0,0 +1,1976 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright (c) 2003-2005 Vassili Karpov (malc) + */ + +#include "qemu/osdep.h" +#include "qemu/audio.h" +#include "migration/vmstate.h" +#include "qemu/bswap.h" +#include "qemu/timer.h" +#include "qapi/error.h" +#include "qapi/clone-visitor.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi/qapi-visit-audio.h" +#include "qapi/qapi-commands-audio.h" +#include "qobject/qdict.h" +#include "qemu/error-report.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "qemu/help_option.h" +#include "qom/object.h" +#include "system/system.h" +#include "system/replay.h" +#include "system/runstate.h" +#include "trace.h" + +#define AUDIO_CAP "audio" +#include "audio_int.h" + +/* #define DEBUG_OUT */ +/* #define DEBUG_CAPTURE */ +/* #define DEBUG_POLL */ + +#define SW_NAME(sw) (sw)->name ? (sw)->name : "unknown" + +const struct mixeng_volume nominal_volume =3D { + .mute =3D 0, +#ifdef FLOAT_MIXENG + .r =3D 1.0, + .l =3D 1.0, +#else + .r =3D 1ULL << 32, + .l =3D 1ULL << 32, +#endif +}; + +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; +} + +static inline int audio_bits_to_index (int bits) +{ + switch (bits) { + case 8: + return 0; + + case 16: + return 1; + + case 32: + return 2; + + default: + audio_bug ("bits_to_index", 1); + AUD_log (NULL, "invalid bits %d\n", bits); + return 0; + } +} + +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 void audio_print_settings (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"); + 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"); +} + +static int audio_validate_settings (const struct audsettings *as) +{ + int invalid; + + invalid =3D as->nchannels < 1; + invalid |=3D as->endianness !=3D 0 && as->endianness !=3D 1; + + switch (as->fmt) { + case AUDIO_FORMAT_S8: + case AUDIO_FORMAT_U8: + case AUDIO_FORMAT_S16: + case AUDIO_FORMAT_U16: + case AUDIO_FORMAT_S32: + case AUDIO_FORMAT_U32: + case AUDIO_FORMAT_F32: + break; + default: + invalid =3D 1; + break; + } + + invalid |=3D as->freq <=3D 0; + return invalid ? -1 : 0; +} + +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 + && 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); +} + +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->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_second =3D info->freq * info->bytes_per_frame; + info->swap_endianness =3D (as->endianness !=3D HOST_BIG_ENDIAN); +} + +void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int= len) +{ + if (!len) { + return; + } + + 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; + + case 32: + { + int i; + uint32_t *p =3D buf; + int32_t s =3D INT32_MAX; + + if (info->swap_endianness) { + s =3D bswap32 (s); + } + + for (i =3D 0; i < len * info->nchannels; i++) { + p[i] =3D s; + } + } + break; + + default: + AUD_log (NULL, "audio_pcm_info_clear_buf: invalid bits %d\n", + info->bits); + break; + } + } +} + +/* + * Capture + */ +static CaptureVoiceOut *audio_pcm_capture_find_specific(AudioMixengBackend= *s, + struct audsettings= *as) +{ + CaptureVoiceOut *cap; + + for (cap =3D s->cap_head.lh_first; cap; cap =3D cap->entries.le_next) { + if (audio_pcm_info_eq (&cap->hw.info, as)) { + return cap; + } + } + return NULL; +} + +static void audio_notify_capture (CaptureVoiceOut *cap, audcnotification_e= cmd) +{ + struct capture_callback *cb; + +#ifdef DEBUG_CAPTURE + dolog ("notification %d sent\n", cmd); +#endif + for (cb =3D cap->cb_head.lh_first; cb; cb =3D cb->entries.le_next) { + cb->ops.notify (cb->opaque, cmd); + } +} + +static void audio_capture_maybe_changed(CaptureVoiceOut *cap, bool enabled) +{ + if (cap->hw.enabled !=3D enabled) { + audcnotification_e cmd; + cap->hw.enabled =3D enabled; + cmd =3D enabled ? AUD_CNOTIFY_ENABLE : AUD_CNOTIFY_DISABLE; + audio_notify_capture (cap, cmd); + } +} + +static void audio_recalc_and_notify_capture (CaptureVoiceOut *cap) +{ + HWVoiceOut *hw =3D &cap->hw; + SWVoiceOut *sw; + bool enabled =3D false; + + for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { + if (sw->active) { + enabled =3D true; + break; + } + } + audio_capture_maybe_changed (cap, enabled); +} + +static void audio_detach_capture (HWVoiceOut *hw) +{ + SWVoiceCap *sc =3D hw->cap_head.lh_first; + + while (sc) { + SWVoiceCap *sc1 =3D sc->entries.le_next; + SWVoiceOut *sw =3D &sc->sw; + CaptureVoiceOut *cap =3D sc->cap; + int was_active =3D sw->active; + + if (sw->rate) { + st_rate_stop (sw->rate); + sw->rate =3D NULL; + } + + QLIST_REMOVE (sw, entries); + QLIST_REMOVE (sc, entries); + g_free (sc); + if (was_active) { + /* We have removed soft voice from the capture: + this might have changed the overall status of the capture + since this might have been the only active voice */ + audio_recalc_and_notify_capture (cap); + } + sc =3D sc1; + } +} + +static int audio_attach_capture (HWVoiceOut *hw) +{ + AudioMixengBackend *s =3D hw->s; + CaptureVoiceOut *cap; + + audio_detach_capture (hw); + for (cap =3D s->cap_head.lh_first; cap; cap =3D cap->entries.le_next) { + SWVoiceCap *sc; + SWVoiceOut *sw; + HWVoiceOut *hw_cap =3D &cap->hw; + + sc =3D g_malloc0(sizeof(*sc)); + + sc->cap =3D cap; + sw =3D &sc->sw; + sw->hw =3D hw_cap; + sw->info =3D hw->info; + sw->empty =3D true; + sw->active =3D hw->enabled; + sw->vol =3D nominal_volume; + sw->rate =3D st_rate_start (sw->info.freq, hw_cap->info.freq); + QLIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries); + 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 + if (sw->active) { + audio_capture_maybe_changed (cap, 1); + } + } + return 0; +} + +/* + * Hard voice (capture) + */ +static size_t audio_pcm_hw_find_min_in (HWVoiceIn *hw) +{ + SWVoiceIn *sw; + size_t m =3D hw->total_samples_captured; + + for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { + if (sw->active) { + m =3D MIN (m, sw->total_hw_samples_acquired); + } + } + return m; +} + +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); + return 0; + } + return live; +} + +static size_t audio_pcm_hw_conv_in(HWVoiceIn *hw, void *pcm_buf, size_t sa= mples) +{ + size_t conv =3D 0; + STSampleBuffer *conv_buf =3D &hw->conv_buf; + + while (samples) { + uint8_t *src =3D advance(pcm_buf, conv * hw->info.bytes_per_frame); + size_t proc =3D MIN(samples, conv_buf->size - conv_buf->pos); + + hw->conv(conv_buf->buffer + conv_buf->pos, src, proc); + conv_buf->pos =3D (conv_buf->pos + proc) % conv_buf->size; + samples -=3D proc; + conv +=3D proc; + } + + return conv; +} + +/* + * Soft voice (capture) + */ +static void audio_pcm_sw_resample_in(SWVoiceIn *sw, + size_t frames_in_max, size_t frames_out_max, + size_t *total_in, size_t *total_out) +{ + HWVoiceIn *hw =3D sw->hw; + struct st_sample *src, *dst; + size_t live, rpos, frames_in, frames_out; + + live =3D hw->total_samples_captured - sw->total_hw_samples_acquired; + rpos =3D audio_ring_posb(hw->conv_buf.pos, live, hw->conv_buf.size); + + /* resample conv_buf from rpos to end of buffer */ + src =3D hw->conv_buf.buffer + rpos; + frames_in =3D MIN(frames_in_max, hw->conv_buf.size - rpos); + dst =3D sw->resample_buf.buffer; + frames_out =3D frames_out_max; + st_rate_flow(sw->rate, src, dst, &frames_in, &frames_out); + rpos +=3D frames_in; + *total_in =3D frames_in; + *total_out =3D frames_out; + + /* resample conv_buf from start of buffer if there are input frames le= ft */ + if (frames_in_max - frames_in && rpos =3D=3D hw->conv_buf.size) { + src =3D hw->conv_buf.buffer; + frames_in =3D frames_in_max - frames_in; + dst +=3D frames_out; + frames_out =3D frames_out_max - frames_out; + st_rate_flow(sw->rate, src, dst, &frames_in, &frames_out); + *total_in +=3D frames_in; + *total_out +=3D frames_out; + } +} + +static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t buf_len) +{ + HWVoiceIn *hw =3D sw->hw; + size_t live, frames_out_max, total_in, total_out; + + live =3D hw->total_samples_captured - sw->total_hw_samples_acquired; + 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); + return 0; + } + + frames_out_max =3D MIN(buf_len / sw->info.bytes_per_frame, + sw->resample_buf.size); + + audio_pcm_sw_resample_in(sw, live, frames_out_max, &total_in, &total_o= ut); + + if (!hw->pcm_ops->volume_in) { + mixeng_volume(sw->resample_buf.buffer, total_out, &sw->vol); + } + sw->clip(buf, sw->resample_buf.buffer, total_out); + + sw->total_hw_samples_acquired +=3D total_in; + return total_out * sw->info.bytes_per_frame; +} + +/* + * Hard voice (playback) + */ +static size_t audio_pcm_hw_find_min_out (HWVoiceOut *hw, int *nb_livep) +{ + SWVoiceOut *sw; + size_t m =3D SIZE_MAX; + int nb_live =3D 0; + + for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { + if (sw->active || !sw->empty) { + m =3D MIN (m, sw->total_hw_samples_mixed); + nb_live +=3D 1; + } + } + + *nb_livep =3D nb_live; + return m; +} + +static size_t audio_pcm_hw_get_live_out (HWVoiceOut *hw, int *nb_live) +{ + size_t smin; + int nb_live1; + + smin =3D audio_pcm_hw_find_min_out (hw, &nb_live1); + if (nb_live) { + *nb_live =3D nb_live1; + } + + if (nb_live1) { + size_t live =3D smin; + + if (audio_bug(__func__, live > hw->mix_buf.size)) { + dolog("live=3D%zu hw->mix_buf.size=3D%zu\n", live, hw->mix_buf= .size); + return 0; + } + return live; + } + return 0; +} + +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; +} + +static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, size_t le= n) +{ + size_t clipped =3D 0; + size_t pos =3D hw->mix_buf.pos; + + while (len) { + st_sample *src =3D hw->mix_buf.buffer + pos; + uint8_t *dst =3D advance(pcm_buf, clipped * hw->info.bytes_per_fra= me); + size_t samples_till_end_of_buf =3D hw->mix_buf.size - pos; + size_t samples_to_clip =3D MIN(len, samples_till_end_of_buf); + + hw->clip(dst, src, samples_to_clip); + + pos =3D (pos + samples_to_clip) % hw->mix_buf.size; + len -=3D samples_to_clip; + clipped +=3D samples_to_clip; + } +} + +/* + * Soft voice (playback) + */ +static void audio_pcm_sw_resample_out(SWVoiceOut *sw, + size_t frames_in_max, size_t frames_out_max, + size_t *total_in, size_t *total_out) +{ + HWVoiceOut *hw =3D sw->hw; + struct st_sample *src, *dst; + size_t live, wpos, frames_in, frames_out; + + live =3D sw->total_hw_samples_mixed; + wpos =3D (hw->mix_buf.pos + live) % hw->mix_buf.size; + + /* write to mix_buf from wpos to end of buffer */ + src =3D sw->resample_buf.buffer; + frames_in =3D frames_in_max; + dst =3D hw->mix_buf.buffer + wpos; + frames_out =3D MIN(frames_out_max, hw->mix_buf.size - wpos); + st_rate_flow_mix(sw->rate, src, dst, &frames_in, &frames_out); + wpos +=3D frames_out; + *total_in =3D frames_in; + *total_out =3D frames_out; + + /* write to mix_buf from start of buffer if there are input frames lef= t */ + if (frames_in_max - frames_in > 0 && wpos =3D=3D hw->mix_buf.size) { + src +=3D frames_in; + frames_in =3D frames_in_max - frames_in; + dst =3D hw->mix_buf.buffer; + frames_out =3D frames_out_max - frames_out; + st_rate_flow_mix(sw->rate, src, dst, &frames_in, &frames_out); + *total_in +=3D frames_in; + *total_out +=3D frames_out; + } +} + +static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t buf_len) +{ + HWVoiceOut *hw =3D sw->hw; + size_t live, dead, hw_free, sw_max, fe_max; + size_t frames_in_max, frames_out_max, total_in, total_out; + + 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); + return 0; + } + + if (live =3D=3D hw->mix_buf.size) { +#ifdef DEBUG_OUT + dolog ("%s is full %zu\n", sw->name, live); +#endif + return 0; + } + + dead =3D hw->mix_buf.size - live; + hw_free =3D audio_pcm_hw_get_free(hw); + hw_free =3D hw_free > live ? hw_free - live : 0; + frames_out_max =3D MIN(dead, hw_free); + sw_max =3D st_rate_frames_in(sw->rate, frames_out_max); + fe_max =3D MIN(buf_len / sw->info.bytes_per_frame + sw->resample_buf.p= os, + sw->resample_buf.size); + frames_in_max =3D MIN(sw_max, fe_max); + + if (!frames_in_max) { + return 0; + } + + if (frames_in_max > sw->resample_buf.pos) { + sw->conv(sw->resample_buf.buffer + sw->resample_buf.pos, + buf, frames_in_max - sw->resample_buf.pos); + if (!sw->hw->pcm_ops->volume_out) { + mixeng_volume(sw->resample_buf.buffer + sw->resample_buf.pos, + frames_in_max - sw->resample_buf.pos, &sw->vol); + } + } + + audio_pcm_sw_resample_out(sw, frames_in_max, frames_out_max, + &total_in, &total_out); + + sw->total_hw_samples_mixed +=3D total_out; + sw->empty =3D sw->total_hw_samples_mixed =3D=3D 0; + + /* + * Upsampling may leave one audio frame in the resample buffer. Decrem= ent + * total_in by one if there was a leftover frame from the previous res= ample + * pass in the resample buffer. Increment total_in by one if the curre= nt + * resample pass left one frame in the resample buffer. + */ + if (frames_in_max - total_in =3D=3D 1) { + /* copy one leftover audio frame to the beginning of the buffer */ + *sw->resample_buf.buffer =3D *(sw->resample_buf.buffer + total_in); + total_in +=3D 1 - sw->resample_buf.pos; + sw->resample_buf.pos =3D 1; + } else if (total_in >=3D sw->resample_buf.pos) { + total_in -=3D sw->resample_buf.pos; + sw->resample_buf.pos =3D 0; + } + +#ifdef DEBUG_OUT + dolog ( + "%s: write size %zu written %zu total mixed %zu\n", + SW_NAME(sw), + buf_len / sw->info.bytes_per_frame, + total_in, + sw->total_hw_samples_mixed + ); +#endif + + return total_in * sw->info.bytes_per_frame; +} + +#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, + info->nchannels); +} +#endif + +#define DAC +#include "audio_template.h" +#undef DAC +#include "audio_template.h" + +/* + * Timer + */ +static int audio_is_timer_needed(AudioMixengBackend *s) +{ + HWVoiceIn *hwi =3D NULL; + HWVoiceOut *hwo =3D NULL; + + while ((hwo =3D audio_pcm_hw_find_any_enabled_out(s, hwo))) { + if (!hwo->poll_mode) { + return 1; + } + } + while ((hwi =3D audio_pcm_hw_find_any_enabled_in(s, hwi))) { + if (!hwi->poll_mode) { + return 1; + } + } + return 0; +} + +static void audio_reset_timer(AudioMixengBackend *s) +{ + if (audio_is_timer_needed(s)) { + timer_mod_anticipate_ns(s->ts, + qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + s->period_ticks); + if (!s->timer_running) { + s->timer_running =3D true; + s->timer_last =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + trace_audio_timer_start(s->period_ticks / SCALE_MS); + } + } else { + timer_del(s->ts); + if (s->timer_running) { + s->timer_running =3D false; + trace_audio_timer_stop(); + } + } +} + +static void audio_timer (void *opaque) +{ + int64_t now, diff; + AudioMixengBackend *s =3D opaque; + + now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + diff =3D now - s->timer_last; + if (diff > s->period_ticks * 3 / 2) { + trace_audio_timer_delayed(diff / SCALE_MS); + } + s->timer_last =3D now; + + audio_run(s, "timer"); + audio_reset_timer(s); +} + +/* + * Public API + */ +static size_t audio_mixeng_backend_write(AudioBackend *be, SWVoiceOut *sw, + void *buf, size_t size) +{ + HWVoiceOut *hw; + + if (!sw) { + /* XXX: Consider options */ + return size; + } + hw =3D sw->hw; + + if (!hw->enabled) { + dolog("Writing to disabled voice %s\n", SW_NAME(sw)); + return 0; + } + + 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); + } +} + +static size_t audio_mixeng_backend_read(AudioBackend *be, + SWVoiceIn *sw, void *buf, size_t s= ize) +{ + HWVoiceIn *hw; + + if (!sw) { + /* XXX: Consider options */ + return size; + } + hw =3D sw->hw; + + if (!hw->enabled) { + dolog("Reading from disabled voice %s\n", SW_NAME(sw)); + return 0; + } + + 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); + } + +} + +static int audio_mixeng_backend_get_buffer_size_out(AudioBackend *be, SWVo= iceOut *sw) +{ + if (!sw) { + return 0; + } + + if (audio_get_pdo_out(sw->s->dev)->mixing_engine) { + return sw->resample_buf.size * sw->info.bytes_per_frame; + } + + return sw->hw->samples * sw->hw->info.bytes_per_frame; +} + +static void audio_mixeng_backend_set_active_out(AudioBackend *be, SWVoiceO= ut *sw, + bool on) +{ + HWVoiceOut *hw; + + if (!sw) { + return; + } + + hw =3D sw->hw; + if (sw->active !=3D on) { + AudioMixengBackend *s =3D sw->s; + SWVoiceOut *temp_sw; + SWVoiceCap *sc; + + if (on) { + 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); + } + audio_reset_timer (s); + } + } + } else { + if (hw->enabled) { + int nb_active =3D 0; + + for (temp_sw =3D hw->sw_head.lh_first; temp_sw; + temp_sw =3D temp_sw->entries.le_next) { + nb_active +=3D temp_sw->active !=3D 0; + } + + hw->pending_disable =3D nb_active =3D=3D 1; + } + } + + for (sc =3D hw->cap_head.lh_first; sc; sc =3D sc->entries.le_next)= { + sc->sw.active =3D hw->enabled; + if (hw->enabled) { + audio_capture_maybe_changed (sc->cap, 1); + } + } + sw->active =3D on; + } + +} + +static void audio_mixeng_backend_set_active_in(AudioBackend *be, SWVoiceIn= *sw, bool on) +{ + HWVoiceIn *hw; + + if (!sw) { + return; + } + + hw =3D sw->hw; + if (sw->active !=3D on) { + AudioMixengBackend *s =3D sw->s; + SWVoiceIn *temp_sw; + + 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); + } + audio_reset_timer (s); + } + } + sw->total_hw_samples_acquired =3D hw->total_samples_captured; + } else { + if (hw->enabled) { + int nb_active =3D 0; + + for (temp_sw =3D hw->sw_head.lh_first; temp_sw; + temp_sw =3D temp_sw->entries.le_next) { + nb_active +=3D temp_sw->active !=3D 0; + } + + if (nb_active =3D=3D 1) { + hw->enabled =3D false; + if (hw->pcm_ops->enable_in) { + hw->pcm_ops->enable_in(hw, false); + } + } + } + } + sw->active =3D on; + } +} + +static size_t audio_get_avail(SWVoiceIn *sw) +{ + size_t live; + + if (!sw) { + return 0; + } + + 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); + return 0; + } + + ldebug ( + "%s: get_avail live %zu frontend frames %u\n", + SW_NAME (sw), + live, st_rate_frames_out(sw->rate, live) + ); + + return live; +} + +static size_t audio_get_free(SWVoiceOut *sw) +{ + size_t live, dead; + + if (!sw) { + return 0; + } + + live =3D sw->total_hw_samples_mixed; + + if (audio_bug(__func__, live > sw->hw->mix_buf.size)) { + dolog("live=3D%zu sw->hw->mix_buf.size=3D%zu\n", live, + sw->hw->mix_buf.size); + return 0; + } + + dead =3D sw->hw->mix_buf.size - live; + +#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 + + return dead; +} + +static void audio_capture_mix_and_clear(HWVoiceOut *hw, size_t rpos, + size_t samples) +{ + size_t n; + + if (hw->enabled) { + SWVoiceCap *sc; + + for (sc =3D hw->cap_head.lh_first; sc; sc =3D sc->entries.le_next)= { + SWVoiceOut *sw =3D &sc->sw; + size_t rpos2 =3D rpos; + + n =3D samples; + while (n) { + size_t till_end_of_hw =3D hw->mix_buf.size - rpos2; + size_t to_read =3D MIN(till_end_of_hw, n); + size_t live, frames_in, frames_out; + + sw->resample_buf.buffer =3D hw->mix_buf.buffer + rpos2; + sw->resample_buf.size =3D to_read; + live =3D sw->total_hw_samples_mixed; + + audio_pcm_sw_resample_out(sw, + to_read, sw->hw->mix_buf.size - = live, + &frames_in, &frames_out); + + sw->total_hw_samples_mixed +=3D frames_out; + sw->empty =3D sw->total_hw_samples_mixed =3D=3D 0; + + if (to_read - frames_in) { + dolog("Could not mix %zu frames into a capture " + "buffer, mixed %zu\n", + to_read, frames_in); + break; + } + n -=3D to_read; + rpos2 =3D (rpos2 + to_read) % hw->mix_buf.size; + } + } + } + + n =3D MIN(samples, hw->mix_buf.size - rpos); + mixeng_clear(hw->mix_buf.buffer + rpos, n); + mixeng_clear(hw->mix_buf.buffer, samples - n); +} + +static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, size_t live) +{ + size_t clipped =3D 0; + + 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); + + if (size =3D=3D 0) { + break; + } + + decr =3D MIN(size / hw->info.bytes_per_frame, 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= ) / + hw->info.bytes_per_frame; + + live -=3D proc; + clipped +=3D proc; + hw->mix_buf.pos =3D (hw->mix_buf.pos + proc) % hw->mix_buf.size; + + if (proc =3D=3D 0 || proc < decr) { + break; + } + } + + if (hw->pcm_ops->run_buffer_out) { + hw->pcm_ops->run_buffer_out(hw); + } + + return clipped; +} + +static void audio_run_out(AudioMixengBackend *s) +{ + HWVoiceOut *hw =3D NULL; + SWVoiceOut *sw; + + while ((hw =3D audio_pcm_hw_find_any_enabled_out(s, hw))) { + size_t played, live, prev_rpos; + size_t hw_free =3D audio_pcm_hw_get_free(hw); + int nb_live; + + if (!audio_get_pdo_out(s->dev)->mixing_engine) { + /* there is exactly 1 sw for each hw with no mixeng */ + sw =3D hw->sw_head.lh_first; + + 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 (sw->active) { + sw->callback.fn(sw->callback.opaque, + hw_free * sw->info.bytes_per_frame); + } + + if (hw->pcm_ops->run_buffer_out) { + hw->pcm_ops->run_buffer_out(hw); + } + + continue; + } + + for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { + if (sw->active) { + size_t sw_free =3D audio_get_free(sw); + size_t free; + + if (hw_free > sw->total_hw_samples_mixed) { + free =3D st_rate_frames_in(sw->rate, + MIN(sw_free, hw_free - sw->total_hw_samples_mixed)= ); + } else { + free =3D 0; + } + if (free > sw->resample_buf.pos) { + free =3D MIN(free, sw->resample_buf.size) + - sw->resample_buf.pos; + sw->callback.fn(sw->callback.opaque, + free * sw->info.bytes_per_frame); + } + } + } + + live =3D audio_pcm_hw_get_live_out (hw, &nb_live); + if (!nb_live) { + live =3D 0; + } + + if (audio_bug(__func__, live > hw->mix_buf.size)) { + dolog("live=3D%zu hw->mix_buf.size=3D%zu\n", live, hw->mix_buf= .size); + continue; + } + + if (hw->pending_disable && !nb_live) { + SWVoiceCap *sc; +#ifdef DEBUG_OUT + dolog ("Disabling voice\n"); +#endif + hw->enabled =3D false; + hw->pending_disable =3D false; + if (hw->pcm_ops->enable_out) { + hw->pcm_ops->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; + audio_recalc_and_notify_capture (sc->cap); + } + continue; + } + + if (!live) { + if (hw->pcm_ops->run_buffer_out) { + hw->pcm_ops->run_buffer_out(hw); + } + continue; + } + + prev_rpos =3D hw->mix_buf.pos; + played =3D audio_pcm_hw_run_out(hw, live); + replay_audio_out(&played); + if (audio_bug(__func__, hw->mix_buf.pos >=3D hw->mix_buf.size)) { + dolog("hw->mix_buf.pos=3D%zu hw->mix_buf.size=3D%zu played=3D%= zu\n", + hw->mix_buf.pos, hw->mix_buf.size, played); + hw->mix_buf.pos =3D 0; + } + +#ifdef DEBUG_OUT + dolog("played=3D%zu\n", played); +#endif + + if (played) { + audio_capture_mix_and_clear (hw, prev_rpos, played); + } + + for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { + if (!sw->active && sw->empty) { + continue; + } + + 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); + played =3D sw->total_hw_samples_mixed; + } + + sw->total_hw_samples_mixed -=3D played; + + if (!sw->total_hw_samples_mixed) { + sw->empty =3D true; + } + } + } +} + +static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, size_t samples) +{ + size_t conv =3D 0; + + if (hw->pcm_ops->run_buffer_in) { + hw->pcm_ops->run_buffer_in(hw); + } + + 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); + + assert(size % hw->info.bytes_per_frame =3D=3D 0); + if (size =3D=3D 0) { + break; + } + + proc =3D audio_pcm_hw_conv_in(hw, buf, size / hw->info.bytes_per_f= rame); + + samples -=3D proc; + conv +=3D proc; + hw->pcm_ops->put_buffer_in(hw, buf, proc * hw->info.bytes_per_fram= e); + } + + return conv; +} + +static void audio_run_in(AudioMixengBackend *s) +{ + HWVoiceIn *hw =3D NULL; + + if (!audio_get_pdo_in(s->dev)->mixing_engine) { + while ((hw =3D audio_pcm_hw_find_any_enabled_in(s, hw))) { + /* there is exactly 1 sw for each hw with no mixeng */ + SWVoiceIn *sw =3D hw->sw_head.lh_first; + if (sw->active) { + sw->callback.fn(sw->callback.opaque, INT_MAX); + } + } + return; + } + + while ((hw =3D audio_pcm_hw_find_any_enabled_in(s, hw))) { + SWVoiceIn *sw; + size_t captured =3D 0, min; + int pos; + + if (replay_mode !=3D REPLAY_MODE_PLAY) { + captured =3D audio_pcm_hw_run_in( + hw, hw->conv_buf.size - audio_pcm_hw_get_live_in(hw)); + } + + replay_audio_in_start(&captured); + assert(captured <=3D hw->conv_buf.size); + if (replay_mode =3D=3D REPLAY_MODE_PLAY) { + hw->conv_buf.pos =3D (hw->conv_buf.pos + captured) % hw->conv_= buf.size; + } + for (pos =3D (hw->conv_buf.pos - captured + hw->conv_buf.size) % h= w->conv_buf.size; + pos !=3D hw->conv_buf.pos; + pos =3D (pos + 1) % hw->conv_buf.size) { + uint64_t left, right; + + if (replay_mode =3D=3D REPLAY_MODE_RECORD) { + audio_sample_to_uint64(hw->conv_buf.buffer, pos, &left= , &right); + } + replay_audio_in_sample_lr(&left, &right); + if (replay_mode =3D=3D REPLAY_MODE_PLAY) { + audio_sample_from_uint64(hw->conv_buf.buffer, pos, lef= t, right); + } + } + replay_audio_in_finish(); + + min =3D audio_pcm_hw_find_min_in (hw); + hw->total_samples_captured +=3D captured - min; + + for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { + sw->total_hw_samples_acquired -=3D min; + + if (sw->active) { + size_t sw_avail =3D audio_get_avail(sw); + size_t avail; + + avail =3D st_rate_frames_out(sw->rate, sw_avail); + if (avail > 0) { + avail =3D MIN(avail, sw->resample_buf.size); + sw->callback.fn(sw->callback.opaque, + avail * sw->info.bytes_per_frame); + } + } + } + } +} + +static void audio_run_capture(AudioMixengBackend *s) +{ + CaptureVoiceOut *cap; + + for (cap =3D s->cap_head.lh_first; cap; cap =3D cap->entries.le_next) { + size_t live, rpos, captured; + HWVoiceOut *hw =3D &cap->hw; + SWVoiceOut *sw; + + captured =3D live =3D audio_pcm_hw_get_live_out (hw, NULL); + rpos =3D hw->mix_buf.pos; + while (live) { + size_t left =3D hw->mix_buf.size - rpos; + size_t to_capture =3D MIN(live, left); + struct st_sample *src; + struct capture_callback *cb; + + src =3D hw->mix_buf.buffer + rpos; + hw->clip (cap->buf, src, to_capture); + mixeng_clear (src, to_capture); + + for (cb =3D cap->cb_head.lh_first; cb; cb =3D cb->entries.le_n= ext) { + cb->ops.capture (cb->opaque, cap->buf, + to_capture * hw->info.bytes_per_frame); + } + rpos =3D (rpos + to_capture) % hw->mix_buf.size; + live -=3D to_capture; + } + hw->mix_buf.pos =3D rpos; + + for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { + if (!sw->active && sw->empty) { + continue; + } + + 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); + captured =3D sw->total_hw_samples_mixed; + } + + sw->total_hw_samples_mixed -=3D captured; + sw->empty =3D sw->total_hw_samples_mixed =3D=3D 0; + } + } +} + +void audio_run(AudioMixengBackend *s, const char *msg) +{ + audio_run_out(s); + audio_run_in(s); + audio_run_capture(s); + +#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; + } +#endif +} + +void audio_generic_run_buffer_in(HWVoiceIn *hw) +{ + 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); + hw->pos_emul =3D hw->pending_emul =3D 0; + } + + 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); + hw->pending_emul +=3D read; + hw->pos_emul =3D (hw->pos_emul + read) % hw->size_emul; + if (read < read_len) { + break; + } + } +} + +void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size) +{ + size_t start; + + start =3D audio_ring_posb(hw->pos_emul, hw->pending_emul, hw->size_emu= l); + assert(start < hw->size_emul); + + *size =3D MIN(*size, hw->pending_emul); + *size =3D MIN(*size, hw->size_emul - start); + return hw->buf_emul + start; +} + +void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size) +{ + assert(size <=3D hw->pending_emul); + hw->pending_emul -=3D size; +} + +size_t audio_generic_buffer_get_free(HWVoiceOut *hw) +{ + if (hw->buf_emul) { + return hw->size_emul - hw->pending_emul; + } else { + return hw->samples * hw->info.bytes_per_frame; + } +} + +void audio_generic_run_buffer_out(HWVoiceOut *hw) +{ + while (hw->pending_emul) { + size_t write_len, written, start; + + start =3D audio_ring_posb(hw->pos_emul, hw->pending_emul, hw->size= _emul); + assert(start < hw->size_emul); + + write_len =3D MIN(hw->pending_emul, hw->size_emul - start); + + written =3D hw->pcm_ops->write(hw, hw->buf_emul + start, write_len= ); + hw->pending_emul -=3D written; + + if (written < write_len) { + break; + } + } +} + +void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size) +{ + 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); + hw->pos_emul =3D hw->pending_emul =3D 0; + } + + *size =3D MIN(hw->size_emul - hw->pending_emul, + hw->size_emul - hw->pos_emul); + return hw->buf_emul + hw->pos_emul; +} + +size_t audio_generic_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size) +{ + assert(buf =3D=3D hw->buf_emul + hw->pos_emul && + size + hw->pending_emul <=3D hw->size_emul); + + hw->pending_emul +=3D size; + hw->pos_emul =3D (hw->pos_emul + size) % hw->size_emul; + + return size; +} + +size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size) +{ + size_t total =3D 0; + + if (hw->pcm_ops->buffer_get_free) { + size_t free =3D hw->pcm_ops->buffer_get_free(hw); + + size =3D MIN(size, free); + } + + 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); + + if (dst_size =3D=3D 0) { + break; + } + + copy_size =3D MIN(size - total, dst_size); + if (dst) { + memcpy(dst, (char *)buf + total, copy_size); + } + proc =3D hw->pcm_ops->put_buffer_out(hw, dst, copy_size); + total +=3D proc; + + if (proc =3D=3D 0 || proc < copy_size) { + break; + } + } + + return total; +} + +size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size) +{ + size_t total =3D 0; + + if (hw->pcm_ops->run_buffer_in) { + hw->pcm_ops->run_buffer_in(hw); + } + + while (total < size) { + size_t src_size =3D size - total; + void *src =3D hw->pcm_ops->get_buffer_in(hw, &src_size); + + if (src_size =3D=3D 0) { + break; + } + + memcpy((char *)buf + total, src, src_size); + hw->pcm_ops->put_buffer_in(hw, src, src_size); + total +=3D src_size; + } + + return total; +} + +static bool audio_mixeng_backend_realize(AudioBackend *abe, + Audiodev *dev, Error **errp) +{ + AudioMixengBackend *be =3D AUDIO_MIXENG_BACKEND(abe); + audio_driver *drv =3D AUDIO_MIXENG_BACKEND_GET_CLASS(be)->driver; + + be->dev =3D dev; + 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; + } + 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; + } + + audio_init_nb_voices_out(be, drv, 1); + audio_init_nb_voices_in(be, drv, 0); + be->drv =3D drv; + + if (be->dev->timer_period <=3D 0) { + be->period_ticks =3D 1; + } else { + be->period_ticks =3D be->dev->timer_period * (int64_t)SCALE_US; + } + + return true; +} + +static void audio_vm_change_state_handler (void *opaque, bool running, + RunState state) +{ + AudioMixengBackend *s =3D opaque; + HWVoiceOut *hwo =3D NULL; + HWVoiceIn *hwi =3D NULL; + + 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); + } + } + + 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); + } + } + audio_reset_timer (s); +} + +static const VMStateDescription vmstate_audio; + +static const char *audio_mixeng_backend_get_id(AudioBackend *be) +{ + return AUDIO_MIXENG_BACKEND(be)->dev->id; +} + +static CaptureVoiceOut *audio_mixeng_backend_add_capture( + AudioBackend *be, + struct audsettings *as, + struct audio_capture_ops *ops, + void *cb_opaque); + +static void audio_mixeng_backend_del_capture( + AudioBackend *be, + CaptureVoiceOut *cap, + void *cb_opaque); + +static void audio_mixeng_backend_set_volume_out(AudioBackend *be, SWVoiceO= ut *sw, + Volume *vol); +static void audio_mixeng_backend_set_volume_in(AudioBackend *be, SWVoiceIn= *sw, + Volume *vol); + +static void audio_mixeng_backend_class_init(ObjectClass *klass, const void= *data) +{ + AudioBackendClass *be =3D AUDIO_BACKEND_CLASS(klass); + + be->realize =3D audio_mixeng_backend_realize; + be->get_id =3D audio_mixeng_backend_get_id; + be->open_in =3D audio_mixeng_backend_open_in; + be->open_out =3D audio_mixeng_backend_open_out; + be->close_in =3D audio_mixeng_backend_close_in; + be->close_out =3D audio_mixeng_backend_close_out; + be->is_active_out =3D audio_mixeng_backend_is_active_out; + be->is_active_in =3D audio_mixeng_backend_is_active_in; + be->set_active_out =3D audio_mixeng_backend_set_active_out; + be->set_active_in =3D audio_mixeng_backend_set_active_in; + be->set_volume_out =3D audio_mixeng_backend_set_volume_out; + be->set_volume_in =3D audio_mixeng_backend_set_volume_in; + be->read =3D audio_mixeng_backend_read; + be->write =3D audio_mixeng_backend_write; + be->get_buffer_size_out =3D audio_mixeng_backend_get_buffer_size_out; + be->add_capture =3D audio_mixeng_backend_add_capture; + be->del_capture =3D audio_mixeng_backend_del_capture; +} + +static void audio_mixeng_backend_init(Object *obj) +{ + AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(obj); + + QLIST_INIT(&s->hw_head_out); + QLIST_INIT(&s->hw_head_in); + QLIST_INIT(&s->cap_head); + s->ts =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s); + + s->vmse =3D qemu_add_vm_change_state_handler(audio_vm_change_state_han= dler, s); + assert(s->vmse !=3D NULL); + + vmstate_register_any(NULL, &vmstate_audio, s); +} + +static void audio_mixeng_backend_finalize(Object *obj) +{ + AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(obj); + HWVoiceOut *hwo, *hwon; + HWVoiceIn *hwi, *hwin; + + QLIST_FOREACH_SAFE(hwo, &s->hw_head_out, entries, hwon) { + SWVoiceCap *sc; + + if (hwo->enabled && hwo->pcm_ops->enable_out) { + hwo->pcm_ops->enable_out(hwo, false); + } + hwo->pcm_ops->fini_out (hwo); + + for (sc =3D hwo->cap_head.lh_first; sc; sc =3D sc->entries.le_next= ) { + CaptureVoiceOut *cap =3D sc->cap; + struct capture_callback *cb; + + for (cb =3D cap->cb_head.lh_first; cb; cb =3D cb->entries.le_n= ext) { + cb->ops.destroy (cb->opaque); + } + } + QLIST_REMOVE(hwo, entries); + } + + 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); + } + hwi->pcm_ops->fini_in (hwi); + QLIST_REMOVE(hwi, entries); + } + + if (s->drv) { + s->drv->fini (s->drv_opaque); + s->drv =3D NULL; + } + + if (s->dev) { + qapi_free_Audiodev(s->dev); + s->dev =3D NULL; + } + + if (s->ts) { + timer_free(s->ts); + s->ts =3D NULL; + } + + if (s->vmse) { + qemu_del_vm_change_state_handler(s->vmse); + s->vmse =3D NULL; + } + + vmstate_unregister(NULL, &vmstate_audio, s); +} + +static bool vmstate_audio_needed(void *opaque) +{ + /* + * Never needed, this vmstate only exists in case + * an old qemu sends it to us. + */ + return false; +} + +static const VMStateDescription vmstate_audio =3D { + .name =3D "audio", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D vmstate_audio_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_END_OF_LIST() + } +}; + +static struct audio_pcm_ops capture_pcm_ops; + +static CaptureVoiceOut *audio_mixeng_backend_add_capture( + AudioBackend *be, + struct audsettings *as, + struct audio_capture_ops *ops, + void *cb_opaque) +{ + AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(be); + CaptureVoiceOut *cap; + struct capture_callback *cb; + + if (!s) { + error_report("Capturing without setting an audiodev is not support= ed"); + abort(); + } + + if (!audio_get_pdo_out(s->dev)->mixing_engine) { + dolog("Can't capture with mixeng disabled\n"); + return NULL; + } + + if (audio_validate_settings (as)) { + dolog ("Invalid settings were passed when trying to add capture\n"= ); + audio_print_settings (as); + return NULL; + } + + cb =3D g_malloc0(sizeof(*cb)); + cb->ops =3D *ops; + cb->opaque =3D cb_opaque; + + cap =3D audio_pcm_capture_find_specific(s, as); + if (cap) { + QLIST_INSERT_HEAD (&cap->cb_head, cb, entries); + } else { + HWVoiceOut *hw; + + cap =3D g_malloc0(sizeof(*cap)); + + 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); + + /* XXX find a more elegant way */ + hw->samples =3D 4096 * 4; + audio_pcm_hw_alloc_resources_out(hw); + + audio_pcm_init_info (&hw->info, as); + + cap->buf =3D g_malloc0_n(hw->mix_buf.size, hw->info.bytes_per_fram= e); + + if (hw->info.is_float) { + 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] + [hw->info.swap_endianness] + [audio_bits_to_index(hw->info.bits)]; + } + + QLIST_INSERT_HEAD (&s->cap_head, cap, entries); + QLIST_INSERT_HEAD (&cap->cb_head, cb, entries); + + QLIST_FOREACH(hw, &s->hw_head_out, entries) { + audio_attach_capture (hw); + } + } + + return cap; +} + +static void audio_mixeng_backend_del_capture( + AudioBackend *be, + CaptureVoiceOut *cap, + void *cb_opaque) +{ + struct capture_callback *cb; + + for (cb =3D cap->cb_head.lh_first; cb; cb =3D cb->entries.le_next) { + if (cb->opaque =3D=3D cb_opaque) { + cb->ops.destroy (cb_opaque); + QLIST_REMOVE (cb, entries); + g_free (cb); + + if (!cap->cb_head.lh_first) { + SWVoiceOut *sw =3D cap->hw.sw_head.lh_first, *sw1; + + while (sw) { + SWVoiceCap *sc =3D (SWVoiceCap *) sw; +#ifdef DEBUG_CAPTURE + dolog ("freeing %s\n", sw->name); +#endif + + sw1 =3D sw->entries.le_next; + if (sw->rate) { + st_rate_stop (sw->rate); + sw->rate =3D NULL; + } + QLIST_REMOVE (sw, entries); + QLIST_REMOVE (sc, entries); + g_free (sc); + sw =3D sw1; + } + QLIST_REMOVE (cap, entries); + g_free(cap->hw.mix_buf.buffer); + g_free (cap->buf); + g_free (cap); + } + return; + } + } +} + +static void audio_mixeng_backend_set_volume_out(AudioBackend *be, SWVoiceO= ut *sw, + Volume *vol) +{ + if (sw) { + HWVoiceOut *hw =3D sw->hw; + + 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; + + if (hw->pcm_ops->volume_out) { + hw->pcm_ops->volume_out(hw, vol); + } + } +} + +static void audio_mixeng_backend_set_volume_in(AudioBackend *be, SWVoiceIn= *sw, + Volume *vol) +{ + if (sw) { + HWVoiceIn *hw =3D sw->hw; + + 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; + + if (hw->pcm_ops->volume_in) { + hw->pcm_ops->volume_in(hw, vol); + } + } +} + +audsettings audiodev_to_audsettings(AudiodevPerDirectionOptions *pdo) +{ + return (audsettings) { + .freq =3D pdo->frequency, + .nchannels =3D pdo->channels, + .fmt =3D pdo->format, + .endianness =3D HOST_BIG_ENDIAN, + }; +} + +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) +{ + uint64_t usecs =3D pdo->has_buffer_length ? pdo->buffer_length : def_u= secs; + return (as->freq * usecs + 500000) / 1000000; +} + +/* samples =3D channels * frames =3D channels * freq * usec / 1e6 */ +int audio_buffer_samples(AudiodevPerDirectionOptions *pdo, + audsettings *as, int def_usecs) +{ + return as->nchannels * audio_buffer_frames(pdo, as, def_usecs); +} + +/* + * bytes =3D bytes_per_sample * samples =3D + * bytes_per_sample * channels * freq * usec / 1e6 + */ +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); +} + +void audio_rate_start(RateCtl *rate) +{ + memset(rate, 0, sizeof(RateCtl)); + rate->start_ticks =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); +} + +size_t audio_rate_peek_bytes(RateCtl *rate, struct audio_pcm_info *info) +{ + int64_t now; + int64_t ticks; + int64_t bytes; + int64_t frames; + + now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + ticks =3D now - rate->start_ticks; + bytes =3D muldiv64(ticks, info->bytes_per_second, NANOSECONDS_PER_SECO= ND); + frames =3D (bytes - rate->bytes_sent) / info->bytes_per_frame; + rate->peeked_frames =3D frames; + + return frames < 0 ? 0 : frames * info->bytes_per_frame; +} + +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); + audio_rate_start(rate); + } + + rate->bytes_sent +=3D bytes_used; +} + +size_t audio_rate_get_bytes(RateCtl *rate, struct audio_pcm_info *info, + size_t bytes_avail) +{ + size_t bytes; + + bytes =3D audio_rate_peek_bytes(rate, info); + bytes =3D MIN(bytes, bytes_avail); + audio_rate_add_bytes(rate, bytes); + + return bytes; +} + +static const TypeInfo audio_types[] =3D { + { + .name =3D TYPE_AUDIO_MIXENG_BACKEND, + .parent =3D TYPE_AUDIO_BACKEND, + .instance_size =3D sizeof(AudioMixengBackend), + .instance_init =3D audio_mixeng_backend_init, + .instance_finalize =3D audio_mixeng_backend_finalize, + .class_size =3D sizeof(AudioMixengBackendClass), + .class_init =3D audio_mixeng_backend_class_init, + }, +}; + +DEFINE_TYPES(audio_types) diff --git a/audio/audio.c b/audio/audio.c index 22e55ac9758..6f10ee470ee 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1,1751 +1,55 @@ -/* - * QEMU Audio subsystem - * - * Copyright (c) 2003-2005 Vassili Karpov (malc) - * - * Permission is hereby granted, free of charge, to any person obtaining a= copy - * of this software and associated documentation files (the "Software"), t= o deal - * in the Software without restriction, including without limitation the r= ights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included= in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN - * THE SOFTWARE. - */ - -#include "qemu/osdep.h" -#include "qemu/audio.h" -#include "migration/vmstate.h" -#include "qemu/timer.h" -#include "qapi/error.h" -#include "qapi/clone-visitor.h" -#include "qapi/qobject-input-visitor.h" -#include "qapi/qapi-visit-audio.h" -#include "qapi/qapi-commands-audio.h" -#include "qobject/qdict.h" -#include "qemu/bswap.h" -#include "qemu/error-report.h" -#include "qemu/log.h" -#include "qemu/module.h" -#include "qemu/help_option.h" -#include "qom/object.h" -#include "system/system.h" -#include "system/replay.h" -#include "system/runstate.h" -#include "trace.h" - -#define AUDIO_CAP "audio" -#include "audio_int.h" - -/* #define DEBUG_LIVE */ -/* #define DEBUG_OUT */ -/* #define DEBUG_CAPTURE */ -/* #define DEBUG_POLL */ - -#define SW_NAME(sw) (sw)->name ? (sw)->name : "unknown" - - -/* Order of CONFIG_AUDIO_DRIVERS is import. - The 1st one is the one used by default, that is the reason - that we generate the list. -*/ -const char *audio_prio_list[] =3D { -#ifdef CONFIG_GIO - "dbus", -#endif - "spice", - CONFIG_AUDIO_DRIVERS - "none", - NULL -}; - -typedef struct AudiodevListEntry { - Audiodev *dev; - QSIMPLEQ_ENTRY(AudiodevListEntry) next; -} AudiodevListEntry; - -typedef QSIMPLEQ_HEAD(, AudiodevListEntry) AudiodevListHead; - -static AudiodevListHead audiodevs =3D - QSIMPLEQ_HEAD_INITIALIZER(audiodevs); -static AudiodevListHead default_audiodevs =3D - QSIMPLEQ_HEAD_INITIALIZER(default_audiodevs); - -static AudioBackendClass *audio_be_class_by_name(const char *name) -{ - g_autofree char *tname =3D g_strconcat("audio-", name, NULL); - ObjectClass *oc =3D module_object_class_by_name(tname); - - if (!oc || !object_class_dynamic_cast(oc, TYPE_AUDIO_BACKEND)) { - return NULL; - } - - return AUDIO_BACKEND_CLASS(oc); -} - -static AudioBackend *default_audio_be; - -const struct mixeng_volume nominal_volume =3D { - .mute =3D 0, -#ifdef FLOAT_MIXENG - .r =3D 1.0, - .l =3D 1.0, -#else - .r =3D 1ULL << 32, - .l =3D 1ULL << 32, -#endif -}; - -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; -} - -static inline int audio_bits_to_index (int bits) -{ - switch (bits) { - case 8: - return 0; - - case 16: - return 1; - - case 32: - return 2; - - default: - audio_bug ("bits_to_index", 1); - AUD_log (NULL, "invalid bits %d\n", bits); - return 0; - } -} - -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 void audio_print_settings (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"); - 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"); -} - -static int audio_validate_settings (const struct audsettings *as) -{ - int invalid; - - invalid =3D as->nchannels < 1; - invalid |=3D as->endianness !=3D 0 && as->endianness !=3D 1; - - switch (as->fmt) { - case AUDIO_FORMAT_S8: - case AUDIO_FORMAT_U8: - case AUDIO_FORMAT_S16: - case AUDIO_FORMAT_U16: - case AUDIO_FORMAT_S32: - case AUDIO_FORMAT_U32: - case AUDIO_FORMAT_F32: - break; - default: - invalid =3D 1; - break; - } - - invalid |=3D as->freq <=3D 0; - return invalid ? -1 : 0; -} - -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 - && 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); -} - -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->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_second =3D info->freq * info->bytes_per_frame; - info->swap_endianness =3D (as->endianness !=3D HOST_BIG_ENDIAN); -} - -void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int= len) -{ - if (!len) { - return; - } - - 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; - - case 32: - { - int i; - uint32_t *p =3D buf; - int32_t s =3D INT32_MAX; - - if (info->swap_endianness) { - s =3D bswap32 (s); - } - - for (i =3D 0; i < len * info->nchannels; i++) { - p[i] =3D s; - } - } - break; - - default: - AUD_log (NULL, "audio_pcm_info_clear_buf: invalid bits %d\n", - info->bits); - break; - } - } -} - -/* - * Capture - */ -static CaptureVoiceOut *audio_pcm_capture_find_specific(AudioMixengBackend= *s, - struct audsettings= *as) -{ - CaptureVoiceOut *cap; - - for (cap =3D s->cap_head.lh_first; cap; cap =3D cap->entries.le_next) { - if (audio_pcm_info_eq (&cap->hw.info, as)) { - return cap; - } - } - return NULL; -} - -static void audio_notify_capture (CaptureVoiceOut *cap, audcnotification_e= cmd) -{ - struct capture_callback *cb; - -#ifdef DEBUG_CAPTURE - dolog ("notification %d sent\n", cmd); -#endif - for (cb =3D cap->cb_head.lh_first; cb; cb =3D cb->entries.le_next) { - cb->ops.notify (cb->opaque, cmd); - } -} - -static void audio_capture_maybe_changed(CaptureVoiceOut *cap, bool enabled) -{ - if (cap->hw.enabled !=3D enabled) { - audcnotification_e cmd; - cap->hw.enabled =3D enabled; - cmd =3D enabled ? AUD_CNOTIFY_ENABLE : AUD_CNOTIFY_DISABLE; - audio_notify_capture (cap, cmd); - } -} - -static void audio_recalc_and_notify_capture (CaptureVoiceOut *cap) -{ - HWVoiceOut *hw =3D &cap->hw; - SWVoiceOut *sw; - bool enabled =3D false; - - for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { - if (sw->active) { - enabled =3D true; - break; - } - } - audio_capture_maybe_changed (cap, enabled); -} - -static void audio_detach_capture (HWVoiceOut *hw) -{ - SWVoiceCap *sc =3D hw->cap_head.lh_first; - - while (sc) { - SWVoiceCap *sc1 =3D sc->entries.le_next; - SWVoiceOut *sw =3D &sc->sw; - CaptureVoiceOut *cap =3D sc->cap; - int was_active =3D sw->active; - - if (sw->rate) { - st_rate_stop (sw->rate); - sw->rate =3D NULL; - } - - QLIST_REMOVE (sw, entries); - QLIST_REMOVE (sc, entries); - g_free (sc); - if (was_active) { - /* We have removed soft voice from the capture: - this might have changed the overall status of the capture - since this might have been the only active voice */ - audio_recalc_and_notify_capture (cap); - } - sc =3D sc1; - } -} - -static int audio_attach_capture (HWVoiceOut *hw) -{ - AudioMixengBackend *s =3D hw->s; - CaptureVoiceOut *cap; - - audio_detach_capture (hw); - for (cap =3D s->cap_head.lh_first; cap; cap =3D cap->entries.le_next) { - SWVoiceCap *sc; - SWVoiceOut *sw; - HWVoiceOut *hw_cap =3D &cap->hw; - - sc =3D g_malloc0(sizeof(*sc)); - - sc->cap =3D cap; - sw =3D &sc->sw; - sw->hw =3D hw_cap; - sw->info =3D hw->info; - sw->empty =3D true; - sw->active =3D hw->enabled; - sw->vol =3D nominal_volume; - sw->rate =3D st_rate_start (sw->info.freq, hw_cap->info.freq); - QLIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries); - 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 - if (sw->active) { - audio_capture_maybe_changed (cap, 1); - } - } - return 0; -} - -/* - * Hard voice (capture) - */ -static size_t audio_pcm_hw_find_min_in (HWVoiceIn *hw) -{ - SWVoiceIn *sw; - size_t m =3D hw->total_samples_captured; - - for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { - if (sw->active) { - m =3D MIN (m, sw->total_hw_samples_acquired); - } - } - return m; -} - -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); - return 0; - } - return live; -} - -static size_t audio_pcm_hw_conv_in(HWVoiceIn *hw, void *pcm_buf, size_t sa= mples) -{ - size_t conv =3D 0; - STSampleBuffer *conv_buf =3D &hw->conv_buf; - - while (samples) { - uint8_t *src =3D advance(pcm_buf, conv * hw->info.bytes_per_frame); - size_t proc =3D MIN(samples, conv_buf->size - conv_buf->pos); - - hw->conv(conv_buf->buffer + conv_buf->pos, src, proc); - conv_buf->pos =3D (conv_buf->pos + proc) % conv_buf->size; - samples -=3D proc; - conv +=3D proc; - } - - return conv; -} - -/* - * Soft voice (capture) - */ -static void audio_pcm_sw_resample_in(SWVoiceIn *sw, - size_t frames_in_max, size_t frames_out_max, - size_t *total_in, size_t *total_out) -{ - HWVoiceIn *hw =3D sw->hw; - struct st_sample *src, *dst; - size_t live, rpos, frames_in, frames_out; - - live =3D hw->total_samples_captured - sw->total_hw_samples_acquired; - rpos =3D audio_ring_posb(hw->conv_buf.pos, live, hw->conv_buf.size); - - /* resample conv_buf from rpos to end of buffer */ - src =3D hw->conv_buf.buffer + rpos; - frames_in =3D MIN(frames_in_max, hw->conv_buf.size - rpos); - dst =3D sw->resample_buf.buffer; - frames_out =3D frames_out_max; - st_rate_flow(sw->rate, src, dst, &frames_in, &frames_out); - rpos +=3D frames_in; - *total_in =3D frames_in; - *total_out =3D frames_out; - - /* resample conv_buf from start of buffer if there are input frames le= ft */ - if (frames_in_max - frames_in && rpos =3D=3D hw->conv_buf.size) { - src =3D hw->conv_buf.buffer; - frames_in =3D frames_in_max - frames_in; - dst +=3D frames_out; - frames_out =3D frames_out_max - frames_out; - st_rate_flow(sw->rate, src, dst, &frames_in, &frames_out); - *total_in +=3D frames_in; - *total_out +=3D frames_out; - } -} - -static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t buf_len) -{ - HWVoiceIn *hw =3D sw->hw; - size_t live, frames_out_max, total_in, total_out; - - live =3D hw->total_samples_captured - sw->total_hw_samples_acquired; - 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); - return 0; - } - - frames_out_max =3D MIN(buf_len / sw->info.bytes_per_frame, - sw->resample_buf.size); - - audio_pcm_sw_resample_in(sw, live, frames_out_max, &total_in, &total_o= ut); - - if (!hw->pcm_ops->volume_in) { - mixeng_volume(sw->resample_buf.buffer, total_out, &sw->vol); - } - sw->clip(buf, sw->resample_buf.buffer, total_out); - - sw->total_hw_samples_acquired +=3D total_in; - return total_out * sw->info.bytes_per_frame; -} - -/* - * Hard voice (playback) - */ -static size_t audio_pcm_hw_find_min_out (HWVoiceOut *hw, int *nb_livep) -{ - SWVoiceOut *sw; - size_t m =3D SIZE_MAX; - int nb_live =3D 0; - - for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { - if (sw->active || !sw->empty) { - m =3D MIN (m, sw->total_hw_samples_mixed); - nb_live +=3D 1; - } - } - - *nb_livep =3D nb_live; - return m; -} - -static size_t audio_pcm_hw_get_live_out (HWVoiceOut *hw, int *nb_live) -{ - size_t smin; - int nb_live1; - - smin =3D audio_pcm_hw_find_min_out (hw, &nb_live1); - if (nb_live) { - *nb_live =3D nb_live1; - } - - if (nb_live1) { - size_t live =3D smin; - - if (audio_bug(__func__, live > hw->mix_buf.size)) { - dolog("live=3D%zu hw->mix_buf.size=3D%zu\n", live, hw->mix_buf= .size); - return 0; - } - return live; - } - return 0; -} - -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; -} - -static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, size_t le= n) -{ - size_t clipped =3D 0; - size_t pos =3D hw->mix_buf.pos; - - while (len) { - st_sample *src =3D hw->mix_buf.buffer + pos; - uint8_t *dst =3D advance(pcm_buf, clipped * hw->info.bytes_per_fra= me); - size_t samples_till_end_of_buf =3D hw->mix_buf.size - pos; - size_t samples_to_clip =3D MIN(len, samples_till_end_of_buf); - - hw->clip(dst, src, samples_to_clip); - - pos =3D (pos + samples_to_clip) % hw->mix_buf.size; - len -=3D samples_to_clip; - clipped +=3D samples_to_clip; - } -} - -/* - * Soft voice (playback) - */ -static void audio_pcm_sw_resample_out(SWVoiceOut *sw, - size_t frames_in_max, size_t frames_out_max, - size_t *total_in, size_t *total_out) -{ - HWVoiceOut *hw =3D sw->hw; - struct st_sample *src, *dst; - size_t live, wpos, frames_in, frames_out; - - live =3D sw->total_hw_samples_mixed; - wpos =3D (hw->mix_buf.pos + live) % hw->mix_buf.size; - - /* write to mix_buf from wpos to end of buffer */ - src =3D sw->resample_buf.buffer; - frames_in =3D frames_in_max; - dst =3D hw->mix_buf.buffer + wpos; - frames_out =3D MIN(frames_out_max, hw->mix_buf.size - wpos); - st_rate_flow_mix(sw->rate, src, dst, &frames_in, &frames_out); - wpos +=3D frames_out; - *total_in =3D frames_in; - *total_out =3D frames_out; - - /* write to mix_buf from start of buffer if there are input frames lef= t */ - if (frames_in_max - frames_in > 0 && wpos =3D=3D hw->mix_buf.size) { - src +=3D frames_in; - frames_in =3D frames_in_max - frames_in; - dst =3D hw->mix_buf.buffer; - frames_out =3D frames_out_max - frames_out; - st_rate_flow_mix(sw->rate, src, dst, &frames_in, &frames_out); - *total_in +=3D frames_in; - *total_out +=3D frames_out; - } -} - -static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t buf_len) -{ - HWVoiceOut *hw =3D sw->hw; - size_t live, dead, hw_free, sw_max, fe_max; - size_t frames_in_max, frames_out_max, total_in, total_out; - - 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); - return 0; - } - - if (live =3D=3D hw->mix_buf.size) { -#ifdef DEBUG_OUT - dolog ("%s is full %zu\n", sw->name, live); -#endif - return 0; - } - - dead =3D hw->mix_buf.size - live; - hw_free =3D audio_pcm_hw_get_free(hw); - hw_free =3D hw_free > live ? hw_free - live : 0; - frames_out_max =3D MIN(dead, hw_free); - sw_max =3D st_rate_frames_in(sw->rate, frames_out_max); - fe_max =3D MIN(buf_len / sw->info.bytes_per_frame + sw->resample_buf.p= os, - sw->resample_buf.size); - frames_in_max =3D MIN(sw_max, fe_max); - - if (!frames_in_max) { - return 0; - } - - if (frames_in_max > sw->resample_buf.pos) { - sw->conv(sw->resample_buf.buffer + sw->resample_buf.pos, - buf, frames_in_max - sw->resample_buf.pos); - if (!sw->hw->pcm_ops->volume_out) { - mixeng_volume(sw->resample_buf.buffer + sw->resample_buf.pos, - frames_in_max - sw->resample_buf.pos, &sw->vol); - } - } - - audio_pcm_sw_resample_out(sw, frames_in_max, frames_out_max, - &total_in, &total_out); - - sw->total_hw_samples_mixed +=3D total_out; - sw->empty =3D sw->total_hw_samples_mixed =3D=3D 0; - - /* - * Upsampling may leave one audio frame in the resample buffer. Decrem= ent - * total_in by one if there was a leftover frame from the previous res= ample - * pass in the resample buffer. Increment total_in by one if the curre= nt - * resample pass left one frame in the resample buffer. - */ - if (frames_in_max - total_in =3D=3D 1) { - /* copy one leftover audio frame to the beginning of the buffer */ - *sw->resample_buf.buffer =3D *(sw->resample_buf.buffer + total_in); - total_in +=3D 1 - sw->resample_buf.pos; - sw->resample_buf.pos =3D 1; - } else if (total_in >=3D sw->resample_buf.pos) { - total_in -=3D sw->resample_buf.pos; - sw->resample_buf.pos =3D 0; - } - -#ifdef DEBUG_OUT - dolog ( - "%s: write size %zu written %zu total mixed %zu\n", - SW_NAME(sw), - buf_len / sw->info.bytes_per_frame, - total_in, - sw->total_hw_samples_mixed - ); -#endif - - return total_in * sw->info.bytes_per_frame; -} - -#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, - info->nchannels); -} -#endif - -#define DAC -#include "audio_template.h" -#undef DAC -#include "audio_template.h" - -/* - * Timer - */ -static int audio_is_timer_needed(AudioMixengBackend *s) -{ - HWVoiceIn *hwi =3D NULL; - HWVoiceOut *hwo =3D NULL; - - while ((hwo =3D audio_pcm_hw_find_any_enabled_out(s, hwo))) { - if (!hwo->poll_mode) { - return 1; - } - } - while ((hwi =3D audio_pcm_hw_find_any_enabled_in(s, hwi))) { - if (!hwi->poll_mode) { - return 1; - } - } - return 0; -} - -static void audio_reset_timer(AudioMixengBackend *s) -{ - if (audio_is_timer_needed(s)) { - timer_mod_anticipate_ns(s->ts, - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + s->period_ticks); - if (!s->timer_running) { - s->timer_running =3D true; - s->timer_last =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - trace_audio_timer_start(s->period_ticks / SCALE_MS); - } - } else { - timer_del(s->ts); - if (s->timer_running) { - s->timer_running =3D false; - trace_audio_timer_stop(); - } - } -} - -static void audio_timer (void *opaque) -{ - int64_t now, diff; - AudioMixengBackend *s =3D opaque; - - now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - diff =3D now - s->timer_last; - if (diff > s->period_ticks * 3 / 2) { - trace_audio_timer_delayed(diff / SCALE_MS); - } - s->timer_last =3D now; - - audio_run(s, "timer"); - audio_reset_timer(s); -} - -/* - * Public API - */ -static size_t audio_mixeng_backend_write(AudioBackend *be, SWVoiceOut *sw, - void *buf, size_t size) -{ - HWVoiceOut *hw; - - if (!sw) { - /* XXX: Consider options */ - return size; - } - hw =3D sw->hw; - - if (!hw->enabled) { - dolog("Writing to disabled voice %s\n", SW_NAME(sw)); - return 0; - } - - 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); - } -} - -static size_t audio_mixeng_backend_read(AudioBackend *be, - SWVoiceIn *sw, void *buf, size_t s= ize) -{ - HWVoiceIn *hw; - - if (!sw) { - /* XXX: Consider options */ - return size; - } - hw =3D sw->hw; - - if (!hw->enabled) { - dolog("Reading from disabled voice %s\n", SW_NAME(sw)); - return 0; - } - - 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); - } - -} - -static int audio_mixeng_backend_get_buffer_size_out(AudioBackend *be, SWVo= iceOut *sw) -{ - if (!sw) { - return 0; - } - - if (audio_get_pdo_out(sw->s->dev)->mixing_engine) { - return sw->resample_buf.size * sw->info.bytes_per_frame; - } - - return sw->hw->samples * sw->hw->info.bytes_per_frame; -} - -static void audio_mixeng_backend_set_active_out(AudioBackend *be, SWVoiceO= ut *sw, - bool on) -{ - HWVoiceOut *hw; - - if (!sw) { - return; - } - - hw =3D sw->hw; - if (sw->active !=3D on) { - AudioMixengBackend *s =3D sw->s; - SWVoiceOut *temp_sw; - SWVoiceCap *sc; - - if (on) { - 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); - } - audio_reset_timer (s); - } - } - } else { - if (hw->enabled) { - int nb_active =3D 0; - - for (temp_sw =3D hw->sw_head.lh_first; temp_sw; - temp_sw =3D temp_sw->entries.le_next) { - nb_active +=3D temp_sw->active !=3D 0; - } - - hw->pending_disable =3D nb_active =3D=3D 1; - } - } - - for (sc =3D hw->cap_head.lh_first; sc; sc =3D sc->entries.le_next)= { - sc->sw.active =3D hw->enabled; - if (hw->enabled) { - audio_capture_maybe_changed (sc->cap, 1); - } - } - sw->active =3D on; - } - -} - -static void audio_mixeng_backend_set_active_in(AudioBackend *be, SWVoiceIn= *sw, bool on) -{ - HWVoiceIn *hw; - - if (!sw) { - return; - } - - hw =3D sw->hw; - if (sw->active !=3D on) { - AudioMixengBackend *s =3D sw->s; - SWVoiceIn *temp_sw; - - 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); - } - audio_reset_timer (s); - } - } - sw->total_hw_samples_acquired =3D hw->total_samples_captured; - } else { - if (hw->enabled) { - int nb_active =3D 0; - - for (temp_sw =3D hw->sw_head.lh_first; temp_sw; - temp_sw =3D temp_sw->entries.le_next) { - nb_active +=3D temp_sw->active !=3D 0; - } - - if (nb_active =3D=3D 1) { - hw->enabled =3D false; - if (hw->pcm_ops->enable_in) { - hw->pcm_ops->enable_in(hw, false); - } - } - } - } - sw->active =3D on; - } -} - -static size_t audio_get_avail(SWVoiceIn *sw) -{ - size_t live; - - if (!sw) { - return 0; - } - - 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); - return 0; - } - - ldebug ( - "%s: get_avail live %zu frontend frames %u\n", - SW_NAME (sw), - live, st_rate_frames_out(sw->rate, live) - ); - - return live; -} - -static size_t audio_get_free(SWVoiceOut *sw) -{ - size_t live, dead; - - if (!sw) { - return 0; - } - - live =3D sw->total_hw_samples_mixed; - - if (audio_bug(__func__, live > sw->hw->mix_buf.size)) { - dolog("live=3D%zu sw->hw->mix_buf.size=3D%zu\n", live, - sw->hw->mix_buf.size); - return 0; - } - - dead =3D sw->hw->mix_buf.size - live; - -#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 - - return dead; -} - -static void audio_capture_mix_and_clear(HWVoiceOut *hw, size_t rpos, - size_t samples) -{ - size_t n; - - if (hw->enabled) { - SWVoiceCap *sc; - - for (sc =3D hw->cap_head.lh_first; sc; sc =3D sc->entries.le_next)= { - SWVoiceOut *sw =3D &sc->sw; - size_t rpos2 =3D rpos; - - n =3D samples; - while (n) { - size_t till_end_of_hw =3D hw->mix_buf.size - rpos2; - size_t to_read =3D MIN(till_end_of_hw, n); - size_t live, frames_in, frames_out; - - sw->resample_buf.buffer =3D hw->mix_buf.buffer + rpos2; - sw->resample_buf.size =3D to_read; - live =3D sw->total_hw_samples_mixed; - - audio_pcm_sw_resample_out(sw, - to_read, sw->hw->mix_buf.size - = live, - &frames_in, &frames_out); - - sw->total_hw_samples_mixed +=3D frames_out; - sw->empty =3D sw->total_hw_samples_mixed =3D=3D 0; - - if (to_read - frames_in) { - dolog("Could not mix %zu frames into a capture " - "buffer, mixed %zu\n", - to_read, frames_in); - break; - } - n -=3D to_read; - rpos2 =3D (rpos2 + to_read) % hw->mix_buf.size; - } - } - } - - n =3D MIN(samples, hw->mix_buf.size - rpos); - mixeng_clear(hw->mix_buf.buffer + rpos, n); - mixeng_clear(hw->mix_buf.buffer, samples - n); -} - -static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, size_t live) -{ - size_t clipped =3D 0; - - 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); - - if (size =3D=3D 0) { - break; - } - - decr =3D MIN(size / hw->info.bytes_per_frame, 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= ) / - hw->info.bytes_per_frame; - - live -=3D proc; - clipped +=3D proc; - hw->mix_buf.pos =3D (hw->mix_buf.pos + proc) % hw->mix_buf.size; - - if (proc =3D=3D 0 || proc < decr) { - break; - } - } - - if (hw->pcm_ops->run_buffer_out) { - hw->pcm_ops->run_buffer_out(hw); - } - - return clipped; -} - -static void audio_run_out(AudioMixengBackend *s) -{ - HWVoiceOut *hw =3D NULL; - SWVoiceOut *sw; - - while ((hw =3D audio_pcm_hw_find_any_enabled_out(s, hw))) { - size_t played, live, prev_rpos; - size_t hw_free =3D audio_pcm_hw_get_free(hw); - int nb_live; - - if (!audio_get_pdo_out(s->dev)->mixing_engine) { - /* there is exactly 1 sw for each hw with no mixeng */ - sw =3D hw->sw_head.lh_first; - - 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 (sw->active) { - sw->callback.fn(sw->callback.opaque, - hw_free * sw->info.bytes_per_frame); - } - - if (hw->pcm_ops->run_buffer_out) { - hw->pcm_ops->run_buffer_out(hw); - } - - continue; - } - - for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { - if (sw->active) { - size_t sw_free =3D audio_get_free(sw); - size_t free; - - if (hw_free > sw->total_hw_samples_mixed) { - free =3D st_rate_frames_in(sw->rate, - MIN(sw_free, hw_free - sw->total_hw_samples_mixed)= ); - } else { - free =3D 0; - } - if (free > sw->resample_buf.pos) { - free =3D MIN(free, sw->resample_buf.size) - - sw->resample_buf.pos; - sw->callback.fn(sw->callback.opaque, - free * sw->info.bytes_per_frame); - } - } - } - - live =3D audio_pcm_hw_get_live_out (hw, &nb_live); - if (!nb_live) { - live =3D 0; - } - - if (audio_bug(__func__, live > hw->mix_buf.size)) { - dolog("live=3D%zu hw->mix_buf.size=3D%zu\n", live, hw->mix_buf= .size); - continue; - } - - if (hw->pending_disable && !nb_live) { - SWVoiceCap *sc; -#ifdef DEBUG_OUT - dolog ("Disabling voice\n"); -#endif - hw->enabled =3D false; - hw->pending_disable =3D false; - if (hw->pcm_ops->enable_out) { - hw->pcm_ops->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; - audio_recalc_and_notify_capture (sc->cap); - } - continue; - } - - if (!live) { - if (hw->pcm_ops->run_buffer_out) { - hw->pcm_ops->run_buffer_out(hw); - } - continue; - } - - prev_rpos =3D hw->mix_buf.pos; - played =3D audio_pcm_hw_run_out(hw, live); - replay_audio_out(&played); - if (audio_bug(__func__, hw->mix_buf.pos >=3D hw->mix_buf.size)) { - dolog("hw->mix_buf.pos=3D%zu hw->mix_buf.size=3D%zu played=3D%= zu\n", - hw->mix_buf.pos, hw->mix_buf.size, played); - hw->mix_buf.pos =3D 0; - } - -#ifdef DEBUG_OUT - dolog("played=3D%zu\n", played); -#endif - - if (played) { - audio_capture_mix_and_clear (hw, prev_rpos, played); - } - - for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { - if (!sw->active && sw->empty) { - continue; - } - - 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); - played =3D sw->total_hw_samples_mixed; - } - - sw->total_hw_samples_mixed -=3D played; - - if (!sw->total_hw_samples_mixed) { - sw->empty =3D true; - } - } - } -} - -static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, size_t samples) -{ - size_t conv =3D 0; - - if (hw->pcm_ops->run_buffer_in) { - hw->pcm_ops->run_buffer_in(hw); - } - - 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); - - assert(size % hw->info.bytes_per_frame =3D=3D 0); - if (size =3D=3D 0) { - break; - } - - proc =3D audio_pcm_hw_conv_in(hw, buf, size / hw->info.bytes_per_f= rame); - - samples -=3D proc; - conv +=3D proc; - hw->pcm_ops->put_buffer_in(hw, buf, proc * hw->info.bytes_per_fram= e); - } - - return conv; -} - -static void audio_run_in(AudioMixengBackend *s) -{ - HWVoiceIn *hw =3D NULL; - - if (!audio_get_pdo_in(s->dev)->mixing_engine) { - while ((hw =3D audio_pcm_hw_find_any_enabled_in(s, hw))) { - /* there is exactly 1 sw for each hw with no mixeng */ - SWVoiceIn *sw =3D hw->sw_head.lh_first; - if (sw->active) { - sw->callback.fn(sw->callback.opaque, INT_MAX); - } - } - return; - } - - while ((hw =3D audio_pcm_hw_find_any_enabled_in(s, hw))) { - SWVoiceIn *sw; - size_t captured =3D 0, min; - int pos; - - if (replay_mode !=3D REPLAY_MODE_PLAY) { - captured =3D audio_pcm_hw_run_in( - hw, hw->conv_buf.size - audio_pcm_hw_get_live_in(hw)); - } - - replay_audio_in_start(&captured); - assert(captured <=3D hw->conv_buf.size); - if (replay_mode =3D=3D REPLAY_MODE_PLAY) { - hw->conv_buf.pos =3D (hw->conv_buf.pos + captured) % hw->conv_= buf.size; - } - for (pos =3D (hw->conv_buf.pos - captured + hw->conv_buf.size) % h= w->conv_buf.size; - pos !=3D hw->conv_buf.pos; - pos =3D (pos + 1) % hw->conv_buf.size) { - uint64_t left, right; - - if (replay_mode =3D=3D REPLAY_MODE_RECORD) { - audio_sample_to_uint64(hw->conv_buf.buffer, pos, &left= , &right); - } - replay_audio_in_sample_lr(&left, &right); - if (replay_mode =3D=3D REPLAY_MODE_PLAY) { - audio_sample_from_uint64(hw->conv_buf.buffer, pos, lef= t, right); - } - } - replay_audio_in_finish(); - - min =3D audio_pcm_hw_find_min_in (hw); - hw->total_samples_captured +=3D captured - min; - - for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { - sw->total_hw_samples_acquired -=3D min; - - if (sw->active) { - size_t sw_avail =3D audio_get_avail(sw); - size_t avail; - - avail =3D st_rate_frames_out(sw->rate, sw_avail); - if (avail > 0) { - avail =3D MIN(avail, sw->resample_buf.size); - sw->callback.fn(sw->callback.opaque, - avail * sw->info.bytes_per_frame); - } - } - } - } -} - -static void audio_run_capture(AudioMixengBackend *s) -{ - CaptureVoiceOut *cap; - - for (cap =3D s->cap_head.lh_first; cap; cap =3D cap->entries.le_next) { - size_t live, rpos, captured; - HWVoiceOut *hw =3D &cap->hw; - SWVoiceOut *sw; - - captured =3D live =3D audio_pcm_hw_get_live_out (hw, NULL); - rpos =3D hw->mix_buf.pos; - while (live) { - size_t left =3D hw->mix_buf.size - rpos; - size_t to_capture =3D MIN(live, left); - struct st_sample *src; - struct capture_callback *cb; - - src =3D hw->mix_buf.buffer + rpos; - hw->clip (cap->buf, src, to_capture); - mixeng_clear (src, to_capture); - - for (cb =3D cap->cb_head.lh_first; cb; cb =3D cb->entries.le_n= ext) { - cb->ops.capture (cb->opaque, cap->buf, - to_capture * hw->info.bytes_per_frame); - } - rpos =3D (rpos + to_capture) % hw->mix_buf.size; - live -=3D to_capture; - } - hw->mix_buf.pos =3D rpos; - - for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { - if (!sw->active && sw->empty) { - continue; - } - - 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); - captured =3D sw->total_hw_samples_mixed; - } - - sw->total_hw_samples_mixed -=3D captured; - sw->empty =3D sw->total_hw_samples_mixed =3D=3D 0; - } - } -} - -void audio_run(AudioMixengBackend *s, const char *msg) -{ - audio_run_out(s); - audio_run_in(s); - audio_run_capture(s); - -#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; - } -#endif -} - -void audio_generic_run_buffer_in(HWVoiceIn *hw) -{ - 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); - hw->pos_emul =3D hw->pending_emul =3D 0; - } - - 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); - hw->pending_emul +=3D read; - hw->pos_emul =3D (hw->pos_emul + read) % hw->size_emul; - if (read < read_len) { - break; - } - } -} - -void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size) -{ - size_t start; - - start =3D audio_ring_posb(hw->pos_emul, hw->pending_emul, hw->size_emu= l); - assert(start < hw->size_emul); - - *size =3D MIN(*size, hw->pending_emul); - *size =3D MIN(*size, hw->size_emul - start); - return hw->buf_emul + start; -} - -void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size) -{ - assert(size <=3D hw->pending_emul); - hw->pending_emul -=3D size; -} - -size_t audio_generic_buffer_get_free(HWVoiceOut *hw) -{ - if (hw->buf_emul) { - return hw->size_emul - hw->pending_emul; - } else { - return hw->samples * hw->info.bytes_per_frame; - } -} - -void audio_generic_run_buffer_out(HWVoiceOut *hw) -{ - while (hw->pending_emul) { - size_t write_len, written, start; - - start =3D audio_ring_posb(hw->pos_emul, hw->pending_emul, hw->size= _emul); - assert(start < hw->size_emul); - - write_len =3D MIN(hw->pending_emul, hw->size_emul - start); - - written =3D hw->pcm_ops->write(hw, hw->buf_emul + start, write_len= ); - hw->pending_emul -=3D written; - - if (written < write_len) { - break; - } - } -} - -void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size) -{ - 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); - hw->pos_emul =3D hw->pending_emul =3D 0; - } - - *size =3D MIN(hw->size_emul - hw->pending_emul, - hw->size_emul - hw->pos_emul); - return hw->buf_emul + hw->pos_emul; -} - -size_t audio_generic_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size) -{ - assert(buf =3D=3D hw->buf_emul + hw->pos_emul && - size + hw->pending_emul <=3D hw->size_emul); - - hw->pending_emul +=3D size; - hw->pos_emul =3D (hw->pos_emul + size) % hw->size_emul; - - return size; -} - -size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size) -{ - size_t total =3D 0; - - if (hw->pcm_ops->buffer_get_free) { - size_t free =3D hw->pcm_ops->buffer_get_free(hw); - - size =3D MIN(size, free); - } - - 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); - - if (dst_size =3D=3D 0) { - break; - } - - copy_size =3D MIN(size - total, dst_size); - if (dst) { - memcpy(dst, (char *)buf + total, copy_size); - } - proc =3D hw->pcm_ops->put_buffer_out(hw, dst, copy_size); - total +=3D proc; - - if (proc =3D=3D 0 || proc < copy_size) { - break; - } - } - - return total; -} - -size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size) -{ - size_t total =3D 0; - - if (hw->pcm_ops->run_buffer_in) { - hw->pcm_ops->run_buffer_in(hw); - } - - while (total < size) { - size_t src_size =3D size - total; - void *src =3D hw->pcm_ops->get_buffer_in(hw, &src_size); - - if (src_size =3D=3D 0) { - break; - } - - memcpy((char *)buf + total, src, src_size); - hw->pcm_ops->put_buffer_in(hw, src, src_size); - total +=3D src_size; - } - - return total; -} - -static bool audio_mixeng_backend_realize(AudioBackend *abe, - Audiodev *dev, Error **errp) -{ - AudioMixengBackend *be =3D AUDIO_MIXENG_BACKEND(abe); - audio_driver *drv =3D AUDIO_MIXENG_BACKEND_GET_CLASS(be)->driver; - - be->dev =3D dev; - 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; - } - 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; - } - - audio_init_nb_voices_out(be, drv, 1); - audio_init_nb_voices_in(be, drv, 0); - be->drv =3D drv; - - if (be->dev->timer_period <=3D 0) { - be->period_ticks =3D 1; - } else { - be->period_ticks =3D be->dev->timer_period * (int64_t)SCALE_US; - } - - return true; -} - -static void audio_vm_change_state_handler (void *opaque, bool running, - RunState state) -{ - AudioMixengBackend *s =3D opaque; - HWVoiceOut *hwo =3D NULL; - HWVoiceIn *hwi =3D NULL; - - 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); - } - } - - 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); - } - } - audio_reset_timer (s); -} - -static const VMStateDescription vmstate_audio; - -static const char *audio_mixeng_backend_get_id(AudioBackend *be) -{ - return AUDIO_MIXENG_BACKEND(be)->dev->id; -} - -static CaptureVoiceOut *audio_mixeng_backend_add_capture( - AudioBackend *be, - struct audsettings *as, - struct audio_capture_ops *ops, - void *cb_opaque); - -static void audio_mixeng_backend_del_capture( - AudioBackend *be, - CaptureVoiceOut *cap, - void *cb_opaque); - -static void audio_mixeng_backend_set_volume_out(AudioBackend *be, SWVoiceO= ut *sw, - Volume *vol); -static void audio_mixeng_backend_set_volume_in(AudioBackend *be, SWVoiceIn= *sw, - Volume *vol); - -static void audio_mixeng_backend_class_init(ObjectClass *klass, const void= *data) -{ - AudioBackendClass *be =3D AUDIO_BACKEND_CLASS(klass); - - be->realize =3D audio_mixeng_backend_realize; - be->get_id =3D audio_mixeng_backend_get_id; - be->open_in =3D audio_mixeng_backend_open_in; - be->open_out =3D audio_mixeng_backend_open_out; - be->close_in =3D audio_mixeng_backend_close_in; - be->close_out =3D audio_mixeng_backend_close_out; - be->is_active_out =3D audio_mixeng_backend_is_active_out; - be->is_active_in =3D audio_mixeng_backend_is_active_in; - be->set_active_out =3D audio_mixeng_backend_set_active_out; - be->set_active_in =3D audio_mixeng_backend_set_active_in; - be->set_volume_out =3D audio_mixeng_backend_set_volume_out; - be->set_volume_in =3D audio_mixeng_backend_set_volume_in; - be->read =3D audio_mixeng_backend_read; - be->write =3D audio_mixeng_backend_write; - be->get_buffer_size_out =3D audio_mixeng_backend_get_buffer_size_out; - be->add_capture =3D audio_mixeng_backend_add_capture; - be->del_capture =3D audio_mixeng_backend_del_capture; -} - -static void audio_mixeng_backend_init(Object *obj) -{ - AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(obj); - - QLIST_INIT(&s->hw_head_out); - QLIST_INIT(&s->hw_head_in); - QLIST_INIT(&s->cap_head); - s->ts =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s); - - s->vmse =3D qemu_add_vm_change_state_handler(audio_vm_change_state_han= dler, s); - assert(s->vmse !=3D NULL); - - vmstate_register_any(NULL, &vmstate_audio, s); -} - -static void audio_mixeng_backend_finalize(Object *obj) -{ - AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(obj); - HWVoiceOut *hwo, *hwon; - HWVoiceIn *hwi, *hwin; - - QLIST_FOREACH_SAFE(hwo, &s->hw_head_out, entries, hwon) { - SWVoiceCap *sc; +/* SPDX-License-Identifier: MIT */ =20 - if (hwo->enabled && hwo->pcm_ops->enable_out) { - hwo->pcm_ops->enable_out(hwo, false); - } - hwo->pcm_ops->fini_out (hwo); - - for (sc =3D hwo->cap_head.lh_first; sc; sc =3D sc->entries.le_next= ) { - CaptureVoiceOut *cap =3D sc->cap; - struct capture_callback *cb; +#include "qemu/osdep.h" +#include "qemu/audio.h" +#include "qemu/help_option.h" +#include "qapi/clone-visitor.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi/qapi-visit-audio.h" +#include "qapi/qapi-commands-audio.h" +#include "qobject/qdict.h" +#include "system/system.h" =20 - for (cb =3D cap->cb_head.lh_first; cb; cb =3D cb->entries.le_n= ext) { - cb->ops.destroy (cb->opaque); - } - } - QLIST_REMOVE(hwo, entries); - } +/* Order of CONFIG_AUDIO_DRIVERS is import. + The 1st one is the one used by default, that is the reason + that we generate the list. +*/ +const char *audio_prio_list[] =3D { +#ifdef CONFIG_GIO + "dbus", +#endif + "spice", + CONFIG_AUDIO_DRIVERS + "none", + NULL +}; =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); - } - hwi->pcm_ops->fini_in (hwi); - QLIST_REMOVE(hwi, entries); - } +typedef struct AudiodevListEntry { + Audiodev *dev; + QSIMPLEQ_ENTRY(AudiodevListEntry) next; +} AudiodevListEntry; =20 - if (s->drv) { - s->drv->fini (s->drv_opaque); - s->drv =3D NULL; - } +typedef QSIMPLEQ_HEAD(, AudiodevListEntry) AudiodevListHead; =20 - if (s->dev) { - qapi_free_Audiodev(s->dev); - s->dev =3D NULL; - } +static AudiodevListHead audiodevs =3D + QSIMPLEQ_HEAD_INITIALIZER(audiodevs); +static AudiodevListHead default_audiodevs =3D + QSIMPLEQ_HEAD_INITIALIZER(default_audiodevs); =20 - if (s->ts) { - timer_free(s->ts); - s->ts =3D NULL; - } +static AudioBackendClass *audio_be_class_by_name(const char *name) +{ + g_autofree char *tname =3D g_strconcat("audio-", name, NULL); + ObjectClass *oc =3D module_object_class_by_name(tname); =20 - if (s->vmse) { - qemu_del_vm_change_state_handler(s->vmse); - s->vmse =3D NULL; + if (!oc || !object_class_dynamic_cast(oc, TYPE_AUDIO_BACKEND)) { + return NULL; } =20 - vmstate_unregister(NULL, &vmstate_audio, s); + return AUDIO_BACKEND_CLASS(oc); } =20 +static AudioBackend *default_audio_be; + static Object *get_audiodevs_root(void) { return object_get_container("audiodevs"); @@ -1758,25 +62,6 @@ void audio_cleanup(void) object_unparent(get_audiodevs_root()); } =20 -static bool vmstate_audio_needed(void *opaque) -{ - /* - * Never needed, this vmstate only exists in case - * an old qemu sends it to us. - */ - return false; -} - -static const VMStateDescription vmstate_audio =3D { - .name =3D "audio", - .version_id =3D 1, - .minimum_version_id =3D 1, - .needed =3D vmstate_audio_needed, - .fields =3D (const VMStateField[]) { - VMSTATE_END_OF_LIST() - } -}; - void audio_create_default_audiodevs(void) { for (int i =3D 0; audio_prio_list[i]; i++) { @@ -1817,15 +102,13 @@ static AudioBackend *audio_init(Audiodev *dev, Error= **errp) assert(!default_audio_be); for (;;) { AudiodevListEntry *e =3D QSIMPLEQ_FIRST(&default_audiodevs); - if (!e) { error_setg(errp, "no default audio driver available"); return NULL; } - dev =3D e->dev; QSIMPLEQ_REMOVE_HEAD(&default_audiodevs, next); + be =3D audio_be_new(e->dev, NULL); g_free(e); - be =3D audio_be_new(dev, NULL); if (be) { break; } @@ -1856,156 +139,35 @@ AudioBackend *audio_get_default_audio_be(Error **er= rp) return default_audio_be; } =20 -static struct audio_pcm_ops capture_pcm_ops; - -static CaptureVoiceOut *audio_mixeng_backend_add_capture( - AudioBackend *be, - struct audsettings *as, - struct audio_capture_ops *ops, - void *cb_opaque) -{ - AudioMixengBackend *s =3D AUDIO_MIXENG_BACKEND(be); - CaptureVoiceOut *cap; - struct capture_callback *cb; - - if (!s) { - error_report("Capturing without setting an audiodev is not support= ed"); - abort(); - } - - if (!audio_get_pdo_out(s->dev)->mixing_engine) { - dolog("Can't capture with mixeng disabled\n"); - return NULL; - } - - if (audio_validate_settings (as)) { - dolog ("Invalid settings were passed when trying to add capture\n"= ); - audio_print_settings (as); - return NULL; - } - - cb =3D g_malloc0(sizeof(*cb)); - cb->ops =3D *ops; - cb->opaque =3D cb_opaque; - - cap =3D audio_pcm_capture_find_specific(s, as); - if (cap) { - QLIST_INSERT_HEAD (&cap->cb_head, cb, entries); - } else { - HWVoiceOut *hw; - - cap =3D g_malloc0(sizeof(*cap)); - - 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); - - /* XXX find a more elegant way */ - hw->samples =3D 4096 * 4; - audio_pcm_hw_alloc_resources_out(hw); - - audio_pcm_init_info (&hw->info, as); - - cap->buf =3D g_malloc0_n(hw->mix_buf.size, hw->info.bytes_per_fram= e); - - if (hw->info.is_float) { - 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] - [hw->info.swap_endianness] - [audio_bits_to_index(hw->info.bits)]; - } - - QLIST_INSERT_HEAD (&s->cap_head, cap, entries); - QLIST_INSERT_HEAD (&cap->cb_head, cb, entries); - - QLIST_FOREACH(hw, &s->hw_head_out, entries) { - audio_attach_capture (hw); - } - } - - return cap; -} - -static void audio_mixeng_backend_del_capture( - AudioBackend *be, - CaptureVoiceOut *cap, - void *cb_opaque) +void audio_help(void) { - struct capture_callback *cb; - - for (cb =3D cap->cb_head.lh_first; cb; cb =3D cb->entries.le_next) { - if (cb->opaque =3D=3D cb_opaque) { - cb->ops.destroy (cb_opaque); - QLIST_REMOVE (cb, entries); - g_free (cb); + int i; =20 - if (!cap->cb_head.lh_first) { - SWVoiceOut *sw =3D cap->hw.sw_head.lh_first, *sw1; + printf("Available audio drivers:\n"); =20 - while (sw) { - SWVoiceCap *sc =3D (SWVoiceCap *) sw; -#ifdef DEBUG_CAPTURE - dolog ("freeing %s\n", sw->name); -#endif + for (i =3D 0; i < AUDIODEV_DRIVER__MAX; i++) { + const char *name =3D AudiodevDriver_str(i); + AudioBackendClass *be =3D audio_be_class_by_name(name); =20 - sw1 =3D sw->entries.le_next; - if (sw->rate) { - st_rate_stop (sw->rate); - sw->rate =3D NULL; - } - QLIST_REMOVE (sw, entries); - QLIST_REMOVE (sc, entries); - g_free (sc); - sw =3D sw1; - } - QLIST_REMOVE (cap, entries); - g_free(cap->hw.mix_buf.buffer); - g_free (cap->buf); - g_free (cap); - } - return; + if (be) { + printf("%s\n", name); } } } =20 -static void audio_mixeng_backend_set_volume_out(AudioBackend *be, SWVoiceO= ut *sw, - Volume *vol) +void audio_parse_option(const char *opt) { - if (sw) { - HWVoiceOut *hw =3D sw->hw; - - 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; + Audiodev *dev =3D NULL; =20 - if (hw->pcm_ops->volume_out) { - hw->pcm_ops->volume_out(hw, vol); - } + if (is_help_option(opt)) { + audio_help(); + exit(EXIT_SUCCESS); } -} - -static void audio_mixeng_backend_set_volume_in(AudioBackend *be, SWVoiceIn= *sw, - Volume *vol) -{ - if (sw) { - HWVoiceIn *hw =3D sw->hw; - - 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; + Visitor *v =3D qobject_input_visitor_new_str(opt, "driver", &error_fat= al); + visit_type_Audiodev(v, NULL, &dev, &error_fatal); + visit_free(v); =20 - if (hw->pcm_ops->volume_in) { - hw->pcm_ops->volume_in(hw, vol); - } - } + audio_add_audiodev(dev); } =20 static void audio_create_pdos(Audiodev *dev) @@ -2104,6 +266,124 @@ static void audio_validate_per_direction_opts( } } =20 +static AudiodevPerDirectionOptions *audio_get_pdo_out(Audiodev *dev) +{ + switch (dev->driver) { + case AUDIODEV_DRIVER_NONE: + return dev->u.none.out; +#ifdef CONFIG_AUDIO_ALSA + case AUDIODEV_DRIVER_ALSA: + return qapi_AudiodevAlsaPerDirectionOptions_base(dev->u.alsa.out); +#endif +#ifdef CONFIG_AUDIO_COREAUDIO + case AUDIODEV_DRIVER_COREAUDIO: + return qapi_AudiodevCoreaudioPerDirectionOptions_base( + dev->u.coreaudio.out); +#endif +#ifdef CONFIG_DBUS_DISPLAY + case AUDIODEV_DRIVER_DBUS: + return dev->u.dbus.out; +#endif +#ifdef CONFIG_AUDIO_DSOUND + case AUDIODEV_DRIVER_DSOUND: + return dev->u.dsound.out; +#endif +#ifdef CONFIG_AUDIO_JACK + case AUDIODEV_DRIVER_JACK: + return qapi_AudiodevJackPerDirectionOptions_base(dev->u.jack.out); +#endif +#ifdef CONFIG_AUDIO_OSS + case AUDIODEV_DRIVER_OSS: + return qapi_AudiodevOssPerDirectionOptions_base(dev->u.oss.out); +#endif +#ifdef CONFIG_AUDIO_PA + case AUDIODEV_DRIVER_PA: + return qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.out); +#endif +#ifdef CONFIG_AUDIO_PIPEWIRE + case AUDIODEV_DRIVER_PIPEWIRE: + return qapi_AudiodevPipewirePerDirectionOptions_base(dev->u.pipewi= re.out); +#endif +#ifdef CONFIG_AUDIO_SDL + case AUDIODEV_DRIVER_SDL: + return qapi_AudiodevSdlPerDirectionOptions_base(dev->u.sdl.out); +#endif +#ifdef CONFIG_AUDIO_SNDIO + case AUDIODEV_DRIVER_SNDIO: + return dev->u.sndio.out; +#endif +#ifdef CONFIG_SPICE + case AUDIODEV_DRIVER_SPICE: + return dev->u.spice.out; +#endif + case AUDIODEV_DRIVER_WAV: + return dev->u.wav.out; + + case AUDIODEV_DRIVER__MAX: + break; + } + abort(); +} + +static AudiodevPerDirectionOptions *audio_get_pdo_in(Audiodev *dev) +{ + switch (dev->driver) { + case AUDIODEV_DRIVER_NONE: + return dev->u.none.in; +#ifdef CONFIG_AUDIO_ALSA + case AUDIODEV_DRIVER_ALSA: + return qapi_AudiodevAlsaPerDirectionOptions_base(dev->u.alsa.in); +#endif +#ifdef CONFIG_AUDIO_COREAUDIO + case AUDIODEV_DRIVER_COREAUDIO: + return qapi_AudiodevCoreaudioPerDirectionOptions_base( + dev->u.coreaudio.in); +#endif +#ifdef CONFIG_DBUS_DISPLAY + case AUDIODEV_DRIVER_DBUS: + return dev->u.dbus.in; +#endif +#ifdef CONFIG_AUDIO_DSOUND + case AUDIODEV_DRIVER_DSOUND: + return dev->u.dsound.in; +#endif +#ifdef CONFIG_AUDIO_JACK + case AUDIODEV_DRIVER_JACK: + return qapi_AudiodevJackPerDirectionOptions_base(dev->u.jack.in); +#endif +#ifdef CONFIG_AUDIO_OSS + case AUDIODEV_DRIVER_OSS: + return qapi_AudiodevOssPerDirectionOptions_base(dev->u.oss.in); +#endif +#ifdef CONFIG_AUDIO_PA + case AUDIODEV_DRIVER_PA: + return qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.in); +#endif +#ifdef CONFIG_AUDIO_PIPEWIRE + case AUDIODEV_DRIVER_PIPEWIRE: + return qapi_AudiodevPipewirePerDirectionOptions_base(dev->u.pipewi= re.in); +#endif +#ifdef CONFIG_AUDIO_SDL + case AUDIODEV_DRIVER_SDL: + return qapi_AudiodevSdlPerDirectionOptions_base(dev->u.sdl.in); +#endif +#ifdef CONFIG_AUDIO_SNDIO + case AUDIODEV_DRIVER_SNDIO: + return dev->u.sndio.in; +#endif +#ifdef CONFIG_SPICE + case AUDIODEV_DRIVER_SPICE: + return dev->u.spice.in; +#endif + case AUDIODEV_DRIVER_WAV: + return dev->u.wav.in; + + case AUDIODEV_DRIVER__MAX: + break; + } + abort(); +} + static void audio_validate_opts(Audiodev *dev, Error **errp) { Error *err =3D NULL; @@ -2128,37 +408,6 @@ static void audio_validate_opts(Audiodev *dev, Error = **errp) } } =20 -void audio_help(void) -{ - int i; - - printf("Available audio drivers:\n"); - - for (i =3D 0; i < AUDIODEV_DRIVER__MAX; i++) { - const char *name =3D AudiodevDriver_str(i); - AudioBackendClass *be =3D audio_be_class_by_name(name); - - if (be) { - printf("%s\n", name); - } - } -} - -void audio_parse_option(const char *opt) -{ - Audiodev *dev =3D NULL; - - if (is_help_option(opt)) { - audio_help(); - exit(EXIT_SUCCESS); - } - Visitor *v =3D qobject_input_visitor_new_str(opt, "driver", &error_fat= al); - visit_type_Audiodev(v, NULL, &dev, &error_fatal); - visit_free(v); - - audio_add_audiodev(dev); -} - void audio_add_audiodev(Audiodev *dev) { AudiodevListEntry *e; @@ -2190,65 +439,6 @@ void audio_init_audiodevs(void) } } =20 -audsettings audiodev_to_audsettings(AudiodevPerDirectionOptions *pdo) -{ - return (audsettings) { - .freq =3D pdo->frequency, - .nchannels =3D pdo->channels, - .fmt =3D pdo->format, - .endianness =3D HOST_BIG_ENDIAN, - }; -} - -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) -{ - uint64_t usecs =3D pdo->has_buffer_length ? pdo->buffer_length : def_u= secs; - return (as->freq * usecs + 500000) / 1000000; -} - -/* samples =3D channels * frames =3D channels * freq * usec / 1e6 */ -int audio_buffer_samples(AudiodevPerDirectionOptions *pdo, - audsettings *as, int def_usecs) -{ - return as->nchannels * audio_buffer_frames(pdo, as, def_usecs); -} - -/* - * bytes =3D bytes_per_sample * samples =3D - * bytes_per_sample * channels * freq * usec / 1e6 - */ -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); -} - AudioBackend *audio_be_by_name(const char *name, Error **errp) { Object *obj =3D object_resolve_path_component(get_audiodevs_root(), na= me); @@ -2269,51 +459,6 @@ const char *audio_application_name(void) return vm_name ? vm_name : "qemu"; } =20 -void audio_rate_start(RateCtl *rate) -{ - memset(rate, 0, sizeof(RateCtl)); - rate->start_ticks =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); -} - -size_t audio_rate_peek_bytes(RateCtl *rate, struct audio_pcm_info *info) -{ - int64_t now; - int64_t ticks; - int64_t bytes; - int64_t frames; - - now =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); - ticks =3D now - rate->start_ticks; - bytes =3D muldiv64(ticks, info->bytes_per_second, NANOSECONDS_PER_SECO= ND); - frames =3D (bytes - rate->bytes_sent) / info->bytes_per_frame; - rate->peeked_frames =3D frames; - - return frames < 0 ? 0 : frames * info->bytes_per_frame; -} - -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); - audio_rate_start(rate); - } - - rate->bytes_sent +=3D bytes_used; -} - -size_t audio_rate_get_bytes(RateCtl *rate, struct audio_pcm_info *info, - size_t bytes_avail) -{ - size_t bytes; - - bytes =3D audio_rate_peek_bytes(rate, info); - bytes =3D MIN(bytes, bytes_avail); - audio_rate_add_bytes(rate, bytes); - - return bytes; -} - AudiodevList *qmp_query_audiodevs(Error **errp) { AudiodevList *ret =3D NULL; @@ -2323,17 +468,3 @@ AudiodevList *qmp_query_audiodevs(Error **errp) } return ret; } - -static const TypeInfo audio_types[] =3D { - { - .name =3D TYPE_AUDIO_MIXENG_BACKEND, - .parent =3D TYPE_AUDIO_BACKEND, - .instance_size =3D sizeof(AudioMixengBackend), - .instance_init =3D audio_mixeng_backend_init, - .instance_finalize =3D audio_mixeng_backend_finalize, - .class_size =3D sizeof(AudioMixengBackendClass), - .class_init =3D audio_mixeng_backend_class_init, - } -}; - -DEFINE_TYPES(audio_types) diff --git a/audio/meson.build b/audio/meson.build index 17f58369c20..0e33b6f9836 100644 --- a/audio/meson.build +++ b/audio/meson.build @@ -2,6 +2,7 @@ audio_ss =3D ss.source_set() audio_ss.add(files( 'audio.c', 'audio-be.c', + 'audio-mixeng-be.c', 'mixeng.c', 'noaudio.c', 'wavaudio.c', --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771855284; cv=none; d=zohomail.com; s=zohoarc; b=iEJ3q+kh+mX0c3y19F/1Ei16JK3sRHenjCZjuIU+1PZOvsorj60UCOiWLVRDqKErYJaS5UbRZGzyed5TVMMftvQ3rTfdU/JlY+4+BMh4lD0iGm/bITGvYUBttlWICZrrQBx7PgLdeBofXS9I1UbCcHnMmDtKGHjgI85nN26ig5E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855284; 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=Ss9oHxzNE9nQ9jCG/M5jycsST569jt37+/YoOvR3kZY=; b=EKmIRhaNImeYksntIL6zVyUsrvUHjJOe/NUOLiN61nlQhisCyCj5/wfm+IEPhDdVkD+a6ahJYo5daERrES6KytvWP1hgHkM2HtR54dcC5O7Xh1s+b0E4rezqjqrCTJyT0VwKg7eAcUd4fMbxHAKqLM6KGWPxwTqf98qC7nNa1i4= 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 1771855284842462.4887366222415; Mon, 23 Feb 2026 06:01:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWMo-0000ZH-Mr; Mon, 23 Feb 2026 08:52:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWJa-0003FR-Il for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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 1vuWJX-0007CN-0P for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:33 -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-176-iV6-lwHYM1-BEdPzbpS2EQ-1; Mon, 23 Feb 2026 08:49: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 53E491955F0C; Mon, 23 Feb 2026 13:49:27 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B2627180066A; Mon, 23 Feb 2026 13:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854570; 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=Ss9oHxzNE9nQ9jCG/M5jycsST569jt37+/YoOvR3kZY=; b=Sp2OOCP+5pb/ClfLXM7DlZ6DObgcjho/myaD1PzDCRhQ7GI5FaTj5j3W46oMXb5IDnzl4q 8VuyutiK/wlOIZEkfWdqDPqOy1CQI+2YtZTDtWxVVJEFUQWn+Gt7k+VIbKd7I0x7qFIFpN gJVEo90UXySB9iNcAnuzhuBYMo+MP+4= X-MC-Unique: iV6-lwHYM1-BEdPzbpS2EQ-1 X-Mimecast-MFC-AGG-ID: iV6-lwHYM1-BEdPzbpS2EQ_1771854567 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 41/85] audio: make audio_driver init() & fini() optional Date: Mon, 23 Feb 2026 14:46:42 +0100 Message-ID: <20260223134731.2377432-42-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855287289158500 From: Marc-Andr=C3=A9 Lureau The next patches are going to remove usage of the driver callbacks in favor of QOM realize/finalize. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio-mixeng-be.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index f906c84bf7c..45873646b3c 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -1521,9 +1521,11 @@ 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; - be->drv_opaque =3D drv->init(be->dev, errp); - if (!be->drv_opaque) { - return false; + if (drv->init !=3D NULL) { + be->drv_opaque =3D drv->init(be->dev, errp); + if (!be->drv_opaque) { + return false; + } } =20 if (!drv->pcm_ops->get_buffer_in) { @@ -1664,7 +1666,9 @@ static void audio_mixeng_backend_finalize(Object *obj) } =20 if (s->drv) { - s->drv->fini (s->drv_opaque); + if (s->drv->fini) { + s->drv->fini (s->drv_opaque); + } s->drv =3D NULL; } =20 --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771854785; cv=none; d=zohomail.com; s=zohoarc; b=bzkUSZV9X3vdDm2iiNHfUu4CmZNMC6RiCp2q3HBW1ep71kQniZEd6QypPpG7CjvMzRAFq0aO36bkiJaPVJ217BoVw7Y7b4ZlvXqNpoRjcisOVkxUFzkIgGtzom1bM9BdeDZfxlA2D05hZvCQ+lTOiCNgg0ePPKdX1YtViUFeSJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854785; 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=D1cgBDMElYegVttWxsnLL/ETaht8kC+6H0Ppeh74A/c=; b=efMWpBKTz7QoEVGEp4ppshZo3HgxprvfHlASvhqNpmhz6NUaOO8r+U2H/eJL7dJQpbVPunHoHh+MGb9jvygsB0FVZj5lM2zFHCX6rQWclL2vna2T+ey0vQPW1zUddbjj7jQLNNaCqitT3Sgjeyt1mCA5aAFrUO9KrXESNaWXZ6o= 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 1771854785663806.1797415823139; Mon, 23 Feb 2026 05:53:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWKC-0004Lb-RL; Mon, 23 Feb 2026 08:50: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 1vuWJe-0003Gi-Ho for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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 1vuWJb-0007Ct-5G for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:36 -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-395-OAAjJDwRPoqsH0WONq7E8Q-1; Mon, 23 Feb 2026 08:49:31 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 187EF1956073; Mon, 23 Feb 2026 13:49:30 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0270319560A2; Mon, 23 Feb 2026 13:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854574; 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=D1cgBDMElYegVttWxsnLL/ETaht8kC+6H0Ppeh74A/c=; b=L0+EAsQ1TS3ZpJ/Vqwhhzs98DE6SXWsqD/9ern90ZrzvUgotmk6cz/0jPwBp5oadmrZ1iW P8yBVgNGgsNs1mMsa/MCRBZbWgoEGP+qgOTyg7XyPbTHwE+7lfIZCT7o4+DYQq5AgmYlzl qD1XMBnbHeYL531dIrmqzE095tNYBYw= X-MC-Unique: OAAjJDwRPoqsH0WONq7E8Q-1 X-Mimecast-MFC-AGG-ID: OAAjJDwRPoqsH0WONq7E8Q_1771854570 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 42/85] audio/dbus: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 14:46:43 +0100 Message-ID: <20260223134731.2377432-43-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854786109158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 269db7877b6..fb059815de9 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_obj; -}; - -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; } @@ -734,6 +735,7 @@ static const TypeInfo audio_types[] =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 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771854974; cv=none; d=zohomail.com; s=zohoarc; b=R1DZMY5EjAmc5sKTX7c+YAvjev6QeTCngUnSDpSji6jgwhHey3ebS9tx5SVkTc0Doxv2fZVjJy/tmg0+NXd/GbfNEmh9UVRNeDidR6QMxqsqAvmXLSxOf9BU4rV30Ac8wfj+m2v/DhNLQ7VMlbtIL5OuX//WxT+BGN9X087owqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854974; 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=bAOgBxSVBxg4rG7YAbPn+jORLT0sScr7l61x0jGcsvw=; b=jSqkK4X+u7tzhPBEdpDJ52uL9FYUjES2aCRC6DrFlbl2N6SyJziD7OPJq0Dmt3S6oOKGAc6OxwBPkE4Wh3zWvL1aAA5JFW/81AlS+BOH261Gp1ytnYTpgDpsxTwI9hN1iMHQCzLF9nwB7/qZeVFHhURwXodIXaSqt0o+dC/3mgE= 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 1771854974225264.2030027846499; Mon, 23 Feb 2026 05:56:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWLX-0006j2-6U; Mon, 23 Feb 2026 08:51:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWJe-0003Ga-7B for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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 1vuWJb-0007D1-GU for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49: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-44-pRBBmwlZMY6DYKKTowPz4Q-1; Mon, 23 Feb 2026 08:49:33 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8778918005B0; Mon, 23 Feb 2026 13:49:32 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DC09F1955D85; Mon, 23 Feb 2026 13:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854574; 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=bAOgBxSVBxg4rG7YAbPn+jORLT0sScr7l61x0jGcsvw=; b=b7LUTXhiWA+KOL5d9hT0vcRQH1InGGWRK3Qvdrl1YSiS32z4Ck26aqv3o/WfQC6nRYkmrw f8BXxebsAai4+vV4qFu3MjvtSvdVXfPUcSsc4LiIUJUO1M2uC4Ny8pBwuyMWDHLzRrggAP z/0PZ3wVdkzsLfBel/jKJ0xaDmdtLH0= X-MC-Unique: pRBBmwlZMY6DYKKTowPz4Q-1 X-Mimecast-MFC-AGG-ID: pRBBmwlZMY6DYKKTowPz4Q_1771854572 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v3 43/85] audio/spice: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 14:46:44 +0100 Message-ID: <20260223134731.2377432-44-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854975178158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 ad7cb69673b..953dbf6c308 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_obj; }; =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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854838; cv=none; d=zohomail.com; s=zohoarc; b=GNYIsmXU3gIwbNHGdOQjk+lzticj13WZu96yKOqTdBGq6IlkyY1nsb6NXvFw2YL0aToWntReDaoMHT2Khbt4JIvFzfhAjaDEg2bPsy1poH2VTLpI/Ua/scG704hGY1KihPIZHD6QYqKu3dDg8fMuLnec6/qBhl8v5RnUq/O5Yiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854838; 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=DMFSVuo+MgQICi6NX6A9uaEwtkVzqzcuqzOtwdmRNb8=; b=PDgTfMnav2C2IhwPCi3xyNNRbPgO+lkFSkeAXvMwXQEbpTEQqrdHJUkZNUkRzgeJ/VGDGEFGSIMI1l2y9yscfWHGnA6diZdxK6hTpG+SuFSK5peqrbBA10eth9Obpe4r7DJIgM5WCIRbFXTfCzouv5DY1Mj5wBPp6xIQR9R51PI= 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 177185483821076.10598792979476; Mon, 23 Feb 2026 05:53:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWKC-0004BU-0T; Mon, 23 Feb 2026 08:50: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 1vuWK0-0003LK-Su for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:00 -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 1vuWJe-0007DS-S2 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:40 -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-639-3ZmqL4olObW1WAZdD5wd9A-1; Mon, 23 Feb 2026 08:49:36 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3252918002DE; Mon, 23 Feb 2026 13:49:35 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 73A5A1955F22; Mon, 23 Feb 2026 13:49:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854578; 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=DMFSVuo+MgQICi6NX6A9uaEwtkVzqzcuqzOtwdmRNb8=; b=DgZogNYhEg4y58e4JClWax5IhSqcHvKah8LKyZuzVD/Pabmz+DnDVd3uFGbcrCROoWoAgC NhJRRFZ6iUnLH5Qpuk8JZUPR+ujRAjcV1t7CCRxiWj/RQifSA+KJLJxVX2G/E+A9a8epA5 MB0NoTXYkSALCpoQ+zJZRvNGj1CTQ7Q= X-MC-Unique: 3ZmqL4olObW1WAZdD5wd9A-1 X-Mimecast-MFC-AGG-ID: 3ZmqL4olObW1WAZdD5wd9A_1771854575 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 44/85] audio/wav: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 14:46:45 +0100 Message-ID: <20260223134731.2377432-45-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854840291158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 cd2ceffd42b..f1a414f208c 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854784; cv=none; d=zohomail.com; s=zohoarc; b=Hw9Dnl9ScTOOYb+YzP7khUxFUXGdBt4pNUjf2yGwtnS43hk7Zexm8vO4z/9lGHdAweFbry44xi29zsRC2Se0+Vpx0NW4JkItKAUgpv7pA+QrUBaiL1KlZV8w8hxRBDtUdLk1kVFkDYUdl5zGo/onayZH1mlDs+1Lu/XZ+PUeXUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854784; 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=xlYgVBp4rfEz5yRZZFEr+/zGXWEq4y/2XCxEe+g3GVo=; b=KHmyGWxsIqUUrmD3kOe1a4RPH4HvE5TbE8kaCDqRbNKMLBzf8oP0fsd49IqH/Z4W59C9NP6Tc76aZvsCqwUn8xh63zQoZ68oWM8Hxh4Pkq/Mg/udrEUdMmhlez+g7j8LP23Men1OFEM4ngJrKG2Dcz1YyTPUKhiXCU/3FJNWNbA= 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 1771854784390340.43329840685215; Mon, 23 Feb 2026 05:53:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWK9-0003ys-Td; Mon, 23 Feb 2026 08:50: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 1vuWK1-0003Ln-2h for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50: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 1vuWJi-0007Dz-Hz for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:43 -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-515-jFtbffeyNXG3GndClUTioA-1; Mon, 23 Feb 2026 08:49:38 -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 D6AB31800630; Mon, 23 Feb 2026 13:49:37 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 52A1B3000C26; Mon, 23 Feb 2026 13:49:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854581; 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=xlYgVBp4rfEz5yRZZFEr+/zGXWEq4y/2XCxEe+g3GVo=; b=UV0+/GdhET3vnbm4f+gXGnWuI0VMsKqBz4Dn0j6S6Y+DRBiKtrs7kVtOYY/j2eQ7ko1dB5 Mct5gE/UOWH5iArq36QmR3N7Y3CDRm63siU0+5gof5UMskiAj2f7mh0t2g591rRs40Ewkq 2NAoJ9WLJOZ1+1aKKiwE7T9ZxYwgTaU= X-MC-Unique: jFtbffeyNXG3GndClUTioA-1 X-Mimecast-MFC-AGG-ID: jFtbffeyNXG3GndClUTioA_1771854577 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 45/85] audio/noaudio: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 14:46:46 +0100 Message-ID: <20260223134731.2377432-46-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854785954158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 65679b8b13d..2bd110caac4 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854801; cv=none; d=zohomail.com; s=zohoarc; b=MwakSZF7HxE1+/E/MkYw83e73nvs3OWGcDgSMGXgmg/egGOlWKep6/RMKCxeUUvLGFYdkm7mZbHJr1tHlpBzIsWHFsBsdaRpWkclK2b/D2hlHNnNhnkgbsZWJykxMKSXNhhosd4ZvtDYdVrrHQsxABSBgpZ5mSoboCCAR4bKbAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854801; 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=oaDmncSttA6yajhGZ9BDmb+LfKD4WjheIu/dDDpU9Z8=; b=RDJXhVykTmn8BzvXO+6LR9GSyhmD49Q8DmooaA5ZgbyUPOCxnBs/x1Ymkl9gr4hAEwTOEO7dfGQMMvISSBx74UzuRCtP60S4DdMqwVM+FR6UvLw99Gtyxa+X4EfBhhtbOb5e/NHFZTyZQf6BCPmzE0gvUVejU5FVpaRek653cCE= 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 1771854801160830.8670995247958; Mon, 23 Feb 2026 05:53:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWKC-0004M4-TI; Mon, 23 Feb 2026 08:50: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 1vuWK1-0003Lq-3q for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50: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 1vuWJl-0007EH-7l for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:46 -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-518-gu6x8lHyOpO8mFRkNW5Irw-1; Mon, 23 Feb 2026 08:49:41 -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 8A0391955DC9; Mon, 23 Feb 2026 13:49:40 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9F9BF30001BE; Mon, 23 Feb 2026 13:49:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854584; 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=oaDmncSttA6yajhGZ9BDmb+LfKD4WjheIu/dDDpU9Z8=; b=SV27FjslosQhMZPXQuBQfNni1aHEo+EHhpnmiiu4F3Io7b+trRkSA1NKWrDHICXNrE8d7S rrxck66WY9/eM+aMnH0Gz6yIs7fN6BRoyjMlyI7ZwSd938t/GoxNj/DNF1gXLiGv7lYLN/ VfD4DfLPCv14ZQSevveV60ioR9uusCU= X-MC-Unique: gu6x8lHyOpO8mFRkNW5Irw-1 X-Mimecast-MFC-AGG-ID: gu6x8lHyOpO8mFRkNW5Irw_1771854580 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Christian Schoenebeck Subject: [PULL v3 46/85] audio/alsa: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 14:46:47 +0100 Message-ID: <20260223134731.2377432-47-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854802082158501 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 ae1cec6a36e..c2788606b28 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_obj; }; =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_types[] =3D { { .name =3D TYPE_AUDIO_ALSA, --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771855372; cv=none; d=zohomail.com; s=zohoarc; b=lIFdcTuvRH/l1sNTLks7h4AJ+VNhRgxP5DaBwT2ttHo9STcxUDghse7Ivq93+u5cKQtAUpzCBpgOSuQGIaPLJDSVZOGDAUk3AtfI2FIg5jV/h6kp0P/p5rctC7F/Yq7/SiB+HVu82xfINULfbrNw2o1jH+gu1T+UH+mow0iUzFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855372; 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=GrWW6qyzCObCCkngWKeGvAhbZllH9XdTct94omX+fLc=; b=dQiQ4pvN1Rz/WYtmHaiRWHfB0UobSzF9jpL7C+kG4duERKptmlqh8xtFvGodIVk0V5ZHefFR0gfhqwZZ2M7AzJIS1V5EDGvSJ18trwRZFjlPWK9X00Ix2GuuIqYOemAubgy1FUpOyWNFzb93EAafRNAL202H2nACuF+jIDpHurk= 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 1771855372880542.6743193126874; Mon, 23 Feb 2026 06:02:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWLw-0007ZE-Vp; Mon, 23 Feb 2026 08:52:07 -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 1vuWK1-0003N6-HN for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWJm-0007ER-Bd for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:47 -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-258-sOA2QAHwNkqOmgZEIC7Zbg-1; Mon, 23 Feb 2026 08:49:44 -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 A55DF1800365; Mon, 23 Feb 2026 13:49:43 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BC5EF1955F22; Mon, 23 Feb 2026 13:49:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854585; 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=GrWW6qyzCObCCkngWKeGvAhbZllH9XdTct94omX+fLc=; b=D1o4ALdThPqcpcqRVU4zDWPgu9xEb5bAr+dkNf8AJn16/y2CWF2JGyoKtuQ4krX8jr2sE9 o/W/hEyA0KEOyuK3RVaG6laK3lAHxgyhWFGqPGEBnX02CZQ7Dl1XrpVDNmka92X3/83OwT yT0UwX5sI1Z+5NRcbXaBAFfVrtms11Q= X-MC-Unique: sOA2QAHwNkqOmgZEIC7Zbg-1 X-Mimecast-MFC-AGG-ID: sOA2QAHwNkqOmgZEIC7Zbg_1771854583 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 47/85] audio/oss: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 14:46:48 +0100 Message-ID: <20260223134731.2377432-48-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855374146158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/ossaudio.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/audio/ossaudio.c b/audio/ossaudio.c index f64c564e345..fedd2bbd722 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_obj; }; =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"); - return NULL; + qapi_free_Audiodev(dev); + return false; } 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"); - return NULL; + qapi_free_Audiodev(dev); + return false; } - 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_types[] =3D { { .name =3D TYPE_AUDIO_OSS, --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771855257; cv=none; d=zohomail.com; s=zohoarc; b=btZYBLJK/jJSgO4X1eAQaN5QM2acaIn4voamfycbWFMwE6Glqk/Kl+116Gmz1ZLVYRys0qxCHyY5kVFp2kfo3TymLbkdMJsUVl7Ec3Q2s+ZIAxtCWYRchqbEMdYP65m9Tv7yNrWA4TIfqYvhog5D+ZQ+6IVfsEZFlVAp6Sg1Wgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855257; 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=GK+InVNU3f2hcJXrsb/od2DfNR27U7o4tVRJnn/aSD8=; b=RT+p3JfLCwq7mdwbRT66+mJ7ad2AQwEVMLHWa/wIndeSVy/tu42zdnuwgRscRmtSLZWPI4Fp3gWuyybWbqBFtwNm0IwVCcNLLJNg899k1KErnP1RdQZReBLy3ao4tNJaGo3dMA27yuKjsaxEVZEXhIi0S1bUgWQoj42MCmUXwCg= 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 1771855257841363.98928263083565; Mon, 23 Feb 2026 06:00:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWO3-00054u-Aa; Mon, 23 Feb 2026 08:54: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 1vuWK1-0003N9-HE for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWJp-0007Ei-7Q for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:50 -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-402-Ta8TllbWNxCtE4NvQ2R0bg-1; Mon, 23 Feb 2026 08:49:47 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5BA42180025A; Mon, 23 Feb 2026 13:49:46 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8F3E71800370; Mon, 23 Feb 2026 13:49:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854588; 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=GK+InVNU3f2hcJXrsb/od2DfNR27U7o4tVRJnn/aSD8=; b=KtCoqvV5LcahykdvjQmmcALDn0oih+1TQaCDoZBMXNjfanfUXUAZJ42rEAENsO+wQ9CPYP w4jXVFwx3ftvNzNc1qAQ/JWsQWja6ASDPf0+FlLv+dp3OR/baS6ovk7EAmEAV7u0R8j8Sa m6RLW8IlfS26RRZUzpDB6cZOthqwiS8= X-MC-Unique: Ta8TllbWNxCtE4NvQ2R0bg-1 X-Mimecast-MFC-AGG-ID: Ta8TllbWNxCtE4NvQ2R0bg_1771854586 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 48/85] audio/pa: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 14:46:49 +0100 Message-ID: <20260223134731.2377432-49-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855258994158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 331da4f2ed6..97e6c0d1794 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_obj; -}; +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_obj; =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,12 +941,24 @@ 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_types[] =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 --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771854927; cv=none; d=zohomail.com; s=zohoarc; b=NK9CWIg2284oMs5hSOty0BLmridTNLGsXkW6W5nhAEB9QY4J6r+Lj89RdEgpNmkCacahoAM+GKeCNmqekhvyk4PyP/qCojEK3+xqEn9cBOvrBUyIp3jduUqg0cxGse0ZCF6lwssyGf5pqZrY329lSH9XQE1ZdSBqPdOg11RT1v0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854927; 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=N7lpB4YO8784dZ+RNH6GgnM/80tJeOGdjPt/WifQCsU=; b=cp8mQFefM3QKWdYeh9uHHNyz0TFxITX6onP0uffxVAHvok4vw89mTg54+8c6gVVN7zVt+njEaK5E92woQx5Gd64GKc1d1zLV8vqKMGfjiHc4Ch7zCLnvCBSQS7kIgYGEko473R3YaV+5Ysvj2h3PfNpRYVdMDsTMb/NsNtuof/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 1771854926997479.7486588668611; Mon, 23 Feb 2026 05:55:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWMD-0007mK-Hv; Mon, 23 Feb 2026 08:52:24 -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 1vuWK1-0003NA-JP for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:03 -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 1vuWJu-0007FP-3x for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:55 -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-679-rRHkTlaYMVCPMQadKnZWAw-1; Mon, 23 Feb 2026 08:49:49 -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 E1636195609E; Mon, 23 Feb 2026 13:49:48 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 61FE71955F22; Mon, 23 Feb 2026 13:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854593; 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=N7lpB4YO8784dZ+RNH6GgnM/80tJeOGdjPt/WifQCsU=; b=PM/oktkZPMfI58JsaqU+h5lTdNNc2Abf535p8W/jKGaZ/6jOrbFh2Es/k0tMrKp9dxWx4H /clUAFoXncWywRRKj2fHuPAyvl6650QkV8vitwyNFEqru/mH1aOrHA3vFHLeRa8rezyOns F/9szHg4EOnIaLwlMArWdEBrDDUgeKs= X-MC-Unique: rRHkTlaYMVCPMQadKnZWAw-1 X-Mimecast-MFC-AGG-ID: rRHkTlaYMVCPMQadKnZWAw_1771854589 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Thomas Huth Subject: [PULL v3 49/85] audio/sdl: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 14:46:50 +0100 Message-ID: <20260223134731.2377432-50-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854928825158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 a60b1629da0..0dfa3100828 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_obj; }; =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,12 +502,24 @@ 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_types[] =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 --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771854798; cv=none; d=zohomail.com; s=zohoarc; b=XwD5GTzmaO117nVWwXGTR/xHp4PYodQ84oMB5bJlKBOVVYsA/wTsfEH3cMWscToTnlb4Rz46cWM34O/PiGZ/2n9j7dlq9oYw/fXvOxuYtirDfG5adiIf+Ci/MTXHJmIjNZLtc23YyMwitUJToMMfP0uY7PEv8wRbUJfO2nffgaI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854798; 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=J4SucUVkl0WRnnZuCp5t+N6kiYAKNSlru5EZCcCUPGM=; b=PiV+jQ1u07sljWBsy/MseCRA6uIJzwfNsTX2HRoRbcUGax54KiE9ujN2WG1JylEGtj9MslLAAJrzpdcaAy5Uv4M8K98B48yeA03HgRH49BtCV95V3f2/YJHQfYJqXCwtUlPfUIL/wn8gY7zYxFsfTZRCUlHxn6QwHnC5aa5XluM= 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 17718547987261006.6133102240083; Mon, 23 Feb 2026 05:53:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWKG-0004iH-4G; Mon, 23 Feb 2026 08:50: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 1vuWK1-0003NB-HK for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:03 -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 1vuWJw-0007Fk-8y for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:58 -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-711-y0iDH5v5Mt2f3yw0IOkHyQ-1; Mon, 23 Feb 2026 08:49:52 -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 542B618002FF; Mon, 23 Feb 2026 13:49:51 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B8BC61800370; Mon, 23 Feb 2026 13:49:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854595; 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=J4SucUVkl0WRnnZuCp5t+N6kiYAKNSlru5EZCcCUPGM=; b=beQd5CAEckIpsyvAY5JvI665v7BWDjBuzt/OPMwi/kma5TJgNl3qxsRURlDjw8QukgbQok eC9DtzGmaYkJtAk4xXPk1Nr6rM8EpijLMMkrAavwS4TuhpIbA+F33NIgnw+QPh1zzir94t 7Wvu8tU/H14aq82+tRAvrWwDuIdH7nk= X-MC-Unique: y0iDH5v5Mt2f3yw0IOkHyQ-1 X-Mimecast-MFC-AGG-ID: y0iDH5v5Mt2f3yw0IOkHyQ_1771854591 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 50/85] audio/pw: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 14:46:51 +0100 Message-ID: <20260223134731.2377432-51-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854800198158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 3b524dfea5a..ca61a1b4ef5 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_obj; -}; =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,12 +849,24 @@ 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_types[] =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 --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771854927; cv=none; d=zohomail.com; s=zohoarc; b=kU+EKCCRZmtJV7x7Xd1kSwotPZB3dNn4+Z7M0F2NeeqWrMFoR7lhO46qXR43h0z9oBGkh4pl6F46V/RubJReLqhHxDoq1eWIeejHAbXhKP04KQH6TCYJjRusim76KWMB9gjwXcq3VTEvuJ6TsB9m17U7ZYnLLmwYML3Vi7IlH1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854927; 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=aeLvVFUbBqEI+LRYHP7O9XPoCzRHYKuwsHItmspHacQ=; b=O0ur1L7DYI6MLwtcnAt418ZPs25V5tXZxzCBcbIshDZYYNaJQpla0ZObGCg26NtxOaVR6xPh3PAtty75BXlRUwDZgChpAkjSDWuC32esYwKZRddXfmy+Z7eYtJN9XHohGOZyxbxpXXNzDDbIETBAqRJUV0hhYxXCMow7GqBpaNE= 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 1771854927280903.9735591772371; Mon, 23 Feb 2026 05:55:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWKE-0004Xs-N0; Mon, 23 Feb 2026 08:50: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 1vuWK1-0003ND-Jm for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:03 -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 1vuWJx-0007Fy-8v for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:49:59 -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-627-fbWiKWp0MS2bkbYoTKaARg-1; Mon, 23 Feb 2026 08:49:55 -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 4352B1956053; Mon, 23 Feb 2026 13:49:54 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6684B1800670; Mon, 23 Feb 2026 13:49:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854596; 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=aeLvVFUbBqEI+LRYHP7O9XPoCzRHYKuwsHItmspHacQ=; b=WxHNdYYKe4Rjipas2esVIjD65Z3Go6a1WQA1Uymvjzqwjk4WqxHjTb44VaEKh2XqTwjPM/ j7c6Y3/W20Vby/QIjh3g6XTofd6r5Ix8gKe8Zpz7py/FG6u9IoJtsXZS5rGWfu2Iz2oDBC 8FYx0gm2/zEu5AEQfOxFx1tC2mBC07E= X-MC-Unique: fbWiKWp0MS2bkbYoTKaARg-1 X-Mimecast-MFC-AGG-ID: fbWiKWp0MS2bkbYoTKaARg_1771854594 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Christian Schoenebeck Subject: [PULL v3 51/85] audio/jack: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 14:46:52 +0100 Message-ID: <20260223134731.2377432-52-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854928799158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 972b158f023..31e3da6a7fe 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_types[] =3D { { .name =3D TYPE_AUDIO_JACK, --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771855293; cv=none; d=zohomail.com; s=zohoarc; b=Kcm0IGiHS6p/10JPeOR7JGW0MYjab+0tIm2xbLmA5qiDGWsiya+mBkUe0SG85QSZbUpCIYb4P06YDoEOaVUFEL83IosCuQnsuLqmyK3ibDu3/QI6JLi4vAVp+lRS+13mkGBb7iOJcCROwW9EbAIGk8pMZI1bFfjgji51gHZYvR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855293; 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=GAdjP1Lmahfatqe3bM7BO7TbZTqfqsJURW95dVIFOT4=; b=A+vkPJEk07xVfQM3PZ9yddspjrwrem9VLb/bhqh2q9FPJW2qaQmQosPu1zuVIi7FKHr8ETrKTrlUnj+eNX4O8ql5zALDOK8cU91xz9DwjjDuPLUgMFOhUk6x8u8FuVp7/XObX/Ozk8/2oGE7qhm9nedJBFvciD4Cfdt4axV4WYE= 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 1771855293577745.5734636797941; Mon, 23 Feb 2026 06:01:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWKh-0005rm-Bj; Mon, 23 Feb 2026 08:50: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 1vuWK4-0003dJ-R6 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWK2-0007GZ-O2 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:04 -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-301-fHD9fcdkMO22EbbWfDjnIA-1; Mon, 23 Feb 2026 08:49: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 F02291956089; Mon, 23 Feb 2026 13:49:56 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4636419560A2; Mon, 23 Feb 2026 13:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854602; 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=GAdjP1Lmahfatqe3bM7BO7TbZTqfqsJURW95dVIFOT4=; b=eLXJ1iAC2AaLyL+tt559aNVrrXzvRazk9DeLC5Zm90BzaN4YrJND5GLCrCw7YQLTkXsky1 CwytJZ7TD7pABidaXvGQsCOKAbpE6Bh+Vdrsn51s0SmT7VzIQ/mTtpCvR9boWMgbfR5Hz4 VBPNCXpViE2pKq0ZUw9ppeQKXkALNi4= X-MC-Unique: fHD9fcdkMO22EbbWfDjnIA-1 X-Mimecast-MFC-AGG-ID: fHD9fcdkMO22EbbWfDjnIA_1771854597 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Alexandre Ratchov Subject: [PULL v3 52/85] audio/sndio: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 14:46:53 +0100 Message-ID: <20260223134731.2377432-53-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855295282158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 2a9ae42992b..c15d8b6684a 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855070; cv=none; d=zohomail.com; s=zohoarc; b=VODQpHv5BwxMHs0Fq8WAeDlD22T7oD1w6eFn9qpFKSm6G7B/zg99d9u7cBbLA9sCtHM5iCFPmCAuPr7F5pTqKtTVY6WdbywYtn0Vmsa3VDyyV0Akl3n9PYddZGstQiiCB8a2KJntHKRYcAAm9jGCo0ojVcGFNHpB/jGMv9MHuPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855070; 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=8wDShJ+X7UTn+POkwYGZJe1+5q3HI8Li/EquJ/0PdMQ=; b=OZzhi5aU+euUWqAqWb+QS5P7VhYyzhB5D5kpGXPE/DAMB5CBZME+2Y65nLqeRhjb5cr53ze1KE0pCIEH0fAcIEDM7xfU4uXG++roLS7ZE9I7KwYc0DtcuhFripn4wyJY7l4DW8xwd18WDkHHcKg5RFUE6UVB6MoSpSGyp/ySkHc= 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 1771855070931499.30550451172724; Mon, 23 Feb 2026 05:57:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWN1-00021P-EO; Mon, 23 Feb 2026 08:53:07 -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 1vuWK7-0003oz-1o for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50: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 1vuWK5-0007Q5-DX for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:06 -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-19-gwYju-iQND2sTGuV5qb7aQ-1; Mon, 23 Feb 2026 08:50:01 -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 417D018009FC; Mon, 23 Feb 2026 13:50:00 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 57ABA3000C26; Mon, 23 Feb 2026 13:49:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854604; 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=8wDShJ+X7UTn+POkwYGZJe1+5q3HI8Li/EquJ/0PdMQ=; b=gLIKyZfUfkzzSPZlQORLTa0zJH27+CvwNiTLkFBFNqonimQsSyHSw4KmTSfajMZ4VzPIAE krhFlHy4j5mVPybp/vi/rx+u3oOcxM53H1r0falVNmEtg+hoSI3+DhwIEGFqBYFYdWQEjT oC0knh/nucBTJvrcCjdBhaXRYJ/wtbg= X-MC-Unique: gwYju-iQND2sTGuV5qb7aQ-1 X-Mimecast-MFC-AGG-ID: gwYju-iQND2sTGuV5qb7aQ_1771854600 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Christian Schoenebeck , Akihiko Odaki Subject: [PULL v3 53/85] audio/coreaudio: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 14:46:54 +0100 Message-ID: <20260223134731.2377432-54-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855071621158500 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: Mark Cave-Ayland 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 862cb9dd9b0..4a0904f0073 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854802; cv=none; d=zohomail.com; s=zohoarc; b=ZtrL2EQJzV8dBN/6E3akvKjk+psjrp+V6aXm2K8Pde5pTZXFnQNqojylbho9ZuavB/KIsRktTLEpcSHtAozVnzl9pJZJ51tiYqmh0sO8NIpj6i/kgA52/Oc02FjsbnGr7Xe/BNALtcIWA/B77BZbGEA2+dXz9rrg0V9kvevhEpc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854802; 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=Clmca6brEgEy0EO9JVnBRHVqAcmHfxH1ZAQ7KK97pq4=; b=EOrelGShIzop3oReFD2JCffd+reVfIZcyZlNkHN/XR9rme33k2eZr4Z3F/fZms1QyVtxPdr5FlPhBBXZET9r5CQgGKUM0JR0V/G2Z3UBd9VEGC1L/BfGCOci86v3IidmbMCnJj3VVZxWdEBPQUdaNegrs59VOC6eTtPyUweFhO0= 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 17718548025411011.3329388288524; Mon, 23 Feb 2026 05:53:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWMP-00083t-M4; Mon, 23 Feb 2026 08:52:30 -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 1vuWKA-00041i-DS for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:10 -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 1vuWK8-0007SE-Cc for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:10 -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-529-I9rVkf2YPEu7UquJMy4Lxw-1; Mon, 23 Feb 2026 08:50:03 -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 E00A81955DC3; Mon, 23 Feb 2026 13:50:02 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EE87C1955D85; Mon, 23 Feb 2026 13:50:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854607; 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=Clmca6brEgEy0EO9JVnBRHVqAcmHfxH1ZAQ7KK97pq4=; b=e4b6KuQODN8jJ5rzjzoi5k62vPwRnG7KqULkPEt71BMUvhqpM7TrubW1+HEOQpm3UI1655 maf/Wig7JPXrQ3piTXI0r8h2JkrJiExnCHn/EgjGNySioeTIK1TAfw6XTtlD9c9xPXyncB N4KqGH68wPHbnLwsXk/9mQu3HhEjmMI= X-MC-Unique: I9rVkf2YPEu7UquJMy4Lxw-1 X-Mimecast-MFC-AGG-ID: I9rVkf2YPEu7UquJMy4Lxw_1771854603 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 54/85] audio/dsound: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 14:46:55 +0100 Message-ID: <20260223134731.2377432-55-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854804210158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 462d09e02af..a90c348230b 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_obj; + + 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,12 +694,24 @@ 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_types[] =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 --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771854951; cv=none; d=zohomail.com; s=zohoarc; b=k/eDpcU8owW6Cdw7EikVdRtoaU5o0Pu6odMQXpyKCt9ySH4S3jtrCWL3k8goFF7Lt4/Pdu/pr8SNpt7puCUXXhTuOtwnuWiFjcagS5CO6lnWgHzukPkXXZs27lQcw+k658wqbu5WfZKFIBqSldc2qShTqjqIdyDZN0I4vdvyMrs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854951; 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=DT2hdPhk/th3jzqJns9or8rraYYLOeNrzepwoIXfIN0=; b=AF/WZeOnbsDTJixWrKIucpdd4CKd3WKjhpHqBSeoemi3S0KOqy+gMNIDRPFjTtnbVuZNLDWxmQGDhD8LtkUTRqNsq+E+9mkS5VtexdgkeMoY5Tn+6ta2PqJ1ZqQhNSBqj3erERf7TByZQ5NIzw5WE1GhuyGUr+SfBWCLfBU6Lx4= 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 1771854951691383.06614461773177; Mon, 23 Feb 2026 05:55:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWN1-00021j-HF; Mon, 23 Feb 2026 08:53: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 1vuWKG-0004pc-D0 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:17 -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 1vuWKE-0007Tk-0Z for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:16 -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-647-et4KC5udPHmlgqwp0ZuB7A-1; Mon, 23 Feb 2026 08:50:07 -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 4E0AC1956058; Mon, 23 Feb 2026 13:50:06 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D68581955F29; Mon, 23 Feb 2026 13:50:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854613; 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=DT2hdPhk/th3jzqJns9or8rraYYLOeNrzepwoIXfIN0=; b=iZDbmqjrC7Psm9+nmMNfwNpK7gme9Ua3S6jOpN6hLr+wBpVyeei0+WK+Q18PXmcJ5KwubL Lb1SOtsktN+egYmYVyC+Yo6N13CJDOmcZgkuhAvjaGZdkGpfCRnHPh3ANaxzaf23OuEJyf zYHpWZiMq8yLVH1QxANs46hD3xi96cA= X-MC-Unique: et4KC5udPHmlgqwp0ZuB7A-1 X-Mimecast-MFC-AGG-ID: et4KC5udPHmlgqwp0ZuB7A_1771854606 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Thomas Huth , Alexandre Ratchov Subject: [PULL v3 55/85] audio: remove audio_driver init/fini/next Date: Mon, 23 Feb 2026 14:46:56 +0100 Message-ID: <20260223134731.2377432-56-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854953440158500 From: Marc-Andr=C3=A9 Lureau They are no longer used after conversion to QOM. Also removing the drv_opaque from a few of the pcm_ops methods. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki Reviewed-by: Mark Cave-Ayland --- 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 c2788606b28..0c63d133496 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 45873646b3c..ee593310180 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 fb059815de9..9cc6e826b7e 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 31e3da6a7fe..d1bf80f8b68 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 2bd110caac4..6016f516d4a 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 fedd2bbd722..e6f8d6d41e5 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 97e6c0d1794..35818296282 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 ca61a1b4ef5..c668ef19a3e 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 0dfa3100828..a1d453aa307 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 c15d8b6684a..77685e27cb1 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 953dbf6c308..cc6c5d7e287 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 f1a414f208c..f9a0484488b 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 4a0904f0073..a3a0b83eb9d 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854995; cv=none; d=zohomail.com; s=zohoarc; b=n+pqUVGAJt4QxdxMl9u0h7nigSpyNublaAzSez3zlx6+cjEaq/vk1yAKyP3nsCrrfFrtHowIV9Sv46V61JNjYAI0X0NEK7orjAkYd9vCzMLb1+d7RFIwTeLAtqAuFWpxrW7ImEPwfQin46/pxtLi1ca413M2OOonkq6Uqtt+k6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854995; 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=cz6AbaE7CL6KiT71myE0oBxOtXlm0BFJpijm8buyrXU=; b=JdLlSqvpxTJvS2BocyjhDqeNlT9muygMDzN0HL7LR3P/f29Vy6DHf5xq6OUfaA33zcQRN1p92i2f4gid2R15K5YcclRHrxRnEGfL0NInDDnuLKSQz4aX/fR4bPgtXOoRSIpwJKr9GrHWXEuYzTKovdhjlG/ahu0eLTrBgPbsykA= 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 1771854995246905.0049826693271; Mon, 23 Feb 2026 05:56:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWKy-00064o-9E; Mon, 23 Feb 2026 08:51: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 1vuWKI-00058X-IM for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:18 -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 1vuWKF-0007U0-AQ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:17 -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-211-ZMGK3XW4OH24HDC3FemnZg-1; Mon, 23 Feb 2026 08:50:11 -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 B073F1955F04; Mon, 23 Feb 2026 13:50:09 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8C38D1800465; Mon, 23 Feb 2026 13:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854614; 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=cz6AbaE7CL6KiT71myE0oBxOtXlm0BFJpijm8buyrXU=; b=GETxE+HeAwLD92POUfPIWWhoUU5B3CCuHEiP4dKXjnM5Qb6rxx6yt3G6aw/ibsBldIU7fb 8S+89rEps5QxxjaWcjACUXVBXz1Jq77FTvLJmvc9mZBXX6dV7qlSREWZ+e0ec4nDGZRxJl 3ZpFz8bbAt2XMY0ht7B5cJs+ER7FHqc= X-MC-Unique: ZMGK3XW4OH24HDC3FemnZg-1 X-Mimecast-MFC-AGG-ID: ZMGK3XW4OH24HDC3FemnZg_1771854609 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Thomas Huth , Alexandre Ratchov Subject: [PULL v3 56/85] audio: remove audio_driver Date: Mon, 23 Feb 2026 14:46:57 +0100 Message-ID: <20260223134731.2377432-57-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854997138158500 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: Mark Cave-Ayland 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 0c63d133496..d008ce7b627 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -46,7 +46,6 @@ struct AudioALSA { AudioMixengBackend parent_obj; }; =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_types[] =3D { diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index ee593310180..3a0a537713e 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 9cc6e826b7e..82e76c41f9f 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_types[] =3D { diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index a90c348230b..e35b7fc233f 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_types[] =3D { diff --git a/audio/jackaudio.c b/audio/jackaudio.c index d1bf80f8b68..7caa2ddf43f 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -42,7 +42,6 @@ struct AudioJack { AudioMixengBackend parent_obj; }; =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_types[] =3D { diff --git a/audio/noaudio.c b/audio/noaudio.c index 6016f516d4a..be2e2e684ce 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -37,15 +37,6 @@ struct AudioNone { AudioMixengBackend parent_obj; }; =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_types[] =3D { { diff --git a/audio/ossaudio.c b/audio/ossaudio.c index e6f8d6d41e5..0ad974e20cc 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -46,7 +46,6 @@ struct AudioOss { AudioMixengBackend parent_obj; }; =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_types[] =3D { diff --git a/audio/paaudio.c b/audio/paaudio.c index 35818296282..5758050cb55 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_types[] =3D { diff --git a/audio/pwaudio.c b/audio/pwaudio.c index c668ef19a3e..f7f7dfbe0ad 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_types[] =3D { diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index a1d453aa307..62f7ac8d76b 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -50,7 +50,6 @@ struct AudioSdl { AudioMixengBackend parent_obj; }; =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_types[] =3D { diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c index 77685e27cb1..5cd6250775b 100644 --- a/audio/sndioaudio.c +++ b/audio/sndioaudio.c @@ -32,14 +32,6 @@ struct AudioSndio { AudioMixengBackend parent_obj; }; =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_types[] =3D { { diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index cc6c5d7e287..995e0f6faa3 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -39,8 +39,6 @@ struct AudioSpice { AudioMixengBackend parent_obj; }; =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_types[] =3D { { diff --git a/audio/wavaudio.c b/audio/wavaudio.c index f9a0484488b..153e50fa0be 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -37,15 +37,6 @@ struct AudioWav { AudioMixengBackend parent_obj; }; =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_types[] =3D { { diff --git a/audio/coreaudio.m b/audio/coreaudio.m index a3a0b83eb9d..e9274976f94 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -41,15 +41,6 @@ AudioMixengBackend parent_obj; }; =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_types[] =3D { { --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771855003; cv=none; d=zohomail.com; s=zohoarc; b=gnO/i0giNg3JpDXjmkitKVdbpUL9xopwvS0vgGu2Bm1mCPyzJcjzVa5X0UIhMj5oSAx/CRfdYSpXByWEySJQaifB4Y/FR+UdnuQduRJf7SDIdpHnQFMxxMI8V72cOpyDpObEpjNK9xA3JvUHcb5Hk68oN2c94D3lWIQAzFC/ybo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855003; 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=J2LCz+nhDfOxiJOWtzRSCtk7Sk9g0A6PRU372Reg6Kg=; b=GSFNnAZL7ls26W9e8KxK3T3/wGjRUxjCpNhOXvsBXlE3RcYI3fSS6JgM1PXFqvmKr37gfhLn5Xn17WhtlwdQejMbCNmnBB2NAcUxbXj5I4TCklp/xkLCO83uJpu19I3pMjygsa+gTqQkB2nt/SgS+jpHhPoBmnQg7FP/QaXmRYg= 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 177185500313958.77387087321392; Mon, 23 Feb 2026 05:56:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWLW-0006Ws-Al; Mon, 23 Feb 2026 08:51:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWKT-0005om-S1 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:33 -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 1vuWKI-0007UI-Pt for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:26 -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-295-dwKQtCXAO-6JrK0jB3g8_g-1; Mon, 23 Feb 2026 08:50:14 -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 110F61800341; Mon, 23 Feb 2026 13:50:13 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BE5B719560A2; Mon, 23 Feb 2026 13:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854618; 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=J2LCz+nhDfOxiJOWtzRSCtk7Sk9g0A6PRU372Reg6Kg=; b=MjTYw5CyjMHq5gaoP6ner9SjtrI6thQlLLoZLrxARAS+zM6esisvZj9zTzB+hYSgcUcDxH cLcf2UJcO3HDF07dsRJD5zunFSpZ4IpZ6P0eeQ7cAZUZtbCW1AZeHCWc0gG4UmpZ87jPhn a/vJvd/VV39c3OaADr7RVobf2/LknJc= X-MC-Unique: dwKQtCXAO-6JrK0jB3g8_g-1 X-Mimecast-MFC-AGG-ID: dwKQtCXAO-6JrK0jB3g8_g_1771854613 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Thomas Huth , Alexandre Ratchov Subject: [PULL v3 57/85] audio: move pcm_ops into AudioMixengBackendClass Date: Mon, 23 Feb 2026 14:46:58 +0100 Message-ID: <20260223134731.2377432-58-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855005373158500 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 Reviewed-by: Mark Cave-Ayland --- 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 d008ce7b627..8f226b42612 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_types[] =3D { diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index 3a0a537713e..17301ec80e7 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 82e76c41f9f..d8e548bf469 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_types[] =3D { diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index e35b7fc233f..2c592c56663 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_types[] =3D { diff --git a/audio/jackaudio.c b/audio/jackaudio.c index 7caa2ddf43f..e415e94e6e6 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_types[] =3D { diff --git a/audio/noaudio.c b/audio/noaudio.c index be2e2e684ce..e056813181a 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_types[] =3D { diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 0ad974e20cc..d12c65dd0d7 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_types[] =3D { diff --git a/audio/paaudio.c b/audio/paaudio.c index 5758050cb55..b7826402e12 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_types[] =3D { diff --git a/audio/pwaudio.c b/audio/pwaudio.c index f7f7dfbe0ad..7a009a94f3a 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_types[] =3D { diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 62f7ac8d76b..d974d7eac46 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_types[] =3D { diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c index 5cd6250775b..21f43836fd1 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_types[] =3D { diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 995e0f6faa3..0d188e974df 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_types[] =3D { diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 153e50fa0be..ade8fd1d8c3 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_types[] =3D { diff --git a/audio/coreaudio.m b/audio/coreaudio.m index e9274976f94..561c08f47c1 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_types[] =3D { --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771854925; cv=none; d=zohomail.com; s=zohoarc; b=iXGg7LVT4aSUlGu9inv5Q4Wh+kLpNn8bEv8P2kqu1dvwyR3Us0d3s9LpOR2rshOoB5aqzgr2Mw4RLTaT1jkvgg0/Yt7OlkWoFqajJpPkogNi38mbsQLPHlNdlgjfqhQzvn7e+Cv8bCXaG5pK3UqNTHEjLmuZWAS8YR9i8TWsuu4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854925; 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=7y/EYQ+Y5vsg2qiNu5jBHHa59cXGfKBW0/UG4PQ/VuM=; b=Ax3fxei24LkSevBTDhbH0SRhmG7KgWJmDbsJ5339LBlA+ATdMiORQvYzEIkzNmItcwDQwZGCXnMEISLDT4mVZqeM3irw9PjuX10TkKjO6Ky+ELd2rXq/4xYnJJ7CHQmqbU8y8rt6O2l7sVG9McBjgabHxv5r/XTf82X2Lkl/OZg= 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 17718549259771000.5531996998649; Mon, 23 Feb 2026 05:55:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWLZ-0006ry-VT; Mon, 23 Feb 2026 08:51: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 1vuWKS-0005oj-CV for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:33 -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 1vuWKN-0007UX-7T for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:25 -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-491-VHuWnu1AMJSNu-zYfoqsJQ-1; Mon, 23 Feb 2026 08:50:16 -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 7722F19560AD; Mon, 23 Feb 2026 13:50:15 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B50021800677; Mon, 23 Feb 2026 13:50:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854620; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7y/EYQ+Y5vsg2qiNu5jBHHa59cXGfKBW0/UG4PQ/VuM=; b=VPuyVgfZSJxcgHqsjrRD+L4a8lAcVo9bdIiAkhy/Ht6/QNmFPafRDMZ04iC59gWRcfSfau E6B4Xqsk6DaC+4+UVucif6tfzO6a6NjabTNJ6uXuJTA6eIf6nvwKhnBDkN5HDen/Hbajhl kx4u/g35MMWcL2lWJqrHI3J3gMyu9Ig= X-MC-Unique: VHuWnu1AMJSNu-zYfoqsJQ-1 X-Mimecast-MFC-AGG-ID: VHuWnu1AMJSNu-zYfoqsJQ_1771854615 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 58/85] audio: constify some add_capture() arguments Date: Mon, 23 Feb 2026 14:46:59 +0100 Message-ID: <20260223134731.2377432-59-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854926820158500 From: Marc-Andr=C3=A9 Lureau Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: 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 8094a3196c7..ee065fa4968 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 17301ec80e7..d02cfe3c509 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854974; cv=none; d=zohomail.com; s=zohoarc; b=DM6lBsz8Bmwjp00x6FrPXmJS3+J8pRkj0y20YM22NBd23c4tHDTFHqfw2TS+txaNMAF9Egn+39pVxFPLpZIwHJuVko4lM4g7fTgN/GL/NV8A1CvF3MtPBuzNB4JCW/Kiij5q5oB6K+ZoT3vv362IoPdSm5tPGmY5Cfexfkpz2Ro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854974; 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=Vk+tuv/N/RyMuDjUwsZcUAlFQUcm2Bq9JgF070ZHc08=; b=M2GE4E+u9z2SX0qY+m6fr5ydaYNaU4RWeB9512eznXxxtDD6HFJqidyXM8T4j5H/6WmeKXah0hucMZLulOCUNLcJgEQTmTjdLQyRJRXzpaCfS8toLjgmRNPqdTlWcvdVT19VN4pViWI4yEkxC0AhY7TLts4ddNlirOsQZiOvDnQ= 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 1771854974059429.1128910345992; Mon, 23 Feb 2026 05:56:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWMQ-0008CP-C3; Mon, 23 Feb 2026 08:52:30 -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 1vuWKX-0005pH-OU for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50: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 1vuWKR-0007Up-Q1 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:30 -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-8-B600x97SMimrptI41Al3lQ-1; Mon, 23 Feb 2026 08:50:19 -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 C5B8419560A3; Mon, 23 Feb 2026 13:50:18 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BC5BB3003D93; Mon, 23 Feb 2026 13:50:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854624; 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=Vk+tuv/N/RyMuDjUwsZcUAlFQUcm2Bq9JgF070ZHc08=; b=S5JW4JxdBGcJwhm1m7ZBuJva/32v48tzAbmi02Di7TA3M2rh8GNZGb6jsRjykHJgsJyBR4 8FIGHTuijvpAcYkVSxH4INWxDHKxbG2YsmFCYh9bsWHrpXRHEGNCK3uqobui24ip29rhXQ g6jGZ2ohFiA1n5dKqlmz/fkkgZWe9lw= X-MC-Unique: B600x97SMimrptI41Al3lQ-1 X-Mimecast-MFC-AGG-ID: B600x97SMimrptI41Al3lQ_1771854618 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Christian Schoenebeck Subject: [PULL v3 59/85] audio/alsa: replace custom logging with error_report and trace events Date: Mon, 23 Feb 2026 14:47:00 +0100 Message-ID: <20260223134731.2377432-60-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854977122158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 8f226b42612..889240ad0c7 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854939; cv=none; d=zohomail.com; s=zohoarc; b=CXsfeKflFSumyrfllWw3OujpsDZKAjgGlTNXqoegQjTlJYMeh2Ed4gvpA4CqPu+GAhCT7FTIYl67g/oJ1EEA6UXm5rCHoSlUCPcFkBTkmXD6ek3V9pC8H1VW+9HlkTTCkBEM9J9xl0K95NySbCigWzoJetgsB9TQFbZey4m48GQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854939; 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=+Z5jcvVXOzhqc4lUNGAawG594MBKHCLsZuQLgSkTre0=; b=WWGejtZuK3qgnO6OeU0tMJerpYTRGo8290gUMibKgNxOTVEvVid6BYL/mSkh/Y7k5YfWHfbX5vsaqXmGxeZ0hpR4JrAMwCO/KEnbjZtyr8VnPmiJHujZQXEHMHbghD2vEG588pOtdRe/tt51xiFeGN09f4ldmjiyLM6e+pLfaKE= 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 1771854939403655.7405656794886; Mon, 23 Feb 2026 05:55:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWNl-00048Y-Ms; Mon, 23 Feb 2026 08:53:53 -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 1vuWKW-0005pD-HE for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:35 -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 1vuWKO-0007Uj-PV for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:29 -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-683-NPIP436uOk6e4cdbveF5_Q-1; Mon, 23 Feb 2026 08:50:22 -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 5021D1800341; Mon, 23 Feb 2026 13:50:21 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 843A71955F29; Mon, 23 Feb 2026 13:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854623; 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=+Z5jcvVXOzhqc4lUNGAawG594MBKHCLsZuQLgSkTre0=; b=XqepJbsfbX2jXGjxkfN+P2u7pnc6iNjuzqjmDQSazznXnfz7xXWPQYzzxfBK7PNzeolrDd FPp3wA2O5ONKhesSJoGks8FWpDFSwmnfjeV0iUGpksz1YWUz0VQexKGjE48hj12bDSqIN3 PJI3jWa4adLR6DROwHd+TRRzkntOgXc= X-MC-Unique: NPIP436uOk6e4cdbveF5_Q-1 X-Mimecast-MFC-AGG-ID: NPIP436uOk6e4cdbveF5_Q_1771854621 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Christian Schoenebeck , Akihiko Odaki Subject: [PULL v3 60/85] audio/coreaudio: replace custom logging with error_report Date: Mon, 23 Feb 2026 14:47:01 +0100 Message-ID: <20260223134731.2377432-61-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854941512158500 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: Mark Cave-Ayland 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 561c08f47c1..0c0e8583c89 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854926; cv=none; d=zohomail.com; s=zohoarc; b=XGTpJIJiT7oaLLmeqtg4BmSOqWi1VzvXTcuomqwaix3lPI2F+3/H6AxqaY/zjRds2tps6FclwTdbCAr+9YGoo8C6LXDIhX3Wuibu/6hzy2w/lTG+TK6I55gKOW8fzSepAl7OFQaVNSBMNlvWVv4I8eK4uxu3BVdV/4I8Cw03v9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854926; 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=Qe/NKZtpuOPVFCVSXFuizpRBF5ZXWhkVFvUnqc8g7tc=; b=EmSzZlsdsrrvoCuCIRJZUFQMYFH7gLsNQh7SL3uzLGk+wqdtk/ROg0OYDSechhoZPRTm+4TGBRQSlj8DZseQ5wMYrWDXw3H/lWcS9jv//bAz7mSlVNOul70DcIFAEBcGILwehvCQaMq/qVpT1bn6Y2BmE5mzSzT/6RazxXa9rNs= 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 1771854926240585.0555477425875; Mon, 23 Feb 2026 05:55:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWO6-0005Ns-Mm; Mon, 23 Feb 2026 08:54:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWKX-0005pN-Qo for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50: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 1vuWKT-0007VB-Pg for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:33 -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-512-xEVRmxo7O8G1DVE6uCaK6A-1; Mon, 23 Feb 2026 08:50:25 -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 1CDA01956075; Mon, 23 Feb 2026 13:50:24 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6C8863000C26; Mon, 23 Feb 2026 13:50:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854626; 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=Qe/NKZtpuOPVFCVSXFuizpRBF5ZXWhkVFvUnqc8g7tc=; b=UAnXMt1L399elgWMplNNIAydMT7PMHYGZqXj4UTluEEb89gr17ZuZvV6BprwVnvGzZNnjj Uo/AFVOuvgLeXU8WrZwOnBmmhWHmJr514lfUjmDHlE0TIVq/h5Cfv1wA7fnMOgmnR3bIg2 QiBJCwQF9y9lQKXfqwW9nWd3fHoSbyQ= X-MC-Unique: xEVRmxo7O8G1DVE6uCaK6A-1 X-Mimecast-MFC-AGG-ID: xEVRmxo7O8G1DVE6uCaK6A_1771854624 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 61/85] audio/dbus: remove unused AUDIO_CAP macro Date: Mon, 23 Feb 2026 14:47:02 +0100 Message-ID: <20260223134731.2377432-62-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854926753158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 d8e548bf469..5f65c043c16 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854938; cv=none; d=zohomail.com; s=zohoarc; b=hdT9MoWWUk9qvocEkwW7dx4VhwIVy7rMs0ObHQiOR8cmexBzSBNSh5K+/M4173xCvBKqplO07WikF92HC5BazWkdA/eVAVzricAr0GjmZ3sfWFoQHF4R6vOn3tS1pUtzeFSDCHLlvanwTSf6ubz2DwyiQhcdS2/bv1609jcCukE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854938; 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=tU8A8yNmRs3t3CFeMlOVIUqpL4KeMsMPANcwdYdk6c0=; b=bcR1bligYadRpBzowrCrQqc0upWBARgqHXD7X1DUP8jofwwaVT8RAEd+jQ7beWdNwE9JCx+QZHNyTaeTvRf8CrVB4pUb4H9zXDJzL0Pr2KzGRM3rqCNnveIBHonLkjIo6kZnoqFqSqk+tnwdzuB5ImMgrhKMVj0PS7c+EgAGVVE= 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 1771854938044211.1108860240928; Mon, 23 Feb 2026 05:55:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWMc-0008Uw-EP; Mon, 23 Feb 2026 08:52: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 1vuWKe-0005s1-Vx for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50: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 1vuWKb-0007W1-4Z for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:40 -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-554-1Q4IRDfFOO-pJdu3W3SEHg-1; Mon, 23 Feb 2026 08:50:27 -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 A2B921955F3F; Mon, 23 Feb 2026 13:50:26 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C21E91955F22; Mon, 23 Feb 2026 13:50:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854630; 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=tU8A8yNmRs3t3CFeMlOVIUqpL4KeMsMPANcwdYdk6c0=; b=Io1h2jV+tJqA2KWvdyoBXDgtB9a2r4x167UU2iKxtTo80gXA9QsXYJCEnOdUH9QY+WJTrj XMN+X4xkh5GgPd6dZoUHc9yQ3ODfMw9giuEpJHP4hVnq+vppbrIi48DX2GUZOojwut2LKP fLCU+njrqamUVpwpOUHKnyPeI1ondK4= X-MC-Unique: 1Q4IRDfFOO-pJdu3W3SEHg-1 X-Mimecast-MFC-AGG-ID: 1Q4IRDfFOO-pJdu3W3SEHg_1771854626 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 62/85] audio/dsound: replace custom logging with error_report & trace Date: Mon, 23 Feb 2026 14:47:03 +0100 Message-ID: <20260223134731.2377432-63-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854939035158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 2c592c56663..704bc3da73b 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855096; cv=none; d=zohomail.com; s=zohoarc; b=TVwEhO8AHSw6zpML6dR+ib9sp1NSBx+7codvHRJk2BUpcWii93dqNd1n94OdYWhjkclvptEvy9dmFFGqYq6KxBizc3Zxrh477n9Z9s+GlXH89HysfdKSB2B743aS5AifW2kyhAR9kc5m/CVD5OkM/8DBHcj2gXPpVWVjbFlulEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855096; 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=tXlUokVOk05xaO6XwoA2MppkyQAliaUQDcaoGYgnaL4=; b=X39M2AXPLIk2UGcsX12VXCnNqZdaautQTeiVOrs+rn0eUxsFLYHYQ7wo1VrrDLVJr6yGfPgqyMMaTySUAbuwZ3jyvcEiKFyoKwK54UJq9NnwWhUPt6rdzYiML9Gd4orFzxoVnNB68Kiubm+EA5y5TWP/5CQJL4Jk2Sbg1fCElfU= 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 1771855096887772.9507613713826; Mon, 23 Feb 2026 05:58:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWOC-0005Oc-8Y; Mon, 23 Feb 2026 08:54: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 1vuWKe-0005rz-00 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:41 -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 1vuWKZ-0007WV-Vw for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:38 -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-376-eMkU2rObNTad6v56ytYWAw-1; Mon, 23 Feb 2026 08:50:30 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 16FE61800464; Mon, 23 Feb 2026 13:50:29 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 88845180066A; Mon, 23 Feb 2026 13:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854633; 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=tXlUokVOk05xaO6XwoA2MppkyQAliaUQDcaoGYgnaL4=; b=YZulAvBamC27t7qZeMlTWqZRDufEJHIfZO06Q5vuQmMFDViKhmdEq1Wigr3glArkXBPihv URbN1m/SeCqBVE5c+NNh3Y3fDf6k/b69FVBYJlNX7/Sn7O9yDZi+AutopCshHAHtfBoTFT lbtdQoCyVa7XQxJ+jwRJUvoCT3xcksQ= X-MC-Unique: eMkU2rObNTad6v56ytYWAw-1 X-Mimecast-MFC-AGG-ID: eMkU2rObNTad6v56ytYWAw_1771854629 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Christian Schoenebeck Subject: [PULL v3 63/85] audio/jack: replace custom logging with report & trace Date: Mon, 23 Feb 2026 14:47:04 +0100 Message-ID: <20260223134731.2377432-64-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855097796158500 From: Marc-Andr=C3=A9 Lureau Replace the custom audio logging infrastructure with standard QEMU error reporting and tracing. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 e415e94e6e6..a2f725a3232 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854944; cv=none; d=zohomail.com; s=zohoarc; b=FwQ8R4ryxcxnAHkKo7Yye1PJNqme1gJ0lWBKxGalSoEn14XoUp9yPIhar0ToxbTytYXOTVpun9AfBZONJNny8cqLWGlt4xd/pItffQUaL+WYIPPK7vBjct1QfapA0kngY9DDtZBiuGGb4nonl97BNLsVCg+KkDesZ7sdl871OsM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854944; 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=d8K4Q3eWbqo+rZ+tADd7spS5mtAX9KasBSykqrnMWg4=; b=iLQtltXffCfM9mngh3MfbxbX+dgAUEhQ9BbRlvt+zY7lqa3gAvl/9aPlIHuGpIrJOAI2tUZBm64O4LWJEcykpGbhrfFPjeeRBu3GHHy9oEltBJm84Itj/B1VCwcxizDKA1/itXRUuR2xt94qiQSF6++alqel1/jwmz0aYDWNXQM= 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 1771854944085591.2091884127208; Mon, 23 Feb 2026 05:55:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWMQ-0008EA-PJ; Mon, 23 Feb 2026 08:52:30 -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 1vuWKe-0005s0-0l for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50: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 1vuWKb-0007Wg-52 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:39 -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-121-3n5r_NnWNxWeTMJqaBkfAg-1; Mon, 23 Feb 2026 08:50:32 -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 67FAC1800378; Mon, 23 Feb 2026 13:50:31 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CD56230001BE; Mon, 23 Feb 2026 13:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854635; 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=d8K4Q3eWbqo+rZ+tADd7spS5mtAX9KasBSykqrnMWg4=; b=Y6VGBgDm2Gm9aF+0/Av9dO0jSa1Rajw5mKAOXXL7ywfQ8Xi3nqwVMR0yIJETjwK/BFj2Y3 3UIgM4LyrQhcNfra8p1epTRthUgeglJEbVvsfdIyBj7HbZnw5uTZixvmats+4SjujBMkNT m0/kY3a1G8Tachm7FpybGAdSHujpz0k= X-MC-Unique: 3n5r_NnWNxWeTMJqaBkfAg-1 X-Mimecast-MFC-AGG-ID: 3n5r_NnWNxWeTMJqaBkfAg_1771854631 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 64/85] audio/noaudio: remove unused AUDIO_CAP macro Date: Mon, 23 Feb 2026 14:47:05 +0100 Message-ID: <20260223134731.2377432-65-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854944843158500 From: Marc-Andr=C3=A9 Lureau Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 e056813181a..70316c572ec 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855096; cv=none; d=zohomail.com; s=zohoarc; b=bugzdf8vW5kG241UPWm8oUvz6Tb5/STx3BY8OD8i3F9qGwVRByqPf3gApGvEvGJ83AdTnuk2YfFUrGUtxIqN3kZFv7Z3Z9L9a6Gt7RcnTLtvbXvO1ruLsvefSGBGRQ2tDedbHmR/Hf1WAh7D92IWlzm6VmGKLrxDeQkURGYvS20= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855096; 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=XPyKm0uIZ6EnWYaaOkmTTzkbOadyDmkb7sT93ZCTKz8=; b=SOmdyoPh2ZJZn7nAKw78lFxpv5JXwt0yR5AdZmz7D9LZLiUiwzmgQ3JnLU6MJjt8HPegM0iMQGBeYzjOv88y7us6J6h4n2P6OuhxccwWsLuEG2SID98U3nEA7ZyPNwon67ucFB5dBcANiJeJ+s0VlkaL6VlG0G6EI1jg1seuwnM= 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 1771855096845662.9896157044069; Mon, 23 Feb 2026 05:58:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWMv-0001MC-Q6; Mon, 23 Feb 2026 08:53:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWKg-0005ye-15 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50: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 1vuWKd-0007Wu-Lv for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:41 -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-86-2gkRyIPBOdqf2zyo3e7m_w-1; Mon, 23 Feb 2026 08:50:35 -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 3C6641955F3B; Mon, 23 Feb 2026 13:50:34 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7542330001BE; Mon, 23 Feb 2026 13:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854638; 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=XPyKm0uIZ6EnWYaaOkmTTzkbOadyDmkb7sT93ZCTKz8=; b=VV7Rtc/1zFDDuNh6IRmyBzSr45lA0t5IXMWM4vaZYtV7pzUFumDRSWtgHBHGutx5yBpdyl bfFY2QT1Jq27xmtJLpTj7pHqNmgPYv1JQAMzZJMY7QodtoFgVBDWy5pkUWP1nHENzSn6Mr izdDxVIDbmxdHHvt6yszx8OpKCJ+geA= X-MC-Unique: 2gkRyIPBOdqf2zyo3e7m_w-1 X-Mimecast-MFC-AGG-ID: 2gkRyIPBOdqf2zyo3e7m_w_1771854634 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 65/85] audio/oss: replace custom logging with report & trace Date: Mon, 23 Feb 2026 14:47:06 +0100 Message-ID: <20260223134731.2377432-66-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855097888158500 From: Marc-Andr=C3=A9 Lureau Replace the custom audio logging infrastructure with standard QEMU error reporting and tracing. Note the patch drops DEBUG_MISMATCH condition, and now always trace actual audio parameters. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 d12c65dd0d7..81f49f9a7e7 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855105; cv=none; d=zohomail.com; s=zohoarc; b=bhVHm21SaO1UgU9UUbOx/LEajeT1LUqmKWZjAq76Z9HH6nDxN505l/cHYsstTe0DHXo0hqBpygLv6fW6SLaYz3i2Ml7f3swzA+l9GGjUE1YhIXdezi2QF8aAvYucUsD/Km60+RRB2mp0Zn+0PE40KCAu1k8vYfSm4jD8GUJz0XE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855105; 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=PpbyI6BL5TUAi9nTekVnBuEQGB8f86bN7DiGo4Y665s=; b=EZWgOdpw1VPXygxlFVM8x0Co7TJ5G555nXKrQiVALOLVj1VLPEG6X2b+PHHyvgzn04Aw8QZrjJZt8dJMUi1B/R91ItvTHqRKuqup5r7UPPQ0GugF3Ey4o+i1wU7qP9cdkR6/ODW9ohu+Fj2hDWLkL7k7ZK86J+gLE7fuE1yjcf8= 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 1771855105259838.0075035040546; Mon, 23 Feb 2026 05:58:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWPC-0006Lj-Ds; Mon, 23 Feb 2026 08:55:22 -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 1vuWKj-00065I-MX for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:47 -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 1vuWKf-0007Xf-QT for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:44 -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-407-K_lv-a1qMZqXH5G0NCB01g-1; Mon, 23 Feb 2026 08:50:37 -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 98BEE19560B3; Mon, 23 Feb 2026 13:50:36 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DA58930001BE; Mon, 23 Feb 2026 13:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854641; 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=PpbyI6BL5TUAi9nTekVnBuEQGB8f86bN7DiGo4Y665s=; b=DLkZScxFxyfyI64Sk1w3bcRVq1iP4EsiWYLMxDGVxYQSNk9HQNcUY5ZDaDdyySA77CLl5P k9XHrAuVEt7Awa1qiz4XVk627Nit6nlV0qkh2N0sTTxAP0CHRRb8CqhrGcJ6QbeTMZ4ySS PmZsTlDrj5OzDuq6dVF6TqSbsfdKl3A= X-MC-Unique: K_lv-a1qMZqXH5G0NCB01g-1 X-Mimecast-MFC-AGG-ID: K_lv-a1qMZqXH5G0NCB01g_1771854636 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 66/85] audio/pa: replace custom logging with report & trace Date: Mon, 23 Feb 2026 14:47:07 +0100 Message-ID: <20260223134731.2377432-67-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855105909158500 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 *. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 b7826402e12..1501b26386a 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855096; cv=none; d=zohomail.com; s=zohoarc; b=MtfhW+DIKnXHkQ+13RyEtZvkWYlUS1N+IwFzqN5UuJ3VxHuA5++QGKM1YSgjUCp3gijQLjzKfCUU1/u81aQ4Ia6s7CUtSJQQtyZPVjCuSyLVpts+TEooYOyml25ul9PZRVV2/yCkKxcwJd7AXmUflHsrsnPFBlaS09fJELsyiq4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855096; 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=BlvSqwSi5p6HvV5NUZQ1P6/nC//iuZk8I7I3m6Rju4Y=; b=elXRW64I2+dPTvSNrezntojxwVWe4OamqSvMT9qf+9jMsw+EcC7+O2WNX0GPhlOpLuL4ziJsqkJIbdwDsqnzmafAaneWOlZFKyl9/3gn58ZMkGUuluyFH0GolnQ5cQ4b29+3rwLT+SpsEtsh3Ek6Xvad70TY+IlPkz/MuxFQRcM= 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 1771855096299434.41570290074003; Mon, 23 Feb 2026 05:58:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWMo-0000W5-E3; Mon, 23 Feb 2026 08:52:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWKj-00065J-RC for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:49 -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 1vuWKi-0007YH-DT for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50: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-395-Gfhr-RFbOPqTPV167CCcSg-1; Mon, 23 Feb 2026 08:50:40 -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 6689D18002E6; Mon, 23 Feb 2026 13:50:39 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 706C319560A3; Mon, 23 Feb 2026 13:50:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854643; 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=BlvSqwSi5p6HvV5NUZQ1P6/nC//iuZk8I7I3m6Rju4Y=; b=e6R3uu5FzzcXx4FPQ/v91HEbXi41JLf5MjHEyAr5j0g75y63CTo4mzL55zA6m68nVn63EM 6FG2nsg7MNFJO7iuRUY9/mnLrRaS0MVf36AW13qurdzl/p9N6eAdII4pWDiUB3flEIjvu2 bGxk9JYSe7/gE0E7vIPp1pMU/HWuGcE= X-MC-Unique: Gfhr-RFbOPqTPV167CCcSg-1 X-Mimecast-MFC-AGG-ID: Gfhr-RFbOPqTPV167CCcSg_1771854639 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 67/85] audio/pw: replace custom logging with error_report Date: Mon, 23 Feb 2026 14:47:08 +0100 Message-ID: <20260223134731.2377432-68-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855097718158500 From: Marc-Andr=C3=A9 Lureau Replace the custom audio logging infrastructure (dolog macro) with standard QEMU error reporting (error_report). Reviewed-by: Mark Cave-Ayland Reviewed-by: Thomas Huth Reviewed-by: Akihiko Odaki 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 7a009a94f3a..6a80e5a333e 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854930; cv=none; d=zohomail.com; s=zohoarc; b=MOij0OMnL60MYfGsyiLaR7T4lBxSI2F/frEIdr3SG82VnqRqZSwDGpuPQ67l5iReO2/uA381Ux0yoNcxBEMqmKyFZel0RFKN9timzCHqjZnwOFjABDGUyZjOYJdwt5JL0WZnd6KAirdwm5LXIKPjQYqsGflmgGocK+SuvGkHDxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854930; 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=KVxGTqGui8DihhEqyeAGveMoKpNCaaSNpKNzs+Wt8ck=; b=TAgXW7T8HfowJhLrv4Uc8Zy/SUsxmAbRWEp/4zvCN8D78ELNeATXuCVVUtdSoTa+p9Z4APHeA8SvFTQvAmkbR+W42zKgmqFJMDDLp4ZLy5JWIyP0AIU620ioZqYzpkzLlLEq78wpjOANfv70eM2XnIPnICBmF6eDfFI0yt7feAs= 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 1771854930810120.80781274024366; Mon, 23 Feb 2026 05:55:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWMq-0000ky-JN; Mon, 23 Feb 2026 08:52:56 -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 1vuWKn-00066s-S7 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:00 -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 1vuWKl-0007Yq-02 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:48 -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-107-zIUnSbBjPwePfku5wEq08A-1; Mon, 23 Feb 2026 08:50:43 -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 031651956095; Mon, 23 Feb 2026 13:50:42 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2253F1800670; Mon, 23 Feb 2026 13:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854646; 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=KVxGTqGui8DihhEqyeAGveMoKpNCaaSNpKNzs+Wt8ck=; b=Tveip75Bl7e/V6kSbB5SC+jK0Rr3IsXaY5M/o+auv4TRXdMNflZGlBdYVDYTk1o0wKg9QT mbypUXLntJ+uROwQj+s/WbDgeaegqfVQinwQnaVr4Hj5xHiTELLTogpNWZCO2ODsL2Ge7Z AE70U6beUbSnFUFHEr6rP7tTpFye77U= X-MC-Unique: zIUnSbBjPwePfku5wEq08A-1 X-Mimecast-MFC-AGG-ID: zIUnSbBjPwePfku5wEq08A_1771854642 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Thomas Huth Subject: [PULL v3 68/85] audio/sdl: replace custom logging with error_report Date: Mon, 23 Feb 2026 14:47:09 +0100 Message-ID: <20260223134731.2377432-69-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854932829158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Thomas Huth Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/sdlaudio.c | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index d974d7eac46..5f332678209 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,17 +67,6 @@ typedef struct SDLVoiceIn { SDL_AudioDeviceID devid; } SDLVoiceIn; =20 -static void G_GNUC_PRINTF (1, 2) sdl_logerr (const char *fmt, ...) -{ - va_list ap; - - va_start (ap, fmt); - AUD_vlog (AUDIO_CAP, fmt, ap); - va_end (ap); - - AUD_log (AUDIO_CAP, "Reason: %s\n", SDL_GetError ()); -} - static int aud_to_sdlfmt (AudioFormat fmt) { switch (fmt) { @@ -102,10 +91,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 +150,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,27 +168,27 @@ 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 =20 devid =3D SDL_OpenAudioDevice(NULL, rec, req, obt, 0); if (!devid) { - sdl_logerr("SDL_OpenAudioDevice for %s failed\n", - rec ? "recording" : "playback"); + error_report("SDL_OpenAudioDevice for %s failed: %s", + rec ? "recording" : "playback", SDL_GetError()); } =20 #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 +219,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 +267,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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855096; cv=none; d=zohomail.com; s=zohoarc; b=JBrqZJ0F00Y2pUaRUXIktOvnIhsQxEfpNzVPMEjgNb/N4lN2rItzD4Tv0k7uOxLBKijyqhgkpQKdSiRkUQWBQzJu9Uhbl5rm2i0xMYl11jrFxREDqVfVJSJtwo1/HU1S1e/7d6k4OwXrY+Y9cGPRGuwdwS2sLHCsjIigm2iBUSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855096; 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=sjruiADZLPP8r0KetuQzZJsFWpLAik5UDokSmcYCF4s=; b=LF/FCDec+raLaOWIIiKU01cQv95PmnaeMCYSEe+EHgNuiZ6BxDJNV8HACyvjvv5cz+HenBhjo6140+WLvnGhCLhJn86uzoq3SWCEy6h0ioqAs/VisbdtpHRr2L4AZAcc0M05bLtyL1DPTa7K6HBIHTh7qcBIre2hqB5jXwq8O+0= 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 1771855096616801.3274761006397; Mon, 23 Feb 2026 05:58:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWMv-0001Ll-Oz; Mon, 23 Feb 2026 08:53:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWKs-00069F-5T for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:04 -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 1vuWKo-0007Z8-QZ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:53 -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-637-lvMce6xvNTejgtcXPnUo0w-1; Mon, 23 Feb 2026 08:50:45 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8451B1955F0E; Mon, 23 Feb 2026 13:50:44 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0170619560A2; Mon, 23 Feb 2026 13:50:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854649; 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=sjruiADZLPP8r0KetuQzZJsFWpLAik5UDokSmcYCF4s=; b=P41txlu1GnfRRkr6/4Be8j/CmcBS2l/rH7oaChKSCcuEl98WafHvlaelKROSW1ghkHO86h UjpblnAB1n/LeRCJlbCE28koEkGHNQHuZ5q6iJ5ojEpuRPsuCho/TjkG/OOaYep/R5/sQq TQ5L0ZgchnDN+XRlk2PjjLW3CmbuTYs= X-MC-Unique: lvMce6xvNTejgtcXPnUo0w-1 X-Mimecast-MFC-AGG-ID: lvMce6xvNTejgtcXPnUo0w_1771854644 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Alexandre Ratchov Subject: [PULL v3 69/85] audio/sndio: replace custom logging with error_report Date: Mon, 23 Feb 2026 14:47:10 +0100 Message-ID: <20260223134731.2377432-70-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855097766158500 From: Marc-Andr=C3=A9 Lureau Replace the custom audio logging infrastructure (dolog macro) with standard QEMU error reporting (error_report). Reviewed-by: Thomas Huth Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 21f43836fd1..766eceeeefe 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855029; cv=none; d=zohomail.com; s=zohoarc; b=L3LOkLjJwSISmaQv4ZkfX6QrS2IiuWxF07blgaJo1g8odMlHR0O8jkAsepxRxtpO+hS0K+0Fr4oTa6bMfIt4+eeNxS5ijpDNDaj7it9dKQkW1WiU0pF48lmGbuTZqLM7oTDW+mMxpHaLTpRAKRhRPDNejo/T0kCu+aCSp0KeU3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855029; 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=6kxBfDt6iGl2ypAk7+m+3SrhYCySWZ5bRB5vgqjdnOc=; b=LhEG8CxYWuAzO5lljNNQVXQN8jFaHbJAi7KPdbxpaD+/HJ53gx0BUo2iie3ObG/9qnqex0YM+9QxRIMq8jmnIhkRMCElPMEIb4wbudVWCNZUVmAiC5xiQJb2SOc1Ntjqw/TSfsiXkJTSWfAKmwuEZip0tQsAvhWVNH0y1GMXiCs= 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 1771855029837962.6743839211057; Mon, 23 Feb 2026 05:57:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWLX-0006p5-U9; Mon, 23 Feb 2026 08:51:37 -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 1vuWKs-00069E-5F for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:04 -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 1vuWKq-0007ZW-EL for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:53 -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-316-JVitDgMMMbu_A1DhfAAfaQ-1; Mon, 23 Feb 2026 08:50:48 -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 1F8AF1955F03; Mon, 23 Feb 2026 13:50:47 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5915C1955D71; Mon, 23 Feb 2026 13:50:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854651; 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=6kxBfDt6iGl2ypAk7+m+3SrhYCySWZ5bRB5vgqjdnOc=; b=Bb55+1Sq2nlAPAMQW91dZz9H5JHZXMxIzcUS5Us1bUJDflafZQem+ntdGaKd0ujYoape+n w+rD3xNX7GAy1UADRJvcuZJzraSnG05Jw0rnjtjKBC3iNlyz9Y/wSvfnBmQ5Xbw+7W0qOR yWp7TVSLMfOqn84fbrRc/Hzwuvya/VA= X-MC-Unique: JVitDgMMMbu_A1DhfAAfaQ-1 X-Mimecast-MFC-AGG-ID: JVitDgMMMbu_A1DhfAAfaQ_1771854647 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v3 70/85] audio/spice: remove unused AUDIO_CAP macro Date: Mon, 23 Feb 2026 14:47:11 +0100 Message-ID: <20260223134731.2377432-71-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855031335158500 From: Marc-Andr=C3=A9 Lureau The AUDIO_CAP macro is no longer used. Reviewed-by: Thomas Huth Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 0d188e974df..81b897e13e0 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854945; cv=none; d=zohomail.com; s=zohoarc; b=G+gCVzWermc3Y1TOGli9oJ8ihagqtIUyHeAUEuaisQlgaOLWwQ9Cp/+kjKx/yTod2HXUgvoXNaJWDL/4f5vXjul2xmKA5GpBcVIdviEdaMtlG6yo+nDWis7BLvGlnPH4VrqkWMcl9YyWPgqLx4T1xbOtFMdTfbh5YKJyrl8mpsg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854945; 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=ar5aM1J8ZUXRWvOtSSZ03Adb7TEhAQDZwCj6IX+ktYE=; b=HM8yfTn95c6egWuETjhVoQEDefIu4cAo+L7LRzVSGIdfE2D73T9/8WNwcf8SF9C8gzFoKnDzpvvQ3se68J63afmR2nd65X2DLX46lBbloU3vjcsI916G8zAl304egnaJBc+vIDOR5Q9CI7JDXtiX03ZU4rgn0wJa6TGzyhEjAQA= 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 1771854945680236.0042460203972; Mon, 23 Feb 2026 05:55:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWP4-0005r6-BF; Mon, 23 Feb 2026 08:55: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 1vuWKx-00069i-8e for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:06 -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 1vuWKu-0007a4-DM for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:50:57 -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-424-lLibiYLEMlWLJDsMRsavFA-1; Mon, 23 Feb 2026 08:50:51 -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 9905B1956079; Mon, 23 Feb 2026 13:50:49 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1E9CF1800370; Mon, 23 Feb 2026 13:50:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854655; 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=ar5aM1J8ZUXRWvOtSSZ03Adb7TEhAQDZwCj6IX+ktYE=; b=A2mKUeHj3VfgV3w75n/eP7eSABBJapvPDQR1ecezca0FR6paDPeqxRvOL9me0tNxkPCEUv qW14sOSaeB4AQGfO8Gy237LJgyXb3MxDRbCXTGrfUO6Vfc0bXg/1OmbVcvDcXSG/iciEox cAMuPiaLgEBpM0vEqCttX0VaPpKfc0Q= X-MC-Unique: lLibiYLEMlWLJDsMRsavFA-1 X-Mimecast-MFC-AGG-ID: lLibiYLEMlWLJDsMRsavFA_1771854649 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 71/85] audio/wav: replace custom logging with error_report Date: Mon, 23 Feb 2026 14:47:12 +0100 Message-ID: <20260223134731.2377432-72-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854946926158501 From: Marc-Andr=C3=A9 Lureau Replace the custom audio logging infrastructure (dolog macro) with standard QEMU error reporting (error_report). Reviewed-by: Thomas Huth Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 ade8fd1d8c3..eed1e501af0 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854926; cv=none; d=zohomail.com; s=zohoarc; b=mMgFa3vgBV7vsk0pjCwCFF3TIcm/wOP5jtQRYhyfOXjmt6auKjjDujfJOwoomdwP+WmSU5ZZD/zRGIVvCexx+U0VnWVcQTwD/HcqlGQE9Eig5WTNSz6hrPM2s+UkH8seR/aSljxc2FBnKuNBiLxD6Y+Ab5BGhsLwGaIgYE0te9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854926; 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=9PW0mPhi96B1jy2liciMA8T0hiAyIY89/0XH9xb3rNg=; b=a1e+7jfVFCP2c/JX0a9OxKejGYtlvJhe9PcsptTbuardwnXM9xT9WFja4l8sVbOLO8bV6bZAhPo24UT+5Alwf/CQSVWb55ktJKiEiTFCkks0/T/u+TdB6xEfTQmMOqEuAt2yG5sYwlryg9VYgLSB1kYQ+fXaiH1j9KsZ7/f3/LM= 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 1771854926911241.90001195407285; Mon, 23 Feb 2026 05:55:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWOy-0005nR-3D; Mon, 23 Feb 2026 08:55: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 1vuWL0-0006AU-SB for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:08 -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 1vuWKw-0007aB-U8 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:00 -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-608-xEbIj4TBMkm8CfEi_cFPtQ-1; Mon, 23 Feb 2026 08:50:53 -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 0DE33180025F; Mon, 23 Feb 2026 13:50:52 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 660C719560A2; Mon, 23 Feb 2026 13:50:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854656; 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=9PW0mPhi96B1jy2liciMA8T0hiAyIY89/0XH9xb3rNg=; b=hnGPY5ZQBkS5UNLMYIViLL+VIwE3ie/mvS5lzHtUqnvqaqCFKt8I6ba5osZ7bT7ylZXQUo tt+n1OffDW01YDSOng6vOMbWHC46N2DYOFRmqAl7FDpOm87b8ftqiafP6w/T3eHV46/xU3 VbnEAVZbq2wbB/srKUORKESrVBlwyVs= X-MC-Unique: xEbIj4TBMkm8CfEi_cFPtQ-1 X-Mimecast-MFC-AGG-ID: xEbIj4TBMkm8CfEi_cFPtQ_1771854652 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Christian Schoenebeck , Akihiko Odaki Subject: [PULL v3 72/85] audio/mixeng: replace redundant pcm_info fields with AudioFormat Date: Mon, 23 Feb 2026 14:47:13 +0100 Message-ID: <20260223134731.2377432-73-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854929288158500 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 Reviewed-by: Mark Cave-Ayland --- 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..9e4566d60aa 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 d02cfe3c509..931d5b206f2 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 5f65c043c16..b212b3d6022 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 0c0e8583c89..1f4b3d9d467 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854985; cv=none; d=zohomail.com; s=zohoarc; b=WQuxVAYla1ikPhaEhl3nxOs0WQ2SpKnETmzMrbnWkTsqr8TYPSuMt831epF/bARQQ4sTIhbZziA508Mes3HWxCDFdOVXZzwSpnqjykm7brAm4UPvVKTmrTkJLIfVrPeN9134UC0yC6/NMs3MPSjX4k+rW3OkOdEjbLUYc3EuNRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854985; 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=v/djo1cSnBgWLBAGa3V5cosB4hdsRmJsPf7agbTYpJ8=; b=jS35GKjNIH4Nv1ZOyn5mX5wWuGPX2MM/AfVrpFube+f0lIXOUmAW/BSu6EoOIh+zOOLstGjArWmFJdB5D/4cCX8S5xU6QETwvI6uakpnz6cqroDKXzY/3MnYsdLawIT8UTsWS0WeJeg4Dn9d5DC/wMRo+Vv+OzEfpY91LOO6Vtw= 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 1771854985545387.9179228608376; Mon, 23 Feb 2026 05:56:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWNI-00039x-E0; Mon, 23 Feb 2026 08:53:25 -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 1vuWLC-0006IF-7s for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51: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 1vuWL6-0007aj-IE for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:13 -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-683-h73LWp88OXi93iMMESZRZQ-1; Mon, 23 Feb 2026 08:50:57 -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 A3D8C18003F6; Mon, 23 Feb 2026 13:50:55 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4600F1955F22; Mon, 23 Feb 2026 13:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854663; 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=v/djo1cSnBgWLBAGa3V5cosB4hdsRmJsPf7agbTYpJ8=; b=NKNxZDupVEzcR4+/odY2/FNb1VMIB8WlJtrC3158n0QGVe2BuHaejs164wawolXyW+Ayah 4a6lWBPkRjnwefD5j8vyrh+Hr4bZFlRQSCiFqzlqhBauwDe2ObDz1g3JgZd+WgLnJSUR1h Elhv5meScr0pmFBR+gj/S/pWMEwZR/Y= X-MC-Unique: h73LWp88OXi93iMMESZRZQ-1 X-Mimecast-MFC-AGG-ID: h73LWp88OXi93iMMESZRZQ_1771854655 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Christian Schoenebeck , Thomas Huth , Alexandre Ratchov , Laurent Vivier , "Michael S. Tsirkin" , Manos Pitsidianakis , Alistair Francis , "Edgar E. Iglesias" , qemu-arm@nongnu.org (open list:Xilinx ZynqMP and...) Subject: [PULL v3 73/85] audio: replace int endianness with bool big_endian in audsettings Date: Mon, 23 Feb 2026 14:47:14 +0100 Message-ID: <20260223134731.2377432-74-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854987236158500 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(). Reviewed-by: Thomas Huth Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 9e4566d60aa..cff8a334f36 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 889240ad0c7..e2290ea814a 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 931d5b206f2..d05202aabae 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 a2f725a3232..d9ae8edc0e0 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 81f49f9a7e7..157979e84b4 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 1501b26386a..c9957105543 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 6a80e5a333e..b70bf0c1353 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 5f332678209..936a3ed076d 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -96,56 +96,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 @@ -350,7 +350,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; @@ -406,7 +406,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 766eceeeefe..761f23f8273 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; } =20 req.rate =3D as->freq; diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 81b897e13e0..f903ef77e72 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 eed1e501af0..55d12d6cdfd 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 ca44fa372f2..b8376433f7d 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -389,7 +389,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 90d96ae0575..b87a12eb55b 100644 --- a/tests/audio/test-audio.c +++ b/tests/audio/test-audio.c @@ -57,7 +57,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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855429; cv=none; d=zohomail.com; s=zohoarc; b=ezIss5tQjyeC+jGHGb/2/PsO07uRE5rylNUBWbBr+fgODglsdZvOLbGjEKl6S9GUTnEk+CsUrAorT7hTDYhZJTOdq9SgaJmPpl0rUtpqy4tJnl682wxFcyP0x6J2r+ng2aVpI3hMPbw84PN31vvNCvbTLxGbDzl/U+eKdzvVAZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855429; 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=g3OAaXAmQUOzrQJUP1azsyJhaEVjpS4H5leIXvLWgao=; b=LkWo6HZuDnZ+1AqNW8DZYkmSWfgH7uSvkBfYXpEQHiFXgKHa42mkV3fqrG3Ph6WDYqOgCjrAzKaVktmo+3Ckycuku/lViFkqFeS5hn01z7OdE0vFfEUOdiLZ25rIeed07wLBf+OSQnJSLPMAdkrTZfPTEnNAdtiOF0qAiI9IqME= 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 1771855429458686.6559077247192; Mon, 23 Feb 2026 06:03:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWNi-0003fw-7t; Mon, 23 Feb 2026 08:53:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWL8-0006Dw-Kg for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:12 -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 1vuWL2-0007aa-Gp for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:09 -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-mwaAcOvCNg6-7rSssliQnA-1; Mon, 23 Feb 2026 08:50:59 -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 8D2AF180057E; Mon, 23 Feb 2026 13:50:58 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9EE2B19560A3; Mon, 23 Feb 2026 13:50:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854662; 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=g3OAaXAmQUOzrQJUP1azsyJhaEVjpS4H5leIXvLWgao=; b=OBEQj6Lb6X4DLkS2bvemr/9llW2BfJJJoTWiN4BORrMwkpEzJiZNaBlRiWdOeARezdYQrm q/eMWAAaN24kRJbKaiubFYXNKPd3Lx/OojntQRir20rpkiezJO1pN3TlYskFhURMm6ocQY 62Zy/3tvR4SJtGio4iYCb+O0ZPLmJ+Y= X-MC-Unique: mwaAcOvCNg6-7rSssliQnA-1 X-Mimecast-MFC-AGG-ID: mwaAcOvCNg6-7rSssliQnA_1771854658 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 74/85] audio: replace ldebug with trace events Date: Mon, 23 Feb 2026 14:47:15 +0100 Message-ID: <20260223134731.2377432-75-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855430427158500 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. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 d05202aabae..84e4d136de3 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855454; cv=none; d=zohomail.com; s=zohoarc; b=Br3HaGOXSjyfhqfNkt+QdF0Dz7Zj8qIbNjuCVdx4KrZRCln7PcnnPzoqgh28SyEKUVyA/EYrwTdSXMXohyHqrzfpYBOkxjIhw1E0mlAI/Xe7N6Ht93vIV2WRpaQsgvsQt2l7WsA55CtttVcV62cXmvuKUyVIO2Ofc2tQdOxitlI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855454; 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=Ou4jQEnKcubV1QPlYdNBoaG+K2hkcxYp7Svvph6VMJA=; b=BA+ZDEZpj4t6mpicklEJ8dO2bNORDeo31z56QIgas7n/Cs5RvnmAqdHK8uRw+dqOKagx/cAbBPbHM4qO03zvAN5i37T+CB/L4fnbdwU+XgY2hxfpu8pziU465z9ZPgTsPBqeNZy2yAkof/pLGSQyLiZLuyTE6fRHDNeuJ0Wfi2Q= 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 1771855454265454.38936631547824; Mon, 23 Feb 2026 06:04:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWNp-0004TY-5s; Mon, 23 Feb 2026 08:53: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 1vuWLB-0006G9-0F for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:14 -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 1vuWL6-0007ay-HJ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:12 -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-534-NG3SvTTgPEaCzmWQ0mJyFg-1; Mon, 23 Feb 2026 08:51:02 -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 424E81956063; Mon, 23 Feb 2026 13:51:01 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 47EBD30001BE; Mon, 23 Feb 2026 13:51:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854665; 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=Ou4jQEnKcubV1QPlYdNBoaG+K2hkcxYp7Svvph6VMJA=; b=EZPxno3Qdj7p9r0c8UDCmKRC4GWD7TdoL/wmT2RV/PDWw+bplIK/zLwpVEkrGSWLqTz4dt f1BzKkYzeH/JAfE7YBzyKgAmNEKDCBDCUTjcrD7abjn1e3acN6OrFTLJlX15GER0zpKs+y a1Jxmk2cT5XwUcSobsfbmclfc+ZCUMo= X-MC-Unique: NG3SvTTgPEaCzmWQ0mJyFg-1 X-Mimecast-MFC-AGG-ID: NG3SvTTgPEaCzmWQ0mJyFg_1771854661 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 75/85] audio: rework DEBUG_POLL Date: Mon, 23 Feb 2026 14:47:16 +0100 Message-ID: <20260223134731.2377432-76-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855454686158500 From: Marc-Andr=C3=A9 Lureau Use more correct GTimer, specific for each backend, with a trace event. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio_int.h | 1 + include/qemu/timer.h | 1 + audio/audio-mixeng-be.c | 25 +++++++++---------------- audio/trace-events | 1 + 4 files changed, 12 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/include/qemu/timer.h b/include/qemu/timer.h index 7c18da16525..b931181f53d 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -6,6 +6,7 @@ #include "qemu/host-utils.h" =20 #define NANOSECONDS_PER_SECOND 1000000000LL +#define MICROSECONDS_PER_SECOND 1000000LL =20 /* timers */ =20 diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index 84e4d136de3..2aeb05ba37e 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) * MICRO= SECONDS_PER_SECOND; + 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855221; cv=none; d=zohomail.com; s=zohoarc; b=PNzg1CleR/ewwMHJur65Q80vg/IKJMHhWCRNAmY788JQTgu9jb12aSm/nySdRXahMcHTAyGQ3ibVM10+b8DvQW5gbT7Ms67RxRhfBOcBXn0+HnzYi6jKDMRTDb/sgZcdU23Jq3AbyBhxJmrXQ7AYPtTV0i0BXptsS328TSODSNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855221; 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=iolbSR7ouNZT1Z1A/hTnNFQIrAqvCIZOr9ITrRjYxKc=; b=UR25QWn5v6zkAmIykkccCfxGIwYxbnnsShiHhActIhEByfUpNZ7tbe5eUqqYJuGXSCRWezggpxqMkwzQNLdEEZjSLdapQaAdCYDRaaf2n9GHJXMMuUuok7Qp8+nsMpInocKVEZHb15tPB86dFAug2Jt3HjXmrmBxtB3NZ/NGe2U= 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 1771855221177101.64419667331867; Mon, 23 Feb 2026 06:00:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWMy-0001kJ-U1; Mon, 23 Feb 2026 08:53: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 1vuWLA-0006Fr-D3 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:14 -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 1vuWL6-0007b4-HS for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:11 -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-434-d-DHmdP-Nwevi_XA0PrpKA-1; Mon, 23 Feb 2026 08:51:05 -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 2FA651956052; Mon, 23 Feb 2026 13:51:04 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 474E01800286; Mon, 23 Feb 2026 13:51:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854666; 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=iolbSR7ouNZT1Z1A/hTnNFQIrAqvCIZOr9ITrRjYxKc=; b=RftLkQ9oAQ/T/VeNTHq4g8HLXfqSLrsCOZFevHlHJ2jkG4PZ2uGL03CFof0grukb3LQrSQ oxmQKyfvcNtH1u6jkVU2JzqtUZZnGRVWvnAQnqaTvYpFtzPQx0uDFbBXRW3WRir+AOsrDq 3D/n2r0pc6dtsDQMxFP8mM3YgOFuJoQ= X-MC-Unique: d-DHmdP-Nwevi_XA0PrpKA-1 X-Mimecast-MFC-AGG-ID: d-DHmdP-Nwevi_XA0PrpKA_1771854664 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 76/85] audio: replace DEBUG_CAPTURE with traces Date: Mon, 23 Feb 2026 14:47:17 +0100 Message-ID: <20260223134731.2377432-77-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855222601158500 From: Marc-Andr=C3=A9 Lureau Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 2aeb05ba37e..1963f3e5c79 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854817; cv=none; d=zohomail.com; s=zohoarc; b=QjZ+KFlAaND/uq836JTKjT71q5R2ILfLH+/ZwA7BRFn1xe0lODlvV8xQgTn6LDuF6AX/hcrk0M5KWH5U7OiGGk0ASD/3L37Yr7me1XgtRlNlILj+WSAO0dTIZtGGPkm0/uZ8KM+REkSBBq8f3UGKHpo4jKgHfio6UakhUjoRXp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854817; 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=aSGwMcHbaVNmNkq5PewEZLomDYk0YM2vt8y6cmjQBeM=; b=TdLJIZTNhiklMuo3SEswUbBm2/ewY4nboYciZWjcsTabHVZkqB3mwxJ2rGilDMe9hE6EVcsOTx2Xgm03L0dt8AQIiJkKtcEBsKFAer8qn6MrfSx8sRypErF05KYvXKy52CcvVSsF67F+aLT7jdyIevx567fjOxZXetaX8X7FTGI= 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 1771854817411469.30166004641; Mon, 23 Feb 2026 05:53:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWNC-0002zX-LD; Mon, 23 Feb 2026 08:53:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWLB-0006G8-0E for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51: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 1vuWL8-0007bP-CN for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:12 -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-689-7En1FEOzNC-hWjyUT-Ge7Q-1; Mon, 23 Feb 2026 08:51:07 -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 A580A1956053; Mon, 23 Feb 2026 13:51:06 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EC6481955F22; Mon, 23 Feb 2026 13:51:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854668; 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=aSGwMcHbaVNmNkq5PewEZLomDYk0YM2vt8y6cmjQBeM=; b=I7h+l93ESLtmeRhdjZY7SHZCMHsWlBetl8eWvA4SykakfqZUC/ZSATfI78sqNPIB9YyFtW 2bq20h/qu9FAVAkz7l++zESoqjLvlR9hX4u2t5vTgb62q1kEGr9wKPVNvClyL3+Cip0PUL h3bnAy6FK1mzDRQ98zXiJwhWxzCMqS8= X-MC-Unique: 7En1FEOzNC-hWjyUT-Ge7Q-1 X-Mimecast-MFC-AGG-ID: 7En1FEOzNC-hWjyUT-Ge7Q_1771854666 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 77/85] audio: replace DEBUG_OUT with traces Date: Mon, 23 Feb 2026 14:47:18 +0100 Message-ID: <20260223134731.2377432-78-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854818196158500 From: Marc-Andr=C3=A9 Lureau Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 1963f3e5c79..3dd9d17dd25 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854953; cv=none; d=zohomail.com; s=zohoarc; b=a4ZojteV+hf2FHsFkQhAVlDisir3QxVmQHqcOXAWY4XcqHFxauOZuAp8u0tCoteSEa/Mg3YW7KOhE+44PwKaJtFz9o0PcYtTbsa3L3YsFdnkS8LEfc+Ql4YmUS09mjwJXgmM2Sghucj9kr3g/ts21WQ783LuDTwwA505JTh5Zs0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854953; 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=7X/MNV4QeRkE7ESVqU7kS01nb2TKxx3gRC5LLeydeXo=; b=DlLh1Q0fUqYFV2IbE/T15KsXaNXEe79EfFPfg7R+TRZcOaNCU6cHmHCK15vx4HsqFL+jltRiYeGatvahf7s+924HlKmidOgk91vd8zHI3ard3Gj0diogh2ux/GaisX+dwqjgUO1HwhEWuyccGQZYAOC0uX3wt43tMzbzg6LjWN8= 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 1771854953036244.3714837091993; Mon, 23 Feb 2026 05:55:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWP5-0005rJ-1d; Mon, 23 Feb 2026 08:55: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 1vuWLD-0006KK-IM for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWLB-0007ew-Vd for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51: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-428-lgr_e4CiPiaYKYfboRLgLw-1; Mon, 23 Feb 2026 08:51:10 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 51FC31956052; Mon, 23 Feb 2026 13:51:09 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C211A19560B0; Mon, 23 Feb 2026 13:51:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854673; 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=7X/MNV4QeRkE7ESVqU7kS01nb2TKxx3gRC5LLeydeXo=; b=UEs5GpCgEpsM9YBwegQISiF5L/6AYff756ADpMi1Bi+E+UyFLOzqhWDycjHKyTnB7uzhFi +FCHu/GNEFYeDV/cm8KgekeVy7wjHcLSRq60dO0eFnNyKS3XOA49B30K5RrRqdKU0Kze4/ cykOW6pGjmoFZd6x+mkZkwdcecSHVDQ= X-MC-Unique: lgr_e4CiPiaYKYfboRLgLw-1 X-Mimecast-MFC-AGG-ID: lgr_e4CiPiaYKYfboRLgLw_1771854669 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 78/85] audio: replace DEBUG_AUDIO with trace Date: Mon, 23 Feb 2026 14:47:19 +0100 Message-ID: <20260223134731.2377432-79-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854954934158500 From: Marc-Andr=C3=A9 Lureau Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 3dd9d17dd25..7eabb1c2505 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855282; cv=none; d=zohomail.com; s=zohoarc; b=ZLjfOVjzHLQuupF4dHu9P52uMRpQoJMOn4j4zt4EWZXji8wDjoO8m0wp/07XLKZy4ISYR3RBtvO8TdKptBvGRYOtaD8x00d4PwDPmr4gnepacQVt+ziAlneePGLe0DzGW9rHMLLhT0qIkFalH1NNgK2mHfnyTGY8yclE/pv+tRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855282; 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=Zz+Yiw3j6EwnZi+bj/J+8lAYZ4FYD5FVjkb0Yf+zwSY=; b=ZHA+7zbRDgN2g/eatfJRHx73Yqwz3mAo3DBoL1cRAkuGsmL6rj2tMtbnV0qe+omRA4EkIHo20GzaW8TonLw1cPvYVgBnIt0wzxXjooKO6mWaxX45v8Lp9uryK+tt0MdVtysOnU3V63MOn9w+0nZPv/C5Dl92jzGKya7vRJ4siAI= 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 17718552826501000.853101995447; Mon, 23 Feb 2026 06:01:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWPC-0006Ly-F2; Mon, 23 Feb 2026 08:55:22 -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 1vuWLE-0006L3-Po for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:17 -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 1vuWLD-0007fD-Az for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:16 -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-235-N1OdZH-DOr2M6S6iMjNwxQ-1; Mon, 23 Feb 2026 08:51: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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C34DB1956075; Mon, 23 Feb 2026 13:51:11 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 193021955F22; Mon, 23 Feb 2026 13:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854674; 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=Zz+Yiw3j6EwnZi+bj/J+8lAYZ4FYD5FVjkb0Yf+zwSY=; b=QUyRrVKYzs1OcE5goQoelHSxUtciNh4fnqDlknfy+y8wVW9nuX3ftz2T1Xu/H5zXlTbvWd Buy3L6Ac7R8jTTKJqgNVr4+DSL3Fjf+YPlfptzwFCgVgbl9rrfONebUKVPZdvjEcI0Ndvq F/zwYZ3FinVej0qzoZVnHAQgSb+Nbpw= X-MC-Unique: N1OdZH-DOr2M6S6iMjNwxQ-1 X-Mimecast-MFC-AGG-ID: N1OdZH-DOr2M6S6iMjNwxQ_1771854671 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 79/85] tests/audio: add an invalid settings test Date: Mon, 23 Feb 2026 14:47:20 +0100 Message-ID: <20260223134731.2377432-80-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855283195158500 From: Marc-Andr=C3=A9 Lureau As we are going to change the related code next. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 b87a12eb55b..af8cf03d10e 100644 --- a/tests/audio/test-audio.c +++ b/tests/audio/test-audio.c @@ -534,6 +534,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; @@ -589,6 +609,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.53.0 From nobody Sun Apr 12 02:50:03 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=1771854976; cv=none; d=zohomail.com; s=zohoarc; b=mlnzPry+i68htPXh9e6H+TWjSP5eKuqCykuKMVenRrZbEyjK3glFBUdF/I8BEwRKvAzIjtcCN1hbl3Csc3jTorSHyUd1Ut/0zEFO5wfucH+lmvF0ByzYZWa13wNFfQwli/ZEsqSAdVfhxafaWDusEsF1ExMbu7IP1cBAm2oC8PU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771854976; 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=3BzHio1y3pT17YOqFFK+PMBjalzrS7rqi2xWt3RdrZk=; b=ZT5PncIK6DAirgklvCbXntHVeeQBpBDarfmiMePd1Uc4+cIeD5nAzTI5KgqjeF1kN2hmvbs6RajxjOvFeB39bsct2ysjUiX8fgQjbFXX73l1DSwj3oOylYk5FvKKACTC0ngwQhS15SIoVkaxWjr3dXm+C24aBuCAqELBWrFXkPk= 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 17718549769282.2730408957082773; Mon, 23 Feb 2026 05:56:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWN1-00022N-HO; Mon, 23 Feb 2026 08:53: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 1vuWLH-0006Sx-Uk for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51: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 1vuWLG-0007im-C6 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51: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-278-WqFqcBpVOpa6uCthMc9vNw-1; Mon, 23 Feb 2026 08:51: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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 97212195608D; Mon, 23 Feb 2026 13:51:14 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C90C31800673; Mon, 23 Feb 2026 13:51:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854677; 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=3BzHio1y3pT17YOqFFK+PMBjalzrS7rqi2xWt3RdrZk=; b=Yo268y4F8mRIOUsJy3cV/mUrfYujxLNuhJ0wY3VSGYBcVnQVgzcmFejuVrSB9ryDM4RI2B c7gtV7QwMQVNFXpiO4yxkt3e9RxuZtsRcom6kkvJOoUNoEfUTTwt5fWAnq6wWXYLBR1uhx 4g7IzvdqxOYGT6qJOvDgepA/cR2dQjA= X-MC-Unique: WqFqcBpVOpa6uCthMc9vNw-1 X-Mimecast-MFC-AGG-ID: WqFqcBpVOpa6uCthMc9vNw_1771854674 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 80/85] audio: rework invalid audsettings error Date: Mon, 23 Feb 2026 14:47:21 +0100 Message-ID: <20260223134731.2377432-81-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771854979057158500 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 Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 7eabb1c2505..bb8c0b56f78 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855510; cv=none; d=zohomail.com; s=zohoarc; b=dls6TYt2upzakpssfzGTF+vUkS+nzKWuPbmq+r89bKNZ+il0F756G+WTooItwOmDJLUX4fyAuicYd8SQUNIuVQe37pxQrTYrC22VgKP/7zXa6bikdEARBIEBoVgCCjCi4lUZ6gkfELjsObpfHZADKSwawSRJdHBI739o1v2BCEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855510; 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=KcMrLyAIgOYdFY64yVHRXdrwUnIJyXUy4fcgyWcJqb8=; b=M3m/Ccx9Tk7oe7qkbeelcwghsqOBEnSg4GaUPQVLdlzIh7rKriTysLJ8afJfI1ZAcqLgXm5mINPRGbGrYOzgaQd0hP2qoTUAnSUWM7I2F0CsQKpMrMArdnGBGRrIa32OzAGIkC6z6K1HTwTaD+xbdvHsJZVOddXHTx2KSuoMXhM= 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 1771855510089237.27544013186355; Mon, 23 Feb 2026 06:05:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWNm-0004Jx-IG; Mon, 23 Feb 2026 08:53:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuWLR-0006ZI-PC for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:33 -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 1vuWLL-0007mt-Ay for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:25 -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-279-l1dLM2K_OKGaHubViHD_2A-1; Mon, 23 Feb 2026 08:51:19 -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 66F391955F68; Mon, 23 Feb 2026 13:51:17 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AFF2E1800670; Mon, 23 Feb 2026 13:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854682; 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=KcMrLyAIgOYdFY64yVHRXdrwUnIJyXUy4fcgyWcJqb8=; b=Jua5wFV5zHlvHjVokGKbKeheiMGdYgdAIgVPQJrdWck6hDRenCEOGN9prpi3JbT98uu/Mq wEYm8D4zGbyuLjBV7ptqaCQREfVMWwUmGrgFFk0p9TXCtozsvTUJBqsXAYjkXpuT2+ZCK2 16WdkbUm0DvbiJ5po8Lddh7ry0mehmI= X-MC-Unique: l1dLM2K_OKGaHubViHD_2A-1 X-Mimecast-MFC-AGG-ID: l1dLM2K_OKGaHubViHD_2A_1771854677 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 81/85] audio: rework audio_bug() Date: Mon, 23 Feb 2026 14:47:22 +0100 Message-ID: <20260223134731.2377432-82-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855511131158500 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 Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 bb8c0b56f78..45bcfb74338 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -31,6 +31,8 @@ =20 #define SW_NAME(sw) (sw)->name ? (sw)->name : "unknown" =20 +#define audio_bug(fmt, ...) error_report("%s: " fmt, __func__, ##__VA_ARGS= __) + const struct mixeng_volume nominal_volume =3D { .mute =3D 0, #ifdef FLOAT_MIXENG @@ -42,23 +44,6 @@ const struct mixeng_volume nominal_volume =3D { #endif }; =20 -int audio_bug (const char *funcname, int cond) -{ - if (cond) { - static int shown; - - AUD_log (NULL, "A bug was just triggered in %s\n", funcname); - if (!shown) { - shown =3D 1; - AUD_log (NULL, "Save all your work and restart without audio\n= "); - AUD_log (NULL, "I am sorry\n"); - } - AUD_log (NULL, "Context:\n"); - } - - return cond; -} - /* * Convert audio format to mixeng_clip index. Used by audio_pcm_sw_init_ a= nd * audio_mixeng_backend_add_capture() @@ -332,8 +317,8 @@ static size_t audio_pcm_hw_find_min_in (HWVoiceIn *hw) static size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw) { size_t live =3D hw->total_samples_captured - audio_pcm_hw_find_min_in = (hw); - if (audio_bug(__func__, live > hw->conv_buf.size)) { - dolog("live=3D%zu hw->conv_buf.size=3D%zu\n", live, hw->conv_buf.s= ize); + if (live > hw->conv_buf.size) { + audio_bug("live=3D%zu hw->conv_buf.size=3D%zu", live, hw->conv_buf= .size); return 0; } return live; @@ -402,8 +387,8 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *bu= f, size_t buf_len) if (!live) { return 0; } - if (audio_bug(__func__, live > hw->conv_buf.size)) { - dolog("live_in=3D%zu hw->conv_buf.size=3D%zu\n", live, hw->conv_bu= f.size); + if (live > hw->conv_buf.size) { + audio_bug("live=3D%zu hw->conv_buf.size=3D%zu", live, hw->conv_buf= .size); return 0; } =20 @@ -454,8 +439,8 @@ static size_t audio_pcm_hw_get_live_out (HWVoiceOut *hw= , int *nb_live) if (nb_live1) { size_t live =3D smin; =20 - if (audio_bug(__func__, live > hw->mix_buf.size)) { - dolog("live=3D%zu hw->mix_buf.size=3D%zu\n", live, hw->mix_buf= .size); + if (live > hw->mix_buf.size) { + audio_bug("live=3D%zu hw->mix_buf.size=3D%zu", live, hw->mix_b= uf.size); return 0; } return live; @@ -533,8 +518,8 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t buf_len) size_t frames_in_max, frames_out_max, total_in, total_out; =20 live =3D sw->total_hw_samples_mixed; - if (audio_bug(__func__, live > hw->mix_buf.size)) { - dolog("live=3D%zu hw->mix_buf.size=3D%zu\n", live, hw->mix_buf.siz= e); + if (live > hw->mix_buf.size) { + audio_bug("live=3D%zu hw->mix_buf.size=3D%zu", live, hw->mix_buf.s= ize); return 0; } =20 @@ -824,9 +809,9 @@ static size_t audio_get_avail(SWVoiceIn *sw) } =20 live =3D sw->hw->total_samples_captured - sw->total_hw_samples_acquire= d; - if (audio_bug(__func__, live > sw->hw->conv_buf.size)) { - dolog("live=3D%zu sw->hw->conv_buf.size=3D%zu\n", live, - sw->hw->conv_buf.size); + if (live > sw->hw->conv_buf.size) { + audio_bug("live=3D%zu sw->hw->conv_buf.size=3D%zu", live, + sw->hw->conv_buf.size); return 0; } =20 @@ -845,9 +830,9 @@ static size_t audio_get_free(SWVoiceOut *sw) =20 live =3D sw->total_hw_samples_mixed; =20 - if (audio_bug(__func__, live > sw->hw->mix_buf.size)) { - dolog("live=3D%zu sw->hw->mix_buf.size=3D%zu\n", live, - sw->hw->mix_buf.size); + if (live > sw->hw->mix_buf.size) { + audio_bug("live=3D%zu sw->hw->mix_buf.size=3D%zu", live, + sw->hw->mix_buf.size); return 0; } =20 @@ -1002,8 +987,8 @@ static void audio_run_out(AudioMixengBackend *s) live =3D 0; } =20 - if (audio_bug(__func__, live > hw->mix_buf.size)) { - dolog("live=3D%zu hw->mix_buf.size=3D%zu\n", live, hw->mix_buf= .size); + if (live > hw->mix_buf.size) { + audio_bug("live=3D%zu hw->mix_buf.size=3D%zu", live, hw->mix_b= uf.size); continue; } =20 @@ -1033,9 +1018,9 @@ static void audio_run_out(AudioMixengBackend *s) prev_rpos =3D hw->mix_buf.pos; played =3D audio_pcm_hw_run_out(hw, live); replay_audio_out(&played); - if (audio_bug(__func__, hw->mix_buf.pos >=3D hw->mix_buf.size)) { - dolog("hw->mix_buf.pos=3D%zu hw->mix_buf.size=3D%zu played=3D%= zu\n", - hw->mix_buf.pos, hw->mix_buf.size, played); + if (hw->mix_buf.pos >=3D hw->mix_buf.size) { + audio_bug("hw->mix_buf.pos=3D%zu hw->mix_buf.size=3D%zu played= =3D%zu", + hw->mix_buf.pos, hw->mix_buf.size, played); hw->mix_buf.pos =3D 0; } =20 @@ -1050,9 +1035,9 @@ static void audio_run_out(AudioMixengBackend *s) continue; } =20 - if (audio_bug(__func__, played > sw->total_hw_samples_mixed)) { - dolog("played=3D%zu sw->total_hw_samples_mixed=3D%zu\n", - played, sw->total_hw_samples_mixed); + if (played > sw->total_hw_samples_mixed) { + audio_bug("played=3D%zu sw->total_hw_samples_mixed=3D%zu", + played, sw->total_hw_samples_mixed); played =3D sw->total_hw_samples_mixed; } =20 @@ -1195,9 +1180,9 @@ static void audio_run_capture(AudioMixengBackend *s) continue; } =20 - if (audio_bug(__func__, captured > sw->total_hw_samples_mixed)= ) { - dolog("captured=3D%zu sw->total_hw_samples_mixed=3D%zu\n", - captured, sw->total_hw_samples_mixed); + if (captured > sw->total_hw_samples_mixed) { + audio_bug("captured=3D%zu sw->total_hw_samples_mixed=3D%zu= ", + captured, sw->total_hw_samples_mixed); captured =3D sw->total_hw_samples_mixed; } =20 --=20 2.53.0 From nobody Sun Apr 12 02:50:03 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=1771855071; cv=none; d=zohomail.com; s=zohoarc; b=jzohfHI90V5bOOTHFOAC4XdDJB+OQ3XDqMIMJa5uKVHo2cuqAtTdloc9aPf2kvJu9UItD0PRuHedW2yMEihEMIYBSLFbXP2rF0qlDCe+DYPEl82wK0CUV6r7/Qa5DkdM2UQO72UuV/GuuNvQSy+hyqdHHxRZ3CAmnwZ4de7pEuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855071; 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=LGq+VCEW90rvm6mfQdjwX9Xt4WycZSlTKQAB6s+z0Ro=; b=eRXyhZkmEZCmkaYO2Js20LraaXClELRTLA+F/X/QE/M1jUPkqLUBdQyg4ImpW4Qsgm4DrtJSSuumR0NDltn7P2sWt5W2bjYyHsAlHVEG82iKiFI9ydOiYwpFpEuSvEE5UQl/TErzDQkZ80ZQG0mpLb37lZJdz4BW6T596+QU+9s= 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 1771855071222179.56093610327048; Mon, 23 Feb 2026 05:57:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWMw-0001UB-SA; Mon, 23 Feb 2026 08:53: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 1vuWLM-0006WA-NN for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:31 -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 1vuWLK-0007ml-Ff for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:24 -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-678-mcWUsffePquWbwEFn67uIQ-1; Mon, 23 Feb 2026 08:51:20 -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 CBA8719560B7; Mon, 23 Feb 2026 13:51:19 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 531E01800668; Mon, 23 Feb 2026 13:51:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854681; 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=LGq+VCEW90rvm6mfQdjwX9Xt4WycZSlTKQAB6s+z0Ro=; b=RX/Hhksz77xvObWcJ6Gie8xwqu4t5QkLVzc1VyyxptoTbJGQg4Y8rPLRPAWaFm0iY/elHg 05XlSKxR3gqmns8MwDqlH+0po2Di4vHtLi+Jq8vD9Y1u2sv5RKESPoa4WmgQNFCc9LZfYX uZ+zxiubnVe2OHbbcdj6QKdLn6fErp4= X-MC-Unique: mcWUsffePquWbwEFn67uIQ-1 X-Mimecast-MFC-AGG-ID: mcWUsffePquWbwEFn67uIQ_1771854679 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 82/85] audio: replace remaining dolog() and AUD_log Date: Mon, 23 Feb 2026 14:47:23 +0100 Message-ID: <20260223134731.2377432-83-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855071671158500 From: Marc-Andr=C3=A9 Lureau Use warn_report/error_report and trace instead. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 45bcfb74338..87e5a2fc3af 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855413; cv=none; d=zohomail.com; s=zohoarc; b=Lek1cUSxOhVvUhgzt9X0MIvCpa9aE8Iq5I9njos6EM5m/xlt5FPgdZD5kQb/tfKs5xjT0P+0mY1L4WjgnA4yEDbAERNhmDjHGUn3mW/hkoKvxbBa6brLbziFyMzjEmBKOqOEn9aG1/RNyxcEBydBrhjMd/bjr7Hft0HE8WtkpQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855413; 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=qHtia56UKjNTTvnuasDzFPRyibi+QTZoxgNI+zRK13U=; b=FCXsXql54+L6GPvRk/efO8Wr/2OVVSr/LMn1nw7ckv696v4ds3ariMEVYFzuD01+u0rxq0tKcqQuBBtynGHhK2hl6pWZKqcdcPh1wr13zGsNJwIZbwrFQjS+HwyK4Lv/DLOLYCK4wKZ/ssPLWqbJjqm5V0b0K9CVR+OHzeMEcCc= 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 1771855413336691.329390352184; Mon, 23 Feb 2026 06:03:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWNn-0004NB-BM; Mon, 23 Feb 2026 08:53: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 1vuWLT-0006cS-NK for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:34 -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 1vuWLR-0007pz-6P for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:30 -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-138-63C2-JsHNYidFXRNxjMLvA-1; Mon, 23 Feb 2026 08:51:23 -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 3827C19560B2; Mon, 23 Feb 2026 13:51:22 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A86B3195419E; Mon, 23 Feb 2026 13:51:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854685; 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=qHtia56UKjNTTvnuasDzFPRyibi+QTZoxgNI+zRK13U=; b=XMoYt1g0ZGj4u7nYIzCmUxgAfwpsK0SdN4wf5OSysdTugQWNkn+B4/i8KL8Wvlx+qKL/am SujiWvKNXGlqxAOeCm0FkuUnrC/PHFrIBunvxBVXUhRO/0cHAengwIcqWHTVu/PsYZ3Ax/ jq9xu0f2CCU6F3J0M2CKqIDWS4fXK1U= X-MC-Unique: 63C2-JsHNYidFXRNxjMLvA-1 X-Mimecast-MFC-AGG-ID: 63C2-JsHNYidFXRNxjMLvA_1771854682 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 83/85] audio: remove AUD_log/ldebug Date: Mon, 23 Feb 2026 14:47:24 +0100 Message-ID: <20260223134731.2377432-84-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855414383158500 From: Marc-Andr=C3=A9 Lureau audio/ is now converted to use QEMU standard trace & error reporting. Reviewed-by: Mark Cave-Ayland Reviewed-by: Akihiko Odaki 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 87e5a2fc3af..a6d5812fc65 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855142; cv=none; d=zohomail.com; s=zohoarc; b=Axy/W1NtW1nt5MblKDS526Lczi96eyhkB7m4HvbyVg/UXYvzNIzKd49A6Rkj6YGaFVbyqpzaRKC34SYDLbBtQpvki8wLE6ct/TVCOnEchq6PtpxU3fL+Qw0AU3+27+BEgCMt1GDjvgLemJRaHC49xPJrkRgJKEh69T5aUBrS8Ps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855142; 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=/DiwelkNN1JYmnmGdofPnD6WuDrkgpfcki7utGg1rLc=; b=YAC8RD7E+SGCYUkR0JY1we8I4nEYfY6lysuTcDRc9F8nGuMf0poBM9vkYGArVmNboudJDbOuINsdSUby3jzXiMI0X6Fnm32a3JzSJPuYivNSbzH+12A9b89s1UnSijGpwKLv2E+IhJugFUZbUJtpzdt7TJfUi3atDJGYYY3G7ag= 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 1771855142599826.1340963374862; Mon, 23 Feb 2026 05:59:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWMy-0001es-5C; Mon, 23 Feb 2026 08:53: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 1vuWLV-0006cZ-J2 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:34 -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 1vuWLS-0007r9-9G for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:32 -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-637-xYlxzM9IPHSie7c8Zk0IUQ-1; Mon, 23 Feb 2026 08:51:26 -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 AF22719560A6; Mon, 23 Feb 2026 13:51:24 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 247581800668; Mon, 23 Feb 2026 13:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854689; 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=/DiwelkNN1JYmnmGdofPnD6WuDrkgpfcki7utGg1rLc=; b=ZGX7x+/NDDTyQSK8LcezqDLJ5j4k6mYHjgm7V0dZusZWDtZpOnd7bv5rEQoETJnFWJyTCn vZ8U9TeV0hNuJiJ5DdQFiCKYCN3OlnPknm0p313UbZd2owz4Go8d3FG/lOj22TGbv2rjOA grGv1I2Ez0/RhQx8a9rvtpTtxvNG2t4= X-MC-Unique: xYlxzM9IPHSie7c8Zk0IUQ-1 X-Mimecast-MFC-AGG-ID: xYlxzM9IPHSie7c8Zk0IUQ_1771854684 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Christian Schoenebeck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki , Thomas Huth , Alexandre Ratchov Subject: [PULL v3 84/85] audio: remove AudioMixengBackendClass.name Date: Mon, 23 Feb 2026 14:47:25 +0100 Message-ID: <20260223134731.2377432-85-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855144140158500 From: Marc-Andr=C3=A9 Lureau Simply use the class name instead. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Mark Cave-Ayland 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 e2290ea814a..dc99ccb44fa 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 b212b3d6022..e9bdf6adb5b 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 704bc3da73b..338ee49c2fe 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 d9ae8edc0e0..f49fd82c45c 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 70316c572ec..ea6a78c7055 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 157979e84b4..63c6e0a291f 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 c9957105543..23e8767a46b 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 b70bf0c1353..a59c22e60b8 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 936a3ed076d..bd6a46e2af1 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -458,7 +458,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 761f23f8273..2e05ef7ea74 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 f903ef77e72..70a0b60dd83 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 55d12d6cdfd..d247dd3ffe6 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 1f4b3d9d467..a28fa77d73f 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.53.0 From nobody Sun Apr 12 02:50:03 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=1771855297; cv=none; d=zohomail.com; s=zohoarc; b=JsmTMz2wdoRrGXpgrVFI+KZkdzntIgBX+F93GU66ejBkfsJprS4jwU2c3Av8INQX/w8wG1CFoT63J8JySKFjmqw5jyaMbU2Df1MQpruxoreCkkFBFkjKXDYrZLrUSIody4unHHZ9qIrUosDKbWvXXDVxc3nhduEltUdlvmIok2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771855297; 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=QEIeaOljREjyrt+RFPojvp1wJdmnjRMxfVO4p58flqQ=; b=S0kPy6zijTnFEp3AMqLz1xN2snhmdkAOJOlINBwmENAH/PY+LKWceUtjPPTv5kCS7zykVp8h1L6HM/qmozbC/BXia0J2abkj6Gmey+U4Gx0dQ28vOzA8+zpo/nmIT4leQzwePjYAb4cb9i23sA7DNa6B6ugiv8uZKRLzFbGJLYw= 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 1771855297867342.1038315192625; Mon, 23 Feb 2026 06:01:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuWNj-0003l2-7C; Mon, 23 Feb 2026 08:53: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 1vuWLT-0006cT-Nm for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:34 -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 1vuWLS-0007qn-3F for qemu-devel@nongnu.org; Mon, 23 Feb 2026 08:51:31 -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-607-0i4-MMzPPQqk4BCBqZoBoQ-1; Mon, 23 Feb 2026 08:51:27 -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 D9BD91955F2A; Mon, 23 Feb 2026 13:51:26 +0000 (UTC) Received: from localhost (unknown [10.45.242.25]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 57E081800668; Mon, 23 Feb 2026 13:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771854689; 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=QEIeaOljREjyrt+RFPojvp1wJdmnjRMxfVO4p58flqQ=; b=XSsn7hRt4JPKrcIip86xAly8M5afBuW3bxjcwyKdVEWX2SbEpJ/9K3LycHcVIvi/H25Ya9 +KHXYotjgmUs+IBT30I+QSDBPEYK6q02dRhBTjOI/Q+ShAxk+vA6iKgYk/bbuX9FOaHxqt onkz3PiB/MwRMO5M9hMkJwrfAZU1z/8= X-MC-Unique: 0i4-MMzPPQqk4BCBqZoBoQ-1 X-Mimecast-MFC-AGG-ID: 0i4-MMzPPQqk4BCBqZoBoQ_1771854687 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL v3 85/85] audio: fix leak of audio capture name Date: Mon, 23 Feb 2026 14:47:26 +0100 Message-ID: <20260223134731.2377432-86-marcandre.lureau@redhat.com> In-Reply-To: <20260223134731.2377432-1-marcandre.lureau@redhat.com> References: <20260223134731.2377432-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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: 1771855299318158500 From: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/audio-mixeng-be.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/audio/audio-mixeng-be.c b/audio/audio-mixeng-be.c index a6d5812fc65..37040450511 100644 --- a/audio/audio-mixeng-be.c +++ b/audio/audio-mixeng-be.c @@ -227,6 +227,7 @@ static void audio_detach_capture (HWVoiceOut *hw) CaptureVoiceOut *cap =3D sc->cap; int was_active =3D sw->active; =20 + g_clear_pointer(&sw->name, g_free); if (sw->rate) { st_rate_stop (sw->rate); sw->rate =3D NULL; @@ -1618,6 +1619,7 @@ static void audio_mixeng_backend_del_capture( SWVoiceCap *sc =3D (SWVoiceCap *) sw; =20 trace_audio_capture_free_sw(sw->name); + g_clear_pointer(&sw->name, g_free); sw1 =3D sw->entries.le_next; if (sw->rate) { st_rate_stop (sw->rate); --=20 2.53.0