From nobody Sun Apr 12 00:57:50 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=1771840125; cv=none; d=zohomail.com; s=zohoarc; b=V/8HDOYJgO6QjmEYOYeKcwFT22TVuSxwlZR5vlcbWut5s/5RLSqr7KP/9oculv7Q8PnNeBYZANPnAncr3cwpeD0/SfUFu/i+pktEre+Pcc/Eq68Hgx25tMIxQQbamIPOugWFUcqblfLaYpBGy2R62PbOVC/yS6urYV7UEuClfic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840125; 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=gZu0GA4Af02C1oLFY1aOL4ctPpb6e0EIjfqhPNOWny4MYJL+xVodvcWQia9BDs07ATFMLjhhXka+0/mJaky4+FnGbAU0bcv07KA7SyO2l2wU5hijrwpNoWfjGoAEV40AiKDM0yao7ktnqkIZs9DF79vRGT2ESGwSTYDvb/i3pYo= 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 1771840125169784.8953964817748; Mon, 23 Feb 2026 01:48:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXJ-00045A-JD; Mon, 23 Feb 2026 04:47: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 1vuSX3-0003vL-Nf for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47: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 1vuSWw-0006oL-SF for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47: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-180-fm1FGkHTOuOBYV1zwpDq7A-1; Mon, 23 Feb 2026 04:47:03 -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 798A61845445; Mon, 23 Feb 2026 09:46:57 +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 0D19D19560A2; Mon, 23 Feb 2026 09:46:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840026; 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=UKT/C9sWjWoVk3StCXLqPjyYQYtIEd+LIrB9gtrSl2Bsbz1sqqQ3WZqBthE1xHmFT/PVBp XLIobMjd+Lfy7cjmkIJjw9Gi3cdLv0GwwUyurJFokRa9BaD1bWlBCIOF9ll33kA8aW+E4Q 7nJupzSQp7Q9BiSzPdCyf59cL6noL9I= X-MC-Unique: fm1FGkHTOuOBYV1zwpDq7A-1 X-Mimecast-MFC-AGG-ID: fm1FGkHTOuOBYV1zwpDq7A_1771840022 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 v2 01/85] audio: remove obsolete/obscure functions Date: Mon, 23 Feb 2026 10:45:19 +0100 Message-ID: <20260223094649.2005118-2-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840126433158500 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 00:57:50 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=1771840051; cv=none; d=zohomail.com; s=zohoarc; b=QpXtGXQGOrut0fhF5elL3XsKvrHEPWc+sEeXsADtQKzU6O55t6vroRM3wqWCdtIxOGDP9luAm4qFl6xZ+nM6Y+3tOg+BPkhe3aTuepT2m2OMte2r5dZBsdSKgxLfKt+i/d6IYQvQrEecaPU9gLAb3+9Vn6z13uD/xxBkT7fmq1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840051; 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=Dh1Tar8Rt/zIbTpOC5w4DfJcxKGLZzcqaLafsPVVsbJ/klNzVKJmZhpvKC/iSf47P9BObI6pzBpffrZdJ15hPJUFDExYBDmnZUjIn/atYFJzL22H1bnyJAznM/vx8lvKo1NETax5Q3syRiW2JwO8uLEbowydURSvn+Qg1sWo4uY= 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 1771840051581502.86869001920616; Mon, 23 Feb 2026 01:47:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXH-00040c-Ta; Mon, 23 Feb 2026 04:47:28 -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 1vuSX3-0003vM-Sf for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:16 -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 1vuSWy-0006oZ-Dx for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:10 -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-580-pIjpfFpvP9qQU-2dRU2Zqg-1; Mon, 23 Feb 2026 04:47:06 -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 70A2B1954232; Mon, 23 Feb 2026 09:47:00 +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 9E3EF1800465; Mon, 23 Feb 2026 09:46:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840027; 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=L1IIfcxGFRaHbTHnGLvqB+9e6sfF67dc+EacXap04ZuCLpaaTqbTBCBJa1QptQcpj9fLPX CshRE1R03GlFCiiB8WQX1nFf3QXesY9PZPR1LdW1n05+2+OMEsH7GM9S4sGmGozHiPXIrW y0+8q73DzcBPAjK5kk0bbffGJ8T1Rf0= X-MC-Unique: pIjpfFpvP9qQU-2dRU2Zqg-1 X-Mimecast-MFC-AGG-ID: pIjpfFpvP9qQU-2dRU2Zqg_1771840025 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 v2 02/85] adlib: remove dead code Date: Mon, 23 Feb 2026 10:45:20 +0100 Message-ID: <20260223094649.2005118-3-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840052313158500 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 00:57:50 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=1771840051; cv=none; d=zohomail.com; s=zohoarc; b=KlsrDNL/ShNV7aAWJ+7YIjtKQOxd/wqlRsOCd4RrThs7lLiTy+p9aKgokSIAwMgx2o4CQmwdCXcG23XwLH8CL4UkYesGSy1NdbA9rTTaA7HsBHqJoqKiTR8HmV4A2ZdUDJjdMJXkrywlxpguSLc9/njA2XpAehs9bo67mgX5aMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840051; 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=cKaP9WHJD3IxFYaxyBhuBFr2nuSZ2cxZ1h50DV2Jy8dUKovuB9zjwWRmU5WboB3dGXXzD8Omsu8a8EqSZN7m9lzlLNVtWno3cjBSJh1njkAUrHC2lPpoTg+pPqAJZThc+fQeCsJTQWoKHYKHqfhiFx56bseJBmV6MOnHhVQN5co= 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 1771840051470965.4410717438744; Mon, 23 Feb 2026 01:47:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXI-00041g-UC; Mon, 23 Feb 2026 04:47: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 1vuSX3-0003vN-T1 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSWz-0006oY-8O for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:13 -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-377-Y3yaVkruNZ6djRS1b2vR4g-1; Mon, 23 Feb 2026 04:47: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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D6F751955F03; Mon, 23 Feb 2026 09:47:02 +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 2B5EE1800351; Mon, 23 Feb 2026 09:47:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840027; 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=f6v6yN7nw8y4yDSH7K50X5E/DcJTHHAoxcAtrtbhM04fMI2152FQC8TOuk4Vi6/H2S3yMZ hgvbmpDIWLCJmkGNj9yRJqO2n0K4nbSNmNDKVgamNMR4kRryFAxWs28gn8/yMp3jdXPv5I q4I5/ZAPJncUUgDpgd3JDS2KdCeW7/0= X-MC-Unique: Y3yaVkruNZ6djRS1b2vR4g-1 X-Mimecast-MFC-AGG-ID: Y3yaVkruNZ6djRS1b2vR4g_1771840024 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 v2 03/85] audio/adlib: drop ts_helper HWVoice field Date: Mon, 23 Feb 2026 10:45:21 +0100 Message-ID: <20260223094649.2005118-4-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840052326158500 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 00:57:50 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=1771840070; cv=none; d=zohomail.com; s=zohoarc; b=VhNNrFt56S+Hc6bWtYzb4PklY7Y/DNX5OPTH0M1E0PoOm/nqhaUZfow7k2wnnNr8NqAorSOO+S5APKix04N1c3Bh1b/vBB/cfc0WINbaQcXSesQYlZt7Z2b5bd/i+UmweB08+V15XCKwATqAFo/FRGMbdpBkaS56+wmlxCIxU4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840070; 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=aep1ypMQnjxlTXHXvp9bnIa7ALRqUIJf7N0zlagaJ9E5G+YGPOuoBqI04Or8IMxTLumt6XMMXidE+Y5M1hN4HlI+pWdoB2LS4TI3B2qldJdz4c0w8pDy3eoJUYX5+rTwGiP/PpGNuLMuNo4umcXgVloyuOt1C/boGGroAxlsA/s= 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 1771840070146161.0108491862593; Mon, 23 Feb 2026 01:47:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXJ-00045r-PD; Mon, 23 Feb 2026 04:47: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 1vuSX6-0003w0-HH for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47: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 1vuSX2-0006or-Le for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:14 -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-528-YnveCmhUPB6qjhTnsdftnQ-1; Mon, 23 Feb 2026 04:47:06 -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 BA73E19560B2; Mon, 23 Feb 2026 09:47:05 +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 D3E971955D85; Mon, 23 Feb 2026 09:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840030; 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=P2MJIArCfUusMtdUovzXXTuJLcorPVS8sMtpnTUbGqk3OqDNVXgA+B69PSq0AN0DZnmQxr Ixng1gEoQubYZxbuL2ciLW5LJJnpew4mVOUXAllYoWvjlQQXVyPSPMpjea8kXy6XEV7Tvq Jfd2aZB8jAqwukEvMydCs9GhRxcYTRM= X-MC-Unique: YnveCmhUPB6qjhTnsdftnQ-1 X-Mimecast-MFC-AGG-ID: YnveCmhUPB6qjhTnsdftnQ_1771840026 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 v2 04/85] audio/dbus: make "dbus" the default backend when using -display dbus Date: Mon, 23 Feb 2026 10:45:22 +0100 Message-ID: <20260223094649.2005118-5-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840072171158500 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 00:57:50 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=1771840683; cv=none; d=zohomail.com; s=zohoarc; b=GTTJmXNndF3YO9tHzKgEm9luZrBDLB5cgKFKH21XYCZNvjxg14wlyeyiFxI1oqLIbv8M5JcLyJ7VKOvf1oDgTIp6RIAxocpO97a26LbZOJuunnaBkc710i687zfAb3UyvaGjRkEE5bv28L35ElodNzsEp3ecp7OeR6wNqEoV9tQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840683; 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=BiJ6FWXxsnkMDDskdni6GNbTYD+nD1LddY26aYDEXCLgP1YOVgF5x5uEr6bk70Cjpb333AwApNJ2O4uB3/L4MwgQteD5Tpp07ejw7F40eP9xxKud2/T66qihPG9Cba/SUDzhD+r7bQ0uZzdxepyrcKjFrbV2nUpF6RK5wYqQTSw= 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 1771840683202496.455294373509; Mon, 23 Feb 2026 01:58:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXK-00047H-6J; Mon, 23 Feb 2026 04:47: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 1vuSX6-0003w1-HJ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47: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 1vuSX4-0006p6-1M for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:15 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-rHFZCeklPp6yT2dhLybcMA-1; Mon, 23 Feb 2026 04:47:09 -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 3B72B19560A1; Mon, 23 Feb 2026 09:47:08 +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 88FEC1800676; Mon, 23 Feb 2026 09:47:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840033; 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=jP5kHSsuIieruclOR60gyQV2Qh3BSuKgxwGVrW5rwcj/4xKUaC07Ax+fwqyNp1nzD37ll2 LrFKxA3eI3iqEtLlcp8Y5HYxa5rZdanUfn/q3dWGlSRR/zTwcw3N4ccLRDBP/lufiFtmlW /xw0xp10Yt66Ltt62nLmB6S4dsCK0tc= X-MC-Unique: rHFZCeklPp6yT2dhLybcMA-1 X-Mimecast-MFC-AGG-ID: rHFZCeklPp6yT2dhLybcMA_1771840028 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 05/85] qemu-options.hx: clarify default audio backend selection Date: Mon, 23 Feb 2026 10:45:23 +0100 Message-ID: <20260223094649.2005118-6-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840685041158500 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 00:57:50 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=1771840657; cv=none; d=zohomail.com; s=zohoarc; b=Uy367dVSeMOXJ2AZ5DErabhAMomCIvlnCPRphJVBD8nJTF2jq7JKerYx9EEtexxICv47t1YHTq0iyHdwEyxA37qzI7y8bkoVjxffGEJGIO95Sj7ZimPB5mfj9sUzyGxSOxvRW83AUE9wRlfAuaEA/8L4mRhI9/0MVBQuxChamHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840657; 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=S708Jdfd8YLDPnYSAiPFpT1MQOue+DFQHPQxHb1uNvYzFC0IaD/t4x+6hCAxW6F3sJsATgTwzdiLHTsiXicezhGCh80PKsROBYF1Z2ERii4SWjQgI3dgdVZ0mPga+RgP0lgNErTMBU+q7o8lb9FFcD/yKPzfYsS1543izmoGH7s= 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 1771840657662148.3102111266786; Mon, 23 Feb 2026 01:57:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXK-00048R-Bn; Mon, 23 Feb 2026 04:47: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 1vuSX7-0003wL-Kp for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:21 -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 1vuSX6-0006pN-A9 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47: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-246-n3REWqRTOQC6PwHXWZxOBA-1; Mon, 23 Feb 2026 04:47:12 -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 344CB19560A1; Mon, 23 Feb 2026 09:47:11 +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 8BE4C1800668; Mon, 23 Feb 2026 09:47:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840034; 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=SPBDe7ojLPpYysJqpK9/aa4un2hRzOLrLr9xv0tthMEVEZNtyjt9vX5lhGYjBmg4fIsAfF mrjRkBpUalKvzmBrYPD9cJyU5N6HoR/zSUHvD5mWmAqvudwO7UxUSHM6AUXxsWaek94CbE Ztne9ZOdm5IEXKhAfKedQy081SNgeKk= X-MC-Unique: n3REWqRTOQC6PwHXWZxOBA-1 X-Mimecast-MFC-AGG-ID: n3REWqRTOQC6PwHXWZxOBA_1771840031 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 06/85] qemu-options.hx: document -audiodev dbus Date: Mon, 23 Feb 2026 10:45:24 +0100 Message-ID: <20260223094649.2005118-7-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840658897158500 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 00:57:50 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=1771840355; cv=none; d=zohomail.com; s=zohoarc; b=hpPp8dzFpsdq7yeHbMGDroA8n/rM5COMUdCFSKw5gs71wn4YVg6nZ9ZeoQ/MsGcxmllPoRA1zmk965anmutAxBc5r3tt0klMWCnP9ouLgzxucRoaUvw0asVQWE/bxyVcwBoYpDJGGvfgialSZiySLH5AjrnMuKjkyMo5fKPyna0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840355; 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=gbBrMGZuNUxkfciG0P7F/z5+fYu3/X4IAo8tKZdhgTzwCS7blLNmVB1hI6aMYDsXhb+y3ngeSYpO+jjDHCAmv1vi/X8/bKBga1/0KDYycgYKKEa+EhrUa9wqs36Dl8DKz41Bm+R49difhZaQIZdqvuAKMFKPyxQVxBju/sBpgHY= 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 1771840355908337.13267872802135; Mon, 23 Feb 2026 01:52:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXL-0004Dl-Bx; Mon, 23 Feb 2026 04:47: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 1vuSXA-0003zm-TE for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47: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 1vuSX9-0006pm-Bd for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47: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-518-RQeKIWzEOwKkjGiN4tn9UA-1; Mon, 23 Feb 2026 04:47:14 -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 A509E19560A3; Mon, 23 Feb 2026 09:47:13 +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 227C01955F22; Mon, 23 Feb 2026 09:47:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840038; 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=e+SFE7HMUUiK46T6x+gkEvuzl3J20rrLL+DjDfQ8K2SWdjhmTAapVNiip7j9AgndcFf8rm G4YxtGLpSM2Ti+SPFrXG8vCtcz6wqk8v5Wg72tSbz9fyKxlGoz1yOiR0eVmG1zgzulXOYc DiICuu90//DaNuOjMsBDn4duXH57AB4= X-MC-Unique: RQeKIWzEOwKkjGiN4tn9UA-1 X-Mimecast-MFC-AGG-ID: RQeKIWzEOwKkjGiN4tn9UA_1771840033 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 v2 07/85] audio: replace vm_running with runstate_is_running() Date: Mon, 23 Feb 2026 10:45:25 +0100 Message-ID: <20260223094649.2005118-8-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840357430158500 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 00:57:50 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=1771840661; cv=none; d=zohomail.com; s=zohoarc; b=LHqp2/P01SnVd6m4sGGGbwQTscyKCCa+EVZY/Xp/m2g34fN26D2Q+w2nMDqxv51FQ32mDzMDxF6808iemlo+jncR5ywT4i/cC+qErKDYmdDvV5BB0F8eHuGdfh49aLyVr9UINX93hbpimnFFplriCzF4COJ64cOW6AWpFTOxDhk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840661; 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=Jm7ZuNBTke3CZ1+Hgrg91ep5QxXbO7m3F89j0m3ah4Omu1Ih9XK5SzhjZq6aztcowStMqf+CULrn8YbfjrKeRt6mmLJZeaNYcu/p2EXIBPY2FKRukO8x32umx8MXZGL81VxP73+KY2ZE2kNdq68DRd/HJXxjwqlCWlL9J4v77JM= 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 1771840660994401.73063945902356; Mon, 23 Feb 2026 01:57:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXK-00049B-NV; Mon, 23 Feb 2026 04:47: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 1vuSXC-00040b-UW for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:25 -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 1vuSXB-0006q0-JZ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:22 -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-522-dBelR8UbNbuXPtS7DauhDQ-1; Mon, 23 Feb 2026 04:47: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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 513ED195608A; Mon, 23 Feb 2026 09:47: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 9F3D81800668; Mon, 23 Feb 2026 09:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840040; 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=Paasb4cIWY5S0VrAaZxcHtzi7uD8V118rwcjlMEDmnNlkRxR1h9ythaxbY9y+1U70IOSv7 SsC4aGEr/i8QPMWsj6yOQEYdjy8nkUsV0ntu7Qr4cG5wXs50kAha9BItjjfCIaelfxbNJJ oIHDcXYlBDsDuz/UkDQxHkQDp9B0mDc= X-MC-Unique: dBelR8UbNbuXPtS7DauhDQ-1 X-Mimecast-MFC-AGG-ID: dBelR8UbNbuXPtS7DauhDQ_1771840036 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 v2 08/85] audio: list backends as modules Date: Mon, 23 Feb 2026 10:45:26 +0100 Message-ID: <20260223094649.2005118-9-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840662920158500 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 00:57:50 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=1771840125; cv=none; d=zohomail.com; s=zohoarc; b=jKVX9KWUW6rWD1Mae/TOpS54uPFqXPICy0NVvjWA5Xsl/fSQ0uo5ZbsM+lmqcQnvr408qOmGxe32K3OVwqmmBQxkH71nLfXPbfuxGKL++ZmdK2BnXqss9RGxn8A/9mB8QjR/qHREkrqySL56hfJnX0K39Rl13TcXUJsDbvSx1BM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840125; 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=dkHOFUAfBqSLk9g2fYou7ziGsCwoD/UvRsdVc+GnD88=; b=X3VTyaHH7PmU4EUguxdgry9eKHOKaMRxuvpTYSYzwN2DKcql+vQa6sA5V75NRLAuCe3hxup1snhGZ/qT+T+mVaX11GxIE5UkHPyl0T2GX0BY88Uo8WvXfhj44o//cckrkvWMYzpBhPm2bHHkhwF2N3lQqDtIUP5ZSO6ahoYNmWU= 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 177184012518934.343534299362204; Mon, 23 Feb 2026 01:48:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXb-0004bk-Sv; Mon, 23 Feb 2026 04:47: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 1vuSXU-0004ZZ-QH for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47: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 1vuSXR-0006ra-7r for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:39 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-0uzDuWIMPY2Q9uUHximcWg-1; Mon, 23 Feb 2026 04:47: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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C376F19560A1; Mon, 23 Feb 2026 09:47:18 +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 3F6A81955F22; Mon, 23 Feb 2026 09:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840056; 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=dkHOFUAfBqSLk9g2fYou7ziGsCwoD/UvRsdVc+GnD88=; b=PxNGTerBFU7qdLhl5bJVAThSoCQtqYRBdkq70BynxK3uDU4AcRzbI0scZB9PxHqUclPKTm +O6++RkKZGZBnZaeL6s5zxkzQllfx+6BJcF0wTTyFcIaLTwJmLoVuIodzl/Qa/LstINGrt Ni1A+sg2E4zkRqtGsH4QsjqTNQjLRvo= X-MC-Unique: 0uzDuWIMPY2Q9uUHximcWg-1 X-Mimecast-MFC-AGG-ID: 0uzDuWIMPY2Q9uUHximcWg_1771840039 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 v2 09/85] build-sys: create a libaudio Date: Mon, 23 Feb 2026 10:45:27 +0100 Message-ID: <20260223094649.2005118-10-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840126376158500 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 4af32c3e1f2..904605b844f 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 00:57:50 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=1771840235; cv=none; d=zohomail.com; s=zohoarc; b=KX1G9nvRULlVLlOAI5LQgCbOBGEutT/44lhj/aNo76yG5sxyohd/fPqsjy6facBXKuA+EjGhO1CuunXEf0r+x7W/GbX8X0CjecGScR/FU9dwfRxuSQMc0WnPxIYZ5m3HKRVGTVfSUk2XeX552OzyxqE8ZnW129r3EhGz6qZEgHg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840235; 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=NiIn7yCOS56UyOJPkwXJLZkgeBH/9N0ZlywoTSy3D9rp6oxFRDM4Mr8oKOsmGiFPCuPLavwxYtaLhIR/Bv6JJomWX2B/DUk5AwoQF1lwN6p04Dq5qXeUHluqIpHWw4zu1NBhlmHjsl5js2UPtkottwI8PlmwG3bdG7/+AhcvqAM= 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 1771840235905614.2628570699169; Mon, 23 Feb 2026 01: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 1vuSXL-0004D3-6A; Mon, 23 Feb 2026 04:47: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 1vuSXI-00041U-2x for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSXG-0006qX-NN for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:27 -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-588-dFGwIm9mMym0nMkY0X8GdQ-1; Mon, 23 Feb 2026 04:47:22 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A0789195605A; Mon, 23 Feb 2026 09:47:21 +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 CE0611800674; Mon, 23 Feb 2026 09:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840046; 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=A4BMAg0YKKFr+WQd812nxLp3yZNEseVuk+ORsLL5VAf1BbCxc8VurfY3e2oRhJZXO8hX0O g74d8IeKF0ncvXVYx5MzlRS7K7YWM0+Yui9PhLuOzmnwP/JvGcTb5eX0eR9JAlFfEn3Wij ZhaDNmeq0/m9kh8Yfs8qnTs0dbBI+2c= X-MC-Unique: dFGwIm9mMym0nMkY0X8GdQ-1 X-Mimecast-MFC-AGG-ID: dFGwIm9mMym0nMkY0X8GdQ_1771840041 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 v2 10/85] scripts/modinfo: add type annotations Date: Mon, 23 Feb 2026 10:45:28 +0100 Message-ID: <20260223094649.2005118-11-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840236869158500 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 00:57:50 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=1771840129; cv=none; d=zohomail.com; s=zohoarc; b=POgw0En120TfowBd9o8WjSMHqGluC8eODV8Qzeqk5cvDedLj4Djbyxh69IaW9Pfr8tDxIZrrrXPfunwrbyN0OUqMMEyVkzieGiED/bmK5EA4Pl9rPZ+TQIeV+RCDL6m7SN7dEHUmiHVcy1BQXnsz6Jxe2KWKB+0F5JwqWDygq/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840129; 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=aavRpOq0gG3eVdUso+juTcL9oK4LdhwDiwahOjTu3fNdHbsLlWmuHRjxp/CG57/TvOERtxHs1y2eqwJEqAzIvHeRVXgi6CE3EdaALNfSoGih+m0viM2aH+Vhz4JGRb5x0ak2WSXm+fPW+lWcPNeaq3AXFXu/hrMHbJ4zqfF+GZ4= 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 17718401296701016.2375367268729; Mon, 23 Feb 2026 01:48:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXS-0004RR-M9; Mon, 23 Feb 2026 04:47:38 -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 1vuSXJ-00042U-5q for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47: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 1vuSXH-0006qg-LF for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:28 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-54-5PNEFu7kNsKlA2rnZ8W9xA-1; Mon, 23 Feb 2026 04:47:25 -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 1C0821956095; Mon, 23 Feb 2026 09:47: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 6023B180067A; Mon, 23 Feb 2026 09:47:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840047; 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=EDDiGQkYyANuiO2iUtPPoEoBpRiGO4yeZUxGiWT/EBUiLykIfv3I4duCSk/CsvwaAWaVtG aBaczC7x1SBdob/hxBiCPTa++1JC9au7keglZNgZOX/cidoDbIpLV1FuUU8LmvhjgEU8DS bsjB3qw9/Lxjl8B3NvvFhaPJxxZ2wJs= X-MC-Unique: 5PNEFu7kNsKlA2rnZ8W9xA-1 X-Mimecast-MFC-AGG-ID: 5PNEFu7kNsKlA2rnZ8W9xA_1771840044 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 v2 11/85] scripts/modinfo: remove trailing ; Date: Mon, 23 Feb 2026 10:45:29 +0100 Message-ID: <20260223094649.2005118-12-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840130517158500 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 00:57:50 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=1771840071; cv=none; d=zohomail.com; s=zohoarc; b=khO+PBAOIGJUBFDhO5Xzj+XWvzI4jFpMw2bs7jegeGLimRAg/E+SYO52OZ34VrPYwgs9aaopn70o5q7ZkP/FEchtFe3GMRg6c5j7p56me7HUWYGKLzg1t2yChRODnQIplPw8+Bx+/Uyxjir4wmkB4/RxtvsY5GGfTIROkcdFyi8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840071; 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=a951G+Qon84mGhdcABG3jp/w2KWTGZRhClP8zQv+ipRKHLfev8oLwvbBZ0PqMo5W05zNsEnzAAzhQaYROyLRutVga94JtuICTSpPAsHsmEJTd6kLAqcsVwnDxf9lnm0qgm+0CawV4y1a4G8r4UcR6zSADciMUKwsgU7USw0shAA= 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 1771840071501903.7241483482651; Mon, 23 Feb 2026 01:47:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXT-0004W7-Ku; Mon, 23 Feb 2026 04:47: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 1vuSXM-0004I3-1y for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47: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 1vuSXK-0006r9-J0 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:31 -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-122-ID8cPJE8Nw6b3OcJKc3OCA-1; Mon, 23 Feb 2026 04:47: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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F11FE18002C2; Mon, 23 Feb 2026 09:47: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 475401955D85; Mon, 23 Feb 2026 09:47:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840049; 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=ge30ADbe8ZfGs0zh1qPHTuPFgcYqWSQIzpo2PUATxtVxfMg9YwgwY0M9k0yWOsWxfiNt3d WOgbPXTEJBEGttrEM0iwudYz+kqVn0Jk0iiROl03BHGVQ/7OVN3dD+rQBzk7EVumCB/YMY 28XTNUfys+J7/DVnHODZ0J9tiJD/og8= X-MC-Unique: ID8cPJE8Nw6b3OcJKc3OCA-1 X-Mimecast-MFC-AGG-ID: ID8cPJE8Nw6b3OcJKc3OCA_1771840047 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 v2 12/85] scripts/modinfo: use in instead of find() Date: Mon, 23 Feb 2026 10:45:30 +0100 Message-ID: <20260223094649.2005118-13-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840072125158500 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 00:57:50 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=1771840192; cv=none; d=zohomail.com; s=zohoarc; b=QNb7wPHWVJgN3Vkb555q9kc5DutZqPMFjiCoCFpw3UwFjWTL4G1P++o8WtnDlfQ2+o66TGdLCst59vwcNUbn1wUBN9+Q0KlOlCYT5Wpqg8OX85qf40Lg7NTn9Ga6RliqYDHp2dNZHrr3OkTg9VTGSgBD7UBvNTBnQxNfYSiZ1MA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840192; 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=S1yDk9SDx1/nFVTZ+M9brEmmoYRhNWxLTZV5AhC3qbg+d2nE1/p8X4b7VOiE5pSFdnk5qmfJ7RsezhTUwk6D+a3K0GWTKfSdQq2XE1PgzIqRGFjvj+dG8XZgpbqrECTM1UrFX+l4YLKY0iRrhdV4KZuWw0xxLvZ8poDq6PFk/ZQ= 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 1771840192519176.7799121325927; Mon, 23 Feb 2026 01:49:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXf-0004hR-JH; Mon, 23 Feb 2026 04:47: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 1vuSXP-0004KB-Qh for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:36 -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 1vuSXN-0006rL-P4 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:35 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-295-zg83TSB3PamprbsrnWFgPQ-1; Mon, 23 Feb 2026 04:47:30 -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 AA6781956050; Mon, 23 Feb 2026 09:47:29 +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 E79041800591; Mon, 23 Feb 2026 09:47:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840053; 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=VdMCLducP8uZGviwioOsC8TOa+v/HWg0h8aB+fDchW9FTtJ0sWk7BZVFunT7Ekw6TmRPR4 QOXsznnMXtGlOxIEXv7yZMbvyaTs8WMDrzFbHUNSSTD48YsPhmYS+1WnOGXI5H/jkSAiQ9 gct1nL5SuwSSjqUHVggNpefNiRjNz7A= X-MC-Unique: zg83TSB3PamprbsrnWFgPQ-1 X-Mimecast-MFC-AGG-ID: zg83TSB3PamprbsrnWFgPQ_1771840049 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 v2 13/85] scripts/modinfo: use f-strings Date: Mon, 23 Feb 2026 10:45:31 +0100 Message-ID: <20260223094649.2005118-14-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840194712158500 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 00:57:50 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=1771840270; cv=none; d=zohomail.com; s=zohoarc; b=YyXxTPh30B7i788ObidP+Fr4q+xbftRdKP5qAVrAuz8vK4Nz0t1OQ9LNeTTt65J9INZYNosD4Yr6qA1cFBrOIZS8JgCc8sajULeqUnyfCIAUAqcd/Rn5JwUJyPKwqJZsSvmeKPUcbIdTOkE3oWtb4oMezQKGEOJOT5Xbu3Ig0kI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840270; 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=XZ4f4xnvmMSNYZas/4UlaRwYh8hMirhaomUCaRqVIMf/pfskoHICEgkpyNgQW89W6yVj1h63OcvLt43RgfRoDyFrnE6XTBh1f0MzBMeqFXhvsBvlmFhjxsSyNikb0bnAl9Nyp/eAbhNrQNdHSra3lj4ZAJ+HeGoQC/UFBUQgcrY= 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 1771840270044549.2461505757246; Mon, 23 Feb 2026 01:51:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXe-0004e3-0h; Mon, 23 Feb 2026 04:47: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 1vuSXQ-0004Q1-Oh for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSXP-0006rP-8M for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:36 -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-674-AZ5AdIHvPlW-rVFmCi02dA-1; Mon, 23 Feb 2026 04:47:32 -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 048851956095; Mon, 23 Feb 2026 09:47:32 +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 601911800674; Mon, 23 Feb 2026 09:47:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840054; 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=ZAuYxBN3v3r9ocwP/gXt5SgajObBaqatahbdxxhDbLRPRBfIt/YfSh2zayzV40wlhTQojA +t5B00isq8nHjQBx7gO+tEoVLl7J9/w1xpkrjBZwVd/tfZV2Q88/0opzd1mJkH4lSvJ58r nCBfcUieqQsyYyqzzRLqJ9pnRRYj/4g= X-MC-Unique: AZ5AdIHvPlW-rVFmCi02dA-1 X-Mimecast-MFC-AGG-ID: AZ5AdIHvPlW-rVFmCi02dA_1771840052 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 v2 14/85] scripts/modinfo: use argparse Date: Mon, 23 Feb 2026 10:45:32 +0100 Message-ID: <20260223094649.2005118-15-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840271015158500 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 00:57:50 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=1771840235; cv=none; d=zohomail.com; s=zohoarc; b=WjpyqNg9OlF8/vIHguc7XmkdgiD2+CQcR7W1v2O6/M9+rGHaThe8yYeOlGt386R00Ng144ETXjgmZHG+EYKXf6fBTJFffHTo8/A1FaAG+qHQTLYj+q/pTxKH9UmW/NrVSGFzNbqf6F77TlpXgKrcA2XhMK1pc9u3gCyo2Ya9WG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840235; 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=NKvaCPT+bAn0q+BF0Un1VYJhbLcoYiu/C16oP4hIUnwb3n0OEwFjX0U7WxDkEtlhlVrBpMHF3UaIaFjj6oMqRduVXtgdgejQkTzNSTSYvr9rJ2CLrpsG0WUpZOlhNtlTb/4gYAbYu9SyitYCibILrAhzNY1+yxyyjdt1BhJYyNw= 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 1771840235080897.8143107793162; Mon, 23 Feb 2026 01: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 1vuSXh-0004pk-RF; Mon, 23 Feb 2026 04:47: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 1vuSXc-0004de-6G for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47: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 1vuSXU-0006rk-JR for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:46 -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-107-wF4H7SwxPF60xGHqM_ISLA-1; Mon, 23 Feb 2026 04:47: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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 919531956095; Mon, 23 Feb 2026 09:47: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 0C7163003D8F; Mon, 23 Feb 2026 09:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840059; 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=dyA17Q47Jq/4SDYr3S1Tb/hEwN331msYNHybvo2jdV5jdvn8acv3HU7gKFrceXJlUYUNxt 23zG+cR4770hysuZdk454nTsgjXDrlfLD2zT8KZZiJiAKm2pQmdnl2bsB6OsWAu36nZ+E7 arQOh1E9HgoWiVc+WdO/iAXxO9rfxiw= X-MC-Unique: wF4H7SwxPF60xGHqM_ISLA-1 X-Mimecast-MFC-AGG-ID: wF4H7SwxPF60xGHqM_ISLA_1771840054 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 v2 15/85] scripts/modinfo: make --devices optional Date: Mon, 23 Feb 2026 10:45:33 +0100 Message-ID: <20260223094649.2005118-16-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840236860158500 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 00:57:50 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=1771840299; cv=none; d=zohomail.com; s=zohoarc; b=F0B0gQR10bx0yR8yaosig+FbPxWJBZk+YzYouBypz1O2sCewB9AhKkdnl/hMGFpPIgJWO67dX1GgM6EdNNPu0k9eNK6Cp39vtkN2L0d29+cg/+omVI+cPICU0xlPd/OptE43vNa49X1cBnJ70LceyOA/sf5paZzvlOj0usmDX7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840299; 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=Q5MLk4r72sQ4KGepAbFFaMiYZs3hZu6qTjzt5eoraeIjhVvUb7Pd98yNcNBGduCIsDs0aZHbwy+qvU6BRurnp7jc/cuwSzS9krJHMjdY/Ouw5E9ka8BK8MilKb3+f48UWFL9fFAI2amSIr1QjiApTvfVlLEu0XHKC1CyjTaLeT4= 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 177184029984366.84986597220336; Mon, 23 Feb 2026 01: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 1vuSXh-0004pl-SP; Mon, 23 Feb 2026 04:47: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 1vuSXe-0004gg-5u for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSXX-0006rn-DO for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:49 -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-421-ZNxTUrWPN_yWBQiMbcwnTg-1; Mon, 23 Feb 2026 04:47:37 -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 053F61956096; Mon, 23 Feb 2026 09:47:37 +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 760531955F22; Mon, 23 Feb 2026 09:47:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840059; 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=ZPYQ0hUvRm1Sml+wzo1p7MhpaMjB3+Uk8ymOsKpY9PHs2T7fY+utlGxh0GcQ7GvMcljgkr 8ZDh8YZ7I480cGgZhzwgFsAT/DCIkLrw2YeCs5ZAqU6FdpiG5+SBmjvPAcdC8RrMVYVjTX sCDkymxIkYJPMOQVAPxptsJ+eUSr8Xg= X-MC-Unique: ZNxTUrWPN_yWBQiMbcwnTg-1 X-Mimecast-MFC-AGG-ID: ZNxTUrWPN_yWBQiMbcwnTg_1771840057 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 v2 16/85] scripts/modinfo: add --skip-missing-deps Date: Mon, 23 Feb 2026 10:45:34 +0100 Message-ID: <20260223094649.2005118-17-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840301225158500 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 00:57:50 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=1771840171; cv=none; d=zohomail.com; s=zohoarc; b=fFcSz6KGybAIqf+eD9aIZiQ3US9cG4oKcpJyH/6qB5XttW5rPnoBoOh8Scg/w9aYjAm81oTsOw9SOdpTKTFPxAmTUadEpIo/GLubaBS2/1Npr0BsehhFtzGOgKi7glkF5WsXCSskf8WR6YCLgMJZL6rQWvFeNP7yf2kr+yy9emM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840171; 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=WMT17atKJEN1654SEaEG4wU8L8pDkRYq7O6iMyqjkB7vivFom+bq+uS7awREL0QN3zru1bCKi3wgv8Eav/jDOQaEbXb8cCgq+yhuq85kttFd2K3zw56oZhYgwYQTAC8Rgg81MUDNCDjQGrOLVeX3nSiUT029grZq5T67AewkiYs= 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 1771840171114184.02611248863695; Mon, 23 Feb 2026 01:49:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXm-0004zX-UU; Mon, 23 Feb 2026 04: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 1vuSXe-0004hL-8v for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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 1vuSXb-0006sG-V8 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:49 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-132-2x_zxLZSO_eRSd-_Ql331w-1; Mon, 23 Feb 2026 04:47:40 -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 8DCA71956095; Mon, 23 Feb 2026 09:47:39 +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 E4ED01800672; Mon, 23 Feb 2026 09:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840063; 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=Q0+E0mVLBpiAqbvoG5Dw+VtzVH5696GNfsGx77rwMa+HFvynY4oyvvaYotzdydHb/1hP+H 23gVCdkOsGCHMpTRyJKHfQcNwvezZGWkfKxKmEh/d3OHZ06P8wun8pP7OrO9LzNwS0M/pz XeaSG1K4kSeM9kgtMbSjLqnb855nirU= X-MC-Unique: 2x_zxLZSO_eRSd-_Ql331w-1 X-Mimecast-MFC-AGG-ID: 2x_zxLZSO_eRSd-_Ql331w_1771840059 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 v2 17/85] util: add some extra stubs for qemu modules initialization Date: Mon, 23 Feb 2026 10:45:35 +0100 Message-ID: <20260223094649.2005118-18-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840172539158500 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 00:57:50 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=1771840357; cv=none; d=zohomail.com; s=zohoarc; b=fwcductsh7t46qkztJg2FURFGVrWqvDKcHjdy8FHNeWe4QnKGjmHkVh3+AhC7tsuYXlUqGQhpB/v/AMR0Cdudgkr/5scoxu00A4hvW27YZg+hRknbeHxXBDhXunxOHuQeTKIensGyANDg8KfjdMjM6ixT0PZnxwX0gc3A2Sze8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840357; 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=mZI/g/JNt5rKzyGgatxGPPj3P6y0/UpsyVG4CqQP9mc=; b=gMPfoJlJiytMiZeIy77Pn3zMyS9+UqTKUqAn+rprZ9HWZHHI+J8lNUhjS+7Wep4n699LWblboKYQnLxGTe8HNlgikFt3mIWFGGppESw1Q05wZbtRsnULysmCj++nLBGZajRkNBndGSkTLX1PLXYr6aEIzogqi9sDPVz1JaxY+K0= 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 1771840357361457.53896241059465; Mon, 23 Feb 2026 01:52:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXt-00057v-I5; Mon, 23 Feb 2026 04:48:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSXg-0004pi-Pa for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSXd-0006si-RT for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:52 -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-453-QjPAPAzcPhmYbZcTozDQ5Q-1; Mon, 23 Feb 2026 04:47: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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 685E019560B7; Mon, 23 Feb 2026 09:47: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 60AAF1800668; Mon, 23 Feb 2026 09:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840068; 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=mZI/g/JNt5rKzyGgatxGPPj3P6y0/UpsyVG4CqQP9mc=; b=FVQB2yzqobpnRwkqNaHt7mUWRraGLNOYgXnLpid8zbzO2aNs/+Ket47H+SWXfFTqwzY+Ic 6ri+w+qok9WQLjf+ybWCBdQRVOaMuptgjvmculQublrIggH3kW3sq9gFEiwHKiaMc3IkzS yrlXQks+UTtGs5pccd4Tq3QtpXOamHc= X-MC-Unique: QjPAPAzcPhmYbZcTozDQ5Q-1 X-Mimecast-MFC-AGG-ID: QjPAPAzcPhmYbZcTozDQ5Q_1771840062 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 v2 18/85] tests: start manual audio backend test Date: Mon, 23 Feb 2026 10:45:36 +0100 Message-ID: <20260223094649.2005118-19-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840359541158500 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 e0c481e2125..9caf62a05a5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3035,6 +3035,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 904605b844f..659f4739b10 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 cbe79162411..cb766e49ca4 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -83,6 +83,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 00:57:50 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=1771840115; cv=none; d=zohomail.com; s=zohoarc; b=YApUPni3kdDZFMB5vjKQcUG1hEa3dFDNs8+1K+HQsYQXbt9sa0t5B7dQm8XR/hQ4HwVec9CKKDcapLzvzgCai17kYwW+mZK16eOxDtS1V3dk8l/xYbSegk+BZalUSi6sPsXpEB3Tkrjr2VOK3Pkfjjs5nV/FQYbSve9ynG/ztzA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840115; 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=aei8v20VrB7lWfyZwBGHsW+kTxBcyxpBgRulsLMhg54/Qa77tn4dY3XZ+PZGwCF6kt3PEY5ozzKXxxBNmh/K4vDGI7EdKLnwE5NroagNmJyYBfvy+/ECMkyprKLkt0aD7q8skQsluaNsSkAYpveZ9jXgZDfC11XsSBMjdHAVZvA= 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 1771840115794176.8864553805197; Mon, 23 Feb 2026 01:48:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXj-0004tp-Uf; Mon, 23 Feb 2026 04:47: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 1vuSXf-0004lf-Od for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47: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 1vuSXd-0006sp-Rl for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:51 -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-294-MDgk0iX5NkiTr1o624AH_Q-1; Mon, 23 Feb 2026 04:47:45 -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 D338918004AD; Mon, 23 Feb 2026 09:47:44 +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 3B7EC3000C26; Mon, 23 Feb 2026 09:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840068; 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=FpVV5jjf9FAthDQz/MD7LJWreY6T82ZyFmsboOWyA2c9HVxnXsn8r72hf5kj35YYZ/W5mX bSpgvCHpB4CPKvYtQa75lxCRDe0NP8hErchR66E21YVYKDU6exujbX54ZHj3w0vQgVHcJT PWGwsfw9RPruNZS3L1RA5jcouaBdchs= X-MC-Unique: MDgk0iX5NkiTr1o624AH_Q-1 X-Mimecast-MFC-AGG-ID: MDgk0iX5NkiTr1o624AH_Q_1771840064 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 v2 19/85] audio: constify audsettings argument Date: Mon, 23 Feb 2026 10:45:37 +0100 Message-ID: <20260223094649.2005118-20-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840116626158500 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 00:57:50 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=1771840139; cv=none; d=zohomail.com; s=zohoarc; b=S5EP1T2c2E1nD2O400AQPA9bti2VLylqijL+W13V6l4XbnK3hxtdtZizWX7ARvKyFTcdALhblYgfMkgwZUrYQlhqVIfrDIR82S+SxKDYFQaOXWQlpBAvB7Aapj+oRLWY6OEOZON0YLL8ViXpIykFJa8bJTQFs2uY0wLlgwmjTBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840139; 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=GSdyqUSlahvu3+MnrntpRC8/SnnlgTGzk83YeaRN5HTh3cVFs+pSlPyOEYVh0E89825JnJ5smgLQKlVFbW8BH/23Qi/t/feevE3Y6Y+HxKoyTysxsnkbsEKf9jIOwHg4aB9l2zXzceuBs7JUqu+61E0IUEzy/y2YqMLcbeIPEcA= 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 1771840139340403.0945544912173; Mon, 23 Feb 2026 01:48:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXs-000564-BN; Mon, 23 Feb 2026 04:48: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 1vuSXi-0004uL-T2 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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 1vuSXf-0006tM-H3 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:54 -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-581-FLdq4-_fOIKPgRWbpUXFFg-1; Mon, 23 Feb 2026 04:47: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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9A15D195605A; Mon, 23 Feb 2026 09:47: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 C09371955D85; Mon, 23 Feb 2026 09:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840070; 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=H96iN6Cgbp35qmbmfxremlKke2F+dmOf+5NRdA2qgc4cnjRXmWffqQDAzamfDLMUJjepPy xdO4MFpd6k08ws2JYe5f1GAd2kp8Nq8u34+d6n0Ft9IyegZT7WJy+698FGL3sBuY1vHptD KMrmsE2+ueAyrLLEjTkTa5m1UfKrAbI= X-MC-Unique: FLdq4-_fOIKPgRWbpUXFFg-1 X-Mimecast-MFC-AGG-ID: FLdq4-_fOIKPgRWbpUXFFg_1771840067 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 v2 20/85] audio: introduce AudioMixengBackend Date: Mon, 23 Feb 2026 10:45:38 +0100 Message-ID: <20260223094649.2005118-21-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840140599158500 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 00:57:50 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=1771840222; cv=none; d=zohomail.com; s=zohoarc; b=Fhgs8GKOj3kuya17y56f/Z7e+wiMoXW8LawhhfJJFyoCPNT1Ti9lw7/ew7hJiKjEhqqB3brzXzBDLa4SF4JgFIE2s6MBNW7GibP/7tJQZ1tZCVoE7jr8Cxk8unap0aqkhho63aLWe9t9K6FM3FBSlkkDBXZxq2Bqgrz0Mv8o0bQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840222; 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=Nc6XeSfTHQyTQRgJWbiv1NuhuBRcouVldFoVW+6Qbvr+x7HFaiz9/hBGZh5LT5oXxBRrw2fEKPLEy5qG0p/EWk243O0fJGIfVeRFHYXgvdwWohNJcYhz5atj8QWHpWnmn0XbmTISL13k++Z1jq8UEj6LMXg43QTbKwsOksZm9xQ= 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 1771840222769730.0141178752174; Mon, 23 Feb 2026 01:50:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXu-0005E8-OV; Mon, 23 Feb 2026 04:48: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 1vuSXl-0004zW-1a for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSXj-0006ts-OY for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:56 -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-613-JQUmWgcjOr61lPwchCG6Dw-1; Mon, 23 Feb 2026 04:47:51 -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 6A68B1956095; Mon, 23 Feb 2026 09:47:50 +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 8FA8430001BE; Mon, 23 Feb 2026 09:47:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840075; 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=MoGBLES/OQaUzfItIw1ngZQr2/PDWFx1SqB4QB1NUa6/YhJdxG7x6OnwkrucA1vySefZ+m yzVnoj8/uVljZGkfJFBz0cRQFrSUorXs5OQUakhDEla/w5QlDqg0N0bqrCUl3s+fKXnVdM heH9AdwUV5LAIeaJshnJoWLPw+aPtsI= X-MC-Unique: JQUmWgcjOr61lPwchCG6Dw-1 X-Mimecast-MFC-AGG-ID: JQUmWgcjOr61lPwchCG6Dw_1771840070 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 v2 21/85] audio: use DEFINE_TYPES Date: Mon, 23 Feb 2026 10:45:39 +0100 Message-ID: <20260223094649.2005118-22-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840224813158500 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 00:57:50 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=1771840169; cv=none; d=zohomail.com; s=zohoarc; b=Nor9i5+1DExmzg5jIRL7xyvTwwc9zZnOiIetfl4nMxzsyCiNDUoqiUMd1/nWRTFIbh1wl1EBRT1/56LPNi/l1kDYcHXc62bMgQfCkP3D+zRbNyBY6CSblHJj3+WtFeB7fh9Vbk6k6j8h6JHbKI4jn4kU1/2azveJ82xhZE65Gi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840169; 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=le5tTw6cqSJkuF/h1Wto6c7wTKUBmgTUwV4/LDGS8OX3uu324+ALN6qeMyDt3g6u88hLIePm5S55aZjdUFpjnGnvfYpQv7KCFEBPRI8iVI1u6LW7VjjqgwdurACO7RiIkYiNlUy/++n6kBGa17YUoAKwU8HRJqGMZUPZs179b8k= 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 1771840169504379.3064487012356; Mon, 23 Feb 2026 01:49:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXw-0005L9-UL; Mon, 23 Feb 2026 04:48: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 1vuSXn-00052Q-0T for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:02 -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 1vuSXl-0006tx-Du for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:47:58 -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-266-FGvl63-lMfyMdrwsoNKuwA-1; Mon, 23 Feb 2026 04:47:54 -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 7C8DF19560A1; Mon, 23 Feb 2026 09:47:53 +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 55E0719560A2; Mon, 23 Feb 2026 09:47:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840076; 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=iZs+tyF3TtMClLrhQMzFcy+8xN6V6do+JEorQuoZAsHlmUhEKlBm/S8mjcjSc4hmT0oeu1 qZDOdrEkUHGOWajMh5m7uN+6JGZlGGWD1zq25o/tmwOca+ymIT55O7lIafdKNXXh5r/lGf Z+4YrRvRT1o6XwyHO7FJ9Pud0wbbZ/c= X-MC-Unique: FGvl63-lMfyMdrwsoNKuwA-1 X-Mimecast-MFC-AGG-ID: FGvl63-lMfyMdrwsoNKuwA_1771840073 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 v2 22/85] audio: simplify audio_init() Date: Mon, 23 Feb 2026 10:45:40 +0100 Message-ID: <20260223094649.2005118-23-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840170543158500 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 00:57:50 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=1771840477; cv=none; d=zohomail.com; s=zohoarc; b=OLgE+3PQ9zgnRoT79+jDadrnhHOdr+gOecRWbkZ7eaaisQsDG+rcp0o1HHYhObP+ub/tDsHB888zU8JVnYVm7IgkTN/Po0dnJQa6DAGxelT35XjVwLkpytSrXpuRa2rmkApCH5emWd0D3WxKPWbk8NiV1M9sR8reY8E2/HJqZMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840477; 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=UWz36zItYiFnT0NQPT3+1KAHCRtU7M5EJ/R3N3XoBFRsEv7O7T9r0T0/6VdWBF8kkTQ79ENRyxpzaIbs1nRX8rXv0BBEY2LhlzGOwsRHmUw4w5STCl6s+fbEjRVVefLmH6pNhySUW2QbRTDYlrqkQTb72o3OXQScpLL2/T7eYZ0= 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 1771840477131649.4789264743134; Mon, 23 Feb 2026 01:54:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSXv-0005Ft-EW; Mon, 23 Feb 2026 04:48: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 1vuSXr-00055O-IN for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48: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 1vuSXq-0006um-0X for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:03 -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-344-HculXjhiMF-hizM59llo1A-1; Mon, 23 Feb 2026 04:47:57 -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 95020195609F; Mon, 23 Feb 2026 09:47:56 +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 E555A30001BE; Mon, 23 Feb 2026 09:47:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840081; 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=Ilo8tcNSyhFBFbG4+UVlG1rbGlyJ59SX1AxPaLFJ4CtvU7Bb7wk1nlM23aCyxCoS8RX2c4 7UGrbJAfxTC49BmY2siN1tRZa1F3n0XNDqVggBu8EbzeI4l78Giw/Y/Lmn84FB+k8KpZDI fUnNnqVQNs4nqUAr9Zo/VqkyUToTh44= X-MC-Unique: HculXjhiMF-hizM59llo1A-1 X-Mimecast-MFC-AGG-ID: HculXjhiMF-hizM59llo1A_1771840076 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 v2 23/85] audio: move object creation to audio_driver_init() Date: Mon, 23 Feb 2026 10:45:41 +0100 Message-ID: <20260223094649.2005118-24-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840478063158500 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 00:57:50 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=1771840501; cv=none; d=zohomail.com; s=zohoarc; b=i5bcOkKSAQhDL6X0hsshDNmT4F9LaysZDpRwc3pb5QpR81PGGdwBtBwbkuMarklRL9u8SUdNfRVLYqa25vNQ3icgSlhfJ9DFB75/P44K6KtUKkV58WRqVL8OLw9UImXAvh33x3GWnfcOf8gVACYFTcFqzi4hSlNJUq+I9k4ohSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840501; 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=BqvOo9RcAHfDEESAXlyGpEeWglSqacj4Zu/yzSKYH0rtvBblz68T4DX6sUKdHDwYiEO9rh9AkF3tcjrlEmDf0faKAAoHzBM7SfV6YgD/h+piaGHwDCUX7lQJh4SW5S3ORhqIcbCk+ZZFoKcvIkkuaQYjsnCc09k1aesFHkuBpI4= 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 1771840501437778.712380370598; Mon, 23 Feb 2026 01:55:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSYZ-000738-If; Mon, 23 Feb 2026 04:48: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 1vuSY9-0006Zu-EQ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSY7-0006wq-5O for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:21 -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-55-ZAHnlDvsNCq3IPnXgxUpYQ-1; Mon, 23 Feb 2026 04:48:02 -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 416501800639; Mon, 23 Feb 2026 09:48:00 +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 3B2E11800351; Mon, 23 Feb 2026 09:47:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840098; 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=ixWwuQkb+QDrwZu+Bt8R6CX/0y3qqnJDj4uYUiKlxLQXnZ7jhknEdSzFyvD8Msvq6hQOah q/GYp+Vj4TsoF7INkWbJDY4VA99lOBlZGS3jbHPu8om5yNSzzUugQV7/tAo8IaI/Vg7o5d e8eT3Nweo06zEuqIavyNUAMvy7JvDpU= X-MC-Unique: ZAHnlDvsNCq3IPnXgxUpYQ-1 X-Mimecast-MFC-AGG-ID: ZAHnlDvsNCq3IPnXgxUpYQ_1771840081 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 v2 24/85] audio: add QOM module-objects for each backend Date: Mon, 23 Feb 2026 10:45:42 +0100 Message-ID: <20260223094649.2005118-25-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840502336158500 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 00:57:50 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=1771840363; cv=none; d=zohomail.com; s=zohoarc; b=NODH2QcLOMFpjAkqgH7j52FdvtjG+sbz9Q82TJWG98KdCDpWBAWqvTKao/sBCplCZCAVJzjMu76QOvRxn2p4SFjLQvKdnM+6huzzuDHrYFu2kOCkV7nj6L1jGduI6XxKW02e/1B9mG8mcKiGj/eL9OAnQ99/iP9cDcuV+6yvKpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840363; 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=OMJcbEZ8tlPBhoY3kiL71YslZ+XNNEoPo9Nyc4qkgQqTOePrks+LJu0/jbWEnkfs5wCoaHQ+ljC+IIjF6iIjUgvtXQAbhiKlXCKLI3QZHfyxfjtoeANnJSqx0Q+fbUeWJaDF7unOIajRIyq2lLwryWPfhHkYAoSuH9aSuZwI7rM= 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 1771840363380620.3493246020769; Mon, 23 Feb 2026 01:52:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSY1-0005qK-6e; Mon, 23 Feb 2026 04:48: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 1vuSXz-0005ad-2h for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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 1vuSXx-0006vN-3J for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48: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-689-NXtg73qsNj6CcNvvW6Ee0Q-1; Mon, 23 Feb 2026 04:48:04 -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 269E619560A2; Mon, 23 Feb 2026 09:48:03 +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 783D630001BE; Mon, 23 Feb 2026 09:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840088; 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=TCCw+eLyQ6FjR3POKl6rKhkGiNiIa7ktPdn8rpzxoW+hzFjSATx2mWYLj1L3pCa5f5t51G rm99PQ2A0XpecCbw1fEA13LrtxE3IQ8l3VMO1KgOZjaGSkGmGBQxC9etlXlZ2+0XvKM4V9 A13XVavkDQ/xtqiXuYorMBNJdsM5Ei0= X-MC-Unique: NXtg73qsNj6CcNvvW6Ee0Q-1 X-Mimecast-MFC-AGG-ID: NXtg73qsNj6CcNvvW6Ee0Q_1771840083 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 v2 25/85] audio: remove set_dbus_server from audio_driver Date: Mon, 23 Feb 2026 10:45:43 +0100 Message-ID: <20260223094649.2005118-26-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840365540158500 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 00:57:50 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=1771840119; cv=none; d=zohomail.com; s=zohoarc; b=CJCo7oIht/6HgviROOkR2qQ542bAJ/yft2sUqpf/KKWatB/j1GThJD2fFOJFdZMTShgafV1FN66Ae3izk+S2meWzl5PmkdkELEvpM8Q0CeUdR/rasOQEinCZ8b1lAKnIKLHE67+rFq3Ts7cngfkQ4YozzZYu2x89taZZkkwYOuU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840119; 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=L6d9ySKr1u0Gdw2iiQs9g6nHtOS+UvDns/fmhFnbLvssJ18dSWMMy6hi7FqGhsM/PRZP4LBol/xTbQ3AbSZht/NAn5jUg76gvBum/h9Iy22gaVHrdm1PHs2Aj80bGkMKDJ4digWAofBxKIsBJGqMteD1PyrnSC5j+iWEloxJ5po= 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 1771840119857683.3727689854541; Mon, 23 Feb 2026 01:48:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSY2-0005y4-9D; Mon, 23 Feb 2026 04:48: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 1vuSXz-0005ax-5E for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48: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 1vuSXx-0006vP-5Q for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:10 -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-314-0Ww2L7uUMwm3Uuhk1ZJ4_g-1; Mon, 23 Feb 2026 04: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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 65E0519560B2; Mon, 23 Feb 2026 09:48:05 +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 DC68730001BE; Mon, 23 Feb 2026 09:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840088; 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=a1hA/+WH1i0ismX9+IV5Z4hm15x4HBjHdByJW5sIPM+LwhSh4akRvu6ob8HRjBdM/aQnaL 1u+dIe6tMr/qhBWMU5dan9E5iVhkB6fmGFqOcnfuhR+iBAPHWAj8lzixBgiO6ySm6ShK/E uv8durVAM4FHu1dJPTknoIZrY3v9N7Q= X-MC-Unique: 0Ww2L7uUMwm3Uuhk1ZJ4_g-1 X-Mimecast-MFC-AGG-ID: 0Ww2L7uUMwm3Uuhk1ZJ4_g_1771840085 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 v2 26/85] audio: lookup "audio-" object types, and realize them Date: Mon, 23 Feb 2026 10:45:44 +0100 Message-ID: <20260223094649.2005118-27-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840122402158500 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 00:57:50 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=1771840196; cv=none; d=zohomail.com; s=zohoarc; b=F36289FyHKm+tcGOhDdh5M/mE4GPFX87CluVp9kqPzeE2U/7Qq9o3lRDCnw48OSWv/iJvkpiN0IuMNC8ytxTjxdrNyh/YPGywQTR7txFxQHuvdU20iOgm+jz+kJEr/07eEm5SUZHiaEUU71OlAmLcFFmcjhmfz0/D7tA2ryaYew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840196; 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=Aa4IB9LCB42IZASX8HOmqBVOVNYcnF/quMI/m871UsPSq2iJKgN8oyTgM6LE1L3HM6H7UvEJW/FoknUIVZBUMxtG8oby4WVvXjRVJdcqct/iviEtwVhU/UniYZifo9/v9gTjmEA3qRijlzEWREUTFf2BJWeF78c5TsHbzwTXqZk= 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 177184019626670.79313367213774; Mon, 23 Feb 2026 01:49:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSYP-0006lu-W9; Mon, 23 Feb 2026 04:48:38 -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 1vuSY7-0006Vy-If for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:19 -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 1vuSY5-0006wZ-Kv for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48: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-225-bJn5KIgzPWWmJMjjylOiQw-1; Mon, 23 Feb 2026 04:48:11 -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 07AB719560B2; Mon, 23 Feb 2026 09:48:09 +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 7C87A1955F22; Mon, 23 Feb 2026 09:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840096; 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=Vt1M/eE7uLHzigfDD9g6n8dBkV5gw0NjbX4La3TkZdrgDlizwRepVaPnq6FbyGp+Ew2R1i 7BiBnRXval71fLqLtRjgqJYSTb+HRzFtP8egzp2fR50mxhRbBWhDN0UMsoze3JrduZp+db SozcgVKYhLe6y+46WYriDhrZmSYiiMA= X-MC-Unique: bJn5KIgzPWWmJMjjylOiQw-1 X-Mimecast-MFC-AGG-ID: bJn5KIgzPWWmJMjjylOiQw_1771840089 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 v2 27/85] audio: drop audio driver registration Date: Mon, 23 Feb 2026 10:45:45 +0100 Message-ID: <20260223094649.2005118-28-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840198021158500 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 00:57:50 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=1771840129; cv=none; d=zohomail.com; s=zohoarc; b=SjtnynZYxg3Q/cQpU/WwI/dkDuQ6Zco6OsfTWA2RznwfXqw5MBieeTqY7TLjNRIBPfDlyGaWf1p80WkESwjsXxdVB8MeiMOfR43J/Ngmj3NHzvuMev6Dgds5JHJHHT/ibuYXKTPcl3V+cxRjHnxF88V99Z+1hzZnErjCikXuK+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840129; 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=i42y/Z8CIAxO4EBlIEU/pvdbu8Qf3xCPQ24Hmi0Eve1jhGqHppwjYxfieKci6hK/cBRex2+Uswm0M18+AaTxgdf6vMVuawguKaUk9iBwiKpq0aqdjERHSFWeFlpbSrZIafkSn/7UFzdEShCVfnh4UvVlaUcSBSTFB0ZALj96ELM= 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 1771840129955807.5934355820257; Mon, 23 Feb 2026 01:48:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSYB-0006Xu-B0; Mon, 23 Feb 2026 04: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 1vuSY5-0006Id-1A for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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 1vuSY3-0006wG-E5 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:16 -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-611-pLkx1r5PMKiwd_ICCs6Acg-1; Mon, 23 Feb 2026 04:48:13 -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 55BB01800613; Mon, 23 Feb 2026 09:48:12 +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 6202D3000C26; Mon, 23 Feb 2026 09:48:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840094; 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=aGZNCeXw+vu+GtPRGW8nGz6XMeLyIzr8kD55pt8VSopdUA+8M/h5+O5FmLSlIWPU/fDfP9 bbYujs6cTHKxVG6tfNHV/QKNra47KFxO3Yc5sOP45GA87iwiQ03htvZqhLV1SwssDf1klD WT00DpW9lahnv9rYmCZBjGVGnK0SOJE= X-MC-Unique: pLkx1r5PMKiwd_ICCs6Acg-1 X-Mimecast-MFC-AGG-ID: pLkx1r5PMKiwd_ICCs6Acg_1771840092 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 28/85] module: remove audio module support Date: Mon, 23 Feb 2026 10:45:46 +0100 Message-ID: <20260223094649.2005118-29-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840130525158500 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 00:57:50 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=1771840622; cv=none; d=zohomail.com; s=zohoarc; b=AihsC7X5PgC+xe99ZXFhyZ9B4s+kuHeY/DEG0EHt7SOhG3WNxWpAdn9MwRZv3tpK4hfh2QyvY/V/oEJ6Zw3DHJoi+xM5HR3KGcoPubTdB8vKZF7YSsEa9sPZTIddbJXnyLYCq3WtAh0h0I4UJj1lT6dPXqY69MmVKwqdadoP748= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840622; 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=UCp2pfcJuv3TaCanouf6GzxJcKjE6Z7EYumwrlCoFD1G0hbCgSwXZmkqpLN8vdlY6NlAB2fvhsju2b+peLDmyB3Asd1sOJkustb1ueQqFSfZiqkbOgAoR+vOVTAF5vbyVehTTjICros4wtCuLC8Ba5D4RZ9j3wr3A9HayTkP210= 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 1771840622273724.5918231410017; Mon, 23 Feb 2026 01:57:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZ5-0007gI-PQ; Mon, 23 Feb 2026 04: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 1vuSYF-0006dK-Nj for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSYC-0006xO-0Y for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:25 -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-478--rrfd7VSMt69JjtrWT-Yow-1; Mon, 23 Feb 2026 04: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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0512C1800265; Mon, 23 Feb 2026 09:48:15 +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 414F030001BE; Mon, 23 Feb 2026 09:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840103; 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=LjEgzaiBJdghbUCZ1nLV2YLEovT3No35NUQA8nrvTkDmlTUaQdRbk9ocFP8kghscLqR9Mt 6GG/V16++wPoZrUU/5vBrDj3GUOg0SwiFi0QIauTyrmfIFqfQwXb3VR9tODjHMasDVCYuk dWhWAQrUQJwmu7woJiVB87aE5DUlj/o= X-MC-Unique: -rrfd7VSMt69JjtrWT-Yow-1 X-Mimecast-MFC-AGG-ID: -rrfd7VSMt69JjtrWT-Yow_1771840095 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 v2 29/85] audio: replace type_init() with DEFINE_TYPES Date: Mon, 23 Feb 2026 10:45:47 +0100 Message-ID: <20260223094649.2005118-30-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840622759158500 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 00:57:50 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=1771840490; cv=none; d=zohomail.com; s=zohoarc; b=Lii1yaX+hJEK7YVukNXxcneNtv73k4Uov3Xij49HKOGG5rAY1pbZwfmoguqpzrSZebsiq/5/l9QVY85W0H4URlH7OvCiTQxzVkmqvMxOpFZb+TBCpvBnT3Q470T+OodRig0ftOA+aDzi8gRMx4fEORyjhdrRAaPXzLGVc7dFUzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840490; 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=HU7z8RvztV4VU/3fa63WTlfR7Bk87W/Yz8faq5C9uGgGaaMCdLWgeNNjypaCHemQUypi9claVNBUBmGSgtLWjCdUU5iNfK7rRjb6J83B4yNEsn/GEeq2bW+lPF/cUOS++m/qH+gm4hpzpaO+U9/qBUnFPtiL90/0howu+lv75Dw= 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 1771840490042850.9468452384273; Mon, 23 Feb 2026 01:54:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSYj-0007JO-FF; Mon, 23 Feb 2026 04:48: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 1vuSYF-0006dY-Og for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSYC-0006xR-1n for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:25 -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-170-lo7hqmk-POK-ylBdNfyrKA-1; Mon, 23 Feb 2026 04:48:18 -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 924FB1800A3C; Mon, 23 Feb 2026 09:48:17 +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 00CCE3003D8F; Mon, 23 Feb 2026 09:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840103; 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=cCkXuDb2d69TrDZ+ps42Ieu5KY+a0aMzs3jcshXEjzMJ/eRgib3bhtBQG8VIvA5u83ypiw +KSna377aoIPCKHg6EnKm3YGF0nTbBtGe+ApU04x9nZBlJ4qRgT1yl5SaZgCcvl6UldzNv 0jYrBX8Vg1kV+JsVvJbeOSCZK8LYT1Y= X-MC-Unique: lo7hqmk-POK-ylBdNfyrKA-1 X-Mimecast-MFC-AGG-ID: lo7hqmk-POK-ylBdNfyrKA_1771840097 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 v2 30/85] audio: keep a strong reference on the backend Date: Mon, 23 Feb 2026 10:45:48 +0100 Message-ID: <20260223094649.2005118-31-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840492146158500 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 00:57:50 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=1771840357; cv=none; d=zohomail.com; s=zohoarc; b=TXW0dyb2p7HXhIJiBcfCs9KdlSct4gzEDs/f2XIqG80exXsu2mzgLlrWxBo9uxaf8Wmec2ZBKoyNTa/OfaZ6pj0gV6+V+6gowgNKp7sx2q70FCVBHGDy1jKaoCThCScf1RJf3IVH7qem0frqk+AgySy0MY2SGUDL91CozVeHYCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840357; 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=axGs0ykWPkUC4+P0bbwM6xuuhhpyShlmHhiQsWg2wDzZzi27z2N4bwcQ3524XM+w/xsCZ9CvDPvrqdvxxmwOYnwJshjbsy049LoFIADmPcstv2zWbTjmyItOSTE8HGeKaU+d3o0OamtBSTA7GznlPYXm0vHd+4DodA4hH1QRswA= 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 1771840357066619.4765231636749; Mon, 23 Feb 2026 01:52:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSYh-0007Dy-Iu; Mon, 23 Feb 2026 04:48: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 1vuSYF-0006dV-Oc for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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 1vuSYC-0006xT-5t for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:26 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-HpSl5IECPXeBKUoh1v6EeQ-1; Mon, 23 Feb 2026 04:48:21 -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 B4CD91956078; Mon, 23 Feb 2026 09:48:20 +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 79B461955F22; Mon, 23 Feb 2026 09:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840103; 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=N+SUGFJdbObd77Ao3dHSz3dGqtiqpXWRrQbXR09pgHLjj2lklNPMaTzXJBsMrS4DqLzbBy DwWpqJt91PWbPUI8anwKOv6yXI2n1DujST1+NyKzvhPaIqd8HYzDTyjCn/HkcWQb54UHJa qmVnTxPXz8eQDfVilFviCtAQMeZWSm0= X-MC-Unique: HpSl5IECPXeBKUoh1v6EeQ-1 X-Mimecast-MFC-AGG-ID: HpSl5IECPXeBKUoh1v6EeQ_1771840100 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 v2 31/85] audio: make list type declaration private Date: Mon, 23 Feb 2026 10:45:49 +0100 Message-ID: <20260223094649.2005118-32-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840357390158500 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 00:57:50 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=1771840532; cv=none; d=zohomail.com; s=zohoarc; b=hx6bSbXNh1NQzob30yCsQCRNIJWw4pbgoC5c+14OgUK/1VltiLsvuOA+nvtbMKnDAgmR+/7VCA32sR/21fKGcxuI7lyeoWcu/JQ7El/V5tW8O4bH1j3Hym2QZ6ozj7g3lsoXHWYXOEdXi3f/IAXk+FHbNnrF3Y72mD61Rx44U6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840532; 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=MMGCFaCag6YMBwRt1SzC7REe/3cBw5UyGGMsA7zNksqiaY8MZWawqM4s+e3z4syUxdkpJhzLJMv2ChPpGHN1B/aEh8UFHcvTPs6VHHbpBfAOyADEQjA+FGqLHWgM55NgYG5Ziq6Wv4TGjPcu4C6hiC3DCQ78RzHA+dhfpzve4nQ= 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 1771840532953775.791358862412; Mon, 23 Feb 2026 01:55:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSYZ-00071E-2L; Mon, 23 Feb 2026 04:48: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 1vuSYK-0006k9-Ks for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48: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 1vuSYF-0006xs-Ge for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:32 -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-153-zrS7oSHGN_6izDG19jTGyQ-1; Mon, 23 Feb 2026 04:48:24 -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 EB6301800352; Mon, 23 Feb 2026 09:48:23 +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 F035E1800674; Mon, 23 Feb 2026 09:48:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840106; 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=cFdj9w+anTeW6SDOAsLZyX0Zfk3Da74iBDPA2hWSFSOqF9KZJSstgvVpslp/hZ6charqWr ESkUvK0E148TtjXeWF++Gza5JlgPBOWvk/crRGfyT4/cTXFIZ7oLWqO/+PRPG3brkgqWIX k7I0491G43lixGpdrtCwcjvTEjk+P0k= X-MC-Unique: zrS7oSHGN_6izDG19jTGyQ-1 X-Mimecast-MFC-AGG-ID: zrS7oSHGN_6izDG19jTGyQ_1771840104 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 v2 32/85] audio: make create_pdos() private Date: Mon, 23 Feb 2026 10:45:50 +0100 Message-ID: <20260223094649.2005118-33-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840534324158500 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 00:57:50 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=1771840172; cv=none; d=zohomail.com; s=zohoarc; b=BbGJ7zbxuMwXkT/rIoH796RE2IrFjU4Kim0iol9bBRoUd2YXWaPae9m3WU52GwPLHIiNducaSpMS6hPWUCd9F3CWLS9VAELzGP8ahVNcfr8UlQ+uYOGYBkRgwaSHwvYr32OzQ3VT+gknCxZwAxuSPKsmnWHq4DZ40hQNsdS1fxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840172; 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=NCJvsZXOjpYmI7TRuSJ0ZtkKXZLDcK+/rbQpyk/PIqS60x6j2pJ3dhMComPf/0XuFH8k03VQYNAvUhbwsAWtXeqxn9GgbR33NkwsXDrrZxNqWcOaD7vHVijppv2h6cO5QuZawWgb08OSX+UXjHwMMX6wDSWwY4CVmXdd4r8BkVY= 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 1771840172242974.8024510239269; Mon, 23 Feb 2026 01:49:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSYa-0007CJ-Dk; Mon, 23 Feb 2026 04:48: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 1vuSYN-0006lt-Cc for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:37 -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 1vuSYK-0006yT-QA for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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-511-BEtAJuHsNJK8jrlO6Mr0LQ-1; Mon, 23 Feb 2026 04:48: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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3F31A1800366; Mon, 23 Feb 2026 09:48: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 BA1291800672; Mon, 23 Feb 2026 09:48:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840112; 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=Mv7FtuECWDBNbHuZz69j8zfTNWzWekQS5dhBRCDqH+QcbVEkpaa/skNy1xlw6YSMDqDhAf p5aEil9gKEIveTpU5Cwuh7M2nsxKqixWP1hlqdTaeNaSGmy/Psai8qUvr53Mxk9ZZm1rD+ YbWAs417efuqu7FboPWX1v5j0+vT8aQ= X-MC-Unique: BEtAJuHsNJK8jrlO6Mr0LQ-1 X-Mimecast-MFC-AGG-ID: BEtAJuHsNJK8jrlO6Mr0LQ_1771840106 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 v2 33/85] replay: remove dependency on audio/ Date: Mon, 23 Feb 2026 10:45:51 +0100 Message-ID: <20260223094649.2005118-34-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840172721158500 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 00:57:50 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=1771840181; cv=none; d=zohomail.com; s=zohoarc; b=eOilRYtqJ3CcFG/h/Is1MJ4K9LocsUGoQu1Nj4g4V6uNAFKLwyu8ENdfeXkjIJVQRUuPxbMB8kYiKOvfRU0W6YXfMdYnfgifMvtwNmiDYDCtjJJ77rO8WZo+LSQmyhq2baol4nAGbnvzZKyTOgkJUeTNThR67s15HF2nISfBgws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840181; 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=32WFOc5uOoFBKCIWZ5Udbsc+mY+tpUP+Ingx1iQ3Jbk=; b=L4LkAnWSAJpISLqyTiVDDrBhTDGLB2yjPAwoR7OG9zYdOMH1aTD0q8Smwdx8QaKIcfzpLGVKM+4U1Q4HS0ioOxx2ZHV/xxSjgqu0YVVd/C1+bveCFgoxoxEoqNGffnedSE3NqPJTGd6bPK+kx8RdjphbCKEJhC4NMRvdKYy0JnA= 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 1771840181772755.1383919127005; Mon, 23 Feb 2026 01:49:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZ3-0007dT-Tt; Mon, 23 Feb 2026 04: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 1vuSYR-0006s2-3A for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48: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 1vuSYM-0006yl-Su for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48: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-646-9b67FtzpMh6Aej54_-7sfg-1; Mon, 23 Feb 2026 04: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 0B484180061C; Mon, 23 Feb 2026 09: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 62BF719560A7; Mon, 23 Feb 2026 09:48:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840113; 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=32WFOc5uOoFBKCIWZ5Udbsc+mY+tpUP+Ingx1iQ3Jbk=; b=KBXAPqcAt5MxHOy2GkaC6/CHVDDtwmcGDP51iUnRfBPtD68arQ/gw+G6O0fVzAPgW2Z2nC jx47HA8Mzr69uLbvI9HR3dhC4prA2ZUXl37GKspWkoBAr0+9pPNaiRhYZVI+xzr1+stwMc dmMuDTX5iQ7FNBDl9W5OXRONFOk7UXU= X-MC-Unique: 9b67FtzpMh6Aej54_-7sfg-1 X-Mimecast-MFC-AGG-ID: 9b67FtzpMh6Aej54_-7sfg_1771840110 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 v2 34/85] audio: make all the backend-specific APIs take the be Date: Mon, 23 Feb 2026 10:45:52 +0100 Message-ID: <20260223094649.2005118-35-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840182734158500 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 9101560f387..47fef61af88 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -463,7 +463,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, @@ -471,7 +471,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); @@ -561,9 +561,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); @@ -1166,7 +1166,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)); @@ -1258,7 +1259,8 @@ static void virtio_snd_pcm_in_cb(void *data, int avai= lable) return_rx_buffer(stream, buffer); break; } - size =3D AUD_read(stream->voice.in, + size =3D AUD_read(stream->s->audio_be, + stream->voice.in, buffer->data + buffer->size, MIN(available, (stream->params.period_bytes - buffer->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 00:57:50 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=1771840555; cv=none; d=zohomail.com; s=zohoarc; b=YIMt+gsc7sSMsJTIioltUVQhFfbA0y6vgoJKzJasZnox1fEv56vb+EC3Gb5IfsoiCmj6jb9hBAlY0v+mXMcDyDgiC3YAx96bhFafLDAy/baMZL9x7/aeZdwRiQ341072u9AGzzrjwm86vEiCzXTe4uromAwCj02bnikJxfB7a8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840555; 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=AOlOVV7F3jdfksYxciSR00lGQoYurXAPk2K1Zn4MYja5PBIiQvfnvt72xMBZbydU/+kGFr8zfOkABmpDrbLQ+vT2Xd8kp/Hdu4K9ZpxZLFNmPfodSTjyTRiIUHeWwiQS+5c3kKjcfnVaY2yh+7LeoeSMurvlrng1LKjOeYBzPBo= 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 1771840555774661.0507652267268; Mon, 23 Feb 2026 01:55:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZA-00082M-6a; Mon, 23 Feb 2026 04:49: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 1vuSYT-0006u2-DZ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48: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 1vuSYR-0006zk-1O for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:41 -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-602-DIwiVj7PPEyjIyI8XYT6TA-1; Mon, 23 Feb 2026 04:48: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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6B0A8180025E; Mon, 23 Feb 2026 09:48: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 A447D30001BE; Mon, 23 Feb 2026 09:48:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840118; 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=Q/H2RN9YH6GVKE2/B20QtbND2GMd9O+/0yqa/3EbmbvFUdUcmpfebeWx6HrooamwwoWvu6 7rB0QUoMBLB9D+wlyrkvKcEORxwbfXnTG9hpCi8uvd7RaMyVIzNlfBmJTple45mOqY5vag 792UcD45jufF8ZwyyXhI+ALIsqM5eFo= X-MC-Unique: DIwiVj7PPEyjIyI8XYT6TA-1 X-Mimecast-MFC-AGG-ID: DIwiVj7PPEyjIyI8XYT6TA_1771840114 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 v2 35/85] audio: make AudioBackend truly abstract Date: Mon, 23 Feb 2026 10:45:53 +0100 Message-ID: <20260223094649.2005118-36-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840556591158500 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 00:57:50 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=1771840258; cv=none; d=zohomail.com; s=zohoarc; b=Yj53bUWKTAdp9D4cIn3as/jVJMiTEHUw2XqLtZht5YVPIY/p9CNR/VV8hpFOm6oZFCPMfSXV1b85ECX8FyhwaIpWRP9+jOdGFuEeargpUt2ySHf8QN+kVq5xE9viyEfY6xeP+R9kn7nomFoMHS2avcqwSTpsyGP+GRaHSi12ueM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840258; 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=NtOdHcRt93nKXNumloFz5Ymxd+EsM8eoR8mcxIqXZOoi8DXETxwEfZAyOD/qIwKXuCsoyfvr13dI1epAQJDWmLM5Klt3MCRd7IcAunA6MlrH4jntg9RaIlEAC/kOJb+rjd2moSx85B9Vpx4M2eN9XZMxu6/rEKRvPXZNocfnWa0= 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 1771840258430908.6252927403132; Mon, 23 Feb 2026 01:50:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZB-0008EV-BH; Mon, 23 Feb 2026 04:49: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 1vuSYY-00071z-7V for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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 1vuSYV-00070n-Qr for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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-347-4qejeqOgMtyRGOcl1K3y-Q-1; Mon, 23 Feb 2026 04:48:39 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2C7461956059; Mon, 23 Feb 2026 09:48:38 +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 506601800465; Mon, 23 Feb 2026 09:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840122; 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=Z7jhfVt9/bHPoOAbseSitgm+OQH1hJWQGogRRsiLSG657GSG7O4KYEdz0zroCOIjIwFi2Y Ssp6Wk99bzugjIeuF80OCC1wek32Me5tSYiUMCstSSZ54FFXOr3+Df3gSvhnQJ6PJwO2FS VWsp2rPTGh5H4C79aSusdCqyafz5pZg= X-MC-Unique: 4qejeqOgMtyRGOcl1K3y-Q-1 X-Mimecast-MFC-AGG-ID: 4qejeqOgMtyRGOcl1K3y-Q_1771840118 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 v2 36/85] audio: split AudioBackend Date: Mon, 23 Feb 2026 10:45:54 +0100 Message-ID: <20260223094649.2005118-37-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840259107158500 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 00:57:50 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=1771840165; cv=none; d=zohomail.com; s=zohoarc; b=dRGLLf3YQTJFGlih7Smt1NcPiuFFJ3vTI9Taaas02CyZQIa1bEkooa+W718qD6n999hx9GINcXiyRxV+D09TI9ocYOuenD71MrtaCEMOxjXpda6lgq4LY0xUgFhZBK2NP6t3czvdC0QxsKzKBkfvUHwkmP0X1lYZJn0QA3dPjvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840165; 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=HvNBDmel9ARMwegRd/YmMEMKg6Yt+JvTX8PNo8lp3vE=; b=iP9wQ1YTCVT5ONU9Wndo30YXw8sgA6EzObKfuUvZj3sbiCKc/MYF3JkOMB3yq3M4RU0Q1bGVPa6MPFnGg/tSdX07zGvBUq5XgTXp8rv/+jNqgdMPXXDpUHjdb9+H/7SwWPZ15hB8C7yCSaQooUJhcsnmLyi5QUL2jjdmiBpT0fo= 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 1771840165419152.270976348756; Mon, 23 Feb 2026 01:49:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZ9-0007uW-3X; Mon, 23 Feb 2026 04:49: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 1vuSYf-0007Jv-1h for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48: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 1vuSYa-00071G-SX for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:52 -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-523-q6s1Lx3lMPKointhRCyFRQ-1; Mon, 23 Feb 2026 04:48:43 -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 883D71956095; Mon, 23 Feb 2026 09:48:42 +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 7635B3003D93; Mon, 23 Feb 2026 09:48:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840128; 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=HvNBDmel9ARMwegRd/YmMEMKg6Yt+JvTX8PNo8lp3vE=; b=hjYstse30Iv8zL8UTW5JwZ/GJjwxZMkEIylQclNczPlpie2HMn+4qPjwXnFbKkiKSrSD+v sqFzV922HDpJHRq5Y9x+TN+JiLD9Ssq1vIw+EBGwB1RleJpKpaDA5jDYDlFRMdM6G1Jdkp AGRMG79LNnIwV57dxJzwCWfBAC8rRiM= X-MC-Unique: q6s1Lx3lMPKointhRCyFRQ-1 X-Mimecast-MFC-AGG-ID: q6s1Lx3lMPKointhRCyFRQ_1771840122 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 v2 37/85] audio: AUD_ -> audio_be_ Date: Mon, 23 Feb 2026 10:45:55 +0100 Message-ID: <20260223094649.2005118-38-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840191055158500 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 | 34 +++++----- 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, 278 insertions(+), 276 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 47fef61af88..89e24c0a8e0 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -391,10 +391,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; } } @@ -457,21 +457,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); @@ -561,9 +561,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); @@ -1053,7 +1053,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 @@ -1135,10 +1135,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) { @@ -1153,7 +1153,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; } @@ -1166,7 +1166,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)); @@ -1230,10 +1230,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) { @@ -1248,7 +1248,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; } @@ -1259,7 +1259,7 @@ static void virtio_snd_pcm_in_cb(void *data, int avai= lable) return_rx_buffer(stream, buffer); break; } - size =3D AUD_read(stream->s->audio_be, + size =3D audio_be_read(stream->s->audio_be, stream->voice.in, buffer->data + buffer->size, MIN(available, (stream->params.period_bytes - 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 00:57:50 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=1771840376; cv=none; d=zohomail.com; s=zohoarc; b=AaXUhlAWcP7j8ZT9QmnrG3K26kDvVXtYdHZE+cOIh9XShoL1fxUhOBxb40rm+y21s4+0PpMzkttXSRJ5dO/m/qqnd9OLxmpoNs7iO/cvT9r4136xhRDmLdEjahguv/VB6m4RbOauAltvORq4FNNSjJxdMagFD+ZZSUErXEu/ZEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840376; 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=S0wqFaf2g/rSrG2EHQs6v6QlSZsjc/zVgglDBLGSXfmsD9CviHnAkXm1TEuhN8/Cn6f9g5qoCDmKtr/Y0ceOFWsgDprBcRrlsiDKYVrj1gbqzSsTmbHJIWSzV4PGoLLdVEnCpjtys4O7kcIkWP8xTJVh8yZTbUOnBlDU9UKEiaE= 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 1771840376579669.1758411059224; Mon, 23 Feb 2026 01:52:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZF-0000El-4L; Mon, 23 Feb 2026 04:49: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 1vuSYy-0007dw-5J for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49: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 1vuSYw-000730-JW for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:11 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-674-xkDrZCnPNEGJ6q9qo2KsAg-1; Mon, 23 Feb 2026 04:48:46 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A035E195609D; Mon, 23 Feb 2026 09:48:45 +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 A8FAC195419E; Mon, 23 Feb 2026 09:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840150; 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=dJHHvSUE5uic1MCn1pQstgFlnS+yZMfH0uokvydf5SX54UyKpLqzYvlSLhdVuLQKLL4axp +eamHWs3ufzcmwQOB7jG92bgsp5KqNMILhMK4z1l5tkWhThxGZJSITThg5K2bYWu8k0DxR d4yyDaYIVPwKSjpDT3IzXCewk3hqpJ4= X-MC-Unique: xkDrZCnPNEGJ6q9qo2KsAg-1 X-Mimecast-MFC-AGG-ID: xkDrZCnPNEGJ6q9qo2KsAg_1771840125 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 v2 38/85] audio-be: add common pre-conditions Date: Mon, 23 Feb 2026 10:45:56 +0100 Message-ID: <20260223094649.2005118-39-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840377562158500 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 00:57:50 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=1771840657; cv=none; d=zohomail.com; s=zohoarc; b=SPKl84FJnZcXlIgoHlI8YpCO7uCGk6QZrOJG4QR8H2/Y/SoouAgpEWRFLS6A8w0aAWLb8ry5OfVn0H9ktmhwSZet3cMqIt0fPu/G33x5uYZb/tsaNhido3jxm2p/tLjg6sjs8ZYt5v1S4Q9N4a8UpjzWCX1wduileGzMGBjyE5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840657; 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=UftcP6R1cI6FGEB3Hvghtej2dLUJQHsS9Cn/l6OU2+8xopfxfK9HXzQyhBetE0vkxFRLwpLg3PB36HsA85ucszxq2b5Se75AxwnxkC8+CkoJ2dMog6ZFzS9NIb1qIY154vZH5ZNxMPr80J6pQxXPs+aldCpetJ2ZnznDjNKBm/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 1771840657905915.4413524831497; Mon, 23 Feb 2026 01:57:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZD-0008Vk-Vg; Mon, 23 Feb 2026 04:49:28 -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 1vuSYh-0007ME-1h for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48: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 1vuSYf-00071f-AJ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:48:54 -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-655-rXjY4vXuNBi0ZZHhJeh_rA-1; Mon, 23 Feb 2026 04:48:48 -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 DEE1319560A1; Mon, 23 Feb 2026 09:48:47 +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 539EA30001BE; Mon, 23 Feb 2026 09:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840132; 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=LH7TuHpWVYslFrxVAcMuaInck/qUC4seiM+E8GtVMUv5+ITyLWZIwVrtCBaf+1hxExieq2 PSb7f2mqjrEH3KAdA0CTrK8+3SF2onIJXBJZYXe/Fh5vqvwr6LVLXOojpTF0EXyDgN5pWO vUVMTk1WerKEfcTIulswm/nlG3Ckrd0= X-MC-Unique: rXjY4vXuNBi0ZZHhJeh_rA-1 X-Mimecast-MFC-AGG-ID: rXjY4vXuNBi0ZZHhJeh_rA_1771840128 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 v2 39/85] audio-be: add some state trace for debugging Date: Mon, 23 Feb 2026 10:45:57 +0100 Message-ID: <20260223094649.2005118-40-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840658906158500 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 00:57:50 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=1771840409; cv=none; d=zohomail.com; s=zohoarc; b=l5OOXPFa0f+T9qi+keayE2W3txN48CHIQFnyeMJd1PfOEmyPosclxKgVmpGcmVRYEl1b6tuAsmwaz5JKBxsATVIHRrB1mhOiibivMpitRx7HYkkESOr2VQj7noC226SxAr+gmpa1X2/1hwdJd7o7PmCw8OD+5XtErbsn+NMIlhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840409; 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=ihygnl7U6pbyjC5cjI/U4q70jngHpIO9DS2Vd3J2OOQ0IDnYF11IyRAwNQECYO9LOLhPsTsr4vvywJsp2QCbuYjDA4H3zKJ3/QwnwcoD01LiArtdffJg7h11UK8YH9GfBUCfrYJv8Y46w+4Woc4nypx9RJFqDp9qWMqPGPme+bQ= 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 1771840409113614.6304116039703; Mon, 23 Feb 2026 01:53:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZC-0008Kr-J1; Mon, 23 Feb 2026 04:49:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSYn-0007Y0-Kb for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49: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 1vuSYj-00071x-Cs for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49: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-635-yEokcNeZNGqdKE-j0cxTaA-1; Mon, 23 Feb 2026 04:48:52 -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 56BA11956063; Mon, 23 Feb 2026 09:48:51 +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 334341955D85; Mon, 23 Feb 2026 09:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840136; 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=TKEeHHksqaGKMdp3uGt+knCWpILB5E9Wtbsi4kzZRqm+/n58KUvRnMU+xu0Dz+56C5w1TX 1puEKkXMvS+3+Txf6Cd0jJk/hiwHAQCxVhBxlTRFveIJGdvY+svxkqzWNLQ+Bdsb8IpXfD M3nMkNTNxSIpe56lKFOZghlTirzD2Cs= X-MC-Unique: yEokcNeZNGqdKE-j0cxTaA-1 X-Mimecast-MFC-AGG-ID: yEokcNeZNGqdKE-j0cxTaA_1771840131 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 v2 40/85] audio: split AudioMixengBackend code in audio-mixeng-be.c Date: Mon, 23 Feb 2026 10:45:58 +0100 Message-ID: <20260223094649.2005118-41-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840409850158500 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 00:57:50 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=1771840337; cv=none; d=zohomail.com; s=zohoarc; b=jpfzqQWrA07feBhusccII9oiP6wDjgFLoBlRQU7uceC5Mb7WXJg7s7kNRQhFhweKDxg5xWwBoM7aEKMtDy1fmRqoMAsl8Bc5LIA6EMXD7QEuF0HWByb3jKqJJKyhzhQQUDc0PQHTrkvGSHJWPMgYUb0coB1Dd//pra+GTOwt1q8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840337; 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=jzO8gQ4yJKwshXpUJ3Tgf83KgEoV1pNRwIccHO/T48nm4GSYespRg0BFCn20Zd3MRDfpnQyqqU3J0DLjZ4ngoVPle42H/TDhiLYOFCYHECXuZnw2WVl+bUrYjTkf8MJbEpbd4c+k+YDLlgI/8K2yyJWZpKBB3P+7fjSVOrafezc= 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 1771840337318660.2508000499093; Mon, 23 Feb 2026 01:52:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZB-0008Br-28; Mon, 23 Feb 2026 04:49: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 1vuSYn-0007Xo-8b for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49: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 1vuSYl-000723-RU for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:01 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-120-TdwJmP3fPkCzKwLGjFfn-A-1; Mon, 23 Feb 2026 04:48:54 -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 DF01618001F6; Mon, 23 Feb 2026 09:48:53 +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 391BD1800672; Mon, 23 Feb 2026 09:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840139; 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=HBHKaIQoSJqWewgijdBtLH/KcOX5mJx/OKQVTeoqFmmu/v8WV6dKXgXwplxFdYenJPgRwK nraLtcj+ZBR3atM2gjYcvYlRYMS4hrjyCLU/EdpyacDOaY8ROz7XuEzSlVYJNAX93bhQO7 gArrySZTS008naezO1WdviokptMSRfw= X-MC-Unique: TdwJmP3fPkCzKwLGjFfn-A-1 X-Mimecast-MFC-AGG-ID: TdwJmP3fPkCzKwLGjFfn-A_1771840134 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 v2 41/85] audio: make audio_driver init() & fini() optional Date: Mon, 23 Feb 2026 10:45:59 +0100 Message-ID: <20260223094649.2005118-42-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840339310158500 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 00:57:50 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=1771840478; cv=none; d=zohomail.com; s=zohoarc; b=EEeGett4gvzSYZy8HVudeDhyHGqYvhBQu0VyEBpewvtXmQuprzODth+qFWMlT/FX9lWFiEc765Fm6xZjrNUUJ90WjQaRUqjE8xpOrdaM7WjcN711WVspkrrLbU5bwSLZTqHpZl+yteJjU6mDxTFy68RzmrpqhvSMb/CoaXZb1KY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840478; 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=a+whlQI4D5VSntrWyz5Gq6VCo5vSBEfvznUnPGw/k9gOiGfa2ShfFXDszYhj32oRR1ocuVTt93AIJLCa8/eNUwrdgs51N5dojN8YYLkaXDs93XDKZnWAQYzbtMg6df3w+nE6x3oiyb/s5M1mLAUkDvuLZIOkxs23/rOGiG/DeWY= 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 1771840478603587.5640786014158; Mon, 23 Feb 2026 01:54:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZC-0008Nd-MS; Mon, 23 Feb 2026 04:49:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSYs-0007Zd-H8 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:10 -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 1vuSYq-00072I-Ho for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:06 -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-458-BYclHFFaO4W1zNx-c3Pe5A-1; Mon, 23 Feb 2026 04:48:58 -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 80E6A195609D; Mon, 23 Feb 2026 09:48:57 +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 F1E8219560A3; Mon, 23 Feb 2026 09:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840143; 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=K9hlOpzIhsFPuCpi6oYi2Iapn+X2B6QTrhhrJ9Fv6KtRPncI7fX45NK5rAZTPV4U0OJv74 RxpVl48bDPdmGA4oeXFXKgzYiO377M84JPP1XZyZ72BatEUnuwR2fdKgzzKNa4pLyJxbOB XB8lmcoS9HlCLio81YNaqcYGA5i9qWQ= X-MC-Unique: BYclHFFaO4W1zNx-c3Pe5A-1 X-Mimecast-MFC-AGG-ID: BYclHFFaO4W1zNx-c3Pe5A_1771840137 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 v2 42/85] audio/dbus: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 10:46:00 +0100 Message-ID: <20260223094649.2005118-43-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840480147158500 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 00:57:50 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=1771840364; cv=none; d=zohomail.com; s=zohoarc; b=GX/MsQgXXhr+A/nIWiXTOSCx0X7rWUG3Eq15irTv9Fecj/0kIWCBS0woeJzDmbzp/hLzRBhVU+arSkf0ggIF7kr+v17Ozw/Fg9hLfKtIbRWnVcvUKKXGe76NHptjOJr6im689K7u5Idzt9i6Z2nJ4pPEWeVtTWquyRUbpCquKBk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840364; 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=E/CkqwktRyUHO2pinpcQDKgLUUXNG+rXt8HqXDltAb0KtKQ5jXR4cFyXEkLDIEFpD4/5bE9vb4y6JHSaye1RsX3EW26n3cnWQa3Tt6J+vWdh+q00opVpmwrvmaMF93xbr+Gb/CKCtEjg0GVvzT2irxwcBAX6VaisGB1aYT2xBss= 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 177184036408599.00153372769648; Mon, 23 Feb 2026 01:52:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZF-0000Eo-3c; Mon, 23 Feb 2026 04:49: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 1vuSYw-0007cU-7h for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49: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 1vuSYu-00072g-B4 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:09 -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-444-_r4X3mRrOKOhJmk5vkrK8w-1; Mon, 23 Feb 2026 04:49:02 -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 AB4661956096; Mon, 23 Feb 2026 09:49:01 +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 F34D81800465; Mon, 23 Feb 2026 09:49:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840146; 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=DHAi6576Om96TWdsbO08qoOsB5l/Y6aZIczCH9ZBrXPF5ScsrC34X1nMVj4aOc2EbXEOTw OCkPaIS/a7lOaW1NnFeyCYwOa+GUV03LfTXEl/BPdirokJQGV00AuCB5UoqZ2WRhYAlCqE 18LBuGhOL1RTlcJEbzg6Tacplmw0lPU= X-MC-Unique: _r4X3mRrOKOhJmk5vkrK8w-1 X-Mimecast-MFC-AGG-ID: _r4X3mRrOKOhJmk5vkrK8w_1771840141 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 43/85] audio/spice: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 10:46:01 +0100 Message-ID: <20260223094649.2005118-44-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840365514158500 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 00:57:50 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=1771840199; cv=none; d=zohomail.com; s=zohoarc; b=LaYBS0PdEasb8JO+ZIScAnZkdNwY56IAIAmscYfCUz3yQDH2N6g0oau9DgT5Yu50vbCAsVFXLGOM5HAF5e9g6/WHYxipuvGUwu7isbLWavv9qeI1Z2YD+mrsm0lY1voq6JSAndhd7drsYnHbtkw6dHLerA+r/OBSi/BL4QkZOTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840199; 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=jkepRZryO3HbeS1oCNP3FASGph9V62uJj3pKptRJxT9wcvMbzyoqiTdfRYVdjis/+3yV9nWbpghPeATpi6H4KP4are+jfrrQEWy6F3rIUkl3mddmOm40NhICm4S2sRybqy74UiyTzWb/T2kt7Jl06YvTeQ2PMeDS0q8SS1XoAmU= 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 1771840199568562.9932152750047; Mon, 23 Feb 2026 01:49:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZM-0000ds-Qt; Mon, 23 Feb 2026 04:49:38 -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 1vuSYx-0007dH-CY for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSYv-00072q-Vz for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:11 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-488-_rnTQwv_PLCfp80runsE_Q-1; Mon, 23 Feb 2026 04:49: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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A516D195608A; Mon, 23 Feb 2026 09:49:05 +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 A4C6230001BE; Mon, 23 Feb 2026 09:49:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840149; 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=JVliiAEvZ3ooAjXy6SpJyjYOdV5gq25vQhwcdtLNHe4vgDzHFTphcD4JSmqIJ4bt7gGPGa m0SWauqbtSFZbRmR4fV+e70tBvKSjwwb8omXyfavofpymOHLHk2IkeWAyE2q/QWzlYVln9 4pwshVJGqxUDQhPTrtOfdnECFBbZERg= X-MC-Unique: _rnTQwv_PLCfp80runsE_Q-1 X-Mimecast-MFC-AGG-ID: _rnTQwv_PLCfp80runsE_Q_1771840145 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 v2 44/85] audio/wav: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 10:46:02 +0100 Message-ID: <20260223094649.2005118-45-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840200701158500 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 00:57:50 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=1771840426; cv=none; d=zohomail.com; s=zohoarc; b=O/arEZ6YZ+H09WbznOiQJxIx8vIYPco+hlv5sppRUdNYTKNIozjS3xvXHeg33dbqjKJsfaLLySn1s4I+bxENZT8a3fnsrR4HX1m2hmECoYmdlk4QEfTXADZAdiZtxfIBkSqziykeQwpo3R2KmyUOkK7+7dGJYOu95WaUlFMBJ2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840426; 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=hgFBdIpC2TXb6gAjoUTIxkMDkJzviZGoFANfMoHgERsS4YabVGrntkGu9wTJZmh+holAmyumvo19BhcEADu5xCT2O9/aGuJ+zuQgQjRbkJ40CHmhWvmaDBXZfARNMdpCPUF/hlP2HZVfBryiI1W/cWxTRq1tf7SV/HH1MGuvBYI= 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 1771840426031605.6209285209829; Mon, 23 Feb 2026 01:53:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZX-0000xO-Uy; Mon, 23 Feb 2026 04:49:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSZ3-0007ic-BH for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:19 -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 1vuSZ2-00073O-0Q for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:17 -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-353-rrF1LeJdP8eP9R7g7GWrMA-1; Mon, 23 Feb 2026 04:49:10 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8EEE91956057; Mon, 23 Feb 2026 09:49:09 +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 BA4E01955F22; Mon, 23 Feb 2026 09:49:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840154; 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=CMT+MM7NEUep044u+Xy7zrydgEKtuO0n+iP9F3DvejK7F7nefM29i/gneCP/WLAGvtk3M1 KsAhFji86MJ+MGUFcZyXr6x7e8qV2wMa1VKoMTDScPeTF1YSE5qUKXsQ+crvKV2TI/gWBH +3EWPE3M6Imo4+lyj7SW9qMXxXUcIkU= X-MC-Unique: rrF1LeJdP8eP9R7g7GWrMA-1 X-Mimecast-MFC-AGG-ID: rrF1LeJdP8eP9R7g7GWrMA_1771840149 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 v2 45/85] audio/noaudio: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 10:46:03 +0100 Message-ID: <20260223094649.2005118-46-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840427736158500 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 00:57:50 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=1771840506; cv=none; d=zohomail.com; s=zohoarc; b=e0ygy7zNVO3m85QaKLsQ4OKslcfd55jNN4byCFZtjjp/QETdXO/dJdM1hTofc62MiS6z126kGl/FoCw7iupR0CEQueA8pHhdQqiaY5u1YEjWu+CwlSSznD8IpdZFg5q+CkXCzEOJDh5mECMrEWFn4nZVcEnyR+buqYHQYt/cSb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840506; 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=kLJnpGRBya3vL5f3DWnB+oGWlxrjEvNq9Kb9sn0hdWOLA0QJloc/P8akSkVKkbRbzvCgtfEGiU12fhFXnUn19/UB6xObH/uNZ5yZwFHGsqbruyIG/b1HEN2SGC8Qw/l68uFZfJ6dAXgEoj9SRarZy5ZFr9IC7GnvzvLmeyw9mR4= 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 1771840506384970.2481040096374; Mon, 23 Feb 2026 01:55:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZZ-00016J-1i; Mon, 23 Feb 2026 04: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 1vuSZ8-0007rn-1d for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49: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 1vuSZ4-00073d-KD for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:21 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-437-DoERPNqkOC69Dj_gnXV44w-1; Mon, 23 Feb 2026 04:49:14 -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 62C3D1800342; Mon, 23 Feb 2026 09:49:13 +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 5CE4C1800465; Mon, 23 Feb 2026 09:49:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840157; 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=FW9uBKPeNAIJPFCZQzE0csiNcFMYjShDY4l9z7v6d3hI+7QO79arrmUYz8cTDcXydXt/Jf TBlC4tfFmzzXFTMsnf0k/GWuSN29EEcvxIPFDeplzodGVhw0Z3xt8gqC3+CWB5YgwhiIIf +TLrdEjKSeWh8pTGgec02ETGnwMXrf8= X-MC-Unique: DoERPNqkOC69Dj_gnXV44w-1 X-Mimecast-MFC-AGG-ID: DoERPNqkOC69Dj_gnXV44w_1771840153 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 v2 46/85] audio/alsa: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 10:46:04 +0100 Message-ID: <20260223094649.2005118-47-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840508186158500 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 00:57:50 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=1771840409; cv=none; d=zohomail.com; s=zohoarc; b=SAx5XlEwA/SEeDw83hmo/LzH9UwZ9JqD29qwE4HWkNqpvvV0Ux8T/086N9v9xk05ss00QeqgRijdW9pAFcPRhX1PvfKRVH+TGVDcSLXaqR2kRsnwGDA1LPVYdQAF0r1YOg+72zyONZ4+pHrs8J59t1o8eouYxQ9LAT6OE8mEX9g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840409; 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=d4j/EWMYDT3IXd+eUdBnyNCiEfBMvsr3Nnb2F0b+cM/Ve4M281zc8ObtpZBO10NfAvGPCixM1VaTd2CS4dWZaV5jBxeeZ1riuUxgUvDKc5LxpOYUXJRsynkEi3zwAQ7fVaNsMpl5FA0mVTMb/e5gyATTvMTmi3nWLVbxKbrLCx0= 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 1771840409363842.7123683375569; Mon, 23 Feb 2026 01:53:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZX-0000xL-VQ; Mon, 23 Feb 2026 04:49:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSZ8-0007rp-1b for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49: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 1vuSZ5-00073l-Pv for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:21 -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-685-gGizn9eZNHGkEhguE1BGIw-1; Mon, 23 Feb 2026 04:49:16 -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 05FC71956052; Mon, 23 Feb 2026 09:49: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 5C6F430001BE; Mon, 23 Feb 2026 09:49:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840158; 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=QvxWEueJymnEULeecHjU4+BkVy+jm6A3eoD7Ceevokc9+tbQRiZAoKx0IGOwyRu/hqTOHj nBkGN6WYwvsIvLAmw7Z09NZa2kkECbFMoZWCJtFSrw+uQ9r4P2kCy2rTsEQw3yiLeac34b uuDP0TBXBFvYK1lMnG7yo2rwvTD6n9o= X-MC-Unique: gGizn9eZNHGkEhguE1BGIw-1 X-Mimecast-MFC-AGG-ID: gGizn9eZNHGkEhguE1BGIw_1771840156 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 v2 47/85] audio/oss: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 10:46:05 +0100 Message-ID: <20260223094649.2005118-48-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840409697158500 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 00:57:50 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=1771840268; cv=none; d=zohomail.com; s=zohoarc; b=dwHlzxddQ1I5HDdgHAMer5WtYLLfDaEu7/lB8onY9QFmNoRMasaY26UA160umdsDHsyeQp5lMGNccOWFne0g53hnmCfci5lOJKRaCGmSvVD83qYXCwBlOypPPfuX5us2aSXqbDGf8qE1H4YrQZnIN0pR4klhXPnl4eI2oPfUHo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840268; 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=dQYy5kGQ5/ald4hrY+2zl/UJarY3gpYc3dYt2ptl0TiKmpbzqGgg0qfJQ14Ja0QJ2smNG1Tu8a1C6CsY1WxdbgUB5Idx2x0o4wozBtrxgFjMVCI7bz1LMfL2AIyFbyPrQosqNqkWq2/wtYAvEo3IrQRyDBEI8OG/iPQ3DLdAbRM= 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 177184026897932.9318763465875; Mon, 23 Feb 2026 01:51:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZM-0000dq-Qe; Mon, 23 Feb 2026 04:49:38 -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 1vuSZ9-00085p-QZ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:24 -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 1vuSZ7-000744-TR for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:23 -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-464-KcKq0gYFONmHDfucINGfXA-1; Mon, 23 Feb 2026 04: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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 67E311956096; Mon, 23 Feb 2026 09: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 B824C1800668; Mon, 23 Feb 2026 09:49:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840161; 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=SNsy5a6wa8wlUyMML8mqkn9yywR76psej6atQDoW8BtPQFof49Rvyn+mojY7QD761FvorL kpVjXsJzMCyi9GoqzwFz07LKXcUmibbVUoYJT6ImQ8mdCSFy1wFv11FP6BYm6uo4npA95o DxOF5ftGsQQQEV3MS4FIxVHPGNxkpTw= X-MC-Unique: KcKq0gYFONmHDfucINGfXA-1 X-Mimecast-MFC-AGG-ID: KcKq0gYFONmHDfucINGfXA_1771840158 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 v2 48/85] audio/pa: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 10:46:06 +0100 Message-ID: <20260223094649.2005118-49-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840271132158500 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 00:57:50 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=1771840200; cv=none; d=zohomail.com; s=zohoarc; b=iOc10id84WaMcVxn0+cJ/f+5gm3vEctvBqezuld1IkMZtB+rOBDSwAvjM7ncNNANrbkDWWci3pHvDNRvhiuQMF48BrlJD9urr46d3jXg/LujA7elvi6W/Jkb0z0fCRkHMRcen+URZVY40YUIyQOd6MLA0asdnubLQchY/tanHK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840200; 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=gBwIfUDqjJyVhb9sCBm4vqCuk909VO9gNKHDvUyBqel70pZxJnOIuMgCv6OsbWzhgcGlgbDsDKRMDAB8CUDm1La0LbNtjDrxaGGAU1AU+mSL70u11b2RhJKtrjFkJQ+4Yj8q1MNMAuh+jMjNpZvn9CTjIVcPvsNVZOPWV8xbJMM= 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 1771840200551499.97696290199644; Mon, 23 Feb 2026 01:50:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZb-0001TH-3R; Mon, 23 Feb 2026 04:49: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 1vuSZE-00008w-Dh for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSZC-00074l-LZ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:28 -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-115-WS3WfwIlMpO966c6kEUj4g-1; Mon, 23 Feb 2026 04:49:22 -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 2D0EB1956070; Mon, 23 Feb 2026 09:49:21 +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 3EC8A30001BE; Mon, 23 Feb 2026 09:49:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840166; 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=Y8+iBuhz1CAwn+ot+zE6qNrXK3mh5p9u+YC6UAVEVE4nhxjsbHpp3CQbqSA80sYjD0BkhM D1ZYeiufSsGE20GoniasivmZEALU+Mto/SBY2m2X7FvmbD5yapb4WG1qW9RGiJ7ib6vrCD XZYI2JFz5aDRlsqJF5brMEngDlerNRs= X-MC-Unique: WS3WfwIlMpO966c6kEUj4g-1 X-Mimecast-MFC-AGG-ID: WS3WfwIlMpO966c6kEUj4g_1771840161 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 v2 49/85] audio/sdl: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 10:46:07 +0100 Message-ID: <20260223094649.2005118-50-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840203278158500 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 00:57:50 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=1771840558; cv=none; d=zohomail.com; s=zohoarc; b=UQoKad4YHYkfgaSpxo3n1DIH1vSRgSO+vfnIrhgkBPW6ecu6dcmXige0CUKMw8A+UwA7WcXHaUQbxn+63JZsc40uL6jKYL41MOFVy25Ozm3BJkYH/nHm3Xujiglkc2YaETrIKllpi0yaLunvDP4DA7hXukjQJ3em7d4iDj/SSHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840558; 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=Tf4+6azkWTDHQ6p2XlGBHzPjd+/Uz7TWAbbqXpIdzGjvzr/YVn4ZtQIy8F6WDfoDz1dGawGNRrchtsMYTVyGDOG099MpNW98ioXM2LNJmujRpwmkM1vt1qSHzOSlY6PNHKFMbGvZi2THCvqBExyhSNMCflUYav2XkJPOrfMODgM= 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 17718405582872.726755675907839; Mon, 23 Feb 2026 01:55:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSaO-0002Z9-Cx; Mon, 23 Feb 2026 04:50: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 1vuSZF-0000Ih-8n for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:29 -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 1vuSZD-00074t-9c for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:29 -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-319-Q39U-WxJP4-f_A_XHsmpcA-1; Mon, 23 Feb 2026 04:49:24 -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 66A221956094; Mon, 23 Feb 2026 09:49:23 +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 B28511955D85; Mon, 23 Feb 2026 09:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840166; 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=YWEuoln2P/EvQwYPGKZwSMne9zYuBbzpy9FhoxV5Pq+njPcj1gVFzVvQKn7M/kkkxq+XL7 cISC8EvYv0h/hn9iS6vHhOFhEnNyAz3uetV2y0FeAfYOjhWLFTEXirWNv5YE9kv3YtG8yk w7fSUNforrYv65BDXGTWhyt7574mg6Y= X-MC-Unique: Q39U-WxJP4-f_A_XHsmpcA-1 X-Mimecast-MFC-AGG-ID: Q39U-WxJP4-f_A_XHsmpcA_1771840163 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 v2 50/85] audio/pw: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 10:46:08 +0100 Message-ID: <20260223094649.2005118-51-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840560597158500 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 00:57:50 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=1771840340; cv=none; d=zohomail.com; s=zohoarc; b=U01LrdplmAlhzJDvyz05Et/E2KZTUTy8OEDg7zvPWuugutbrGTTz6HeGeFMSBRGYBaYHOL45zPaiV8WI3th5MewIHPMnG4MFDPRJqHxlZmXqi75IuiMbDFFEynjkHp+wykCQVGqo9ug8wievhNkpl9CVFunKwcmdJyo/YprV2mw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840340; 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=O81Wqptz0sPMbhKdE29oJmKSTqZ8AtyXSxuu4G4R03ImjJd2QeYoQtnxVePca8rgUlHVxUft9YMn5Yv3bnPwcCqKNOO3G3kKdA1QlXg7aH/FRovAEgFkKkIORLl2H9C51Z0jV0iFxkGc8a7rbxVFWwp/Bs71n3eRW2Tq2Jsswe8= 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 1771840340594891.6147469451128; Mon, 23 Feb 2026 01:52:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZy-00023i-Bh; Mon, 23 Feb 2026 04:50: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 1vuSZH-0000ay-Ul for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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 1vuSZG-00075H-8W for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:31 -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-331-uP1fMsSLM1K_EGrvZ0aPdA-1; Mon, 23 Feb 2026 04:49:26 -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 DA7721800378; Mon, 23 Feb 2026 09:49:25 +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 49A5330001BE; Mon, 23 Feb 2026 09:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840169; 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=XwcYzJZasNNWDj0s5Lh/O0+V8052Sq2PVF9dfTQAvynqvgJBfiV778qAg7fHzt3YTx/wU/ q5/nrQqBZrbNWCmBws+CH3lKYC1+eKA+ibxUb10C/qGNIXRn9SS3frpdeTp0fQHsf8zNP8 cpaov7xotVVHPd4ZrERp05f3CIjJWUM= X-MC-Unique: uP1fMsSLM1K_EGrvZ0aPdA-1 X-Mimecast-MFC-AGG-ID: uP1fMsSLM1K_EGrvZ0aPdA_1771840166 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 v2 51/85] audio/jack: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 10:46:09 +0100 Message-ID: <20260223094649.2005118-52-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840341356158500 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 00:57:50 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=1771840511; cv=none; d=zohomail.com; s=zohoarc; b=FC5hexsXxNLbZ6H7Q4QVqwjZOSW1yCxkxiXFEv6sUa/WJMXs1doTdY8ReC4qraVD1UMaRAMrs7TM3JY9XSp8+ekqjmoYU9QT0PsXSoltB3KhHHqYla7dW/22MTpoCKeXgHfnFhZFip1SUniaV2PwiLXzz6zwW+6hpcDnQ4BWL7Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840511; 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=N98OUrKEryY1/AqE3EE0LAkajbIiKXWLNsQQccT9V5oNKIXN/qpiXoKXW+lH/raWg0N1XuYwWreL5g9DMYRnKR9B9dVfFdLzi5twQ6BO7NlqIqIwWarGqQ/o1BPmufiY45tCE6XO3m0VCi3LBM4L0JGMM6w2EmAbz+5Xw1P1pQE= 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 1771840511489245.50120946974323; Mon, 23 Feb 2026 01:55:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZZ-0001Cz-N1; Mon, 23 Feb 2026 04: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 1vuSZJ-0000cw-7b for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49: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 1vuSZH-00075M-Rf for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:33 -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-546-UfOM_u1GMCKyQQEEXtummw-1; Mon, 23 Feb 2026 04:49:29 -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 715711800581; Mon, 23 Feb 2026 09:49:28 +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 8CCC11955F22; Mon, 23 Feb 2026 09:49:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840171; 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=equfs8gbZS2N4BlgbT/1csSB7Xk+66GHVJNJ12CKvbj9HIS2Nv8dMYY9aU86OxJwSHkFTH LOZMjPbhfWyJHofQJUfiUq0RDJ0pEQd6fjOOGhbkhgcHqau/iohZQuYVI6cYu/+mW9AxGX 3Wamhji0pHdzwmMvAby+DU8KkqCX9VU= X-MC-Unique: UfOM_u1GMCKyQQEEXtummw-1 X-Mimecast-MFC-AGG-ID: UfOM_u1GMCKyQQEEXtummw_1771840168 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 v2 52/85] audio/sndio: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 10:46:10 +0100 Message-ID: <20260223094649.2005118-53-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840512237158500 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 00:57:50 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=1771840635; cv=none; d=zohomail.com; s=zohoarc; b=jrCb/ZQOuyfUk7AaKFTqDustoRWdEru7+F8FW3ivnM+w9tm4dEZoZhU3vX5EzMrriUekB/GyzVQcYTQs6ouRKWUkpYIO3ka3vQueTPiaPxGdQ5z8wzkQ+YD4QbUTQ75SpFMFn9AUf8rZeqKqXOtN9DSfLZcsslMGcX5U73AQpJU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840635; 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=UJ65yMPX4FpSxzdyPS7JtJxDQak+kvmUgLTqRxGaPoY6Q6t1BhRsIHumvt4peLQyxBlg2IdY8/7goi6Vxbl30zs9fkCLrOUfc33USbFo+YeXduAUYWZGrfCkRqgKTHFNr//rLHK40B7pnLL+/qaroJtKpV9ZDZ7K+bOEEgJaWHM= 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 1771840635065239.22010914439352; Mon, 23 Feb 2026 01:57:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSZu-0001vA-Ex; Mon, 23 Feb 2026 04: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 1vuSZQ-0000pb-6i for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49: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 1vuSZO-00075s-Py for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:39 -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-74-TQ2nqU61NnOcMd0t4MDYFA-1; Mon, 23 Feb 2026 04:49:32 -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 4225B1956050; Mon, 23 Feb 2026 09:49:31 +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 761211800668; Mon, 23 Feb 2026 09:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840178; 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=Pj4MNQn3nbPIgAdEING+6KwLjgh/F11jMei1tWOrnwbBiqjjwQ79gXCoMSLmtN9Jkak7Lv 3Ba3oNEqE0pYLC0HPsoRhqwyH+AUiyQL+w9YTK1yjc4Mz145P9Oe8dewoC8GQYMURgq3oj rfr8MXvfCbTk+d1ZGGn6SS6ZsU49mxU= X-MC-Unique: TQ2nqU61NnOcMd0t4MDYFA-1 X-Mimecast-MFC-AGG-ID: TQ2nqU61NnOcMd0t4MDYFA_1771840171 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 v2 53/85] audio/coreaudio: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 10:46:11 +0100 Message-ID: <20260223094649.2005118-54-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840637081158500 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 00:57:50 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=1771840477; cv=none; d=zohomail.com; s=zohoarc; b=LK1E2HJxuxvPZnmMszK5ZCpkQmeQO5BQHfrHGaplunNBty7umoYue0DSWw1aqcmb6NKCkA0J1WghgvO8kZiF0zuNqcA5vmE1RQzeRBVN4XyJsTBBc/YPmsth+hAWw6TjyukLBzqR8YUPsjff0BaiywKLcSuabjeQxvNRsAzYOsI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840477; 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=iH79hHs+2JjtkSJlWKN0H1eLvH3rjBYrpdWVC4hmrF07WvgLk3Rg06NcCfr/mAJvpxkP/muygKxrLrsRxTEmgYSJnPvnzKLwXgOYgo9umPrETV23ceHsKxWXniJZ+I85WBLloeahkEKzxs6NemcdOIp1UkIS1dOsDIR7n+nagEM= 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 1771840477015694.0169427997139; Mon, 23 Feb 2026 01:54:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSaL-0002Sr-Dw; Mon, 23 Feb 2026 04:50:38 -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 1vuSZS-0000vb-96 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49: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 1vuSZQ-000767-Fh for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:42 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-558-vwgZZf1hMFqif8saSqhxCw-1; Mon, 23 Feb 2026 04:49:34 -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 55FF11956056; Mon, 23 Feb 2026 09:49:33 +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 D09E11955F22; Mon, 23 Feb 2026 09:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840179; 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=WZCVccmBxlc379IQLQ7p9D/VUDL1ekCHZtnwL+NWrwjYe6Y0kvCayQwCA0lKI8ZG8t9+B9 bexdh7zfz67ijhrJNXiG8Kxh4wI5ySteOHnJVm0x4EGfqy+5srItpKjR3kx9zjGhXV4bg/ XiUHgD8xMX74iluqsmnLcZRL8M8ug2g= X-MC-Unique: vwgZZf1hMFqif8saSqhxCw-1 X-Mimecast-MFC-AGG-ID: vwgZZf1hMFqif8saSqhxCw_1771840173 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 v2 54/85] audio/dsound: convert to QOM lifecycle methods Date: Mon, 23 Feb 2026 10:46:12 +0100 Message-ID: <20260223094649.2005118-55-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840478136158500 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 00:57:50 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=1771840373; cv=none; d=zohomail.com; s=zohoarc; b=igY0zBmDkKkffNJ+8eAMI5mSAW5OslOwMyV41v87JyNRGQ2GfaeNBRF/fXKwAh9rP7BgcqjSar4EcNzD+07ra1qhUVh5nb1UTmK23lXmF9oPGOQvR5Bggyp+2wd31NOoNoZKYnyLgRBpz3NOblG9gTLd3eTXRqZ0Tc/UvATUG6w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840373; 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=DYRSI/pMmBVdC47iRjWlpWlIdI965/IarezYYQ6zNohZJU/MlJ5TNubuhdkk7Nl8y0GhiqJy2s5CKFKHaC1tg7ZWFaBUyi7uUpGbgCwCGNnIfzeiN27aQA8XwbNXeS09SUpvaNkKOuEan+6KN+HSJg47FXK2jxwMObL4kRZDS7U= 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 1771840373249304.37565679477655; Mon, 23 Feb 2026 01:52:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSaD-0002I2-OM; Mon, 23 Feb 2026 04:50:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSZU-0000wp-9a for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSZS-00076I-3q for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:43 -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-479-At6Td93lMommCCTXAfQleQ-1; Mon, 23 Feb 2026 04:49:38 -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 8EA7119560A3; Mon, 23 Feb 2026 09:49:36 +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 545681800676; Mon, 23 Feb 2026 09:49:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840181; 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=QCgpWcUJcHnItLox2ZzH8bRAJXRoNgtVjFWvhO05ft20UK2FRqy6X6hbRU4GUf39k6TcLq 0n5CSAVDQupllsUa1kTrs582VS2YSAECSyM3Jtysb+ZVd9OtWpW8jjsN2tq+WDrKaRnTBx JMLUBuu5B6qZ37Y0gG337ICihFETNsI= X-MC-Unique: At6Td93lMommCCTXAfQleQ-1 X-Mimecast-MFC-AGG-ID: At6Td93lMommCCTXAfQleQ_1771840176 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 v2 55/85] audio: remove audio_driver init/fini/next Date: Mon, 23 Feb 2026 10:46:13 +0100 Message-ID: <20260223094649.2005118-56-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840374256158500 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 00:57:50 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=1771840650; cv=none; d=zohomail.com; s=zohoarc; b=aPHC3SqtdB1hFSA0YEQftgLTbTRcIci710SnARbdj/nA4/i50FCJ4cKJXwlCcBZv6knBqozXoayFLYjsYq0xT4sXK13AgvF8CcTHfaXfj7W1LKbeidNDTVBs500lrp26EMlSqaADeu6zVfxRMh+4qYMD8KXUgp+nwE7DBQmRzaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840650; 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=RAnA6wbyui5cFQhv+EGdotxNxd2uBCY0tQbZHHRQBAcgUdKE4oeGDGAWey9AnW/ynuWKu1GPZHT6OOoeqe9SbQ9kXv2wM0OiyOPo+JF4GihKbVsrm9GVWWW7Gyqm+onDEnBkV0/LoH3An+0mMNM8F7gzuJo7lMWquDB3n6gUKkM= 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 1771840650493286.4945061977328; Mon, 23 Feb 2026 01:57:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSaT-0002r6-Vp; Mon, 23 Feb 2026 04:50: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 1vuSZY-00013t-OT for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:48 -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 1vuSZV-00076i-Rb for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49: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-590-EAf6SkjuNReksGXWSaLmzA-1; Mon, 23 Feb 2026 04:49:40 -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 5025D1956053; Mon, 23 Feb 2026 09:49:39 +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 4CC201800592; Mon, 23 Feb 2026 09:49:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840185; 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=Bgnj84AcYBgzs6MlzXMhnAZWjcBBhee81bQv9U7M+FFt5xaKzZhkg4rwaS+tdJwh+w+iqO c52sBae+KN/mc0b7a3QPshx2jRtu1BA630H+Sdq5KnRuMHWVflMq15rwDxAkSa5knsAaS/ 5EaAJzjKvX6RX65LxOq6MC+b8KFP/Uk= X-MC-Unique: EAf6SkjuNReksGXWSaLmzA-1 X-Mimecast-MFC-AGG-ID: EAf6SkjuNReksGXWSaLmzA_1771840179 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 v2 56/85] audio: remove audio_driver Date: Mon, 23 Feb 2026 10:46:14 +0100 Message-ID: <20260223094649.2005118-57-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840650913158500 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 00:57:50 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=1771840493; cv=none; d=zohomail.com; s=zohoarc; b=K87SOQc+3o3pwLSIWisWhUVyWz4CnSwjfcG9zJqXxMvcV1+F4tmHWKqcG4DKGwGM985yMovU04ONg8oiLAGrwgwwTYlSP3gbwjRsAmP20bFTXUqZo7gRMk3CcasiD34bEY4wzGPcq4oPUhWzbe/OAr0y4u9rl+6vU5eAqxXk5mw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840493; 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=IGPQfJ6G/aURwoel8fAARY4QjukqRejV26tk8CN99Clj+pyz8ArsYoKgrApZnEQkoUYjlB2xv5mr7OoUUhb/hoYVxiwWmzRmMVid1QRHrzhRohgoCFOPgaStQaOggQUPteZYO3OtgUgGyvKkXmtY0nn3xx4UmZyERukQ+U2mmHk= 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 1771840493448985.419963878139; Mon, 23 Feb 2026 01:54:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScC-0005Nt-HP; Mon, 23 Feb 2026 04:52:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSZd-0001jv-5Y for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49: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 1vuSZZ-000772-6f for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:52 -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-75-RwzRGd9qP0276kT6pepD9A-1; Mon, 23 Feb 2026 04:49:44 -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 7CB4F19560A6; Mon, 23 Feb 2026 09:49:43 +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 96DF31800361; Mon, 23 Feb 2026 09:49:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840188; 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=ge9zTwrWkLZJt0mVaVrr5DHKjHzSN0HVUI498wFV+Rraf3Swc7P/sH1QL2NSSpDdDbnKnj 96ns6CC4Nee/dgvpSovT7YvZ0KwMUawMcqGBGzeNRp08Wnlvm5yxI9ooi88Qqk/kc298aX Zs0ln1DgEdjgttJOBNCM9n3ySl3f6fM= X-MC-Unique: RwzRGd9qP0276kT6pepD9A-1 X-Mimecast-MFC-AGG-ID: RwzRGd9qP0276kT6pepD9A_1771840183 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 v2 57/85] audio: move pcm_ops into AudioMixengBackendClass Date: Mon, 23 Feb 2026 10:46:15 +0100 Message-ID: <20260223094649.2005118-58-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840494398158501 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 00:57:50 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=1771840561; cv=none; d=zohomail.com; s=zohoarc; b=VVwB/QRkKvfmPgwkqJcv8V2B2Dw0do83/p9yamaue8zZHsnZcsxNrVu6zunQ/5bUUq8FK68a78AGE0hZM700CpgA3dI2lh0ijhCXWd71JItXa0fyi74ZC2T/4h7UTSmfKkiQL0QTlCRonL9hhx619IpWyIxJrMw93z+Mzj8VeVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840561; 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=UPlTOu4BXhsdUKP2jzoJZ7qM3xZc5et8ktD485ivK8ZrR5w7a4HShffl9aI1F4SLiSllM7ePGdgLkQCL46h2IkfB3y2t8tL1Vpvu0xrhn3mJvgz4xod6M3Gtve07VcFkfysoGLf/NGHyNgKlj5e23nnf8UGKChwDzJEdpvrGqeY= 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 1771840561319566.2989135465405; Mon, 23 Feb 2026 01:56:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSa4-00028m-64; Mon, 23 Feb 2026 04:50: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 1vuSZd-0001jg-3P for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49: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 1vuSZb-000779-Hf for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:52 -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-473-klK-wGS7NQuf4_nXeOB4JA-1; Mon, 23 Feb 2026 04:49: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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8D2A81800378; Mon, 23 Feb 2026 09:49: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 647A21955D71; Mon, 23 Feb 2026 09:49:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840190; 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=IsDihYS/ZsQZ6OOEiwtjuexf6ATarxi1WI7jnOXqQwyGI549ZmDPr6kJIK0pfnpDx2u1CZ gYJHZ3a2ogh6i+9OsgACrSgfkboDF5yqZ3iwjbGaKijKy1Nhkmk7nbZPjmOA/FYbESrNX1 +c9hjzpHqbfRUUW95mKqWcyZj0w7SoQ= X-MC-Unique: klK-wGS7NQuf4_nXeOB4JA-1 X-Mimecast-MFC-AGG-ID: klK-wGS7NQuf4_nXeOB4JA_1771840187 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 v2 58/85] audio: constify some add_capture() arguments Date: Mon, 23 Feb 2026 10:46:16 +0100 Message-ID: <20260223094649.2005118-59-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840562488158500 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 00:57:50 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=1771840637; cv=none; d=zohomail.com; s=zohoarc; b=BhtLZHLds2kkJqH+ujxsvdJ7v88Ubchh/X3RwWnycdScpuGuOwGrLUcNmbizaj2AOPzBuUYPaaCP7BRkdQeqC17kXYLM8nL7RJR34dK0EY1NXfEv1RptcVLtjkkPeZcNG4YjAYZk6YObqVuqXE2eHjGhUytfWb07Fn15SX5RmWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840637; 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=UL8J9KwMfa01AnPQmoaKcX1G8oAZXW7mv023zCz1IQaCx/7L81WeQ1foNxFzsEEiUzXqApayEYclZm/6tvcl6NCqNaI7BIA9ZaCRkxCsubPap059e4I4hIb7QBVdgr3VgJlNLweXBjXC96+2q4Ft1hyvtXCMSgeU8peDhXCrwdg= 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 1771840637575896.6705207877814; Mon, 23 Feb 2026 01:57:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScD-0005RG-Ed; Mon, 23 Feb 2026 04:52:33 -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 1vuSZi-0001rq-L8 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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 1vuSZg-00077V-Cg for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:49:58 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-203-1HLZsk6OMa66wDMRzuicbg-1; Mon, 23 Feb 2026 04:49:52 -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 709F2195608F; Mon, 23 Feb 2026 09:49: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 AB8D01955D85; Mon, 23 Feb 2026 09:49:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840195; 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=SvkeoUgdCfqgLvfwd7SRBg80+gJW9zeanXz+gvsaaXfxb9PeuwlrhFN8ihI0XfvNtTzxbF OUBjefMRtmtcf/ykY/L5SSFma4k622O+zlM8kNpiSuwXLSZxVjMr+lP81ZY8rVZUccFHbC OyPls9oZcQccERVFtWDC4713rwjw+O8= X-MC-Unique: 1HLZsk6OMa66wDMRzuicbg-1 X-Mimecast-MFC-AGG-ID: 1HLZsk6OMa66wDMRzuicbg_1771840190 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 v2 59/85] audio/alsa: replace custom logging with error_report and trace events Date: Mon, 23 Feb 2026 10:46:17 +0100 Message-ID: <20260223094649.2005118-60-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840638941158500 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 00:57:50 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=1771840337; cv=none; d=zohomail.com; s=zohoarc; b=Co+iJxDjeogJF/+WitMGKqLQyQtJGYXLWn2BtvBB/VM/4ZW/6TvzdP4+NqHIX0TUMZy21LrKgIi1SjwpDjOWXhf+Tlp/2/JUhPHUcU55xkH90YKdj/vs/AnTMiu89XiIOpUCEKQtEjXxa52zJSshpAwwr8eMOdjrcqyuBH1aoXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840337; 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=OnjDFD3uh7XM7EgRHQftIEO3jhEHeZDWPAZakfGdxdRL2KsePzWm5KZwriVhhyfxAI/IzhF8GJKffbfS99djatnnH2/js1eP/o05XLFH6CITlsjVnm/bjtT/ySvhvrwuHdm4QPTvvcIjSA6F5Fmj5PPjc0h8rMOtYDSgvbZd/aY= 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 177184033754595.38236039745402; Mon, 23 Feb 2026 01:52:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSab-00037r-U9; Mon, 23 Feb 2026 04:50: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 1vuSZp-00020e-VU for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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 1vuSZl-00077n-6b for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:04 -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-607-Bk4EQl3iOBCW2F9yIW4KXg-1; Mon, 23 Feb 2026 04:49:53 -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 BDA9E180059A; Mon, 23 Feb 2026 09:49:52 +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 275BC1800351; Mon, 23 Feb 2026 09:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840200; 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=U2At/xF4MzfIHAUTDfW8PbvqU+TgF3HzyS8LiHa2Kobdm9Bb9wnDU2Vh9MGdos6ASrAhuM 94AumafW8Y8+Cu7Kyk7ogsalYLMEantDOPsQDAskuLbbk2O+RObfWN2yBUNJVgB5ApcTVp zVqtkX3TVYexMoC+r2Yp+8BoSFBBkMs= X-MC-Unique: Bk4EQl3iOBCW2F9yIW4KXg-1 X-Mimecast-MFC-AGG-ID: Bk4EQl3iOBCW2F9yIW4KXg_1771840192 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 v2 60/85] audio/coreaudio: replace custom logging with error_report Date: Mon, 23 Feb 2026 10:46:18 +0100 Message-ID: <20260223094649.2005118-61-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840339923158500 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 00:57:50 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=1771840405; cv=none; d=zohomail.com; s=zohoarc; b=GGhxFdek1BAIr9CgtHhwd+ySTTyrPZvLbNijbeMqmJ8hXy1OFrG0dwdBvMD8gqJ03d0x1Erd4rjk/nXRhae7VM9z3amfd0daZERI1hLRSDNfAtV876erUsV7f5GluPixt98d1IWtCpqck356GXGWD9/V002P0VQ6xWjw4QVpM6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840405; 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=oGC+BKdAvizWp+GjlcLXZLIBx/64wjS7TVVrAD1kTwD9P2wOAZget23CKftVx85kP0FVXUIfIHby752NZauteWGs3W2IYxqzUdGSj5CvtVn/nXqkUSQAGQ5fe8gkJR8ETZtFuqAgwcSPO/3FgFDC7K6wGxD/EVF3FGUMqKe7/30= 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 1771840405852731.212409642807; Mon, 23 Feb 2026 01:53:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScG-0005qk-RM; Mon, 23 Feb 2026 04:52:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSZm-0001vW-N4 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:06 -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 1vuSZk-00077k-R4 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:01 -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-537-1_Z0yA_LPw6u3aVQiIc4Lg-1; Mon, 23 Feb 2026 04:49: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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1DAF0195608E; Mon, 23 Feb 2026 09:49:56 +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 843851955D71; Mon, 23 Feb 2026 09:49:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840200; 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=KkBq4nH8hR0HVQ7fly6MhHr6ojF1Z34q8ejgHbt0u/IBFO+iGnjezJBhgOHS0RZb2kApdr T2GrlAHpCfDE6E+4FoklS2GI/+VDPzbRan7a3DcRVVkJ/YLd9sCIKNOQpEOaoarl7ScJqY daYInm76rvl9WRMnSsB+/2j4NyEkRhA= X-MC-Unique: 1_Z0yA_LPw6u3aVQiIc4Lg-1 X-Mimecast-MFC-AGG-ID: 1_Z0yA_LPw6u3aVQiIc4Lg_1771840196 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 v2 61/85] audio/dbus: remove unused AUDIO_CAP macro Date: Mon, 23 Feb 2026 10:46:19 +0100 Message-ID: <20260223094649.2005118-62-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840407619158500 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 00:57:50 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=1771840554; cv=none; d=zohomail.com; s=zohoarc; b=GZuwtSbyTR3VCTzyl1kogeLFAlXCk8JZXV4X8+b6/KBdkl3BUoBxEZju+iC8F/rwkAPp/ZFNZpAW6GhqXKMcZNNUkPscEuHNud8xNZxFj1+clTcvdfP2O4nAuwuasFVy55CWeqk/yztqbNdeVqwY0fanPLakn/ieJEyYu9iEGA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840554; 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=lW2h/eNuUHkXEnZrWr5rTLAjeupKcff8k8Q1ovhCqNAWmAi7R/il06BKxyX5XoGuqk5QBWnuuuNN4k5rZU0oe/rv/5KaV/1A/2QtbAMgvz638i3AKzOYl2nOR3cCVPCfOLge6cPvfWosftvHAbR4WhDl62+ASSmg4E8mmEGtcso= 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 177184055471934.97914359513834; Mon, 23 Feb 2026 01:55:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSba-0004IQ-Tp; Mon, 23 Feb 2026 04:51: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 1vuSZu-00023U-QD for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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 1vuSZp-00079I-V8 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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-553-Kkr2-amrNmqFRlSykax7vg-1; Mon, 23 Feb 2026 04:49:59 -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 E90AD1800348; Mon, 23 Feb 2026 09:49:58 +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 1B5ED1800672; Mon, 23 Feb 2026 09:49:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840203; 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=I7pgaBaucrHWrM+VC4j6BGlB3QaPyISTGsy9F3myEqMXiK8AoEBVrsHq2PgjN6bmdRwrNt cQ1v+gvU9JZ0QP8ODiuMQS/3yNWdReP4lxVLcO5H5vDn1PLdOP+L1Zj1lnmBz/c3V49zNr Y57bRYPnvdSr7HGKD3GSNBI5nkebTmE= X-MC-Unique: Kkr2-amrNmqFRlSykax7vg-1 X-Mimecast-MFC-AGG-ID: Kkr2-amrNmqFRlSykax7vg_1771840199 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 v2 62/85] audio/dsound: replace custom logging with error_report & trace Date: Mon, 23 Feb 2026 10:46:20 +0100 Message-ID: <20260223094649.2005118-63-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840556550158501 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 00:57:50 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=1771840360; cv=none; d=zohomail.com; s=zohoarc; b=J/wxh5IPbLxkuBknaIN86lQhvruSP5O9+mmbPSXzMCNWfEeNvSkOzZ2lBUhuXGn+S+UfrrIQAGyYqnOhZzWNWbkdMZrISXw4ksKOhI7vmcEMv8M+IHsJXQKC/rNtnBXph7do7I3rFec9ByX7ttTYQh7v7xMTF5R5baMyG1qg4tw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840360; 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=M6IllqPJmoMaN3PSOKSt9BPRRzt4wasG5tjCrKvOPCTqZxCbVXlFUk6J+TO4GeypVbcRJLuQa2498NxbEX3qRO7J0V8rFMceB5O5nxx+kU5jlj3EmE4YKeGgJhiaG2o1kTxJGFwJmcOLyXMoiG1h/v2FjpeOhrzWti7JCyCcj5s= 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 1771840360968880.1218186230716; Mon, 23 Feb 2026 01:52:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSb3-0003kF-Oa; Mon, 23 Feb 2026 04: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 1vuSZr-00020n-Dg for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:10 -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 1vuSZp-0007JE-OP for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:07 -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-374-DmcmWgUWMzqx0X315FRCdA-1; Mon, 23 Feb 2026 04:50:02 -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 6C19F1956070; Mon, 23 Feb 2026 09:50:01 +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 D08251955D85; Mon, 23 Feb 2026 09:50:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840204; 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=U9OGDpl396WY5I8a5SeQj3iClcchCy1CoFoUkb3gkcCf7pdnXWW8nj1v8MUINpVHZUToBu lvM+8GzHsymZc1lEuyYa8RSlNFqwvKpb3R1UzshchGQXNKdsEMvBmI3+rKrh5FXvR9Yjzu YwAxxqZJYy13oHXCAt6g76q0PZuUUSY= X-MC-Unique: DmcmWgUWMzqx0X315FRCdA-1 X-Mimecast-MFC-AGG-ID: DmcmWgUWMzqx0X315FRCdA_1771840201 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 v2 63/85] audio/jack: replace custom logging with report & trace Date: Mon, 23 Feb 2026 10:46:21 +0100 Message-ID: <20260223094649.2005118-64-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840361475158500 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 00:57:50 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=1771840408; cv=none; d=zohomail.com; s=zohoarc; b=ayGi3yJj738AiS0mWAmJ7HZDYhAz/EHLy6brbfMmTD05658bdmb4rdRskn8BBYpSQ+MKa1obKdZxDH7SabBRc32QrKxuXOApvstGGhb/VeDlsa/rJ+vqv6H0+DCKjq3Dy1bF688h9CXfBePK1jOsUHO+maiypMyqtbveKvPXUeM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840408; 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=b0PoLgoSgwbAUOmAYKlf/UomFwiprU7FAvkQ8t+kP6xAqCnjlMmlkA3dhe1xaiS11pKmAIP6BvR5Geb8Zk5r+MxFZukKBG/nb6vTNbymD1dI34yitzFFTcQQipM24B9uJrXCMQRlhUG9+7hQT8RMgVok/DOkl0N4udLAUceLNS0= 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 1771840408935820.0792476089998; Mon, 23 Feb 2026 01:53:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScE-0005cZ-Q5; Mon, 23 Feb 2026 04:52:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSZw-00023X-2q for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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 1vuSZu-0007KY-IA for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:11 -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-171-vTJBr-lcPzqrFTDytrTuUA-1; Mon, 23 Feb 2026 04:50:04 -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 EBFD01800615; Mon, 23 Feb 2026 09:50:03 +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 50DC33003D8F; Mon, 23 Feb 2026 09:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840209; 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=CCNqr7a6ABZdDifz/PMUf3I+Tb/o5x1ZT0oMjyld9bsBdvjzEDU0HjE1WRClqFpFFYHkJQ 3uWdBwr1HeSjeaQxh1nMKvhlNqcW0J8gT485Q3rW4ZGMzwWj1tvFCwqmlxmL0IbIQdy+jS 9vH+zsEytL5zgg7QbcNL+FeSPxN2qg4= X-MC-Unique: vTJBr-lcPzqrFTDytrTuUA-1 X-Mimecast-MFC-AGG-ID: vTJBr-lcPzqrFTDytrTuUA_1771840204 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 v2 64/85] audio/noaudio: remove unused AUDIO_CAP macro Date: Mon, 23 Feb 2026 10:46:22 +0100 Message-ID: <20260223094649.2005118-65-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840409618158500 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 00:57:50 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=1771840428; cv=none; d=zohomail.com; s=zohoarc; b=kgXNsBuw/L+yzzKd6UQ7ntRJlsoDlT79igtsh7KRlknTaYNd6RqVOoUHRAEd4HNBOXP0b/CRBxzdJ0+mLnhrPq21WBM2IgxWwg11v/JSqWmVIss2TIcPoDFNWazdnKoh9iAcqcBHW7+l6VuD3pohSntNLgGXvfzVglVkn5i/AgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840428; 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=CNvfpLpvowog9Y6x5f9OTIUhovKksu4m41f5tfn28O0xwr+w5fWJHpQ0RtQbbU/xQy7urb6X4a3VVASH/L+a88LLG64I8d1oCMsKG1qfsvFucwVx043CIEP//IfrGVnhuVemLpgZgacXRtpbrNr7BY4q8X1qrCnvlNQ9WNE0Z/o= 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 1771840428724944.2114871585868; Mon, 23 Feb 2026 01:53:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScH-0005wK-Jt; Mon, 23 Feb 2026 04:52: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 1vuSZx-00023b-2H for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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 1vuSZu-0007Ki-Tq for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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-92-0Mz3kbc5MwGatfP8s_nWog-1; Mon, 23 Feb 2026 04:50: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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D0E801956079; Mon, 23 Feb 2026 09:50: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 AC4BF1955F22; Mon, 23 Feb 2026 09:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840210; 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=FbA4kI/8kUEtkDkUlOTYMKVwdEHl6xYV0Jo5ynkg7Q7mrvlXwE0TujVPqgNaiBkC5LFNvG Z5+thrDnOr/4oZyydmx79dm8J0rr+LPu/d8TLQfKF+fTiI9fc5X1H4GxkhBICv4Dg50LJK yWWHsTrXHm16h0TVqaUwqNOrWC44oJ0= X-MC-Unique: 0Mz3kbc5MwGatfP8s_nWog-1 X-Mimecast-MFC-AGG-ID: 0Mz3kbc5MwGatfP8s_nWog_1771840206 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 v2 65/85] audio/oss: replace custom logging with report & trace Date: Mon, 23 Feb 2026 10:46:23 +0100 Message-ID: <20260223094649.2005118-66-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840429894158500 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 00:57:50 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=1771840540; cv=none; d=zohomail.com; s=zohoarc; b=nVCjZqUxdMfBVsCNdwTtC8HhjMWqWQ/E6HeKJaiDkKx9ST1rIa1GTPgAfEDSLYxvFZJeki0rZ+k0ijBYytWbs5bN3QelMDtDjjN1GI2zvdEnI5Evyq974XSHdg6MTiFno1ys1nxnDY97ZotuY9n7qDYPwaHyiJMciY5JCbhhtuI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840540; 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=GbHMk+xCYmJvuHDlI/M/rErDlfL0e1U+3AlWLjTLygCRSp3oP5dtYSLtrwBOUtesVzjZ7bEveDuzN+jx8nI9NpwNo74Q9V8Q33u2Q+2DfE5vD+YxSmSzH+kYGVljqI/owfWzvfMqZLbsL9Ymo+ktG0596u8Z/iw2g3YcFWlSwMc= 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 1771840540377505.95124997819664; Mon, 23 Feb 2026 01:55:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSc2-0005Bq-BI; Mon, 23 Feb 2026 04: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 1vuSa0-000290-PO for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSZy-0007LX-Sq for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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-424-9zqphqsqOPqbVAjGgT7lSg-1; Mon, 23 Feb 2026 04:50:10 -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 56E3B19560A5; Mon, 23 Feb 2026 09:50:09 +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 C5CF830001BE; Mon, 23 Feb 2026 09:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840214; 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=N4UCDTWRl36ThJdlwhlgYtr2JuLNNDhINVM02jHqtsP+Ow4P5pRraF9nFP9AG30yV999Gx xnJ1RZ7ZvraR54MGZFWjTaarxvkFXz9TZWIEkq3qz5zm3KTdpPhXlgo5qVCNWkCR9vWc04 sD56SFgVsTdne7IC2SvaH6xRDbW85Ts= X-MC-Unique: 9zqphqsqOPqbVAjGgT7lSg-1 X-Mimecast-MFC-AGG-ID: 9zqphqsqOPqbVAjGgT7lSg_1771840209 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 v2 66/85] audio/pa: replace custom logging with report & trace Date: Mon, 23 Feb 2026 10:46:24 +0100 Message-ID: <20260223094649.2005118-67-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840542487158500 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 00:57:50 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=1771840359; cv=none; d=zohomail.com; s=zohoarc; b=R12pQHS1swwBlC0CgPrRVe7daVMnAwdqbPNFNgLxuY2jey0udyalnDGsvts4ueahG3f2lsfm73/RF17B23ON0QsKl7g9RUfyPxixvCCcT8aji0wpOmrCYqkvBhTaD0uDYYdg1lN2WD2I0VCkzgbDX5IVgmowkaGWHq7ObvOhJIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840359; 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=j0xaciiOMIDzXdzxjupa8bH/i53g6F+BdDwqfsN8QLfoCLOGMtOsNQ/B0XTIX8/yWJmzHPyCi9+6STVa9nxVdYnBGe0isZZLHsI6sXkUBWJrhECeYejFMheCfRQ2g7VZnghUZySxLjgc3l5wiW3d4XaSSZIlEQCdvP/cjJ8ybKQ= 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 1771840359679535.8176859580741; Mon, 23 Feb 2026 01:52:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSaR-0002mL-N3; Mon, 23 Feb 2026 04:50:44 -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 1vuSa2-00029f-9a for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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 1vuSa0-0007Ln-6O for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:17 -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-631-xquDECuUNCyXpwy0yJyOAA-1; Mon, 23 Feb 2026 04:50:12 -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 B8135180049D; Mon, 23 Feb 2026 09:50:11 +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 1385D1800668; Mon, 23 Feb 2026 09:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840214; 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=Y3U2KC6UBAeboqLPcGqrCDjVNLjRu/ZDXpPCqjEqd2V/GMNOFmMTJ/9rTRDy+E1p/06w5j Ojl4L+1BagwLK/m6DrAuDhROtMg+qK+qEiwt1O5Wucij1ffMp5Jyt9c6QU+gViH5S8JTAF 3c1RL63wOdQj6gBHAWgYt9ssMfB3P9o= X-MC-Unique: xquDECuUNCyXpwy0yJyOAA-1 X-Mimecast-MFC-AGG-ID: xquDECuUNCyXpwy0yJyOAA_1771840211 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 v2 67/85] audio/pw: replace custom logging with error_report Date: Mon, 23 Feb 2026 10:46:25 +0100 Message-ID: <20260223094649.2005118-68-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840361392158500 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 00:57:50 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=1771840491; cv=none; d=zohomail.com; s=zohoarc; b=jb+CYac6Bqv3chcNAb9izE4E4l75U1NUaLkTVfW1b3YqNRYkxQ7x1KMJuXUyn2gnkOx4bbQm00yvpCvXbK0nD4wwMFG27dHfZSbyfFqGm3Gqk9kfuMao/7QR1QCL+9QesAmNAllXKNU+DdbuFmHiCtLP/EsDa1iFaCWXjKNUAkQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840491; 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=NkeLhr8K6OBxJtF3JjtJFNdli/C73KbO0g0OtnrCNADysBhYTWl1zezmm38inCYbkDr7VZSFp6RYntt+rJF+RIJ5r428m4mDVSSU1aDUKXa+8NtuQPkA+5IL6pXyAh7L8qYNbugluN0tsUheYiD3upD9+Q3MebrQUpKUSP5MRPw= 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 1771840491061207.44544854341257; Mon, 23 Feb 2026 01:54:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSbt-0004je-8x; Mon, 23 Feb 2026 04:52: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 1vuSa6-0002Fi-J9 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:23 -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 1vuSa5-0007ML-1e for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:22 -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-437-raAN9YKhOwSmYr4e4hTVpA-1; Mon, 23 Feb 2026 04:50: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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A87CF1800464; Mon, 23 Feb 2026 09:50: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 9A05B19560A2; Mon, 23 Feb 2026 09:50:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840220; 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=QxCiEzldx5Ng6mnjlcFlTvWnF/6XQzqChK9X9nN93dL463iganh3OzTpA6U5Hjr2OSnqTD u7f2riG0BKwzF5LDI+XobUSrQJbu9K25b82z9uj3fwzAEUKinvRsYvc+AsnyRrTXNabKJ8 grXi6oyWQqEFEMRJGIs2I4Dik2GUfY4= X-MC-Unique: raAN9YKhOwSmYr4e4hTVpA-1 X-Mimecast-MFC-AGG-ID: raAN9YKhOwSmYr4e4hTVpA_1771840214 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 v2 68/85] audio/sdl: replace custom logging with error_report Date: Mon, 23 Feb 2026 10:46:26 +0100 Message-ID: <20260223094649.2005118-69-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840492158158500 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 00:57:50 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=1771840476; cv=none; d=zohomail.com; s=zohoarc; b=CMAlDOglqcj8wpKrdyOit2l3ngstHv1vvfz3LQjz8J0LPSE2sWQ0lGE9LM/E+wkNUj7IIMKIc9HCG042ZQTa0I/KJUOfX1rxCJYP+oTUCduU7yRaVPQOVQTtjDMGVgETlMD/lhvV3Jiv8RKT0yKWzApG2hoYTcRDc48jKhMwlXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840476; 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=huqER681XLeey9kZaHzxZfjB1ncpR+VbnHuCLgV0RD074YvIgMhTyW5AOOnuVgDQyjcXIQTVGfEyBfwUoN1JIRIniAsdr81mXA9E4PKFaWeNIvmOiaEVyyXlhx+RcWj+lCtiNo4WyK/wzJdRFLiaDkGmcuPgT+PtVxdP2xBvp1g= 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 1771840476591531.4850289811615; Mon, 23 Feb 2026 01:54:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSaV-0002vm-CB; Mon, 23 Feb 2026 04:50: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 1vuSa8-0002I1-67 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:24 -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 1vuSa6-0007MU-LU for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:23 -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-460-lCiDJ4zTPsqTEn7M_nfiJg-1; Mon, 23 Feb 2026 04:50:18 -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 E97521956064; Mon, 23 Feb 2026 09:50: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 456801800674; Mon, 23 Feb 2026 09:50:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840222; 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=YAdVL3LLaBFmplB473gKOz7XvB9TwFk0J3itvwcJ1BrPZGsHjqJcN0+6syXmpQO2BSQRK+ NRrki23K2lYKX/4F4Tk1r164yueRe5rfpPW3JyRiV43nz5V28F8clkNbX7kmMiyNMQbpYx jFxYtFKt+AdqgR4v0aEL2NOlZKs8O+M= X-MC-Unique: lCiDJ4zTPsqTEn7M_nfiJg-1 X-Mimecast-MFC-AGG-ID: lCiDJ4zTPsqTEn7M_nfiJg_1771840217 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 v2 69/85] audio/sndio: replace custom logging with error_report Date: Mon, 23 Feb 2026 10:46:27 +0100 Message-ID: <20260223094649.2005118-70-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840478050158501 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 00:57:50 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=1771840593; cv=none; d=zohomail.com; s=zohoarc; b=nl8LNbr7IryYXdRGLViBRDUmcysrn+KdKlD/5O+8HN8i0yRAI0Np6OmD4MQ+wpj8X9sGDvZiVB36iPxk7gmiFFheL2fLEkWkPcPBiQoCs7F0vLaOeOLOfyV9eoH4gFKuIyUb7VhGku2aymzPV8Rssbb6mM8yoBbP/oxr0uJf6ik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840593; 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=W7ihVTOwTO/Tkkoh6sINisEpVgqMZxu7oeYC/LUxls+yrB55dCbewM2ndLCrVxLPvda89Kb+oYW5B0W2kGkX99UeJHWPqCj6qpu5eIRcfgCwFviis0fGBqAOnsiqt1TfFsCun/sFNkdbhClvP4cRQbfv6rHpwB8wodem48JhqYA= 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 1771840593198592.381794867359; Mon, 23 Feb 2026 01:56:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScI-0006Bl-Oz; Mon, 23 Feb 2026 04:52:38 -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 1vuSaB-0002QS-67 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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 1vuSa9-0007Mi-Ql for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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-10-z6reXkmGPWOeGWR4Oe6rlw-1; Mon, 23 Feb 2026 04:50: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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7E9E618005B7; Mon, 23 Feb 2026 09:50: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 F15DD1800668; Mon, 23 Feb 2026 09:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840224; 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=NGqwWFCPjS9TARG9cnpnuwYiNXQAIjs30K+G/RiSS8E3EEoe6PxzbzJ0RoWaUw17z0YnUW 3bDjdUMFD/uKPs7aPIfFsbkKyPvNAEuCfC+dRgLlf9v1My2HwWqX1jnnluSPOl9NjhBsRw cjwp4RL2yw88h2BSaqSKlh7EmhLdhcI= X-MC-Unique: z6reXkmGPWOeGWR4Oe6rlw-1 X-Mimecast-MFC-AGG-ID: z6reXkmGPWOeGWR4Oe6rlw_1771840219 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 70/85] audio/spice: remove unused AUDIO_CAP macro Date: Mon, 23 Feb 2026 10:46:28 +0100 Message-ID: <20260223094649.2005118-71-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840594581158500 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 00:57:50 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=1771840496; cv=none; d=zohomail.com; s=zohoarc; b=DG90AjHokgxwLrHI2VLGLDlBaUNpJjfpE46zOUXG1EWlCckskhi3fMby3NIQSTF0Y8NCFND3/VLXQUZIM8m6zhsjGaUm3oCL5MzryodHssR8b/4IdmKcLnFv0X137/4rRNKQDBC/GKoIKVMGkDmzgMP9I6eqTxWh9vKQ3f5VkoI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840496; 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=bZreDa4zJ9HT3IpIeK3Kw6Xldx6kl1EPYjlNZ4of9QEvq5joPiuXxquX+G2MGbXKJHxcdHUCsN5ri065XF3pz5z9ZrPk/9rXNo8s3bOttwxcawwn1zaBmxjnM9E+hWAgOVmw0u2e7vEHxKuFeKN3+p7jIm8T49S5apDhvtcfr/o= 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 17718404968931001.1766386408956; Mon, 23 Feb 2026 01:54:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScC-0005PF-RH; Mon, 23 Feb 2026 04:52:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSaD-0002T0-RA for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:32 -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 1vuSaC-0007Ms-7m for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:29 -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-159-G0M5jOz9Pf62zbIJBGWgiw-1; Mon, 23 Feb 2026 04:50: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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3D0981956058; Mon, 23 Feb 2026 09:50: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 64BE1195419E; Mon, 23 Feb 2026 09:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840227; 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=SmBdFVyVvgfEP7VjVXphLaSfJlWZJUxT/NvTxBow30YuJ62ZO1w1Rsxlv7HtXAYCgEAk7c P97qdgJqpq7d7VJ3mszSTERo5khq0u1ydx55nCj76FAT2W1x4PArb3g7J2FDFkfbQPDzdt PWSfmmkmIsHIcuu0nQ0ZeeGACcUGi/c= X-MC-Unique: G0M5jOz9Pf62zbIJBGWgiw-1 X-Mimecast-MFC-AGG-ID: G0M5jOz9Pf62zbIJBGWgiw_1771840222 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 v2 71/85] audio/wav: replace custom logging with error_report Date: Mon, 23 Feb 2026 10:46:29 +0100 Message-ID: <20260223094649.2005118-72-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840498152158500 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 00:57:50 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=1771840506; cv=none; d=zohomail.com; s=zohoarc; b=dUThMRHJ2hwgk9ZoeBLPfGFMzwzVbBvukj2SLlHUxtzo1QGNHKeyYHkhRZuBI6FshBaO6GddSgf2ENfb0uNUL4h1pNc/OvOEmGyiVXTvIzY8pm2FbMi8lvKAG78cIsHu6prnnTKkoM7I89UXlf96e5TDt7BLsHc8zQ30pFo14fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840506; 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=D+L3RWVqGskVXolzXzpQw2A82hptBG13LrfEodcbH+PehO3gLaDxvgRRfYpMaIZ7FO2rIVlKipvtzRoZtXgWq0165HATKFJOn+yI8cvH7Y+q34jLOXJt6cxQDT/ubJwSWdktg4P1kApsc0ApQtuKDcN/vAN6nwaMljAmrk1ZCqg= 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 1771840506712507.9277711574391; Mon, 23 Feb 2026 01:55:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScJ-0006Kg-If; Mon, 23 Feb 2026 04:52: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 1vuSaG-0002UL-J8 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSaE-0007N2-Gc for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:32 -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-324-bkWL4uSuOuGqzzbGvVlLeQ-1; Mon, 23 Feb 2026 04:50:26 -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 2C7B91800342; Mon, 23 Feb 2026 09:50:25 +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 1DEC81800351; Mon, 23 Feb 2026 09:50:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840229; 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=OtzzlK5/KSpL75rY/dwSS7KMRwbZ2WPqzh14OGeR5MOt+tjV174ot0LHTYSxik7RFI7kk4 /9rJSzfyOWNtAQ/rldDYB6ZmD3xvmGCOGOQmme8eHImizmdZjqJncXekhI0UHa+heVru9e czraOb4I/jOUHbOMyVQJp6gvARg0To0= X-MC-Unique: bkWL4uSuOuGqzzbGvVlLeQ-1 X-Mimecast-MFC-AGG-ID: bkWL4uSuOuGqzzbGvVlLeQ_1771840225 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 v2 72/85] audio/mixeng: replace redundant pcm_info fields with AudioFormat Date: Mon, 23 Feb 2026 10:46:30 +0100 Message-ID: <20260223094649.2005118-73-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840508311158500 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 00:57:50 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=1771840684; cv=none; d=zohomail.com; s=zohoarc; b=ltTMrfxL5h/rNsIlEKXq8b0srNrKsv6bmVwsM55ajd9lmA5kniJs6lVMRErWTChXDuHz5hwbNhyeYzAvm0IyTOlA1Vbim/W1xLDMYHEL1iQ5dQJW5m6iTWDTVDVgzDwStYystuBIGayhxtm3Q6yYUWdFLrvgrEynwLY18RwCz1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840684; 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=iJi7oR34DgBP+jpHqeJxc7l5EOkuU6U9i1W56NnMyQI=; b=O8RwlAdx8FArVxnrlTry6H0cYwoGUiiV3+9FlX5NCD1G2HCIwrhAyhK6bcGQbTSsLeDwQwUy6bFzkbqSDUkNM9azuSxzCNgoXj05a08I0pnfNr1GZfXZHFWOieOEcxwPIMviWm6bFAJeEd150ItdhOX1kHE/yYSKwsxG78mSRKY= 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 1771840684166765.3613805368061; Mon, 23 Feb 2026 01:58:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSbq-0004bk-Nl; Mon, 23 Feb 2026 04:52: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 1vuSaM-0002bV-Ew for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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 1vuSaJ-0007NN-Ge for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:38 -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-393-1fdd7K2QPK-Xm4Ce5Dixkw-1; Mon, 23 Feb 2026 04:50:30 -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 56EA11956088; Mon, 23 Feb 2026 09:50:28 +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 CC8CD1955F22; Mon, 23 Feb 2026 09:50:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840234; 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=iJi7oR34DgBP+jpHqeJxc7l5EOkuU6U9i1W56NnMyQI=; b=UgzLUoQf7tpiLEhg7QNv+S5TD9MOsvCaHqxS+OuU+DocDEvrNW8C8kkaYuRIpCd1QnAr6Y S2BJru1VUzt/ZfwxivEYXdair+NSRuuJb99KResl3/9mOtGaFBhm9bYe+KJakoiWlRAD6B 884s/tP4nC4Wcay8lWgDBqefFxc+7/g= X-MC-Unique: 1fdd7K2QPK-Xm4Ce5Dixkw-1 X-Mimecast-MFC-AGG-ID: 1fdd7K2QPK-Xm4Ce5Dixkw_1771840228 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 v2 73/85] audio: replace int endianness with bool big_endian in audsettings Date: Mon, 23 Feb 2026 10:46:31 +0100 Message-ID: <20260223094649.2005118-74-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840685480158500 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 89e24c0a8e0..8b949146468 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -378,7 +378,7 @@ static void virtio_snd_get_qemu_audsettings(audsettings= *as, as->nchannels =3D MIN(AUDIO_MAX_CHANNELS, params->channels); as->fmt =3D virtio_snd_get_qemu_format(params->format); as->freq =3D virtio_snd_get_qemu_freq(params->rate); - as->endianness =3D 0; /* Conforming to VIRTIO 1.0: always little endia= n. */ + as->big_endian =3D false; /* Conforming to VIRTIO 1.0: always little e= ndian. */ } =20 /* diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c index 2a286515b14..e2507b0269a 100644 --- a/hw/audio/wm8750.c +++ b/hw/audio/wm8750.c @@ -202,7 +202,7 @@ static void wm8750_set_format(WM8750State *s) return; =20 /* Setup input */ - in_fmt.endianness =3D 0; + in_fmt.big_endian =3D false; in_fmt.nchannels =3D 2; in_fmt.freq =3D s->adc_hz; in_fmt.fmt =3D AUDIO_FORMAT_S16; @@ -215,7 +215,7 @@ static void wm8750_set_format(WM8750State *s) CODEC ".input3", s, wm8750_audio_in_cb, &in_fmt); =20 /* Setup output */ - out_fmt.endianness =3D 0; + out_fmt.big_endian =3D false; out_fmt.nchannels =3D 2; out_fmt.freq =3D s->dac_hz; out_fmt.fmt =3D AUDIO_FORMAT_S16; diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c index 9aa4709b411..7d037b46a35 100644 --- a/hw/display/xlnx_dp.c +++ b/hw/display/xlnx_dp.c @@ -1393,7 +1393,7 @@ static void xlnx_dp_realize(DeviceState *dev, Error *= *errp) as.freq =3D 44100; as.nchannels =3D 2; as.fmt =3D AUDIO_FORMAT_S16; - as.endianness =3D 0; + as.big_endian =3D false; =20 s->amixer_output_stream =3D audio_be_open_out(s->audio_be, s->amixer_output_stream, diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c index 7b758718c12..e18e0a1dfd6 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -975,7 +975,7 @@ static void usb_audio_reinit(USBDevice *dev, unsigned c= hannels) s->out.as.freq =3D USBAUDIO_SAMPLE_RATE; s->out.as.nchannels =3D s->out.channels; s->out.as.fmt =3D AUDIO_FORMAT_S16; - s->out.as.endianness =3D 0; + s->out.as.big_endian =3D false; streambuf_init(&s->out.buf, s->buffer, s->out.channels); =20 s->out.voice =3D audio_be_open_out(s->audio_be, s->out.voice, TYPE_USB= _AUDIO, diff --git a/tests/audio/test-audio.c b/tests/audio/test-audio.c index 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 00:57:50 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=1771840359; cv=none; d=zohomail.com; s=zohoarc; b=ZXsAwuUTi8MnaoUwcDlo1DTVb9SjnDw+CyZcMN0F0tUvvI8WJfQklXO0DvBsw9VMQpfeMZ0VvJYdKZpt62wvOJs+6a+TRdMnZLiAkUmUSxnUzpQ4QvBIV9UjjxbDepRIT8VJmZvaw2ckRkJOyHTMVXDYRkfMRqDSBlrGYblYecw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840359; 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=c2CoLqzx/geFbrFLGRJwp1Vm4sCJxip4DJibqwLmYOS/RGuVqZHd4df0B1K3j5P5VdATNCOb/U6fqowZI3e5cexYGh0nSUcYHmyS3V7VtfvnG4i1bOH+CTG2bPiZb6jExxayystquQFuYt8HupHDs9gryNbJ3N6kWsCPCDxQx6M= 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 1771840359990146.94286341968564; Mon, 23 Feb 2026 01:52:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScD-0005U0-Rt; Mon, 23 Feb 2026 04:52:33 -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 1vuSaN-0002gM-76 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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 1vuSaK-0007NS-Fr for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:38 -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-492-dy9UmovwNkmTVyeszE5lgQ-1; Mon, 23 Feb 2026 04:50:31 -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 A7F681956080; Mon, 23 Feb 2026 09:50:30 +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 2BB001955D85; Mon, 23 Feb 2026 09:50:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840235; 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=dQOcznSSxSxaijJC8+ca5paY9JsDCSXnFz8Bd8RsBTrfVOJGL+sUK/DEePfBgdLmdplFxx Qr5L8e0kJqWpNBp1HA6nKxVDTmemqF5z7z1lvGUbaIDSy1/yiNj9QUztbSeD7584Ul55nW scOwJhinvfNIP3ZuEnf5NoNiLhmIz/Q= X-MC-Unique: dy9UmovwNkmTVyeszE5lgQ-1 X-Mimecast-MFC-AGG-ID: dy9UmovwNkmTVyeszE5lgQ_1771840230 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 v2 74/85] audio: replace ldebug with trace events Date: Mon, 23 Feb 2026 10:46:32 +0100 Message-ID: <20260223094649.2005118-75-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840365461158500 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 00:57:50 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=1771840360; cv=none; d=zohomail.com; s=zohoarc; b=NLUlsNn1huD83D/bHrviVjcDWRfW1zQT+R9kNPbqqUvqRxQTjypD5T1mB4i8rLQcLKzau2XzZU9l2rLpJExfuQfE934KmMKpX4DwJD1H7S4rrUMczIwNvMZLlmXpCd/drf1mjz+q1Ea+A2Y8RijGK7sFbzFWXni0dgoLHdqdRcM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840360; 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=jSHDT52P6P48GJcgQhYaBayc+LLJXaQPqjSFlxp8XnfSZgkd0eWV1cxbRDK0sMsDEggfML1g9+m7BAarRi4jyIyQjdVExsgdywDcnLQzgfMmKI0zbPRe5gAF5lrxAkXjZFoNXE00y6Vf/+daxggf1kS9XZUBY6ddaR/pyQYy52U= 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 1771840360837662.0129123029844; Mon, 23 Feb 2026 01:52:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSbz-00051J-9L; Mon, 23 Feb 2026 04:52: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 1vuSaN-0002hZ-G2 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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 1vuSaK-0007NU-Ji for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:39 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-62-vUFqiOCoO-G4pgICXpGiIQ-1; Mon, 23 Feb 2026 04:50:34 -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 1C11919560A7; Mon, 23 Feb 2026 09:50:33 +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 9799F1955F22; Mon, 23 Feb 2026 09:50:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840236; 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=LOGypRXBLJvR8HAVWnp+1vv/yW8L6Yw/OoNdCSdmy2gAOdL7njLQaX3ODUz+BthqKO+uBo AxtByMnPh+em59ceaLO8sevsLyD+ZQjWZk/TaXd88uFXp+LzuHOQYe5FSi093OEMa9E40y ksCoeRg5W07Mnk6QlmUvDTy/pFykiC0= X-MC-Unique: vUFqiOCoO-G4pgICXpGiIQ-1 X-Mimecast-MFC-AGG-ID: vUFqiOCoO-G4pgICXpGiIQ_1771840233 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 v2 75/85] audio: rework DEBUG_POLL Date: Mon, 23 Feb 2026 10:46:33 +0100 Message-ID: <20260223094649.2005118-76-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840361447158500 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 00:57:50 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=1771840655; cv=none; d=zohomail.com; s=zohoarc; b=i/j6UCYSvzMGjk/ji+EfZni2c/47Szxvapvc1g1m0DWNHv+eX+g+WIJxdv9NIl8OhSqX859NOP+pyfFOgKTsEjv4Uz0MGKlsX4WbyalPGNvOPFGRPrZfOCQjp+fEbE/qeMndeFrvuvhTCXzACOBup8hv5vKQq27/JFWPP+kGaaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840655; 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=nQ9ks0nV15/Voujmvf9X5aGB7yR+djAJ63bPoS0Ro/kAZJqF8wr/lqpe17wMhuRIfnnpBtDbqiYLqerK1q7u+UMwxXVxU0jmDBKveAdKXkY2aLtDmZzTv/wAcy4k7wh+YpG6Z6Zk9MZlpVMhFm1h5lZ/W5f7WV+7fU/3q+h5ASM= 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 1771840655004700.8367372297245; Mon, 23 Feb 2026 01:57:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScD-0005R1-63; Mon, 23 Feb 2026 04:52:33 -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 1vuSaQ-0002mJ-DY for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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 1vuSaO-0007O0-Sb for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:42 -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-582-Yth1Ep02O1qcNZBRLUSTBw-1; Mon, 23 Feb 2026 04:50:36 -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 E36F9180025F; Mon, 23 Feb 2026 09:50:35 +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 E15071800668; Mon, 23 Feb 2026 09:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840240; 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=SeEjoSlOEMCZ5dQhGjJXtzo+ipbJ5ipJfe/xF5BqU+GtFsDT6xeGcBGLxgBRfyiSLgnnYs +dwMvQh4E4oRhNj1yv9ZcouJFqfNkgKWIv8LUSO+gB/a+FeeK5e7udUcANP5DTAWrZPy5i 4FO1WQWjMW4n2WPLrqkrY2xHLeOIF28= X-MC-Unique: Yth1Ep02O1qcNZBRLUSTBw-1 X-Mimecast-MFC-AGG-ID: Yth1Ep02O1qcNZBRLUSTBw_1771840236 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 v2 76/85] audio: replace DEBUG_CAPTURE with traces Date: Mon, 23 Feb 2026 10:46:34 +0100 Message-ID: <20260223094649.2005118-77-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840657076158500 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 00:57:50 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=1771840626; cv=none; d=zohomail.com; s=zohoarc; b=C5wCztKV/lFpIUQ2hDOQpOVNPhPc4Yt4a08TDc4+4sW7McmkSeJ73ltbom43gs9UfU114kWNYYLhZT2M6H2xsYdo9cAjBBjQcvGDJMqCM8glQdoGSg2a1310pz/iUDKapq+bUm9aocO3gXgA6pOSLm/r2VZef62tiVkQI4Xlhj8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840626; 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=RR1WIjNhBHogxph1AJSKXxlLmOcBoSxILrjBCbdBil5dNqkE0499lRM5QNK3fcQ8MSU8K/Sm95pGdMtO17G0S0TYrR/AfRwsXl/c//fNklkmOPijpRrikrdIMz9sHC9pSGIox5U74trRL5J+2PvJRtDyGSIrvi3YrHTKgbiRmh4= 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 177184062658871.84639596949398; Mon, 23 Feb 2026 01:57:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScF-0005jG-T1; Mon, 23 Feb 2026 04:52:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSaU-0002vL-1p for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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 1vuSaS-0007OY-Ib for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:45 -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-177-RuqSYcvGPD23D00NHBx-qQ-1; Mon, 23 Feb 2026 04:50:39 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CF177195608E; Mon, 23 Feb 2026 09:50:38 +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 E480F19560A2; Mon, 23 Feb 2026 09:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840243; 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=fvyMAHmiOAiJ/mpXvblBhxVgMmrcp0smqZrx/RY0h6yxhdQeUr1cVBAihpQirFVZv87uIj O3JSXqFDkrWzwtbdmCgEjhce2o1o3+/fHQmAa3hNhNeJDbGiPRlVvIvYGGEAGiEYMi2XpV JJwLs4FAoRLldI8LV86CLS4zkG4R9N0= X-MC-Unique: RuqSYcvGPD23D00NHBx-qQ-1 X-Mimecast-MFC-AGG-ID: RuqSYcvGPD23D00NHBx-qQ_1771840238 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 v2 77/85] audio: replace DEBUG_OUT with traces Date: Mon, 23 Feb 2026 10:46:35 +0100 Message-ID: <20260223094649.2005118-78-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840628855158500 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 00:57:50 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=1771840388; cv=none; d=zohomail.com; s=zohoarc; b=lGbunNGbgsS1pOJKfMlCDv1gHAFy3TccsHrcM8BYt9uraVNUxC96YkuiQdokQdMkKCoZwF51+r4sX62t2Z6EVuycEFr6WYWczT1s27IsWEVvd8RW0aqPsst0VkXNouN45KcH/QtlDhB5kQkOJFWuEnja7Qb9PWD1E/hfQpdD9Jw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840388; 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=gqpvLwJT2BhyxM5gE0TfMKc/x9D+3dcyRCS+oKKUdsFICgr5Tcb8PPi/FVXk+HmWlUOfWuDuC27xOkSjSBzVQEVHy2jc2Iga298xxssXWT72HKSTDAyvkZoDmKpAG2pRLEeUWubm8+PwXUZZ8Gk8CzuLMVrAkjGV5umY6yEitsA= 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 1771840388462903.8671323643367; Mon, 23 Feb 2026 01:53:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScF-0005ht-Mp; Mon, 23 Feb 2026 04:52:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSaU-0002vn-Dl for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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 1vuSaS-0007OW-HP for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:45 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-477-aKqH-yHBPuGFOFwrHoJysQ-1; Mon, 23 Feb 2026 04:50:42 -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 68062195605F; Mon, 23 Feb 2026 09:50:41 +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 AA4F930001BE; Mon, 23 Feb 2026 09:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840243; 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=byn2CDcVUdU7M2KinY06bVGX2HTiT0N5xb3smqClbNl28/LNUhN+1/DV8kphhN0IwrwD3i GWj21HKhaPHdGe0A+itlUtXho416ZdQqTgBDiTQLdYmic9MKFb3tNYHGQyF/4tTEcN3CQy Eiq8TK+U477zy85oHtnv4ibnnCIIQLg= X-MC-Unique: aKqH-yHBPuGFOFwrHoJysQ-1 X-Mimecast-MFC-AGG-ID: aKqH-yHBPuGFOFwrHoJysQ_1771840241 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 v2 78/85] audio: replace DEBUG_AUDIO with trace Date: Mon, 23 Feb 2026 10:46:36 +0100 Message-ID: <20260223094649.2005118-79-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840389539158500 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 00:57:50 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=1771840635; cv=none; d=zohomail.com; s=zohoarc; b=Rk6A7tmpMIdrNWaPvQIwylpQlyE618FkfZU2PNzuxWDDnWzq4lvBm0PDa06GYlkvpWtjemisqeEwgg8rB1Vs0HRr49eBYzhYvh/nvy8+6xj5gdF6oMcvURJQ1a7QMhsSKjqnwpeX29Ae4Ee8fDCB0PIyRnzulSO18QpLoNAqoEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840635; 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=AnUd2st+BZg2MpTwdI/qDudOGcC4VF9IzvqRvZQbT6KWx9UUHB+mLYFsy19VVJF+/tfSFb9rkebRnpC822vSibbALcPscWsc3YdBqpIv8zU1IarZWuMAW+xjIszS07KFvsTi6dQKMZ3Hf+0nqNAZc6jgPZcblqcaGNl0/EyVkJw= 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 1771840635397317.41376687428726; Mon, 23 Feb 2026 01:57:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSba-0004IA-To; Mon, 23 Feb 2026 04:51: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 1vuSaZ-00039P-Co for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:52 -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 1vuSaX-0007PH-On for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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-515-meN-w0EiN3u6ta5U3f5BjA-1; Mon, 23 Feb 2026 04: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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 343B71800365; Mon, 23 Feb 2026 09: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 50C8819560A2; Mon, 23 Feb 2026 09:50:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840249; 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=QcuZ29C2J1BiRASUGPggk0yl92Ykt3kJ8b3o4gK9LmHeNZIBiq9SZKoh3Zd/QMU7aLIRUV YACRRi5YDmKcPrbdk7M9Mjue3K/kCEQGZ3aILr9A0EYYV/lxachUQi1MwIMGH5HCOd9MrY bhAkwtoOOuKvGyMS6OMt4iWFePhsFAg= X-MC-Unique: meN-w0EiN3u6ta5U3f5BjA-1 X-Mimecast-MFC-AGG-ID: meN-w0EiN3u6ta5U3f5BjA_1771840244 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 v2 79/85] tests/audio: add an invalid settings test Date: Mon, 23 Feb 2026 10:46:37 +0100 Message-ID: <20260223094649.2005118-80-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840637063158500 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 00:57:50 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=1771840382; cv=none; d=zohomail.com; s=zohoarc; b=aFvkuHWa2QqtRxS/BWvQPRY0GWEE8AosaOSxImWPDES35Ss7dnRYEL7DKd4NTQOhHV16qQVhfhiHTNt21w/v4tFPbCujU/x/o6ndJOxB0xJU6woTKlJxTeg7fOHuXzjLxdnSKKLn2PtMszcZUZYzavhoN5WsdxXndh0pFvHJius= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840382; 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=VEZoV5rMMqiSSKmdvV7Yw2cyAFKAMzKRVKyoZ1wj8vZLcfJb34KPjfA9tjt6T19lX/spyAz418tiF1CXnUd1BykFPyhttPR09igmdiS7w3JZtwfY99yn/BbdJMxTLTfkzlqQy9TvkIfa1y7EweB6uUi6aTDXfBtTNa47mumEdcM= 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 1771840382820849.5035512032707; Mon, 23 Feb 2026 01:53:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScG-0005qD-QJ; Mon, 23 Feb 2026 04:52:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSac-0003EJ-4X for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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 1vuSaa-0007PR-Fh for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:53 -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-223-euHVnqJtNtyzDFrxqi04dw-1; Mon, 23 Feb 2026 04:50:47 -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 D07241800365; Mon, 23 Feb 2026 09:50:46 +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 E12811800465; Mon, 23 Feb 2026 09:50:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840251; 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=AJzFRJFcKOnVRfBs3WHyc53gs63j/9U44fB19iJlpTYozWEQG0Ujq+02NE8/aGi7G0QZpn XwfwORY9ElB/D7HP7JaN/gpgCFp4Bl0CyJkCCON19M1cwLEupQG8MPaAx6RAQljyt2YvFO JVhYElF/jZ4PBdq8gl1T2Oi7DoXsSLM= X-MC-Unique: euHVnqJtNtyzDFrxqi04dw-1 X-Mimecast-MFC-AGG-ID: euHVnqJtNtyzDFrxqi04dw_1771840246 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 v2 80/85] audio: rework invalid audsettings error Date: Mon, 23 Feb 2026 10:46:38 +0100 Message-ID: <20260223094649.2005118-81-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840401233158500 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 00:57:50 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=1771840382; cv=none; d=zohomail.com; s=zohoarc; b=SZkHOTAZ2TGlLignMJQ6vATkRk0TZulNSMJKbWa4hRqwSqxCVYzmBVNTR7woib/zz9kT381R8Ytmei4Qwo91T7GUPBSXnCPmAxejdiCIz55BV5Ub/ddBmCxQ5MKvGPrt+rgEycwiKZQWuHxBg9WQULjzYMX9S6jTpdVZVphUl8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840382; 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=KuyGuGPbI1NWP8MX/EIC+JaG7nUBRnW46z1DWXo+o9YBqjL9iWBAeYcM7CljS8AwZQulwsYXzpXUEMtOZtEafzdUmOIMAlaeLxBJmq3GJcyzWUdIwFry9IpJqulBK5eSzB7/T9QMP87aORh/nEDxa8FJtqkV6H8NWeIBiSTbNOw= 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 1771840382154914.3816287190011; Mon, 23 Feb 2026 01:53:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScH-0005wD-HW; Mon, 23 Feb 2026 04:52: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 1vuSac-0003Hm-TP for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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 1vuSab-0007PX-0M for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50: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-91-hvd66MFOPYWhf7peWCT0rg-1; Mon, 23 Feb 2026 04:50:50 -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 6517A1800473; Mon, 23 Feb 2026 09:50:49 +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 C15813000C26; Mon, 23 Feb 2026 09:50:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840252; 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=BzMl1SGCUXBp5P3fT4pAiUCzMlzPNzxX+dluCtmiQ0DzEu8dLXCsj2mQzY5GX0Ihaev87e 7onFShvfRROD2JnzxYfYkKL8Aup0yDNu5XgDsE06vJbtqRA+7j7GiMUROkauzjK9XpGKkz 743dfbbPfHwQS7IYmzFq/TdizXZh9zg= X-MC-Unique: hvd66MFOPYWhf7peWCT0rg-1 X-Mimecast-MFC-AGG-ID: hvd66MFOPYWhf7peWCT0rg_1771840249 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 v2 81/85] audio: rework audio_bug() Date: Mon, 23 Feb 2026 10:46:39 +0100 Message-ID: <20260223094649.2005118-82-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840383716158500 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 00:57:50 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=1771840380; cv=none; d=zohomail.com; s=zohoarc; b=ZvPxLgfcK9xeFbf7uGq8Q1AyS7S4D93LaPee4SsWEd0feuu2C+db+0jJe4oTueXUro/SxPwrexaXVa6Xx/uCZ8gkgcqFTuOeb1WfFwFYws4Jkq4CDVSy35cyBjVjwL9PZTnp94TXc2MvxjwInHfd/6P3feA3QKQSTWETU3+zORg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840380; 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=mFmKZTQrx6g4kmW2jDpsOYJ6iRjTnyYjsKTjZrNkFpGCfOjGpa1a83q8mj7N6CFtB3pADYAxiOTdYfAKF9/hqlXQ11mIufl6nMbKaEBsag1rQvCS33YHoPR8C/ojsYKCjHCC/aQy5FN58oNWx9FhYtaFkJgvx43TabT9mjB0RQw= 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 1771840380081386.66592121033; Mon, 23 Feb 2026 01:53:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScC-0005NC-Cz; Mon, 23 Feb 2026 04:52:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSah-0003U5-GZ for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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 1vuSaf-0007Pp-L6 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:59 -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-100-OwjLCwyaOlewEOzlo_6dYA-1; Mon, 23 Feb 2026 04:50:53 -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 485BA1956096; Mon, 23 Feb 2026 09:50:52 +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 2ACC71800674; Mon, 23 Feb 2026 09:50:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840257; 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=KGwk8VpB8TWktD0MXFBTjDCFge6+2zVd3IC6u+mHeC7b6LYV3jGRb/Gh/PGCHqHrrYgJOw ELXi75GCwHi9B6R8rtSaykToXruBOiCgH96H4AC0MXl0iqqueXIgEtfkr6fAWqVx0Jg+vq KIXbC2Bq82/ihHRnUnAk5y+UUHUN7PA= X-MC-Unique: OwjLCwyaOlewEOzlo_6dYA-1 X-Mimecast-MFC-AGG-ID: OwjLCwyaOlewEOzlo_6dYA_1771840252 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 v2 82/85] audio: replace remaining dolog() and AUD_log Date: Mon, 23 Feb 2026 10:46:40 +0100 Message-ID: <20260223094649.2005118-83-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840381542158500 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 00:57:50 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=1771840477; cv=none; d=zohomail.com; s=zohoarc; b=gAc52xDQ4SwiTu8y5xbKEawTVcuDbgHbaLd1cZc/saFRT2WdhbLoETePizN7wJQk/aTnZBtJs4sYUzuHtL42R9qUtMEUmzeb18rW0TUANlRQQoal/Zw0KVmBJlJ8YUD/th82Rk3x6T27ox8+76bTCDUaE16pggbnV4noacGVM/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840477; 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=g5PD5HPSPS3r2Kyy35W0paT1BE6GobO6n3bD2ZVYs0XYdqsv6oqukmgm9pFQm0188hCis4Ij7gIEhbOeJkrqGGEFHjWpmev8GBakWRTNhDrn0/TRuIYJkAyFEU/QYKWlk6YbpqQPrbuSq0qRj+nsrr+1P07hCHnyoLXr45DpjyE= 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 1771840477479301.4630963990361; Mon, 23 Feb 2026 01:54:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSbt-0004mF-AY; Mon, 23 Feb 2026 04:52: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 1vuSah-0003U6-UU for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04: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 1vuSag-0007Pt-0X for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:50:59 -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-655-EehXSPyWOK-j7t0rpPG-3w-1; Mon, 23 Feb 2026 04:50:55 -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 A6D2A1956096; Mon, 23 Feb 2026 09:50:54 +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 2DCDB1800465; Mon, 23 Feb 2026 09:50:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840257; 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=XKpFWMxPHsEuJ1i3P0Wu33tMK+UuSY+Lp8jbHcY5kJLjSkxlBPFa+kePJvyGAyvCFmCMhf BegObM6cKxaeyhOGEx0Fzi4HtuQ4FtfM6Aa2AshJ9elupbSjHwXRh73WIO90ozgF+K0Kj8 lnwFIZCRKpr6U/kuwPp4is1DjHBOyQQ= X-MC-Unique: EehXSPyWOK-j7t0rpPG-3w-1 X-Mimecast-MFC-AGG-ID: EehXSPyWOK-j7t0rpPG-3w_1771840254 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 v2 83/85] audio: remove AUD_log/ldebug Date: Mon, 23 Feb 2026 10:46:41 +0100 Message-ID: <20260223094649.2005118-84-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840478064158500 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 00:57:50 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=1771840519; cv=none; d=zohomail.com; s=zohoarc; b=ZEsVtMutkk8ZCVhl3Vv6BSdtwf5P0E2k0+pY+fERAJgqZN/I/Xe90FNlgPrfr8gHgxSVEazgEtDSN0DQKbJ3XwDFa8DYlVRQE46IrpcUuppLYkSKikucfvMTetqtt11hsEKbeJp20h1AzIx9gqe/xxkyytYb+EjzWo7Ib5ughjs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840519; 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=AP6aYwc7aFqJSEGl98h4DncgbPNZsBLA7/gqyjkWfS0g5YphcZ7itCLUIsjduu0TmYap2LWClT2nzE7MkVPdF6IxzPs99A5+aE/ijXVR98L1inpHOUxd1HfiHeZB3N0yHNAbHVz5BXEciec3pC/IiCzO8O02En06JWjO1lQYSq4= 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 1771840519447398.5385853103097; Mon, 23 Feb 2026 01:55:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuScI-0006Bp-PD; Mon, 23 Feb 2026 04:52:38 -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 1vuSao-0003Xi-6F for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:51: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 1vuSam-0007QK-BC for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:51:05 -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-587-Woun5poKN-OQ1HAnAFp_lg-1; Mon, 23 Feb 2026 04:50:59 -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 6A4CB1955F44; Mon, 23 Feb 2026 09:50:57 +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 91F181800674; Mon, 23 Feb 2026 09:50:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840263; 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=PrEFOT+SB3VXfFBo1sKTatGdtxoONLq00zzZ0T/p5lMmOlMZt6HYhHKOK2B65lX4FLlIhr 2/oKhVTDc9ZpBJgP5pi0IBfwkGgl6dPGy1DTJzIc4vvykp6fIHwNmK7EQm5qhUR6ud4i1Q olcMsIK6LB4+HoaZQ418kzo0hTyQ6xo= X-MC-Unique: Woun5poKN-OQ1HAnAFp_lg-1 X-Mimecast-MFC-AGG-ID: Woun5poKN-OQ1HAnAFp_lg_1771840257 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 v2 84/85] audio: remove AudioMixengBackendClass.name Date: Mon, 23 Feb 2026 10:46:42 +0100 Message-ID: <20260223094649.2005118-85-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840520367158501 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 00:57:50 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=1771840534; cv=none; d=zohomail.com; s=zohoarc; b=fqR2c3mnhgsJ+0QJIbFg/gtV6BmMZ+KSFgCnCXQGSbMABb+HIp990WpcI2IkyNaphvuef98g38VG/0rnja7TuoyRwaFDYZ1GWrBe00AvuYxsgz8YTff/PFTr3+rrS5OA+gKcS3viylwGiy16dTs2LERhwlFSGqcxtYmmaOXxoXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771840534; 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=iGwdiKfdu3QxDZYOuS3o+9hk8IheNhVJEAZm4jcTxNWTlfOCiq4UeoaZ66yLm2w6cU9lKs5DJ69smKVpLRx9M/hFAHju36VPaXuF6rl3mtH4yzxjIhgkbNqfhWVunuoAx+6a5L5Qn1yhFkfiTJnD+Lf6JzqxI+WUHWs4eP9femE= 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 1771840534479183.33085730216885; Mon, 23 Feb 2026 01:55:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuSbl-0004Uu-Lr; Mon, 23 Feb 2026 04:52: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 1vuSan-0003Xc-6Z for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:51:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuSal-0007QE-PH for qemu-devel@nongnu.org; Mon, 23 Feb 2026 04:51:04 -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-122-j2Y2doLpOACDF_b1Xwohyw-1; Mon, 23 Feb 2026 04:51:01 -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 9EDEC19560A5; Mon, 23 Feb 2026 09:51:00 +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 8C5CE1955F22; Mon, 23 Feb 2026 09:50:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771840263; 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=OFkz25+Y8cVf/oKdQVLEFjZKdO6B/w8PgiS7Lwo/tpR2WN+fwZoQyp04tW6bUz8DDR7KCv y8XysMQqKZ3orguMlTcynd3h7imtWXRR6CC6//SzntfrEB8eB7LTuE5WZWqOTdeuc9qpJK 7bhDp9X/XpHHYzz1faQ/952yyvqRskM= X-MC-Unique: j2Y2doLpOACDF_b1Xwohyw-1 X-Mimecast-MFC-AGG-ID: j2Y2doLpOACDF_b1Xwohyw_1771840260 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 v2 85/85] audio: fix leak of audio capture name Date: Mon, 23 Feb 2026 10:46:43 +0100 Message-ID: <20260223094649.2005118-86-marcandre.lureau@redhat.com> In-Reply-To: <20260223094649.2005118-1-marcandre.lureau@redhat.com> References: <20260223094649.2005118-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: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.798, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.79, 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: 1771840536311158500 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