From nobody Sun Apr 12 04:24:18 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=1771405677; cv=none; d=zohomail.com; s=zohoarc; b=EpuD+q+DMFT02YP/G91edYqt5ATKyt0Pv3dtzc2fmoPDgh5Vv897gEKFOPMDVnvZr/ltdUntt+n+cMxn6MHdG/kVx4nHaOtMart8BZGwuaWxWKUkqw3iKeAeRFjYoHIZWRH0XI5BJ6kgSQjqGMhwLRZmSjeOceUB5PzcMDuOl40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405677; 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=ceWzflkOai2qIteTSiAol/3nU7XRTeo/H0QBZtBO1mTcw5g7KEXaONn9iY442LyOs+BaG3i/kou275V/7/a/G9H/uqwePzIEqC08rpaAfR64Wm1lOw04FpK6o555n04ZjmvEnqH8DNGTsW1V6MGz+DE7OjghPdnT6y13kfx/QZQ= 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 1771405677453273.4322946374858; Wed, 18 Feb 2026 01:07:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTE-0000ij-VR; Wed, 18 Feb 2026 04:03:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdTD-0000iF-Rk for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:03: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 1vsdTC-0008Ru-2Q for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:03:43 -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-418-bJwXkrHVNOqHyDCfj1tj7Q-1; Wed, 18 Feb 2026 04:03:37 -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 DC88F1955D80; Wed, 18 Feb 2026 09:03:35 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E956119560AD; Wed, 18 Feb 2026 09:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405421; 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=KdFzMEJEtOQwnJcbOycUNKOfFw7OiXIBXWNvwhAriNG0zNVPaP8wuX/r1g81Vjtc/d5Qyp +oz6Q2wk6tQFH1xjn2XDia9DEXlRiZjUQmCzbKYUoBUKeFtDkKuZscBuRSf/ogihUBK4u9 P4363dsF75A7xsoga5uHOB98XA8c1lM= X-MC-Unique: bJwXkrHVNOqHyDCfj1tj7Q-1 X-Mimecast-MFC-AGG-ID: bJwXkrHVNOqHyDCfj1tj7Q_1771405416 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 01/85] audio: remove obsolete/obscure functions Date: Wed, 18 Feb 2026 10:02:01 +0100 Message-ID: <20260218090330.1476169-2-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405679626158500 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 04:24:18 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=1771405474; cv=none; d=zohomail.com; s=zohoarc; b=KM69d2/85xlLZ6uB4XzvwM/16azttZ4G5BmHHDvYRM7PRpQgIplSQeOqOAzsrXQzfPZOm9Md4VDMLBi+YkECBi+JYF1yudPTF5XgkTtaHnd1QCwgU+uAkKqn3BTFJ+NyIDg03boc6Zz8BuRr2V3Dot2rtw2v2UFYoc6m3fD5ZYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405474; 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=JeddjGhNJCM/DZbXr4WwZpCU+2qH4taFhx9MKvp4ISF6EsIUIpnJkcZJZbYEe3OYZlAe5oiJFWIotSsQG90QcAcCIkGTvIY2OFUY2ZSodmtG9zHj0UURytUcd/FZ2jZy8uM/xtrK+WmEWEHVVLYaqcmzMBKWE1PuliPiiHCYV/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 177140547420454.49026113234402; Wed, 18 Feb 2026 01:04:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTF-0000is-AG; Wed, 18 Feb 2026 04:03:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdTE-0000ib-AK for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:03:44 -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 1vsdTD-0008S3-0V for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:03:44 -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-189-u_NqhBcBPDylA-0gcxcCTg-1; Wed, 18 Feb 2026 04:03:39 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 134E51800342; Wed, 18 Feb 2026 09:03:39 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DEC541800348; Wed, 18 Feb 2026 09:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405422; 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=Tec/7Ee4pmpX10RvcWnYBOeoP2oDyoPjCBJkMlQk2u3jkHaMcr3Ovm3yK0PITOp/ToRq70 X4hWypkziBGxuxzJrJJ5tVqjF4TfDr5ACA2Ogk4j1EK1lWDYJrK5CqVpZsP2meB7JaTIvg mWJplGquX2zFB5NVGKIC0WV3j8ocWvo= X-MC-Unique: u_NqhBcBPDylA-0gcxcCTg-1 X-Mimecast-MFC-AGG-ID: u_NqhBcBPDylA-0gcxcCTg_1771405419 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 02/85] adlib: remove dead code Date: Wed, 18 Feb 2026 10:02:02 +0100 Message-ID: <20260218090330.1476169-3-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405475038158500 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 04:24:18 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=1771405453; cv=none; d=zohomail.com; s=zohoarc; b=W2ZcjjX58+xmBZhjqNvzUqAoHmm3IKDo7FHGO4m6A7FqnED7j7E25k07Wov1W7S8GXONSQBV+PO/+W+E2j5iroxjys9gEF/OtGlZThWQIItUwl7eTYmA+8FxpoB2augws4hBLamgCojwP0AozZqPknJkSyaYVsZEcKinX5NeBBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405453; 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=oFQItqMECfniCGTKutjZOkN7oRKy5uLgAv3MHhB1iKjscnIP6Nv9ZyGu0OQtd1AJ8dtWKAerLp1RL96g2PSn9Jlzg2EKJ5epelxzb/NipOhBPlLv5PKLoRVSFS1d+pCS4ICGDWKqOXzPP+Sx5sQcSoLSGeb5xm/QDMspRGRADbI= 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 1771405453240968.1456892540514; Wed, 18 Feb 2026 01:04:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTI-0000k9-JU; Wed, 18 Feb 2026 04:03: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 1vsdTH-0000jf-4t for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:03: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 1vsdTF-0008Sa-Mu for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:03: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-355-ekLVpFgsM-6o1FDij37u2g-1; Wed, 18 Feb 2026 04:03: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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 86F86195605C; Wed, 18 Feb 2026 09:03:42 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 04F61180066E; Wed, 18 Feb 2026 09:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405425; 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=RhWyMf+ZRrQNfnGICInAG3h/xhN7KDdsA4kofNZ2glYlncSMpzwINBE/VZg/F73oeCiKGb uInKyDwt6c/chs3LuiXTupRDP4NEizpH562Uca0O+L45O9obDONsJxTc4rDrIlDIYFnGb2 YKS1klXEJliQYePv13eVaOHxMmHqe28= X-MC-Unique: ekLVpFgsM-6o1FDij37u2g-1 X-Mimecast-MFC-AGG-ID: ekLVpFgsM-6o1FDij37u2g_1771405422 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 03/85] audio/adlib: drop ts_helper HWVoice field Date: Wed, 18 Feb 2026 10:02:03 +0100 Message-ID: <20260218090330.1476169-4-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405455268158501 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 04:24:18 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=1771405532; cv=none; d=zohomail.com; s=zohoarc; b=oGitSeNSBFxzReasmvny/7L7BS+jRpi8xQL+Dj8bt90kbHzeKtg6bxk+gl6bbekwq57znCtkJGB0BhUSNUBER6vHTurj1lSIBgeHdYg8jhJ3HMgr/++SRH5LBeWRKYtAEH9kvY4024Y8opQqRimHUf3gv57pU7F6HawyiTQAKiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405532; 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=HEj51XrxRXEafkSHanF5JGfgEmKiIeSV93U5JQEPohuQaPRsiL8l6/vWh6LNt4rbuHqxW8k4d82cMNNk3jQh5UWH4MlDboaGAOkPuBY/rUuPLyPqItaOn8cqzjoTKvO4kSTL7Nh/vjNdPT/I56gbN86/4LG1knRTFvNsTmqsIS8= 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 1771405532974938.4947363573599; Wed, 18 Feb 2026 01:05:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTQ-0000lD-Ux; Wed, 18 Feb 2026 04:03: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 1vsdTN-0000kW-9X for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:03:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdTK-0008Su-CZ for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:03:52 -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-556-iFmyfdv1NHSIc8szs5mryg-1; Wed, 18 Feb 2026 04:03:46 -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 033401956060; Wed, 18 Feb 2026 09:03:45 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5B76D1800348; Wed, 18 Feb 2026 09:03:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405429; 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=cc9LIhd9sF03kaOHC7jN96uVadtvFgHcPEujDCOfEp+5zgJOIsBc715X/wx3wUM+P0bD5q LpQ8wRRWNaQkEzNz2dppJ3YhlMj0l2svW5fEhAv6I4ez1zw1Kmb2yVp1VOXHmqLg7whCH7 WA+nVpYIzGDcnkYTP6CFwqLsrcFBjts= X-MC-Unique: iFmyfdv1NHSIc8szs5mryg-1 X-Mimecast-MFC-AGG-ID: iFmyfdv1NHSIc8szs5mryg_1771405425 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 04/85] audio/dbus: make "dbus" the default backend when using -display dbus Date: Wed, 18 Feb 2026 10:02:04 +0100 Message-ID: <20260218090330.1476169-5-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405534627154100 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 04:24:18 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=1771405458; cv=none; d=zohomail.com; s=zohoarc; b=lHhvxBY6aa4VCH0dZoAvIhpmzypIKDV1HJP/BGctVs7U3J0HbOPxaPNozWv202LLpFgKt1slHokY3Zz2v2M9oaqQpn22i1bsS+5DxIQZCuo2MfZnh3+GDYSMTxmc5irmrPcFY+0gs6BWKbNH75VwESlW2GEdTJR3yd0EWzOEZk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405458; 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=arElfYPAmaT1xAmExRMRki4TKwO/qZ7ceTCSr360b42A/XVBddBz86vG959WdGUZzYPk0ikaK99zKcyZjn5AKenUbEXdynQv3UNoEw2LWrfJgaX2VwJU2NM0SxZ5EX9KKWAbWqXljqhMmfGHHEmhNHmMplg6tI58Uz6KTQbG5Ow= 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 1771405458086567.0087818916853; Wed, 18 Feb 2026 01:04:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTW-0000nW-Ky; Wed, 18 Feb 2026 04:04: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 1vsdTR-0000la-3a for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:03:57 -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 1vsdTO-0008T6-Qj for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:03:56 -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-564-uxncDhp-PMC5ImPZ8PKXKg-1; Wed, 18 Feb 2026 04:03:48 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D74201956048; Wed, 18 Feb 2026 09:03:47 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 492B319560B5; Wed, 18 Feb 2026 09:03:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405433; 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=bHNhff2IfSDXWF8LNxqb0aX2AP9FtseLs70yy6KazPIZE+eEo32iFVFHZbvcQB5k9+IbYi eUSrOC3fVuv3sblfH7yqO2B7KPtmUd/Ev/ziDxvYZyfl84X1uat2opVWQM4EBvhxr3NiB0 scSLXKgF+d+5+N5t5GYdg2+iHmwjd7I= X-MC-Unique: uxncDhp-PMC5ImPZ8PKXKg-1 X-Mimecast-MFC-AGG-ID: uxncDhp-PMC5ImPZ8PKXKg_1771405428 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 05/85] qemu-options.hx: clarify default audio backend selection Date: Wed, 18 Feb 2026 10:02:05 +0100 Message-ID: <20260218090330.1476169-6-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405459051158500 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 04:24:18 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=1771405734; cv=none; d=zohomail.com; s=zohoarc; b=Dnq6OfxD8S7yXEufzA+3pS75Wnqx8oO2yrPCNhcBdqwnkZW4LVSuAVDDeGSl2/duBG0dgUuG5+pvS6P2/uDvshRLoM6dVvJNHeobG0T7W9V6IuPJTnroAm4ngTeZuAeUSbcTT5n3ywY+CUaxumw+fScNX74sgzvol3atKmuLgdI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405734; 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=fr4NcQh0VCHzsczJFH1YLhDzlqUJ6OwWinJibA/SeVScibJ7DHAu7g6fR8Cgyy0wiQkuuSwp/Mv+vNdfxVo7ZmQ2TIPWHT9cW8z52kLADKvtje60z6LS4e7hvdwMYr1m//tuFIG3FhwQDCLudOH/8/05+I73GFLpczJE5l7CnVU= 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 1771405734976891.5208455567999; Wed, 18 Feb 2026 01:08:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTX-0000ol-3b; Wed, 18 Feb 2026 04:04:03 -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 1vsdTR-0000lb-3z for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:03: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 1vsdTN-0008T7-Si for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:03:56 -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-495-xDFImHPYPci8YE9JzIwV_A-1; Wed, 18 Feb 2026 04:03:51 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 87BF51956094; Wed, 18 Feb 2026 09:03:50 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DA89119560AD; Wed, 18 Feb 2026 09:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405433; 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=N2+i+KhEheM2XjbQwChC2Uyac0HNwg/ZYIR5kVTHz/6Uhh/1c4KMZaviObWa8ViT/PNGt2 y5k4fyilwuKdUQXdK9vWpFu9wUmYpPO4N1+WWNOdDFJjODMUWDBc/WxI3eoPoom0Hj2sGW +h3b9O0Me3Mq+XWs87kolgDS4f1Pvhg= X-MC-Unique: xDFImHPYPci8YE9JzIwV_A-1 X-Mimecast-MFC-AGG-ID: xDFImHPYPci8YE9JzIwV_A_1771405430 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 06/85] qemu-options.hx: document -audiodev dbus Date: Wed, 18 Feb 2026 10:02:06 +0100 Message-ID: <20260218090330.1476169-7-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405737372154100 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 04:24:18 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=1771405709; cv=none; d=zohomail.com; s=zohoarc; b=U399/gdl1lxAjb4KNZ7HEiXnzK4cmCKDS8R3oCg3rCDjDCDbKe1PRfKHjNGXVtkCBGKw7dI8VoBKVzzltZRvTxJT9STAr5xT71DFbIt2wXrVVSMpMpcldozjFlFeNks+IuLlMHAt8/ceuUFBpjDhlQZtljzNZCT6WXvKcvPVpwA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405709; 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=F6HzRBa2Sx5tAZOkRTVGYxWZyACinqXm+n5TMUiD2QD+9NULQM4UODNzWSSY2RUYmLZkbOAVqN3/uL39WCMOGXPBlh0f8pC083Q8Mov1BTtAmTDEpqgUjPwEg1KhDy5c/wGpoXdUf+W4d80K1H1MhnN03mLAiddWT2GaUa1dVkE= 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 177140570924776.62265599055138; Wed, 18 Feb 2026 01:08:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTY-0000pl-Iv; Wed, 18 Feb 2026 04:04: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 1vsdTV-0000m1-0Y for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdTS-0008Ts-Bi for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:03:59 -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-113-DRB642vNO-mOoaP2SD3wsQ-1; Wed, 18 Feb 2026 04:03: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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6A8E91955D80; Wed, 18 Feb 2026 09:03:53 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D2840180066B; Wed, 18 Feb 2026 09:03:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405437; 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=KY/h9PhujYMZeasRTRtffgUVR/J1R8aFeuUEaXduKC++7THgVNffkp88XiVhEzM70aVGbG IYu5Uvr1cnly7xirrkiZ9CkcgDV9ZN+79tBlhynV6zogSmapLeK2yNEmxv5H2dZEr89CAs KKQDtFz5zUGb108rbUHt0W29OaM4nP8= X-MC-Unique: DRB642vNO-mOoaP2SD3wsQ-1 X-Mimecast-MFC-AGG-ID: DRB642vNO-mOoaP2SD3wsQ_1771405433 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 07/85] audio: replace vm_running with runstate_is_running() Date: Wed, 18 Feb 2026 10:02:07 +0100 Message-ID: <20260218090330.1476169-8-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405711003154100 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 04:24:18 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=1771405707; cv=none; d=zohomail.com; s=zohoarc; b=MyPq0Yt7CJUP5JiZVcLK/YJGZ5wIgeYy0csMxaRhMJdO0DTS9HwZIQ7+AKuZCoETK0uhdKNqCOVGfw7MFhgwaZfDyt35xEcbVv/iz4ESUopRZNuECod7hEppA+THdaVEm6bADlCoBdJzK+gQd4ekCrywuR7ZkO/6xzqdKBUptmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405707; 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=DsI8P/T1h3Ml7Ymy80jwoFcapml6oa507Gj8Qi0J0QpZhXAX9o04DfMfuFv7J6d9+D9rwPFK3YO5Mhpk8TK2ALwJNvXnjP1CxJE5kUClPbuA1Wn4ikLaRm6yu+fw0Tqgdc7d13YT2Pfl8RqkCyrMIh+KhOpww+z33Je6905CGis= 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 1771405707951173.4906024205087; Wed, 18 Feb 2026 01:08:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTY-0000q0-RD; Wed, 18 Feb 2026 04:04: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 1vsdTW-0000oR-V9 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:02 -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 1vsdTT-0008Tz-Tm for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:01 -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-149-xuGxEy2DPFm6aFNb9ofm5A-1; Wed, 18 Feb 2026 04:03: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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6DC4D1956089; Wed, 18 Feb 2026 09:03:56 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4E9AB1955F43; Wed, 18 Feb 2026 09:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405439; 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=BJOuSd7WjD7DN9Jdf/oyr/NuPuHVGULXJvHnvXCaksboIrjYjTRraWrmcqMhjQTlV2cyxy f8q3psJMW7vAamj8v+2kmlIps4nNNkAaKUswB6DOYdE3db5+XIBFI3LPnLNOc3IQPliG8X m/lXCRm0Hp9oSnHtSlgyRzAYRUrbQPU= X-MC-Unique: xuGxEy2DPFm6aFNb9ofm5A-1 X-Mimecast-MFC-AGG-ID: xuGxEy2DPFm6aFNb9ofm5A_1771405436 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 08/85] audio: list backends as modules Date: Wed, 18 Feb 2026 10:02:08 +0100 Message-ID: <20260218090330.1476169-9-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405709152154100 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 04:24:18 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=1771405468; cv=none; d=zohomail.com; s=zohoarc; b=abQPfftp+cmkEAe9y9xCrA7Xeie6MRd9FJIN7gWW6xFqn/2w1ZkYKjHd1tAB2rxB3AENMTlFa3qIIfWF7xWpFc1s/t8dE6fqmqhfIPsz2cgIGkgRgqneAimgKHyTvZ+FWxEVDR00nM1yN2GCWJXKg2vMASJBeF/ldgMcCzOetuc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405468; 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=UPvnfHNhUi87ZOxWWdfN/RACh7u6BKk9IbI2WDh1R93kwTfPlCswrpe8mCTgDsfFOzlomYc6JMUkl0PW+puzm36Y7/ukg3nBZSfuDdtoNZc7nwETlvpH5Z79AhPI0Pfu4JTEIoPaUX4eruDg0iE5Tz1bis50CYklWrFJ5vXrtrc= 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 1771405468329614.6374276222052; Wed, 18 Feb 2026 01:04:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTb-0000qh-8m; Wed, 18 Feb 2026 04:04:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdTZ-0000qK-N7 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04: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 1vsdTY-0008UF-8Y for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04: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-235-KUOJ3XCSML2j5LJajUhWew-1; Wed, 18 Feb 2026 04:04:00 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3DDF61956066; Wed, 18 Feb 2026 09:03:59 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7BDC619560AD; Wed, 18 Feb 2026 09:03:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405443; 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=ILnGkNPs4nadYEVjqRlREYpJiCL7T0STscjYBgGT0EQa+7D63Hl3ltxQbFCit4588lBez3 YzzDPh8X0hKU/CaN4FQje0WxeDhtlGjTueRrRt2blYBwG3g3+RL21Rz6DyQf9LU3RQekwA QgXnw4FxnZWfLtXtf5YozSmds/IIxzc= X-MC-Unique: KUOJ3XCSML2j5LJajUhWew-1 X-Mimecast-MFC-AGG-ID: KUOJ3XCSML2j5LJajUhWew_1771405439 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 09/85] build-sys: create a libaudio Date: Wed, 18 Feb 2026 10:02:09 +0100 Message-ID: <20260218090330.1476169-10-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405469852154100 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 04:24:18 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=1771405767; cv=none; d=zohomail.com; s=zohoarc; b=XXwOWMQ+JKCo9rIN8Xc9FY3J9J0a6lG2CTmVK1J8pPB/9meuZO8lPWmVoZtlVF8hwDqJXlSAdzcoGoR8ldOt+a6eMmd+r1HhTwevRzAO+3f42RgLy6cpEgtZXtWsaNxaGZQyz8DbXOwnZ0zfDHA53G3rc5lhg+ua23usRKtEe+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405767; 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=XvToJHG5X4L9hSbhilsDmJPf3WjQkho8XLOk48yWji8wS+MRYSXIzv6uaFQqky2zOtAKkOETuVOS2zJffTr1vgRyP8V+nwvp4RiGW7fGpWZ+Xbvs7qA7e0NUuLRVN4jJPcbNZgtFq4OlJevdMUkr7HGOz0IiRw2wvig2gTE3Zrk= 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 1771405767825376.533955140045; Wed, 18 Feb 2026 01:09:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTd-0000rP-NL; Wed, 18 Feb 2026 04:04:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdTc-0000r2-B4 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdTa-0008UP-T6 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:08 -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-636-7WZsw2tXOrO1OxMV8KcAbw-1; Wed, 18 Feb 2026 04:04: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 D244018001FB; Wed, 18 Feb 2026 09:04:02 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 29E3A19560AD; Wed, 18 Feb 2026 09:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405446; 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=WyBAD0pK79iKC1EpF25+fiqKbTGGFlxbuV90Tt9INiwiqtWyToS6qUScLVh2j8NkGiqun/ M2N/nbbIGYBe6k0bksUDjS1d0T+VSo3bOsMlYEbIi61cfDh40z4MNrbZoT4oZYY6w7ayBe HriBr1MT9t57jV8sTuhbdMAV334CT2U= X-MC-Unique: 7WZsw2tXOrO1OxMV8KcAbw-1 X-Mimecast-MFC-AGG-ID: 7WZsw2tXOrO1OxMV8KcAbw_1771405442 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 10/85] scripts/modinfo: add type annotations Date: Wed, 18 Feb 2026 10:02:10 +0100 Message-ID: <20260218090330.1476169-11-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405769837154100 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 04:24:18 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=1771405499; cv=none; d=zohomail.com; s=zohoarc; b=TpqJ0sVHR3KkHmqtxF6rU1DTkGY/KtnW70HZlvqayn734F0jv8KI+OD/I7FTMg21EL1ZzWfT89z8FliXQ71TCDS4GhT+B2PuqljcViCGZlTGwS/q1fTuJqupyTLfhvIAfZVwZh67Cva3L3+KWA+bNDPuVtdrS/vrnmEFaBpHpO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405499; 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=RA+eH/ciS43VZRlsseoiIyNYtJMD7oVOfRmg5Q2K0D+b3eDcPqo6Rgg4Utmqfkf9z7dY/I8E0FLtx48eU+OMCxOJ4Pbtw/YAvccw86BboJT2Ea9zJzOGGeG7nTeN75YyXIkZcNN1tsoyNOnQ6VPb4jWSUoNqO1K2ytREXBidBjE= 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 177140549924032.682021115757266; Wed, 18 Feb 2026 01:04:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTk-0000yY-31; Wed, 18 Feb 2026 04:04: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 1vsdTi-0000yB-K0 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04: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 1vsdTh-0008VC-AT for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:14 -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-630-irziDKwHOEG599alx-9hLQ-1; Wed, 18 Feb 2026 04:04:08 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 471141829E10; Wed, 18 Feb 2026 09:04:06 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4CB2A19560B5; Wed, 18 Feb 2026 09:04:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405452; 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=X7KhTgqdysdjg9nGiDGnfF+vPwIAb+dZuW4DaCxxLqIVyKdrq72XjZpkHwoabf7/ymtjZf 8hGHegRo54K2mB+hZope0WCOyFryGNAiusWX1z9NFOSeqoXJYjoaqxvfTOVbZNKeNZZZZZ GDWLhdYbcqbxwgkNT4jdIicSE+W4K1M= X-MC-Unique: irziDKwHOEG599alx-9hLQ-1 X-Mimecast-MFC-AGG-ID: irziDKwHOEG599alx-9hLQ_1771405447 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 11/85] scripts/modinfo: remove trailing ; Date: Wed, 18 Feb 2026 10:02:11 +0100 Message-ID: <20260218090330.1476169-12-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405500983158500 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 04:24:18 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=1771405508; cv=none; d=zohomail.com; s=zohoarc; b=jndDRWqkfq6/YprhycEsrs+PR/dUr0KAyTWoWwuHHkESuIzqhlZ7z9x28FHtduGZ7SrnQLp4s6tzuSWVBM9K0/2KEwAzExVSX0IgVoKnWhOZBo+dhR78XP1PbHpdIqFqv2a/AK/Jlbs5B/FVuFcKAVUGTDkI4ecf8Y1v7EGDi58= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405508; 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=F/sUhD46kt+m92J2Vs/CTmt7SCkuC8Z6rqFwkR4KLwJWp06RYoL2/nWinEVP1JC36m4iOKeOSdnyKaDlo2G3K7dfx1n3GoclWZ2G4tPGz5PGWrEcHgeSnkJ5+LjsDjuHg83FhdLpQOQ47fAGk7pQXJZsdE7eQ3wLTFQY7fDt/9I= 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 1771405508909233.84972677482813; Wed, 18 Feb 2026 01:05:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTy-0001pE-7G; Wed, 18 Feb 2026 04:04: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 1vsdTx-0001li-3r for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04: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 1vsdTv-0008WO-70 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:28 -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-217-OrgK7UQpOZCQHV9qUfPsnA-1; Wed, 18 Feb 2026 04:04:12 -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 0936D19772D9; Wed, 18 Feb 2026 09:04:09 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7CAD23000218; Wed, 18 Feb 2026 09:04:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405466; 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=PBvTpQK5a++a2mYqRQCenETFxEa0Isr0USXiKS6xS7Dduf+jfHD0kGMVu8E7CWIoesu75S fkLtgSTp7kwRMrwNAyu4Sy9zKs2yzJ398SVmEk5DDAlLuR9lPgkkwNG/B5jpvm1c1eF/le nS9uPPXSeIxUUXiV9HoTAhqHUTu+An4= X-MC-Unique: OrgK7UQpOZCQHV9qUfPsnA-1 X-Mimecast-MFC-AGG-ID: OrgK7UQpOZCQHV9qUfPsnA_1771405451 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 12/85] scripts/modinfo: use in instead of find() Date: Wed, 18 Feb 2026 10:02:12 +0100 Message-ID: <20260218090330.1476169-13-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405510135154100 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 04:24:18 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=1771405511; cv=none; d=zohomail.com; s=zohoarc; b=exA0QpYTEvOqzQoQI+kiZKYhajLzKkROEfs8jbifVLZ93SXsVez+6zHjg2kRt64vGHQUBhDEiT6uqAX2nYaSyckjbC0MNu9VmPKLVJ9BFwkC/yL+xyGXA7oag+WTN14dupWhtKvBzCt4JUqVTInL0HTWUauKtsGSfrqA5lnY7+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405511; 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=lqAdkdbuKKIG3rZxuhLDq7EBb4qbURb6bMiC0xkoLNjErh1A9oxVWqNLTNorP5NmrmG2xHj4Nh6vegG2StnqB8M5xOLfCazuqNP2YS9F9+suXWql1D7jDzLzrRofV8ePxvH0em3zulzlq6OQ0fkuqMfukXO12qdghmULfzzKXFE= 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 1771405511002234.94358177641823; Wed, 18 Feb 2026 01:05:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTp-00015N-Ju; Wed, 18 Feb 2026 04:04: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 1vsdTo-000156-2Q for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04: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 1vsdTm-0008VT-KC for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:19 -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-659-E0V--BqFPY-y8-fs3zRBFw-1; Wed, 18 Feb 2026 04:04:15 -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 8191A1828B6A; Wed, 18 Feb 2026 09:04:11 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DB778300022B; Wed, 18 Feb 2026 09:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405457; 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=F3iM/ezKO+8ZdNDU96YLImAagktzFNYQlw4j+gRpogkN26hQ3nQyKjkmXfJxoFRYxQQMcx Y5VPibUvHs1zAGVVaOzUIK2dr3/bQ7W/kSVgOq+U6foUK66oa9LzXOfQ95OfThFCYA4RgS tAuBl85xyDlS2Gz9c3VK9xJTs9jI3z8= X-MC-Unique: E0V--BqFPY-y8-fs3zRBFw-1 X-Mimecast-MFC-AGG-ID: E0V--BqFPY-y8-fs3zRBFw_1771405454 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 13/85] scripts/modinfo: use f-strings Date: Wed, 18 Feb 2026 10:02:13 +0100 Message-ID: <20260218090330.1476169-14-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405513141158500 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 04:24:18 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=1771405587; cv=none; d=zohomail.com; s=zohoarc; b=MLr/FJ9ENsWqc5BhI+diTHPRf0YcvyWU/pkakoF9GZDqTtEOza8aEEz+V5XBaADRGr2jZGKDQYIa/BZKjq/kc4foagpFr+/NydSG2BZYc4UTL1vjS+AdduqI6XAA45424gKITQ/DgB0jZembltM23CNDiImA5/IZzjLuxotTjtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405587; 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=OapUEGfIqNWzqiBUasEyF+ZoXHnTG56JjAyz+DH9cbWvm7/SsPZHwBGrpy0LiJ1s/3XninsYuI06cwL/YIC1JUqXJNk6vq5wYt6uHS3aXOxeR3yiz1ntXT/mC6gXldv/UZwot4Jj1KUdv//kcacZrdqbdBywxgla/V9GjCFL6+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 1771405587642160.74260001408095; Wed, 18 Feb 2026 01:06:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTs-0001Jp-R9; Wed, 18 Feb 2026 04:04: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 1vsdTq-00016b-GF for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04: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 1vsdTp-0008Vt-2G for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04: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-34-851m5XOgMTCNvgdXnHuTrA-1; Wed, 18 Feb 2026 04:04: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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 348941800639; Wed, 18 Feb 2026 09:04:15 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DD4C2180087D; Wed, 18 Feb 2026 09:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405460; 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=Z3WL7ZUhI9b2azuA7QoWDiR/qKIJYt+Oo5+eG+o6NBZYlXY6b9lCEBUEhHjxtE150nI92M Sm8o5e211Rwld0FO9fwWw5P5BsRBSBiesgngik2t9l21CcxfV/swXXq4sjLJ+BgslU2Qkg 9Eya0G4yzxg9i2yZ4x8OmQRD0RocRZA= X-MC-Unique: 851m5XOgMTCNvgdXnHuTrA-1 X-Mimecast-MFC-AGG-ID: 851m5XOgMTCNvgdXnHuTrA_1771405457 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 14/85] scripts/modinfo: use argparse Date: Wed, 18 Feb 2026 10:02:14 +0100 Message-ID: <20260218090330.1476169-15-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405589384154100 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 04:24:18 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=1771405477; cv=none; d=zohomail.com; s=zohoarc; b=DyFiEreAPFOAWErh5JeSDPnkOgayyvYuQy5WaR6HAwe+M8qBGRNgiQu3tWx4jdT7Nx3VMjsaT9ntKLUfT3KbzeugwQ8sxa61SgU7BNuD0qyHgtDlLI6Wjbshz4QUS1ahc8s++/ZwDDLBw8J8LiU2zhFRwRbSuLDX3to3rGrlE78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405477; 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=H4P8DX6cAH54tfdzzsdDXeCD1FgvrFwuqJSizbVqjz9mijo867gEuITpk64NL4wbLZHhihOlWNH3yYj3tSnU2Z51ftcid2rBn2zv32QL5R42V1Fu8dXogT1fuxlHOTZ7+O6Hmz45VNWupfjO8bXpYzx2yeJPA6BGw2NwKaBeUQE= 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 177140547745848.522946029011564; Wed, 18 Feb 2026 01:04:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTs-0001FT-4F; Wed, 18 Feb 2026 04:04: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 1vsdTq-00015q-Du for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04: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 1vsdTp-0008Vr-0I for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04: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-639-gO5Lv87YNSOzp5LetEefeg-1; Wed, 18 Feb 2026 04:04:19 -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 D83641800A3A; Wed, 18 Feb 2026 09:04:17 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3C83C19560AD; Wed, 18 Feb 2026 09:04:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405460; 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=FWszGPi4zzcTt3NUSQm8TDjZMq9QF/+gvBaF57OkwszaGpGnlikZLvWzqjWRoBatg9cnJM He/51pY54Albok+dQzH9Ewnjzu+xCpNR4u3Mj8bX4v6i8n1kANCsmj7RBHsr/EeGQMQYaj XgYlPM9v4X2rPpTuquZIDMSDnaVdn3E= X-MC-Unique: gO5Lv87YNSOzp5LetEefeg-1 X-Mimecast-MFC-AGG-ID: gO5Lv87YNSOzp5LetEefeg_1771405458 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 15/85] scripts/modinfo: make --devices optional Date: Wed, 18 Feb 2026 10:02:15 +0100 Message-ID: <20260218090330.1476169-16-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405479667154100 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 04:24:18 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=1771405713; cv=none; d=zohomail.com; s=zohoarc; b=LKKVEwLCm8eG5PhY4SoOnUMj2xi/fiZTIfYudDX4mPoFJ7Vxhne5Gw3TOT7QZATYikx6EhtHjdgj/1L9bBWp3L9XciquuLI9rhBKilQqNVqxoyoiueredtbRktKh3+NNVX8M3r04oBYBj1Db1s//XyqWM5n5N7ics08RS9ZhFGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405713; 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=PdhObulqKsGku+SA9FqZEHq/WDXSFnpfbVEVkkt7Zqk/kW8fl2etrhr9Q4l0+Fgys91kctlOSp5ZB3+KV2cRaZhHyEYUIv6xyE6SpKkDgby89c4CnbEdRmy3OZohq23rr8AKZZKaUEYMkQA6gGGp9/SCMqnZouvQIqRbFefqnSQ= 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 1771405713201996.0703027718896; Wed, 18 Feb 2026 01:08:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdTx-0001oB-OJ; Wed, 18 Feb 2026 04:04: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 1vsdTw-0001gn-2K for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04: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 1vsdTu-0008WG-6e for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:27 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-210-qnmTIH6gOFWQ7GJxwT4uNQ-1; Wed, 18 Feb 2026 04:04:21 -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 6D08018003F5; Wed, 18 Feb 2026 09:04:20 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C526019560AD; Wed, 18 Feb 2026 09:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405465; 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=FvoyNw8rCiMdMGa/Suokkc/k0YMXZYM1UqkoG34Il7q3FEzT0DUe6ds4WDokPFxCpiO0Qw VZ8VZUTNDj6Ufv6tRhUT5tt7a8Wqb1Uh6YMpX2VnKOrmf8mfSGHAMNyTDpdASsjwGIYYk1 3kI1U5OZNkhLYA4e+dsVP83E4+TZ/48= X-MC-Unique: qnmTIH6gOFWQ7GJxwT4uNQ-1 X-Mimecast-MFC-AGG-ID: qnmTIH6gOFWQ7GJxwT4uNQ_1771405460 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 16/85] scripts/modinfo: add --skip-missing-deps Date: Wed, 18 Feb 2026 10:02:16 +0100 Message-ID: <20260218090330.1476169-17-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405715093154100 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 04:24:18 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=1771405661; cv=none; d=zohomail.com; s=zohoarc; b=IjFZLMpx2VzaYbhjNb6Jld3iWzI+bl9sGXJAYm8yTy87DMXbJe/s4RpB93kRHJFd96PV7H+mif24UH3hKf3shAZBbbbRNtsoliA/fitfRUap07BVHFYElwbgtMDc6BBahkO2pFFt1xpqISVBet3/8AqMzHojrCuK+PTTw9Kxowo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405661; 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=Vf0+P+3uBtJmixGJRnxVcpBwe9exahKcyaYlo86MSCKjDV6xLW4o314tRGPFZHCxnzB2NoqMxG5UDUWpaEL/vgfPEC0aM+BMyp2szZmBYGk/OOiWkiFBWgR1DGcVMvGTdZB+c0z2qq7rnxGT+3UkaCtHHgrpAPJyIey67APUZDE= 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 1771405661372460.3449319880592; Wed, 18 Feb 2026 01:07:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdU0-0001vx-Bv; Wed, 18 Feb 2026 04:04: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 1vsdTx-0001lt-5h for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04: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 1vsdTu-0008WK-Nu for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:28 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-685-SM-96X2-MFqOlVy_SRhZEg-1; Wed, 18 Feb 2026 04:04: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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B5CAD1800451; Wed, 18 Feb 2026 09:04:23 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BDE021956095; Wed, 18 Feb 2026 09:04:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405466; 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=W7R8MO5OeLcJ1QW+X335LbT2JVnqcOlInPvJs9Ko9xVKB5TYkRS8A1OtkfzXWif10JLuZD EX+xTlsSHVNNAfANs6GH+dZXmo8PWTfioPY9jrnHFlig2CIp0MYhlfmrfhrVOuKZ7aD8FU L5JgSntH7eqV3Rad3kW+b+W+C4ALyn0= X-MC-Unique: SM-96X2-MFqOlVy_SRhZEg-1 X-Mimecast-MFC-AGG-ID: SM-96X2-MFqOlVy_SRhZEg_1771405463 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 17/85] util: add some extra stubs for qemu modules initialization Date: Wed, 18 Feb 2026 10:02:17 +0100 Message-ID: <20260218090330.1476169-18-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405664020158500 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 04:24:18 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=1771405811; cv=none; d=zohomail.com; s=zohoarc; b=PsJl+Ug57giZVHzOTSFSCFHm2GrWpJwySlVysR/UQ8P5jhVoWB9jkA1j8MEnzthRPtDmB20Gyv4CSn76KobHLRb2KkLNi7S1+aN5V0fcYj4uSItckzWtYv+Jl3sBa79LKP5ipH03hBAibogz0tZcpJVzbaYcLxa8dKzCHDsCuqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405811; 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=SJP/flYKvN9bU1g6J/5ioTXLq9KeK1zWwxygHBxBjeE=; b=Z9Kirgqfw+sJdXbMYx8DAdhWqEuHGwjNm3iZ6Vhrs1LBd3N/NO/o3TOYKR3+n7QalOM1ZD8jH7LtPlDgF2427o2KsIash1PU4KxzjI5P+1rh8Hz/VNLbM474gHPn33zN4YjCcietIAJ6WDJOO7lEjeW3157h3prNQ6nYkebpFlI= 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 1771405811667287.60512058567804; Wed, 18 Feb 2026 01:10:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdU5-00029u-1Y; Wed, 18 Feb 2026 04:04: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 1vsdU2-00025T-IQ for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04: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 1vsdTz-00005J-Mq for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:34 -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-460-nA68aN45MbSNaS6ggs4f4Q-1; Wed, 18 Feb 2026 04:04:27 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 49DB919560B2; Wed, 18 Feb 2026 09:04:26 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 843A51956095; Wed, 18 Feb 2026 09:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405471; 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=SJP/flYKvN9bU1g6J/5ioTXLq9KeK1zWwxygHBxBjeE=; b=DWpKyW40UtLIpf3FoMOpzdtcJc+W1VCXJaz1CfpTEiWA065DUQPHVRCIMxOt7+y8A41yve k8q8pqYpP0ItCkSd+c0/UeMv+pmHJKFEpl66Y+XBTRDcuMTHNd3OgTHQKq0sKktLhRi2ah PEJ5qN8Ogy9oTja+kAm42J5X10g5aN4= X-MC-Unique: nA68aN45MbSNaS6ggs4f4Q-1 X-Mimecast-MFC-AGG-ID: nA68aN45MbSNaS6ggs4f4Q_1771405466 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 18/85] tests: start manual audio backend test Date: Wed, 18 Feb 2026 10:02:18 +0100 Message-ID: <20260218090330.1476169-19-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405812190158500 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 d3aa6d6732d..f52ead996b4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3034,6 +3034,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 04:24:18 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=1771405563; cv=none; d=zohomail.com; s=zohoarc; b=LxqA8M9FvGtO4q5CAyTSA1lQbS1SawoTX/gGFz32fNdfexIjtm6Jcq8gIh5yIrxcjCpm0nCRpgTBA5T49i4YxKGu5+jK+0AItZZkXTVWOr3Yia5JF8+sbYseF24yinAgNdqLeFjiFo6HAi3FzYTsjCLY0207Sw7JHcawFcxbC2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405563; 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=cLQAXdeVtkZc3Om3tXhSATa3RN37pQZaRkh1ncyZqP7IEY21ph4WEChT6cnyjk5eO27WB72DmfBFL29lzqA7poXqnNxcYmyfOf+zCU6AkGD8nciQtgNclp7wLBLgbiyVhLL56sveGphbegu+RvWqZAUFm3E0ZqgOdnJNOJ2vg60= 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 1771405563597604.7583308837746; Wed, 18 Feb 2026 01:06:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdU4-00027o-Iz; Wed, 18 Feb 2026 04:04: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 1vsdU3-00027T-Lb for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdU2-00005q-4h for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:35 -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-104-V_i4JJh8N1WAUNSQHMUrgg-1; Wed, 18 Feb 2026 04:04:30 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 332FD1956066; Wed, 18 Feb 2026 09:04:29 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4ADD319560B5; Wed, 18 Feb 2026 09:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405473; 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=DOC+YmZDaFfk2Ha+zmZTzYWunBfyWzOy63fap71JVoKDNrHDIvcK8OFFf+yRJW1IDEIXiO CJ2x1/cHBJtqBMFrU65jwazSrvT5dD+CK9qFNwJ0PyXD3ltxhT6PzSoBgsLetEPQKU4vwp ZoIVzdsTfqsVTWii0CwXpZs2q82y4EI= X-MC-Unique: V_i4JJh8N1WAUNSQHMUrgg-1 X-Mimecast-MFC-AGG-ID: V_i4JJh8N1WAUNSQHMUrgg_1771405469 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 19/85] audio: constify audsettings argument Date: Wed, 18 Feb 2026 10:02:19 +0100 Message-ID: <20260218090330.1476169-20-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405564926154100 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 04:24:18 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=1771405508; cv=none; d=zohomail.com; s=zohoarc; b=MQ0uzlWKdkD5TS99Qniuin5jAd/2KkBxzmCdxueMm0J2dtMWe1beuCNsNInBIHWcxgEeqabKsvLDrCzDKc0T4L9J/88TGrin23roU05F7u6xu3I6aPgbPSXfW2QBjI4LshMwztMNifuGRLDj+7rXwlf5afIkzc6fGSlLztWqVZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405508; 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=AO91rRNpchQzT6zGbBkFvDISXnkDnCt2u4szZwuYAZp5XvV0CEXGvWLABnnk6Omt3x9xDm8QIajem/AYsPsQhkQQ+LGbaoUU4Zis5YOPS3EuOvJqNsJ1HyPsiLuFuG0KXrRKIyd2powEGoN+VWDf2k+o24EeeIGkURaeY/2yr+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 177140550869613.939127100907513; Wed, 18 Feb 2026 01:05:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdUA-0002ZB-Er; Wed, 18 Feb 2026 04:04:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdU8-0002R1-0U for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:40 -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 1vsdU5-00006N-BB for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04: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-435-mNIYwv3GOba5BHYe4PlY3A-1; Wed, 18 Feb 2026 04:04:32 -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 D54B21956060; Wed, 18 Feb 2026 09:04:31 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2AA6A1956095; Wed, 18 Feb 2026 09:04:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405476; 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=f9hwzZP0Aa3KXam/I2ZfHzM8qxuiiMcqm0Sjcma1NMivBD1b8qrI0a7wWbEdFYfelg/kBf YlrnzNavK93/E8xqWGEpe5wSNTnFSUjn68juz58J4IzNscKlyjkbT50a6qL5cJ/3fwdq6D z60cP2sRvPa3R/27q12U7gf5AG+uZBA= X-MC-Unique: mNIYwv3GOba5BHYe4PlY3A-1 X-Mimecast-MFC-AGG-ID: mNIYwv3GOba5BHYe4PlY3A_1771405472 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 20/85] audio: introduce AudioMixengBackend Date: Wed, 18 Feb 2026 10:02:20 +0100 Message-ID: <20260218090330.1476169-21-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405511190158500 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 04:24:18 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=1771405722; cv=none; d=zohomail.com; s=zohoarc; b=WayJvWL2REaCCc1T1a59roaVYbZ/PGBYineCd0ieuKpPfTvb+vFIgg1hyG7l5I0+PoR2dJaNmBb69jtPj/A02fj/Z4wqgOg1yL/cTRVc6XyzdItT0501dOWHQAA3xpa964Qha3jy4E64Suzrq+J4ji4KSVzxMKKcN9Fd5649mzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405722; 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=NMnwSGAPg/jQTQ6Kvf4uAR+KbJNEXJK2lwWPjepytAbFFPxKcIFpilo7A9APic0wahlnZZ3i/kucJh7KUE0Hq77wgYJdFAY/Cti9qMAGFbtUv2c2pDqLhzNdq5kyJ6ojc50RSL2l+FTR4iwmgOS9sQDcCYrG9HmjZG56VdkoqD4= 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 1771405722528877.4221961399022; Wed, 18 Feb 2026 01:08:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdUE-0002fT-BM; Wed, 18 Feb 2026 04:04: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 1vsdU8-0002Ua-Uq for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04: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 1vsdU7-00006Z-Fw for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:40 -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-180-d9Bb1l8ROlKdO-AtJC8Vhw-1; Wed, 18 Feb 2026 04:04:35 -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 735F91955D76; Wed, 18 Feb 2026 09:04:34 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E51281954107; Wed, 18 Feb 2026 09:04:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405478; 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=TbOcF1oR5vadrKoqpcr1oF1j6O3GWC24I6o6EYITzk5rKwPi0gPCkax8Y58BenwDwlIHkb L+QMxDFp6vYxCtemdoWWryPRD2E9G5MhxocdXNyPuuh0NQzE8snfTQEknhCkxgT0lYHHIx mHZ15A6K4zcrQcsKj0NRbZuCNBgpdVM= X-MC-Unique: d9Bb1l8ROlKdO-AtJC8Vhw-1 X-Mimecast-MFC-AGG-ID: d9Bb1l8ROlKdO-AtJC8Vhw_1771405474 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 21/85] audio: use DEFINE_TYPES Date: Wed, 18 Feb 2026 10:02:21 +0100 Message-ID: <20260218090330.1476169-22-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405723785158500 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 04:24:18 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=1771405519; cv=none; d=zohomail.com; s=zohoarc; b=Iu2yxm5Ezx2/iP0byEiksMSur1KF0o93BE9ycc8slN0C5g4m5bP5BZWq8FG4MOLe0kx+x9jKKuohq1Rd8Y0qYW2kzqMjnbL1AO9Oo4yTjF+/w8caRaP8JO2jvlP2weP5hLK1KG2SgXq1OxRk8MS1wKulAWXGjzBoNtki/iTP1aE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405519; 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=D4WfFJEcRYZaF4civaL3cyx4+R1rVMQ8g68/xJHb9RacTzseoxirFXiZZRTFC6sDFhPfg2TLAcwLKNIRHfHp4x3UvwOgWAFy5q9znNT0tcQE478uSO/WJQ/plIzOKlGuDgUshGZVDtWcx2nugcgvJoNimMdP/6vLZIRoXSSiw8o= 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 1771405519240434.13896290026014; Wed, 18 Feb 2026 01:05:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdUW-0002nV-Sh; Wed, 18 Feb 2026 04:05: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 1vsdUB-0002c4-Uu for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdUA-00006p-Aa for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:43 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-v0J110ggOyuVOZN-IKATyQ-1; Wed, 18 Feb 2026 04:04:38 -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 6D12818005B7; Wed, 18 Feb 2026 09:04:37 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C4A3F19560AD; Wed, 18 Feb 2026 09:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405481; 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=ZcB2OxJamJUp2+5lZCg8cIUmtwOwczicpY92U8hd4hGlFze9xCOO/At0S9hu+bJmoFerQ4 8KSVXEIhy8Q08nDtuMTT3J99isGyd0aKpRpeQBWjwgHuwlpzAllO/IQm5Fa8DY1GxhMs86 YkY4hXN+X8OKzWfsEc3yoAm2XH6/RFk= X-MC-Unique: v0J110ggOyuVOZN-IKATyQ-1 X-Mimecast-MFC-AGG-ID: v0J110ggOyuVOZN-IKATyQ_1771405477 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 22/85] audio: simplify audio_init() Date: Wed, 18 Feb 2026 10:02:22 +0100 Message-ID: <20260218090330.1476169-23-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405520315154100 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 04:24:18 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=1771405805; cv=none; d=zohomail.com; s=zohoarc; b=AgwaG5lhJ2vq0khM9IG+mswyUkF2V0MtRd3V+TQI/c1kvH9Poo6nnTKDDpjNhmGaWRTooIslDHZT5orrP+4LCs2mC1UkdqwxdQlaoUbpwH09FUnkmnmnbWOU308FfI3h9ILXJxHlQq2gYPxGFdPiYsmwN2iRa4DymSu15gc0P3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405805; 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=DMK0K4EZGsy8HuSZgbhZXZyBBTAfBUwjnLUP1+ksH3ef3n0CFXd4UEIsn+vUcXGuW744L1L2SOWu20ce6/0qnFA31E7coEMRpIMXn/KX07EguaAL5iJzmd68bqk53kMESgsTMQa0hEyMdEaKMikAA4EKlChKIUt4bV9RIqGSxPw= 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 1771405805449259.5618067527621; Wed, 18 Feb 2026 01:10:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdUb-0003CY-UQ; Wed, 18 Feb 2026 04:05: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 1vsdUG-0002lU-E7 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdUE-000074-BB for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:47 -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-390-2PbopVKnNxGPK66rUM-Hew-1; Wed, 18 Feb 2026 04:04:41 -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 A99621955D8B; Wed, 18 Feb 2026 09:04:40 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D60BD180066F; Wed, 18 Feb 2026 09:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405485; 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=gA9TI/Lg/sN/KWK123MzgCjSmzhW7oE9Ao7v1DQ6YYYt53f/UwZCFTewVGfV0RH0HjucSJ dPCl+jTX7oHhllVLbigIQVQpfdeldMrS+qwQr/T6dG+/mLmPIIbvFB8Fqbpcf6I5uMogZd fjxBKzqweevMNbNmMoD3rRoqjD2eLW8= X-MC-Unique: 2PbopVKnNxGPK66rUM-Hew-1 X-Mimecast-MFC-AGG-ID: 2PbopVKnNxGPK66rUM-Hew_1771405480 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 23/85] audio: move object creation to audio_driver_init() Date: Wed, 18 Feb 2026 10:02:23 +0100 Message-ID: <20260218090330.1476169-24-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405828627158500 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 04:24:18 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=1771405576; cv=none; d=zohomail.com; s=zohoarc; b=aE8Dd4TSPIjR2JEifyep8AKGd0faYuJHnReiqv7GcBe6XmoEXIYAMBXNsNl0BOxyCzNEYlKOs0GHkpcVGwkHB09ByMvP4n13eaJCcqw/TRddT2LfLuFmyNzyDv7/S6lWcCVREbKrjZOar3n3vulZH7xZfeKpGM6Bn8HLVnmN95w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405576; 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=cOeaUnptzNJAjjDn5IbCb+xkSKW2YS/p4FaF0vrsWS5lD63idB9B09j6WqAqF1HHFpfyH2GEJmgmY+f4h8PndIg/9kliM9SM0dVm7oIVVBlBrDifPYSXMaYuuv70Vk9fgxTGn70PEGMS87Gi4prCo3N1r5GxEtlUwAIctu6sgxU= 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 1771405576987403.99897179188974; Wed, 18 Feb 2026 01:06:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdUe-0003R2-DT; Wed, 18 Feb 2026 04:05:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdUO-0002nd-Tn for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:57 -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 1vsdUL-00007l-VT for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:56 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-465-iTdf7s4XPIGdjLSr_PKgZw-1; Wed, 18 Feb 2026 04:04:47 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AFD1B180061C; Wed, 18 Feb 2026 09:04:45 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 897451956095; Wed, 18 Feb 2026 09:04:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405492; 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=D9bXRGD6JGS70BlP1mlnU3AY3HUvprWvqWm/ij0xgYSvytpG78NEczwHxKkew/4veuENpJ q8JFg6bbI5iYch2f4gEDmkZ/9h7dq9Lmfi1NtZNeiTJN2uDILZiSS0zwhi8MHO2pYzaj7j HqgLte53hrHQhUmGnX6hv6CwL+LIdnk= X-MC-Unique: iTdf7s4XPIGdjLSr_PKgZw-1 X-Mimecast-MFC-AGG-ID: iTdf7s4XPIGdjLSr_PKgZw_1771405486 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 24/85] audio: add QOM module-objects for each backend Date: Wed, 18 Feb 2026 10:02:24 +0100 Message-ID: <20260218090330.1476169-25-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405580226154100 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 04:24:18 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=1771405715; cv=none; d=zohomail.com; s=zohoarc; b=Egfu1SWf1Ld5g1xLPn2HLVSATFydp0cxl66D3+FBry7x2EaQL6jnsIRNYCkHJ90/gcnhcp2Dcw4Wg8hrQ+AthHX3/bOE3Q4o06YiVqzIiD3AFvVica0P6jmenrNPHPbt7cYIK0jdI67tlPVCuccc7Wz++h4I3tlBSiv21D0Y89k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405715; 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=WlSD9IOJtpxHd78otCCcI/i7BbF+6uv6qOX9XnZXs5NuGYPnR7DnKi9hrfaptHZ5ANLJxJQknPUxDsYEq7YCV9K+yv52QZp/vwLvCo5obfHYXfyg4f+duLumKRCzhDKq6trGs3ttWYfEomxXVDkeWqc2rb0sWsMy1jY+q2VX4pg= 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 1771405715826674.1301478016532; Wed, 18 Feb 2026 01:08:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdUd-0003Le-Ki; Wed, 18 Feb 2026 04:05:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdUN-0002mk-Lf for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:56 -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 1vsdUL-00007r-Ug for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:55 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-2-fjaNbBckP2i7AX-rlpB3Cg-1; Wed, 18 Feb 2026 04:04:49 -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 AD8BA1956061; Wed, 18 Feb 2026 09:04:48 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B9F3D180058B; Wed, 18 Feb 2026 09:04:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405492; 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=h+aBoMknTiF/cv88COKeFWWOs3blzvuXnr96/tU69sKptiyxDE0Bfj9jb+w79NnIlwPcwX UntH50WMw5QLJO/Gc8gYlEpYLpQbBwhkzUuQwgy3RVZmuea0Qc8MinREJk6P2FbiVyyDQk 55/LYMEO05EpocgPLZxwCvT/jt3q/oA= X-MC-Unique: fjaNbBckP2i7AX-rlpB3Cg-1 X-Mimecast-MFC-AGG-ID: fjaNbBckP2i7AX-rlpB3Cg_1771405488 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 25/85] audio: remove set_dbus_server from audio_driver Date: Wed, 18 Feb 2026 10:02:25 +0100 Message-ID: <20260218090330.1476169-26-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405717706154100 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 04:24:18 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=1771405843; cv=none; d=zohomail.com; s=zohoarc; b=cKrrImh24fCiQhyw+YCC6TaIxr8vr8t6FPuk0Ak2qcI5ewfA43sHdoM5JpfQFvFpVEPNd7fp2O4ORv8mxzEw2Hon8pa6L/G04hiS+reyvBsehjcXSWJTXkj3sommXyQLxiFv0ga5UOgzaIFegafWDn9gw6h4mU2+njxkApCn4hI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405843; 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=XVeu2S1m5zPw4QEO5DQsLESNUHrQjwmg6Ct6PGPuSvbISBapXy4VUw+jSpzqvBK6DxZ++s4X3vaS8AvH9z6DGxKrKftjSUXJV2mhIZ7EAweKGt+A2yoykeQKNw2MBIMdZNuUbtEO2F/RR61LGLVsUBvNTw7JxBE/nVNnwksEdtI= 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 1771405843404580.8682567294376; Wed, 18 Feb 2026 01:10:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdUf-0003Y2-88; Wed, 18 Feb 2026 04:05: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 1vsdUR-0002pZ-DU for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdUO-000088-1a for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:04:57 -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-321-U2R6vF2aNrWmZRRoJ5ri2A-1; Wed, 18 Feb 2026 04:04:52 -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 353341800352; Wed, 18 Feb 2026 09:04:51 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8121430001A5; Wed, 18 Feb 2026 09:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405495; 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=CNwNhlXhSnWQ+YBG4IZ+dLVG8YjYR6BUKhZ/0V7ravULhjS6wTXTcB74ANIKLdN3xBKzF9 1Gjl4AWnz3ugsGjKicdwQB0YHJg4J8dyrfgXCpRdnt5Qq9p0ISu1e4roI+tZgM8Lrm2VzI mFOzEUdV/9So8eTu45BiooQODGXKa+0= X-MC-Unique: U2R6vF2aNrWmZRRoJ5ri2A-1 X-Mimecast-MFC-AGG-ID: U2R6vF2aNrWmZRRoJ5ri2A_1771405491 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 26/85] audio: lookup "audio-" object types, and realize them Date: Wed, 18 Feb 2026 10:02:26 +0100 Message-ID: <20260218090330.1476169-27-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405844209158500 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 04:24:18 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=1771405527; cv=none; d=zohomail.com; s=zohoarc; b=h1KHnK5RqiJ6Paw/xLk/+6X+NhgZoNe3D4kJS0wbfYvFk6uCy7Vq6PK5CB3/oAs4yi2gjGAIbKAReCgWbgFq4s1w0ZpEcw3NcdeIywDObrwK4/DNEhciIGItZDC0qoFSd0saMb8HIJnckkSB5kPXblGPXQKx2G/nD5T/F2UKiIE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405527; 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=RRmt3rclHGTHdsjMCkvNcgmCKgs3p67cRWfUWedKMN3HkayV2vXvQgjNEZRQKJvfHPbbXd6Df8T8RYtApeUv6DSRb0URziR74L4v79Z7JbWxPS3Kl6qdzSrAFMM9hUPH51nrWEaZx1irJr3PLKKlm2DSTN6QkPjW2qVC8tcqcDU= 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 1771405527487269.7034860490518; Wed, 18 Feb 2026 01:05:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdUc-0003FL-Dl; Wed, 18 Feb 2026 04:05: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 1vsdUX-00031Z-BS for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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 1vsdUV-00008y-2g for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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-449-9Sju9SOKNBaBYVAfCFExPw-1; Wed, 18 Feb 2026 04:04:56 -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 9F593195FDC6; Wed, 18 Feb 2026 09:04:54 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2E37F30001B9; Wed, 18 Feb 2026 09:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405501; 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=YQw71Wg2U7n/ZONsuyewwwFy9hClfdmsfgAT4oG2DyS/o3/fxQlr0EmGACzbPpMlq8GDqx /KPBj8VSWWsi38SJADSQ6AEST2ceaiOiycTrtRWMqGu7ugkyxpI8OvEN+zxNjTCdZh3X2D +X4LlClJz5akwZrYewYn9SYeL6dFBkk= X-MC-Unique: 9Sju9SOKNBaBYVAfCFExPw-1 X-Mimecast-MFC-AGG-ID: 9Sju9SOKNBaBYVAfCFExPw_1771405495 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 27/85] audio: drop audio driver registration Date: Wed, 18 Feb 2026 10:02:27 +0100 Message-ID: <20260218090330.1476169-28-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405531418154100 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 04:24:18 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=1771405675; cv=none; d=zohomail.com; s=zohoarc; b=bjm4FhPLLIgGMLR57qLlT9uyxnx7OQG1osd/taCo9zcLRMHt8JReIHif6q+eUMkeI/dNfvnGWkBroUaX3PfqoaWLX2ZMO/mv95eJkXvXVT3hufqJpMcV7eLZCr9M1vBHoySj3z/uKfT0760NF8bI1WBhfSpwU92GCGG6MmO4Cx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405675; 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=foUVgx2Svg06nBFUTh9WRbRNyyNV7iRRTTSfuQ2cIHjRpS9T45pZgwci4mY6971BIx4l2RY6en/Qx0V6kBnWvedic6LwZj2Z7TzK8BcKzoKLkyEBFDFnUjVxoeDK3M/2BqJKQ2NLdP4/0MQk46RaANE/pk5lVrszFfPavIu+D5Y= 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 1771405675390215.7859442920393; Wed, 18 Feb 2026 01:07:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdUg-0003fn-F1; Wed, 18 Feb 2026 04:05: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 1vsdUV-0002w1-Ed for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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 1vsdUS-00008l-KD for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:03 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-324-2Zae4jCePmSP2UhRgSScKA-1; Wed, 18 Feb 2026 04:04:58 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7DF7F1955BC7; Wed, 18 Feb 2026 09:04:57 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D5F3330001A5; Wed, 18 Feb 2026 09:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405500; 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=UY8NOV9RBVtpud/iTXAXdIpCAW4Q8ROJDsj7DXrn5dFbj//jMiiltnDrWHpmufATAvRb1o nBoGBTA7dsqkfNBLlNGbE+HZIbQoXWgVtdzebY9NnBKhaAQ8R7x6tHV+0n86F80izKYRCk 8WV6i+90hMJUn3B5FmmlvNGQWOlPlmI= X-MC-Unique: 2Zae4jCePmSP2UhRgSScKA-1 X-Mimecast-MFC-AGG-ID: 2Zae4jCePmSP2UhRgSScKA_1771405497 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 28/85] module: remove audio module support Date: Wed, 18 Feb 2026 10:02:28 +0100 Message-ID: <20260218090330.1476169-29-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405676494154100 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 04:24:18 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=1771405946; cv=none; d=zohomail.com; s=zohoarc; b=OkuUMvg2BSvvDnNrfiMuyWovPkLQclvQh9u2kyp1WwL8AKvJ/c7Qq6cYw1xCpoQnA4mM9nzGQZJNRr3iltWJvBKC40oyiW+O1KYnS8g63MYbaseMX5R/g5nE10cvFGBzmEH1eaReaejcoiAZjbybD6VpGMvTPaPjS0ERcuOwRUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405946; 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=XK9Nf3LiLofhlmCqtNc/hXVo53VwDNWDaao/PHFJ+fNkDo3+tl063Yo+VuvNnEdAbQ4ITSjwHrLmwEgrIoSYspPIVgVgMwN89eif9UfNR+rOnMg16S2TYTYgtYbVrXkfjGoJw2X66yIEpNFn9E7btnVSzrmllz+lhgp/Ntyuwk0= 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 1771405946222446.2088290481503; Wed, 18 Feb 2026 01:12:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdUi-0003j7-0x; Wed, 18 Feb 2026 04:05: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 1vsdUb-0003EY-RD for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdUZ-0000LD-6D for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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-414-9DtngabgOb-E2MYcSW3uJQ-1; Wed, 18 Feb 2026 04:05: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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B5E021800367; Wed, 18 Feb 2026 09:05:00 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9C8A91956095; Wed, 18 Feb 2026 09:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405506; 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=dr8pMczMSECUQTXNOP1nDAoQSDpBZ2yA33Vi4oh8bPlHGOfxaHkBFiyuL7pmCWGiEZklQR poAncnVlKuZxyL2PQ1yT0+3kN5mKsPzTbgR51zm2Mpsr+Eq8/Nd8SPK/3M/x9zv0MMl1ue 3Jcs1sKrJYKSj92MZB1MyxMFOA0jJPs= X-MC-Unique: 9DtngabgOb-E2MYcSW3uJQ-1 X-Mimecast-MFC-AGG-ID: 9DtngabgOb-E2MYcSW3uJQ_1771405501 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 29/85] audio: replace type_init() with DEFINE_TYPES Date: Wed, 18 Feb 2026 10:02:29 +0100 Message-ID: <20260218090330.1476169-30-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405946519158500 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 04:24:18 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=1771405874; cv=none; d=zohomail.com; s=zohoarc; b=dDCLyynS9p2x/09OlDCWebEOZ9gM3pAnVsAcZYNNsOnQwMSU3PqijVTAzB84Xs4uGTzt10UP98DKfrDjdayHECcL99I3GByIL/zr99LM6m9+YdxkGeOH+RNcZ3HhYfcJW+GCmbzyjvg48EQoyP1VWRlqWX2JKyx/r1T0hh4HqYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405874; 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=dlgSuzOTxQHk8iK9kBgfWetX0fm7KwLSXlLaAlZc0T8Zk0RDODmXV9hAURi/rVTtSI08Ugi4BkSV/eKRcspDkJOJKQdLPyakx5OvB4QZYWb7vFFW1q8uWxqDWWc1jNNe2cTgjyjAch/uTTSDmGhQFidt1MD4d+lNmdOKViR5ZbE= 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 1771405874812984.4707637269242; Wed, 18 Feb 2026 01:11:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdUf-0003ap-Ig; Wed, 18 Feb 2026 04:05: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 1vsdUb-0003Be-2a for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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 1vsdUZ-0000LB-5S for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:08 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-529-y-1lWJH_Ol2cWptyDdR_Vw-1; Wed, 18 Feb 2026 04:05:04 -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 D83BA1954B07; Wed, 18 Feb 2026 09:05:03 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 034B11800348; Wed, 18 Feb 2026 09:05:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405506; 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=CB3Id8ZbCP/K8K/caJTcS7p8SxNL0u8EmO3tkD5x7OrKtE6Xq9iqObsyMXkdeu0sdn3/eC MVJB4hyZIe88Je+1G+z+qIml+4L2ZpK/KbTSOEORIMTaLccpjq3ejDmdUjvS6HAKoAmZ9m 5x+qDWbFJGSkkEr0gjjhuKtJ0P/6Nes= X-MC-Unique: y-1lWJH_Ol2cWptyDdR_Vw-1 X-Mimecast-MFC-AGG-ID: y-1lWJH_Ol2cWptyDdR_Vw_1771405504 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 30/85] audio: keep a strong reference on the backend Date: Wed, 18 Feb 2026 10:02:30 +0100 Message-ID: <20260218090330.1476169-31-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405877374154100 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 04:24:18 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=1771405539; cv=none; d=zohomail.com; s=zohoarc; b=AgqR2dPNiMHqkcF18BlVzpsvqzHiNRtm+Yq10C/4PK913JuEWhicYM2I6qo8SjU9l0XmmzA4C721cMgvUZ++PhcoedR15OOcWXMxCWYcD7FD4SPXEnvsdtJTLmVq8tFVp+aWtPpwCuZd8RdkmQnsFIKI7aNIl0pw2QASbPSUDZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405539; 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=ZTWYx+LVBDisv4EJbNHEpJCQwKNMOTHR07lPXUBJX8A321IU6gAAByyq19ULirPu0+AdCMl2wnco2VjyX3cW4DEqeG0/Nu5+rFN1FdqLlwbuRRk8RYiiQuU2fBLoF3zF5LFF+CmTJb2Y0WHcbXRG/Bcw0g24nMJSjnkL/MNMPEc= 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 1771405539676333.80333881418164; Wed, 18 Feb 2026 01:05:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdUk-00042z-OJ; Wed, 18 Feb 2026 04:05: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 1vsdUi-0003pP-7J for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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 1vsdUe-0000Lg-7n for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:15 -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-215-V1XGf-TKO06yTJ-JaWSIsg-1; Wed, 18 Feb 2026 04:05:07 -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 E48BE1800451; Wed, 18 Feb 2026 09:05:06 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 48BD8180066B; Wed, 18 Feb 2026 09:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405511; 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=C7mkhJzJtQz8SzOf76CUNlROKErmi2Wkv7dqY1HXPYf5sgfJtic5SmLfo/h5C91p9s8omN uyXilOIDGymHKWArkfJm9xA9gnRQNLLpVl+wGgzoA8aAsjwCgMTIGxwy6Ukcieby9rYptH 8p6tarpTZM40Vca5FePp2F66UCgYrMQ= X-MC-Unique: V1XGf-TKO06yTJ-JaWSIsg-1 X-Mimecast-MFC-AGG-ID: V1XGf-TKO06yTJ-JaWSIsg_1771405507 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 31/85] audio: make list type declaration private Date: Wed, 18 Feb 2026 10:02:31 +0100 Message-ID: <20260218090330.1476169-32-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405541110158500 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 04:24:18 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=1771405544; cv=none; d=zohomail.com; s=zohoarc; b=LVqCFoHR8aq631Nk8rAQM7ZqyY7JhUlrF/8eCcZ+mvrNIjplmN6JFktuvE5zZ+kXzVt1GNknF3df+GIssF3aPeltWNCQLoXVtI7tioK2qH/uZZoZtkVC6OlspM0KXldW6xw/nM1aBmJKJI/j90axXgX1rY6K874p++YbSbMidG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405544; 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=NiYctQRIY4DDopnnXxsnhK2339213WFjT/M5E1s+kJ7G7KV7ckzt5HHwxQzx4BaRHwvO8nzskqkd74KylC/37Iun0RTtAkyj/dzQ4933t6FbMN9ndmApbq6zmp0/Mf4IVXI5I0ypKV3OV06RnbsUE6yPBTtSu8ErK6Y1eE1IZzs= 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 1771405544537207.89999926676307; Wed, 18 Feb 2026 01:05:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdUs-0004F2-5z; Wed, 18 Feb 2026 04:05:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdUj-0003zp-Nt for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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 1vsdUh-0000Lx-IM for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:17 -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-593-4Sr_w2UdPN2JkGcZaxGiVQ-1; Wed, 18 Feb 2026 04:05: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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DDD151800366; Wed, 18 Feb 2026 09:05:09 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 281901956095; Wed, 18 Feb 2026 09:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405514; 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=T1yg92gHpm5pMi/yWKwxgU8s/aVypK6MLbyeZAxOkEK+utEKz0K3dZITNueJnhjUGtbF/M UzaPQfay1ysV9kMEPBJw5ckpVNODANHevZx88+owMUuiN34ytLMX4/rgaZOIpEG5ezlvj7 ZcXAl1LZ6udtwFVhfzvKZ4sZ7+4rM7I= X-MC-Unique: 4Sr_w2UdPN2JkGcZaxGiVQ-1 X-Mimecast-MFC-AGG-ID: 4Sr_w2UdPN2JkGcZaxGiVQ_1771405510 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 32/85] audio: make create_pdos() private Date: Wed, 18 Feb 2026 10:02:32 +0100 Message-ID: <20260218090330.1476169-33-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405545170158500 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 04:24:18 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=1771405594; cv=none; d=zohomail.com; s=zohoarc; b=Ptd0TFT8WKIjPy0WNOlchdM3R3x61yrEAiXkgGQ8oEqwrg49xJXGAMoLE/HeyGtlztiW7l3zyP1vAH/gwp6KpVxE9VGQUSwtROD2PXgpyKE+bQifOnaVxtrZMrX5XPzy54hFYw0wWwom2OadiW2+G3ijP8rC9Xq/UfnXDFEBzwI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405594; 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=Y9setnrZk4bZiqlu7Xw9EbOuoP6iqqKij+yxwdWmX5w=; b=CMjEyHSjygWDhn+E/DLmAffza2GF2gSY2dM7iiZ659EwNsp+oAwKn+uaoN3+Iv4+vTbv/e1KNc3IPldK8lBba3VoN9DeFUwG1HFjUwlGylFZrWX8I+ziBuIjIxRqXPtM2hs1x20PvYU9njC07oSZPPxY95Z+cR+xz+Vo+KBN4h4= 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 1771405594685641.8295144947427; Wed, 18 Feb 2026 01:06:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdV0-0004Tc-4Q; Wed, 18 Feb 2026 04:05: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 1vsdUl-00046I-E0 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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 1vsdUh-0000MH-UE for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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-643-0f_d3ygeMtKn_Gjw6Ng0ow-1; Wed, 18 Feb 2026 04:05:13 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8B6BB1955D89; Wed, 18 Feb 2026 09:05:12 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B0C2319560AD; Wed, 18 Feb 2026 09:05:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405515; 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=Y9setnrZk4bZiqlu7Xw9EbOuoP6iqqKij+yxwdWmX5w=; b=WNkXzd5MrJppBZeXYLrFvpO+EDEqS+ZApUOiKXQAnE/HXbOHnCiKThdaST5crq1aAaR/n4 IvyaG0WZgC1TNtnTTVOTbZyHMtq7bfWgCDZVOJFzZha5cawd8BgJGmSO51LGnYq5C8TXjh VBWorPqcNyK1c3Vw54i0IoaMHLXuhQo= X-MC-Unique: 0f_d3ygeMtKn_Gjw6Ng0ow-1 X-Mimecast-MFC-AGG-ID: 0f_d3ygeMtKn_Gjw6Ng0ow_1771405512 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?= Subject: [PULL 33/85] replay: remove dependency on audio/ Date: Wed, 18 Feb 2026 10:02:33 +0100 Message-ID: <20260218090330.1476169-34-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405595480154100 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 +++++++--- 9 files changed, 85 insertions(+), 35 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 --=20 2.53.0 From nobody Sun Apr 12 04:24:18 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=1771405568; cv=none; d=zohomail.com; s=zohoarc; b=m+IHsMfEipkGX4OoWnQF1urdkPudcmJh+ieDrjeK2wGxgMb6REM4PZxInpoBCmlMLaZRM4H4jmtKgH48RNUpqVf8Mn6+iYsNaAcW+/1WEtAJDcBiebZ2O3b9pucSpcfNxKDZk6kSSJ8leT7eq1wLCQm1raMVUxMgtAynxNO/dR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405568; 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=PhEzkj8cRpIEsPP19pjyCOnR2OpGOUybdAQwROvxjVsCEZA66Hkuev7S0tWiKB15LMzb23y5PF/IJVnmrBF/rokhULCYfvDR9fnDg1bGyp7vCNHlGyy35w+x6gU4tOTtFbzdTO+PY80XhrKDVLLlSDc6Oc0SUJRfIohPPjNTgs4= 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 1771405568610485.14007814300317; Wed, 18 Feb 2026 01:06:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdV6-0005IZ-Jw; Wed, 18 Feb 2026 04:05:40 -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 1vsdUs-0004Ko-Mx for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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 1vsdUo-0000Nv-Am for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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-34-pUnDKdk7OW2DFCV_e5bIUA-1; Wed, 18 Feb 2026 04:05:17 -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 842E618ADBC1; Wed, 18 Feb 2026 09:05:16 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DB4C81800594; Wed, 18 Feb 2026 09:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405521; 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=FIK+Kk3lhIOWx30WvSzEG5PULQdTYeNJ4Er+2TxYLc0ECQxP2HX584xFPNGIIQ7fpxeKRP ZHbcDfubnfnVnwYAW1uE2gwgLjQHwXGuUxBei/5W62g/OZEuHZmn4D1IunKHNJxqeQRbr0 N8nBcNI9l4dM5znVGX7uZrphY8tqOvY= X-MC-Unique: pUnDKdk7OW2DFCV_e5bIUA-1 X-Mimecast-MFC-AGG-ID: pUnDKdk7OW2DFCV_e5bIUA_1771405516 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Laurent Vivier , "Michael S. Tsirkin" , Manos Pitsidianakis , Alistair Francis , "Edgar E. Iglesias" , qemu-arm@nongnu.org (open list:Xilinx ZynqMP and...) Subject: [PULL 34/85] audio: make all the backend-specific APIs take the be Date: Wed, 18 Feb 2026 10:02:34 +0100 Message-ID: <20260218090330.1476169-35-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405571136154100 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 04:24:18 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=1771405679; cv=none; d=zohomail.com; s=zohoarc; b=dNp8lrkhx2LZbOMBpcJX2UlO+OjkjfGAtpgf6AS0vwYrifKRX6oZs1r8/TD/lhn6wZjsW0smw+hMqQEd7O7Yhwy/sK1ppRYESGbp72fyINnoDThea0X74Z7kMXv8nL3g+ooPPcteKk/OEFcSxMCyAHNXp8A1lcVd4OB5rSy2LAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405679; 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=LkURMf57B4ji366JT282ohozLE9R2dNV8HSk0B6xzYxvJisBnLm8lnMD8hXNiyzDrYs0FfC2mldFGawJFnHNd191OxWfg6uckNYgzVB9npk8DUee4dLywXeJQjIKNgQDkpLdQJC+wvoYLO1aMYhbleJyukmN09HRw6+TnCsucTU= 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 1771405679179860.6911582795241; Wed, 18 Feb 2026 01:07:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdV1-0004h8-OM; Wed, 18 Feb 2026 04:05: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 1vsdUw-0004Pp-AY for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdUo-0000O4-Q4 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:28 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-230-l9OJ-zhlMrGn_qo3MBKyXw-1; Wed, 18 Feb 2026 04:05:20 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5E1FF1800370; Wed, 18 Feb 2026 09:05:19 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8ED7130001A5; Wed, 18 Feb 2026 09:05:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405522; 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=MNyk7e223/uHIUF8lFj/mcAv4HLxsJYmZDj+3R2DzDR0ABPgKUpLKMR6TiB3YC3lUNjKV/ nd8NDutwExcBQsYg8HsfEfVuH6NjGF/9CHOGGJWl9Zb0Jc1FY1kGmPPnBKyPhkdZuKBLhE KLUMHJIfbcYG0V198yXfJZ6332ZKdwk= X-MC-Unique: l9OJ-zhlMrGn_qo3MBKyXw-1 X-Mimecast-MFC-AGG-ID: l9OJ-zhlMrGn_qo3MBKyXw_1771405519 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 35/85] audio: make AudioBackend truly abstract Date: Wed, 18 Feb 2026 10:02:35 +0100 Message-ID: <20260218090330.1476169-36-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405679779158500 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 04:24:18 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=1771405803; cv=none; d=zohomail.com; s=zohoarc; b=NtdcqS20W3LjksYyXnyBPtEHQJFH7opNhH7hkkr033axj28h0gSbL0hVJkDy8Q6O0m4FpbchEIo3yTq3G/7evMOgkenbFteYCRaV2pwrxbHfHSruvveHnJApCJ0xZCOX0OIZf9nX/UmXKhRWkg7d5WYGrz+chLWK98i8UBgAtrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405803; 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=dbe95sNzEmyVU1MO2M377CM8++hfI8MHP9p5m/JjMFkpWNOthE7mbO63Uzga4ZvQBayzO46BDfgSunvDV1jhkKveflH1PxdvyY3X2YASyh5ehp/PnsZJQ6eOsqNRpzLu5vvGdXpPTDedlSI2K9DGMrTgZON8gC0fgxvCmRBnASA= 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 1771405803924789.2211870932156; Wed, 18 Feb 2026 01:10:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdV3-0004tY-Bx; Wed, 18 Feb 2026 04:05: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 1vsdUw-0004Pq-B3 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdUs-0000T2-Hv for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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-298-aTtJXNZsPuypIEw3BgKbQA-1; Wed, 18 Feb 2026 04:05:22 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F24091955F13; Wed, 18 Feb 2026 09:05:21 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3C211180066B; Wed, 18 Feb 2026 09:05:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405525; 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=D6CxTrwmGFWgTvOzmpqIyYSIhOLt467nfY2AwIIKkQD87m/GRiiu4wiDfFi1hJSQf1dwQn VCpnmbVehAWt69syYbivWv+W4ea7li+G3wX6YWmKaGzXzNsWqbScbT2J13rh1kr3GBssol Qva5YpKGl20ErnvScQrdgxHA9mC7LVM= X-MC-Unique: aTtJXNZsPuypIEw3BgKbQA-1 X-Mimecast-MFC-AGG-ID: aTtJXNZsPuypIEw3BgKbQA_1771405522 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 36/85] audio: split AudioBackend Date: Wed, 18 Feb 2026 10:02:36 +0100 Message-ID: <20260218090330.1476169-37-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405804884154100 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 04:24:18 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=1771405945; cv=none; d=zohomail.com; s=zohoarc; b=F0qsaJMzB4XkUNXNBectl2F4GymsV5cgHc8eS2Q0kd02byr1JptUp/7YT64+uJgNMFPB/k2mSSkLtKJ9ktdEgoc9oizgAKMs6ro6Y47k+zJbE8ge6Rw91sA3wWBIEX8IGhP3lujNEBPcHzqYbX1yga/BQsvcRUciAs7bHUHwFm8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405945; 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=hl6tV6D27T+UAAGeA+2XDTzf5WnQBP8l5uD6aIb8LKGPG+0eBSGnJNxTQnHmFua/RV6WDroFmn7pK60d8OWO2z/95jWWhiw31VPTYZSJunfHrJuXTH9bA5befbAMibkf5rBAQxcFajBg4ujqF3LPPs9C1zZOXvjg8eE0CJVFQlA= 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 1771405945736125.62701190817165; Wed, 18 Feb 2026 01:12:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdV7-0005S3-Ss; Wed, 18 Feb 2026 04:05:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdV3-0004ww-JH for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:37 -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 1vsdUx-0000Xl-Mj for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:37 -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-490-ZHU7w0_eNkiEOn2JtZFtYA-1; Wed, 18 Feb 2026 04:05:27 -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 A6FF31956067; Wed, 18 Feb 2026 09:05:25 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F11E230001A5; Wed, 18 Feb 2026 09:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405531; 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=Fx9Hlyi1pim/6/nRjRU/2rYeRy8pXPPOh5n3fE7pshfjD/zsLfH24A338I2zhXPlAG0xtT IAAfEVbim6KtEFRXzRM1psudb/xpVtc6pXPuYNwklcFFapuRm2PGaUWWvYBXHcWqcw+xYo WNSSWdh1FGe0Vh7w8IznB3XJUDwAMbM= X-MC-Unique: ZHU7w0_eNkiEOn2JtZFtYA-1 X-Mimecast-MFC-AGG-ID: ZHU7w0_eNkiEOn2JtZFtYA_1771405525 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Laurent Vivier , "Michael S. Tsirkin" , Manos Pitsidianakis , Alistair Francis , "Edgar E. Iglesias" , qemu-arm@nongnu.org (open list:Xilinx ZynqMP and...) Subject: [PULL 37/85] audio: AUD_ -> audio_be_ Date: Wed, 18 Feb 2026 10:02:37 +0100 Message-ID: <20260218090330.1476169-38-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405948548154100 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 04:24:18 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=1771405710; cv=none; d=zohomail.com; s=zohoarc; b=FLi0IHhqReZHzI6NYz6u/5zasJANB4VAFMutJV4zws81Bv7H6PwBnmjEa2aXbK5k4ayHYqQTwIp3DVyO9r+2rTu60KY1BCNhMXQfCbdCvREnzMQ5iag29qaTHjrBPy4i/99cvYIYcEniNFNipg9jyhKq25Ob8zyiesiFTKieexw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405710; 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=n0kI34MvEhXYR2qP257u2WjutiX4fDgK7Ou0oim7yFczy0Br6GXn0+IoOd0HrjbP6QHbJqzIlpx6YOIGi1qcCrtWgcJqiYUv8hIJ88kTPkA8BCniVNfWqQE3CXRU7BaKGp62ByNlWHQ9XiW0Xxfw4xVksq9YC85fBF74puVqwoA= 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 1771405710527213.67935619639047; Wed, 18 Feb 2026 01:08:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdV4-00052h-GM; Wed, 18 Feb 2026 04:05: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 1vsdV0-0004XX-5i for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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 1vsdUx-0000XT-I1 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:33 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-544-kzZlMSl0OjWRac8OEs0Gng-1; Wed, 18 Feb 2026 04:05:29 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AC64E1955BC4; Wed, 18 Feb 2026 09:05:28 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id ED9AD19560AD; Wed, 18 Feb 2026 09:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405530; 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=c5ER92gzf/PclvWOY3atREW3UtnNryWO2dKFJAQ3lq7j1kfyDqP6h8UICgQGfePEb3tNA0 HWLmr9Ewvp7jb6xd4mDyAz3VsPOluabh+ijbYNE592ZQ+MDqPJRLyv3r8bFZGY73C3hOrU 1GeWpjDIHHNqpGTQRoHaN4qTXn5XirM= X-MC-Unique: kzZlMSl0OjWRac8OEs0Gng-1 X-Mimecast-MFC-AGG-ID: kzZlMSl0OjWRac8OEs0Gng_1771405528 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 38/85] audio-be: add common pre-conditions Date: Wed, 18 Feb 2026 10:02:38 +0100 Message-ID: <20260218090330.1476169-39-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405711807158500 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 04:24:18 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=1771405683; cv=none; d=zohomail.com; s=zohoarc; b=TVjd6nvFaNrFElr14MI4sbACfCqQdyXOWdQJoiSSwVq5aCpBgr/+sic/QrcoEbZL4pzoM4Igm8sxk9eA/V0eSFtMf0AHZmUKgm+O+TnVRcKrPfLJH92miC08TVK7qyAveEokdSwv67H9iMq4dnr4XxubfeKZ1x5bMl47kR3wgkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405683; 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=NCkdLjtqXClddvC7tCUJ9qa29Lt0bdk+bZQWgyiblWYMf79wxYVVH7mLs+2GjHz3+cVCBA/5bjlhVO9IEGO8nJgAJgIWRzsovRDQJS1I8ZBk1GYAO+i9SgW1bInqwuQMFb50bC6t0DeM4g3lshBkkqu3mnLWMtrSviP+4MwCUTY= 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 1771405683249536.99819394483; Wed, 18 Feb 2026 01:08:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdV5-0005Cf-N7; Wed, 18 Feb 2026 04:05: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 1vsdV2-0004oJ-Hd for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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 1vsdV0-0000Ym-QJ for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:36 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-540-OrlKMch9M-CT1-uuy5v-tg-1; Wed, 18 Feb 2026 04:05:32 -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 B14E31956052; Wed, 18 Feb 2026 09:05:31 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A3C561956095; Wed, 18 Feb 2026 09:05:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405534; 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=Y+Wvqv+j28s+QtD659NSMXSFlyOlhX0mHO/QEe5EGQuxJW8zeTUghmd/YiYPwr+R4v7t6k i7dQLbyrCZtQMmDHpRSGlLLGvGm244UZQe93ibnHlqx6pkfXRV/3Xrd4lVuxiDlOVcLLmJ yB4EPusO/Zm/Bs9+Pv6LjHwrGfPTUF0= X-MC-Unique: OrlKMch9M-CT1-uuy5v-tg-1 X-Mimecast-MFC-AGG-ID: OrlKMch9M-CT1-uuy5v-tg_1771405531 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 39/85] audio-be: add some state trace for debugging Date: Wed, 18 Feb 2026 10:02:39 +0100 Message-ID: <20260218090330.1476169-40-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405684622154100 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 04:24:18 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=1771405883; cv=none; d=zohomail.com; s=zohoarc; b=VEFoqYJ4J0/vxJJhwzJpHFME4MqrLCuKQjj8eatWpyj7PyhUWPBqSBo/9UOfeT6tfR2XSUygcnT8heJ+LsJpyGfEiGJfRxnV31u1dyWQZlra1nQR+sFtb+kKUan8mKaQzpbPibU78VuhNfgiMU//08g/tnFIqRbdoqtL/81JsDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405883; 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=G1WievLDwGgi7HNGx0DHtDbyvwdfGH+G6fbkfV4iL/pepYqaS7yz+5HpHJ0xeIVSbcHSCMD74tdlbimkfZcy6DfPABAiPrk+S/2mflKDSOOcnek4jEFRzyG1td3GYQLXxdjaWV5R0nADjnOEDWY96U4D+BF+iriwOu7wq1HF/DI= 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 177140588389937.64498843938793; Wed, 18 Feb 2026 01:11:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVD-00068E-LR; Wed, 18 Feb 2026 04:05: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 1vsdVC-00063M-2R for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdV7-0000iF-Ce for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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-144-Gfx1Ei5GNP6JKvtywCdRrw-1; Wed, 18 Feb 2026 04:05:36 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 77AD51955BC1; Wed, 18 Feb 2026 09:05:35 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E757430001A5; Wed, 18 Feb 2026 09:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405540; 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=aJfO9yWnUVDjSbFRujHqFDbRCqfpMdqkYTY/qB7RAFWIRsRzbxUYpC/J7QSDV8rwFkQWW2 C/A+0X8mYDZetgiDwFuN2w0ny3zKSxTbatxXz6mrjNNdSZQ/1KSmm5Inz5ebc0YfkQ12Ol 0MaxEvmG8dHkC5dhBMCwn/7CEMyBQVs= X-MC-Unique: Gfx1Ei5GNP6JKvtywCdRrw-1 X-Mimecast-MFC-AGG-ID: Gfx1Ei5GNP6JKvtywCdRrw_1771405535 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 40/85] audio: split AudioMixengBackend code in audio-mixeng-be.c Date: Wed, 18 Feb 2026 10:02:40 +0100 Message-ID: <20260218090330.1476169-41-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405884496158500 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 04:24:18 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=1771405847; cv=none; d=zohomail.com; s=zohoarc; b=JfXfY+enVsWq5BO2jpFnb67/a2t6SfoUHNVdbKzSMucKTXl7T8dY9otPlBEgAJ7N5Zzfn9cG1I7eWUhSrp6001mp/xM38vQgWAr6zgiXQTXW3Ib+Ep37Lpgfvqqk21tcxi7jjQBhWro6WDh2K4BRbbD1RCh5hGaw0VmKPoeWOv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405847; 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=QoDsw3HeHT0HVKWTMhd7jBGyXJx+pmNgGfyIU/5jhYpAmUv3nel/jutTCoCbg3sQmIe/WFf6SDwRJcNbB9ddJnezEY99ERy3YY0snpPhbrVbTFppWWVz6AAZyQrifsXBq4hKujzHbbldFgU407Mswmu1Ok2zq69XLrzOGz6j5H4= 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 1771405846915674.404363587659; Wed, 18 Feb 2026 01:10:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVD-00067H-3b; Wed, 18 Feb 2026 04:05: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 1vsdVB-0005yX-7f for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdV9-0000lq-Cg for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:44 -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-194-NwcKr5enMnK04RTVj339SA-1; Wed, 18 Feb 2026 04:05:39 -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 5A8B41954B05; Wed, 18 Feb 2026 09:05:38 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 811FC30001B9; Wed, 18 Feb 2026 09:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405542; 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=UjnWPlSV/boXWqDiyvODzmaG+1FXD97sUlI9rf4MM6AvqsaQM+9ZxZkB+08+gQSJPqvjpI 9yDDbZ+QlAcuv7kC24WBk5jROGQumZFRBxIOyj0XmUQ+Ai6I8mpj+b/sc/MWQzDEujae78 LV8dXwT4Q/uyZFOD5sZtERlLif/H254= X-MC-Unique: NwcKr5enMnK04RTVj339SA-1 X-Mimecast-MFC-AGG-ID: NwcKr5enMnK04RTVj339SA_1771405538 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 41/85] audio: make audio_driver init() & fini() optional Date: Wed, 18 Feb 2026 10:02:41 +0100 Message-ID: <20260218090330.1476169-42-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405848223158500 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 04:24:18 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=1771405834; cv=none; d=zohomail.com; s=zohoarc; b=CfteuimRJv5zGVWmEjbBmIUWjqay03j2iIqrDKnovDR36qFR45J2rS5nQ9dCN/Ou28CJKPGEg14yiHY4dDhyhm5fXwOYP4go4CGldSx840guLMAPHyfrVJ6DcJOQT7Oy3PPgNnPl4YahWuUypw4NMjPVBj3aUg8NUr84KaEJzeo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405834; 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=P9uQGeOv0SLLgTaCZ0yTlNynwzzwIyDWHBnlr5C9iTxPzJkNjmYEt9l5sjp000ebT4beTvNs89Wn2CLDgYPGH03xT+Vfs60F1iiR1v8r6M+SN0LyZS2xCPjlxvzighqddX3y0e5eAO8B5UZqRlemgsRTBRU3Jdpu+83tG7exNt8= 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 1771405834615578.557603065559; Wed, 18 Feb 2026 01:10:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVG-0006N3-0I; Wed, 18 Feb 2026 04:05: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 1vsdVE-0006Df-GH for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdVC-0000qO-Bs for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:48 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-455-ryfX5MbrNjGZwJndlxljRg-1; Wed, 18 Feb 2026 04:05:42 -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 3B0AC195FDE0; Wed, 18 Feb 2026 09:05:41 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6079D180058A; Wed, 18 Feb 2026 09:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405545; 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=ReGXjGvE2fM6r7exjY5aQs1I3uKoHywlBNSlmu+oZE1wEiQdZO4q+kNGjXUMsoY9OW29RM BL/brurCi4Dmbxo4Av5AtlyCYKrWhaDhUM9nkmUUcZBxw4E6iA7yTd8LK+SbHZlhsEJ//f NV+QLDdfB+Px+P8jaelN8n9AdaG9GQs= X-MC-Unique: ryfX5MbrNjGZwJndlxljRg-1 X-Mimecast-MFC-AGG-ID: ryfX5MbrNjGZwJndlxljRg_1771405541 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 42/85] audio/dbus: convert to QOM lifecycle methods Date: Wed, 18 Feb 2026 10:02:42 +0100 Message-ID: <20260218090330.1476169-43-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405836901154100 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 04:24:18 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=1771405804; cv=none; d=zohomail.com; s=zohoarc; b=jPzI7I/6RNeMuOXbvnz8bA9oJ3xcBV+aWnAEbIl4AzsU6JS462w4NVLU6jrM7lRXqg9THNRRy/9JXoEJFEK6U3bcIiGfz7QlI5dbmAszyA0914NpHZ8tti4wd8jjXeYntVtyiHzQVyyAp7J2g3QPKPPCjYGOje9PoAr9s3PdEmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405804; 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=ZWq5YIIG93ZDygihgWtMzuuv831QaIa/ERYvNu9lMBK/omjedjPW/wJnhIdZLYZbgDt5yHJr0zIxjn2ZIM9oNIgDkNMNJwEHtbrwVCA9uxqYH+Kr4lm9SQEZZezs1RoD7W4v0ueh4ZvbCEpnN9+nnuTkkVWgMJIjGePH0CPzAKQ= 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 1771405804030750.0459436586663; Wed, 18 Feb 2026 01:10:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVI-0006aA-05; Wed, 18 Feb 2026 04:05: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 1vsdVG-0006PO-GP for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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 1vsdVE-0000wZ-P5 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:50 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-61-J5MW_1W-NTu19ndcgrao-Q-1; Wed, 18 Feb 2026 04:05:44 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DCEF51955F1F; Wed, 18 Feb 2026 09:05:43 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 40B2A19560AD; Wed, 18 Feb 2026 09:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405548; 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=Rbpke9Vx7ZVZSh7NvP1+sQ76kL7gspwEpRZfbYHwAJ+CyaUpAR0iPxv5brlTgb3ucDxVTu BK+niZcHt/c+kmAUbvnxdW8Wb7hBtK5g5zzP2y+c4B4XlK38i25uIEojLLxdjqYtl5EH1k ZgDJ2hVTQwhvLlhw40cXTO4stTfuXhY= X-MC-Unique: J5MW_1W-NTu19ndcgrao-Q-1 X-Mimecast-MFC-AGG-ID: J5MW_1W-NTu19ndcgrao-Q_1771405544 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 43/85] audio/spice: convert to QOM lifecycle methods Date: Wed, 18 Feb 2026 10:02:43 +0100 Message-ID: <20260218090330.1476169-44-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405806067158500 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 04:24:18 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=1771405771; cv=none; d=zohomail.com; s=zohoarc; b=k1fheU+qUf0U1LofLjhSLfWR4nbzo5mZYw0qEs91ZIJnZAP1kIJO8+nAd2iyo181fIGrZ9pTxd1S9MYzTshJGUkRyBz17ctYubCS6lQQrxQi7xrz3yVTuxrgcBpw/CkNxZJkdW2rPp01nCoqjUJWZ0PstxuAyDk7dpi5oyfMyLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405771; 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=FqcvAAa8XbJbZzkh9eKvrDOTU5WaJUARvf26PsxL5FhUvRr9wudAes1ATeeLuuguKXO2iLzyeFUDjH9BENlOHKmPf3nN+pgUaEH4FVvHsTs85y77avNwuztjbXKhe52gFNwY2SEgwtPj+wyfY1EjqHx68tRnIAFSzMLA6PhF8EU= 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 1771405771057240.93763317300818; Wed, 18 Feb 2026 01:09:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVZ-0007F2-Jz; Wed, 18 Feb 2026 04:06:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdVN-00073A-HF for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdVM-0001BF-2V for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05:57 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-686-M-Yy9_-4Me2GoiVndILMVQ-1; Wed, 18 Feb 2026 04:05:49 -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 D48151956046; Wed, 18 Feb 2026 09:05:46 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AFF751800672; Wed, 18 Feb 2026 09:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405554; 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=EcuSmwSq6w2n0076q/HvWM7UGfKpPwDxIzaLyvVFcStRq2zEO6B41DMIX7qg9qwd0RJJOf TgLYCnHNbNppYVkJND10kIuKVWwzH6WqAnR5KhV3r6fClaikjHIC/RcW5gMGPhuXWVZotJ FCQCQLHJUU58nZeQ8rpsHBfxl9/mNcg= X-MC-Unique: M-Yy9_-4Me2GoiVndILMVQ-1 X-Mimecast-MFC-AGG-ID: M-Yy9_-4Me2GoiVndILMVQ_1771405546 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 44/85] audio/wav: convert to QOM lifecycle methods Date: Wed, 18 Feb 2026 10:02:44 +0100 Message-ID: <20260218090330.1476169-45-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405771938158500 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 04:24:18 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=1771405801; cv=none; d=zohomail.com; s=zohoarc; b=GD/IfWE8iqwpZ4xxjvT8p0fjSGYo10GPU9UmR0EemZL9i04X1/+WTeqfHTBks+jSaUuJ63R5gGYp3PonbeStOGNxdylPtsy1v41wGGDHEyavZPQPOzXuXeSP/9liL2GdOx6sl4Jwdf5KhjPLhBiC1MG/1ZY9ufjODI/75PcpulU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405801; 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=CefdFRFVX2/9HYCRvoSRW2BXMiZBzGijVuiuz7g/CZbJJSiYf5FZopLUguOpETT/cz7U6jbMzIZpB26nAgWTZs99P846KrUoN5AAxMujUIKhRRwBRLQ9M664RCR6DYpc0sW5GO4WqIL1NQesdSTBFcJBr6i8unq25+Q9yDKn1LY= 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 1771405801477285.107763073535; Wed, 18 Feb 2026 01:10:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVT-00076N-SW; Wed, 18 Feb 2026 04:06:03 -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 1vsdVL-0006yY-2X for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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 1vsdVJ-00015u-Gg for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:05: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-591-j_jVh8xxNkWExXy4-LhZwQ-1; Wed, 18 Feb 2026 04:05:50 -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 2509D19560AA; Wed, 18 Feb 2026 09:05:50 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C19551956095; Wed, 18 Feb 2026 09:05:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405552; 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=LcMO/0P5UIxH3aqOsAGzS03+xXZ9Amgv1xXXeIS0e9FY2A/s2LuBOQytomlyOg719f7z+/ M0178nMcjfQf3aAMz75mf5X9EdEGkkHRna9XXJUO1hXzoY9+raVr+/EeNpUDIEj1uU4tWu iVMsNwL7W2O+Lkf3HnAFHJT/VRLSKck= X-MC-Unique: j_jVh8xxNkWExXy4-LhZwQ-1 X-Mimecast-MFC-AGG-ID: j_jVh8xxNkWExXy4-LhZwQ_1771405550 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 45/85] audio/noaudio: convert to QOM lifecycle methods Date: Wed, 18 Feb 2026 10:02:45 +0100 Message-ID: <20260218090330.1476169-46-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405802015158500 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 04:24:18 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=1771405947; cv=none; d=zohomail.com; s=zohoarc; b=Be0LoPzokAhQrEApxvgIRIN8gCV2uEyiAbT3caOwhhVTCq7W6eNNhp+pfrM1JvhXikMm6wOTFNSt3gWilfx7oR7GQS63CB808rdxDrLHNk4iVKz+cq5RVNDtfELTForn4cFwPEuq87xIJDfO1HQNcP2AhOuL1M0pWFMt3C1UdLY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405947; 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=Cep3P1pzMYXgG7O43p/I7q83Lc/hQIq6W6zL2MxmO5/tqrB0+12IOVqohJcltwW00gt4wzi/QTm/+OCo4uQJFlZIjKKYZMt0ANzFMyiqGT+tijIOkekHszkXizISUwH/hBf1ma4yaLsVv/RdbbMi/atqBZGvfz0DqnU3aX1zUNo= 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 1771405947756920.2324307057173; Wed, 18 Feb 2026 01:12:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVi-0007qc-VM; Wed, 18 Feb 2026 04:06:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdVQ-00076O-Rf for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdVP-0001GM-2a for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:00 -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-641-8io3fhLBOT2ynXGNx6jfEA-1; Wed, 18 Feb 2026 04:05: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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 348BE1800370; Wed, 18 Feb 2026 09:05:53 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 750A71800348; Wed, 18 Feb 2026 09:05:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405558; 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=iKb/KIwWz2qmUsY+PTkvBYk2bHC1YdVgAshURUAy8ZXHKwnDI/iYP29t1vM17UbZZ5WZpc CArUwPSx5dwvrnEdtF77v6nkMI8xWH0ZYLvBGGErJQYxp3AySXlJdBkbXRcnaMmPRE8Crd 6FzBE3PZevCkDL3YW0k+5QufqAOdEEg= X-MC-Unique: 8io3fhLBOT2ynXGNx6jfEA-1 X-Mimecast-MFC-AGG-ID: 8io3fhLBOT2ynXGNx6jfEA_1771405553 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 46/85] audio/alsa: convert to QOM lifecycle methods Date: Wed, 18 Feb 2026 10:02:46 +0100 Message-ID: <20260218090330.1476169-47-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405948492158500 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 04:24:18 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=1771405901; cv=none; d=zohomail.com; s=zohoarc; b=dRlSwBMkxcutuytL/Q6rM9uJXcDpfSRpkPEV6dl4lRQ3HD0dBk6MTAftuIqcvt25YBFKgPNOd97yoWT9lAAaZM8GOpHtPCZfMJAc+UIBjk8suPBjaJHGgy/iKBYvOvwH17p0czcuLKDdxF3LdWL7BkXfAdL5+amtMFuQJ8LRxJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405901; 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=bZUfSWBZ1xiX4wMTdn5Ora0s2P1m6Qtsnt4mrHNJ7KKPJxMyWLgd4yjOW3XtksMwBT/A00fNIu4DpqYs4gpeAPVcKBnyZhwC7+06R01M/fBWYsCDgkhWRpqdetH+lOjJS0dfcbAJLDNjEes+/gykMo+VWbkUaE6zlvrcEHLdpuQ= 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 1771405901721617.9186289463079; Wed, 18 Feb 2026 01:11:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVf-0007Tw-KV; Wed, 18 Feb 2026 04:06:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdVT-0007BY-3Y for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06: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 1vsdVR-0001KL-GI for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:02 -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-384-rZACvFEZMwauKSuIDPl-ZQ-1; Wed, 18 Feb 2026 04:05: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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 671BD1956050; Wed, 18 Feb 2026 09:05:56 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 212E51956095; Wed, 18 Feb 2026 09:05:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405560; 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=ilDhw2o5fIleACxZMNFTWwLL2bZ2tceK+eyKa/ELybyQqmU0LYOehofgWyyBIBeU4fJk4i b1A/2nuL4ccMPMW2mFAHbom3fkL8LSU3qeb9AkDNOreEE/dfn7kfrIYJttL1Wio2umYjVk uPf64O3Fb0glttb6kcMgJ316zyP2Wik= X-MC-Unique: rZACvFEZMwauKSuIDPl-ZQ-1 X-Mimecast-MFC-AGG-ID: rZACvFEZMwauKSuIDPl-ZQ_1771405556 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 47/85] audio/oss: convert to QOM lifecycle methods Date: Wed, 18 Feb 2026 10:02:47 +0100 Message-ID: <20260218090330.1476169-48-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405903780154100 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 04:24:18 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=1771405893; cv=none; d=zohomail.com; s=zohoarc; b=MEnAart6J4oAz5+TYL/GDWOHOI7ZAcaXNe+y3NZ0knuM1cWonl1aYFHkxOTBa9RkOyVxDpqFjkLgZuHENd+qhvnpYolGWLtaisCRBFw8gJeDk3+DK/2F5RAjmAw/QmiRE9Jl+Erbc8U1t9Agd6UakH896nzUUXrIFfF+sfcMI18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405893; 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=PFSQgcHB8MXI3Ur5U/Xbw3NxUDZIWuM2n1UBH+oT94tMZSbdrfU4UJWnTW6cJS2nFvQ1K/dzOwlObg0LTcqNDZ6unQ3KyjO1bJIcRWkZFhWTr/pDuGRBuqlrI71ZGWk2p65N5OrLdRLYWpoupt/IXJkC+ItGSYn73r60s1DlnHE= 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 1771405893908346.1187737609839; Wed, 18 Feb 2026 01:11:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVj-0007sB-4Z; Wed, 18 Feb 2026 04:06: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 1vsdVX-0007Fg-N1 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdVV-0001V9-OR for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:07 -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-274-W1OOMgXaNWe1m4PGN0XoSA-1; Wed, 18 Feb 2026 04:06:00 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 71F86180057E; Wed, 18 Feb 2026 09:05:59 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9851319560AD; Wed, 18 Feb 2026 09:05:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405564; 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=I+XsMQzUzB68n+gUMgWqNsML7soLrMcTmL4STPdYvV7lXPfK2pzhY/Dsb48clx6omfVu7F s1Fzt1di2dLDTkEqnyhDfIz6PxoMlv2KIQm4DFls1gLOXCZaf3s5s8NwNS087m6I8p6rxo Vcpvam51zYMkP4W2Pgp6m9g1A0QmONA= X-MC-Unique: W1OOMgXaNWe1m4PGN0XoSA-1 X-Mimecast-MFC-AGG-ID: W1OOMgXaNWe1m4PGN0XoSA_1771405559 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 48/85] audio/pa: convert to QOM lifecycle methods Date: Wed, 18 Feb 2026 10:02:48 +0100 Message-ID: <20260218090330.1476169-49-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405895736154100 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 04:24:18 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=1771405883; cv=none; d=zohomail.com; s=zohoarc; b=JfnyApYxQ9m4YrjpQtFgj1XuwHQx7SwL6UPYPhiwj4LJowaQd8dqCXBYT1uWINwXk7NZ/QtHOV2h9NVNeCsKOTJX64nxhpwQLmBErI+ZldH+SJKQel3DQT4+krdvTbZlO9zUOSrds0gAkT6r/QQyfy+h1lpCI9tQTb8r1KRNeaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405883; 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=k5KLxSBORY6OKKlQHYPlZCshIGDUkLDMHUaqWtIvRtPryM/b/LoYDLwo1tMejOEpveQ5D9OAcCAnGUUN9iNVgBjcxIgOjgE50afYnGliuSjM+7CKZhQ58xGDcZITPJGocrO4mqTM2gepa/Atl7Qziy5RPWdMuy1apup3m8M2epA= 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 1771405883611513.224833880508; Wed, 18 Feb 2026 01:11:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVj-0007wk-Sd; Wed, 18 Feb 2026 04:06: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 1vsdVZ-0007Iz-Aq for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06: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 1vsdVX-0001bz-Jv for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:09 -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-711-aYDNoKxlPSe-MNmgQf0abA-1; Wed, 18 Feb 2026 04:06:03 -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 408CA1956050; Wed, 18 Feb 2026 09:06:02 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5EEB3180066B; Wed, 18 Feb 2026 09:06:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405567; 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=UeljSIt06p9ChwxmklybEOZbuj5i58xXURIqqmg76Abb+Q/ySQr9jyBSeyNLkvsoX37Exl xlFkgv1/JQEOrSiEhijjCYiMFcv+nKOXoIcbQYkmX6/ZwA8pPzNK/XfDpiDo6Pq5R1L80P R7QKjv0p8LiIuV6Eh45tV1GMt/sCCgU= X-MC-Unique: aYDNoKxlPSe-MNmgQf0abA-1 X-Mimecast-MFC-AGG-ID: aYDNoKxlPSe-MNmgQf0abA_1771405562 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 49/85] audio/sdl: convert to QOM lifecycle methods Date: Wed, 18 Feb 2026 10:02:49 +0100 Message-ID: <20260218090330.1476169-50-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405885520154100 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 04:24:18 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=1771405912; cv=none; d=zohomail.com; s=zohoarc; b=DupQpNrC9eXsKthz16NDF+4qoBVBR4USv+TOmlP0QNxFVe9peqUpzHDvpR2aNqg0N4RjtJ3KG/Ee/DNUPagj2rHN6/7dhTEcP4MxvCr7Ia9tR9ysbFSzIeVuOqdSFgMrnuVsWS1x/lZtdB8qk/Dib+Xut7ZeVoOx9+NEXhZBwuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405912; 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=WqPw4tPfeHYVBkzxo6LLHw7+qMOOvEqjkVvZvAz5TKdyP/5HC3xXYPbNpYMCGDcJl/WjZzO+wDdvxA7TNvG1v5ACsjbexLSt4XWhetAacxzCzfbtWaP47A93OXeqrpUpPb3ph+7vvxbUDDpG2mfkTI3Hcn3fXVyS148VJLJ4sa0= 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 1771405912161437.97911732354714; Wed, 18 Feb 2026 01:11:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVj-0007rq-0y; Wed, 18 Feb 2026 04:06: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 1vsdVd-0007Qa-7M for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdVb-0001lJ-1i for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06: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-593-QyyCXZa8NkegRtTSiO0ZOg-1; Wed, 18 Feb 2026 04:06: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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 32A361956050; Wed, 18 Feb 2026 09:06:05 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5770730001B9; Wed, 18 Feb 2026 09:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405570; 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=RJ3/dMLv3pQklClff2pAxQDti1tr4vbP8npxb6yIUo7YATAerPpEjTktfz4Nz3an4DzPSl fO+Xs6WH86uLaGr7tlYtTsAp/OME7E2euuhsieLfOgCZc4soQr9n2qYkuhUUI8s6+y7AIC D73EbBfhUnyRMCNhz0hIqVzFhcYJbs0= X-MC-Unique: QyyCXZa8NkegRtTSiO0ZOg-1 X-Mimecast-MFC-AGG-ID: QyyCXZa8NkegRtTSiO0ZOg_1771405565 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 50/85] audio/pw: convert to QOM lifecycle methods Date: Wed, 18 Feb 2026 10:02:50 +0100 Message-ID: <20260218090330.1476169-51-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405912531158500 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 04:24:18 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=1771405932; cv=none; d=zohomail.com; s=zohoarc; b=Il8eJzobOjpxOFP4KzDbQNI3tali/AtPCOwPhuMi97fKfi0BWP3akDI45rJyYuifKn62EABVUsvu20sewtxKvXaxJi0nKbi6RssDpaFdBB049x3T2te7f2zWX1BiAHWvzVpNvr/blv5JA+0bjM276ZoWRWaPu03A3/xJVwKsnwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405932; 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=Pctor0Pz/RPJ1kbCqmgc33lj1YJLkHGmPg6lKf2wvTgtQ7t8QLiKBYQReiLGnA/yKyHHgwTn3E2/ydffzLew/Dhf/8/nNVEzD5qrIL/t5iXOyW4nVvKMvXCffEM8DTKGiJ1s1Dh5vrrDcorhyjatU5+LxHCcqUIytFgZx6ujy0Q= 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 1771405932288265.04007489442256; Wed, 18 Feb 2026 01:12:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVi-0007kK-3T; Wed, 18 Feb 2026 04:06:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdVc-0007OI-Qq for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdVb-0001li-AU for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:12 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-79-LXIeUZumMxWQdZAR5heIxQ-1; Wed, 18 Feb 2026 04:06:09 -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 438521955BD9; Wed, 18 Feb 2026 09:06:08 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1E1731956095; Wed, 18 Feb 2026 09:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405570; 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=X2t50Q473WaiQh6qhZ1WMdkzI1NinCIJrVjpkyU4Aj4ag5hvIWbqb8ap92MiZDqKq8Kg2L ushGdKLGVWObJxXgUdM12Dnh71tZhKCpCpGBgCL3fNYrMnEcPh/5X00+Q4JvetBh0G4ff+ 9HEuPNlbJtMstPzGlA7gjG5RltGe+fU= X-MC-Unique: LXIeUZumMxWQdZAR5heIxQ-1 X-Mimecast-MFC-AGG-ID: LXIeUZumMxWQdZAR5heIxQ_1771405568 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 51/85] audio/jack: convert to QOM lifecycle methods Date: Wed, 18 Feb 2026 10:02:51 +0100 Message-ID: <20260218090330.1476169-52-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405932485158500 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 04:24:18 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=1771405901; cv=none; d=zohomail.com; s=zohoarc; b=C9raRBILrKH99T/dNR1Um+3ia2GuOWRUKaO+mXJtBt4OQAyv/U41vefI0vukloynYqjm1fUcnJehSLNAsKq4srQzsez2wpbDmn7+BzxAOwU+VmXJUtEYX6fk70AF6mLzR4A9T1rKbg1jI93Qe/9nw5BcgHfwhdfqEfk5SErHVqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405901; 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=XuE2M8UCiiW0CzvaZtTZpLt1/Tzfj8OjZ37CWIqhuxCL3jtEGU9YY4gRFqhX0+U01Uc84lroCrFRFTn9HHpgxwzzUTOqA4cToVxWTPKTSX6GaRcawKYcambS4vgdOyLZx5Ev5nrrq9IxxTNVHYupMMVlS/kqTM+ZAixrGsNWUA4= 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 1771405901676241.27945635375363; Wed, 18 Feb 2026 01:11:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVn-0008Ie-35; Wed, 18 Feb 2026 04:06: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 1vsdVi-0007np-ED for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdVg-00022R-Ni for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:18 -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-645-516FPvB3OJqeieaQZCkWnQ-1; Wed, 18 Feb 2026 04:06:12 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 84C3718004BB; Wed, 18 Feb 2026 09:06:11 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5ED981800361; Wed, 18 Feb 2026 09:06:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405575; 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=B9Hg7V6gZ64XH5v5chuAW5lYymDG5XKIifaj6sNpCEbXa483Bpz3D0+i5cFYiErqYiIjX5 oYE3rUyAPjBVUHePyKGO1O6AgI83oDHGuoE+hkh6XhM+Rg2gkGhB5749QVevpH7bR3nvOK AI8EvqbuAtaeguGuJ+d0slxKKwh2cw4= X-MC-Unique: 516FPvB3OJqeieaQZCkWnQ-1 X-Mimecast-MFC-AGG-ID: 516FPvB3OJqeieaQZCkWnQ_1771405571 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 52/85] audio/sndio: convert to QOM lifecycle methods Date: Wed, 18 Feb 2026 10:02:52 +0100 Message-ID: <20260218090330.1476169-53-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405919176158500 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 04:24:18 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=1771405793; cv=none; d=zohomail.com; s=zohoarc; b=FvGNk1PX3bs0sPShqG/GhRLolByMV6KKA/6SQ6+SaIdZMP3yN2q63OU4itQpg0EuolRcQfnfzAhF8HedqD9bhVXqXPThyQ5sxMh2eWeFiDdOkOxretP9lbreZ9AUL0C6Rka7aEUh1/1yNiq4Jm2Jv+lVaFoPSqmTa7LtFsd8nww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405793; 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=HoDv9dYpFOl48nypz+9FzMzvsk+Hrd2mLrC73//5ySKMd/Kkib/HUPCzaN3S1GZOcaKjzX5R+l/9lezMVGzhd8pYXljrhJN/ccZTzSstilC2pXt0joUGJCnJVgvkeiPqCNRhFiX0ui5HFQwJ8Gwtyu2joR95kdIR6V3zDSZV2qM= 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 1771405793815122.96859841407809; Wed, 18 Feb 2026 01:09:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVn-0008Nk-UM; Wed, 18 Feb 2026 04:06: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 1vsdVl-00088B-Dj for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:21 -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 1vsdVj-0002BE-Ls for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06: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-495-8Y8iWe_PN6aBYUeqWrOW5g-1; Wed, 18 Feb 2026 04:06:15 -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 657CC1956058; Wed, 18 Feb 2026 09:06:14 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 72F96180058C; Wed, 18 Feb 2026 09:06:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405579; 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=AYuSzlwkP6wvCsmhNhM6UaC0kDMYuiX3xwHu3rB7a3XD2ApGndp2mX6Rnqj76B7D483TqM cfd3UCIR4Q4uwjQrjU4NEUy3Mizlr1zLVcguATFBtN13CbLp0m3IY3Ow2Y3eCVX8ql/vE3 tdhxjPhHwygYCi59V6o4HSsNLBIH3sM= X-MC-Unique: 8Y8iWe_PN6aBYUeqWrOW5g-1 X-Mimecast-MFC-AGG-ID: 8Y8iWe_PN6aBYUeqWrOW5g_1771405574 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 53/85] audio/coreaudio: convert to QOM lifecycle methods Date: Wed, 18 Feb 2026 10:02:53 +0100 Message-ID: <20260218090330.1476169-54-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405794027158500 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 04:24:18 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=1771405681; cv=none; d=zohomail.com; s=zohoarc; b=gnmwaoOCThGtwrY62G3D1lgSowtNphIBsU5gDNohuz13C1z5twpNW7S+lqX0gw3KdTHtonvL8kZnMaIDR2ofWBnt1KWE5aGxHm9XQaHvqtZiYTudQgfimAmtZ2zAQJrzw4+5TwfSBRLMUj9sVvZ/PfWecYE2PX2UV6aX+g13+E4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405681; 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=IZDQ4BbcHNKwG1vqx7rKG8c/gxODHW9GAxMXHUyvGDM5az/WLnS6HQ1WK8mXkVzBNFscsyjsP45Z4ZtPHGjuRYgm11+lyJw5kJ18m3jSisZmPo4b6ktEKaaRXQaNqhYXJLX2CXirD7A00tb1nJYRccOKrqEQ/gmiJ/idndav4q8= 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 1771405681281672.9674357596149; Wed, 18 Feb 2026 01:08:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdVu-00009F-50; Wed, 18 Feb 2026 04:06: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 1vsdVo-0008TF-QD for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:26 -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 1vsdVm-0002II-KE for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:24 -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-660-1vrOS0HbOHqxZwGfv10J6Q-1; Wed, 18 Feb 2026 04:06:17 -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 139DD18002C3; Wed, 18 Feb 2026 09:06:17 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6C1D91800351; Wed, 18 Feb 2026 09:06:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405581; 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=Rzor8eq3NRrPOw88swELrjZO3A4VuCy04WWPb5aL71jA/s6jKKtnQ71gHokkbqV0/6TABy xmipIerb3ZolA2tnkdKxRZDQHwXbFyilxpn7cXakRmDKuTWWi3H8gDS9+Q+qZRKWo1sQ8u /s5tQlhA9APfXFN/ORDHeRzmOz2Y9c4= X-MC-Unique: 1vrOS0HbOHqxZwGfv10J6Q-1 X-Mimecast-MFC-AGG-ID: 1vrOS0HbOHqxZwGfv10J6Q_1771405577 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 54/85] audio/dsound: convert to QOM lifecycle methods Date: Wed, 18 Feb 2026 10:02:54 +0100 Message-ID: <20260218090330.1476169-55-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405681733158500 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 04:24:18 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=1771405791; cv=none; d=zohomail.com; s=zohoarc; b=kMWmYwgVH20K90xruQjlvtr6OlZCcjKwkgknDfB458Bqlfly/OGg952m62M5ZxEHURVLgR3uSbhXnekiXklJNE+dkyLzsl1lsJamRVg2M3YJ1cW0ZUJJ1QFiMUIodAZuk48dKMq2/dDMChZhU3b0kUwfTfqMCwsrftrkvP1WIgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405791; 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=PH6jCPSIJo9ITixNCwbWEspyPJ3w/31Wafi9XL21uGiRi0kQDFlcS5quDywjYHlVNB1u/xPhjOha7kCuLjGmaBXf98k+HsjhtM0KqHO42mcOBGmzowAIOxlJNSdMMiPhXcVADZbdSPCdPBGSJOX881pXXvQblWzOUYKe6/GOdak= 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 1771405791682921.2844200986506; Wed, 18 Feb 2026 01:09:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdWM-0000XM-O7; Wed, 18 Feb 2026 04:06:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdVu-00009t-B0 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06: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 1vsdVr-0002My-5Z for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06: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-179-WVUIUNS1OB-8bIAukDnKnA-1; Wed, 18 Feb 2026 04:06:21 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8B4181955D8C; Wed, 18 Feb 2026 09:06:20 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4B7F31800361; Wed, 18 Feb 2026 09:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405586; 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=COyjXxjClSLUxQt+Qzu8M68eRCYRXjb/varq2G8YbBYwQC9XL1dLe+JdraQSCBaMYFkRuV cPBh9HcgwcCcT3oGJH3l+H9Xln6LarykgdYqAoK0XL3KgLReL3TYa3ghKl0AgyKiDQas7p qw3NrIwkXPz65LLQ79DLXbLEBMj8D6o= X-MC-Unique: WVUIUNS1OB-8bIAukDnKnA-1 X-Mimecast-MFC-AGG-ID: WVUIUNS1OB-8bIAukDnKnA_1771405580 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 55/85] audio: remove audio_driver init/fini/next Date: Wed, 18 Feb 2026 10:02:55 +0100 Message-ID: <20260218090330.1476169-56-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405793029158500 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 04:24:18 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=1771405781; cv=none; d=zohomail.com; s=zohoarc; b=Mfda+AmEjLYjttWq7dguTwHlGEy4VWVxMcbqMswHSyDZ9/Tt+LzCj4rES7O7d4nop4dFyuWOde3fUvjfq33n4ZaoyWDedQiwkcbII769ZUPQGifqwPIHlg9xaB/KL0trFQm/QuVVSYVI/tF9cEwXA0/t7D285WLs9VWeSRgqs4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405781; 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=D/0+vM8OA+8JDluRmcx2m7CKvvn1xPZIPdjjRuRZxkFnqaoGrf0XnWEzaj8DWHWvYYfLaBBT4T7eDuDPKxn16coTcvOnZYPkbRXOEAPjfleje/jgUh2P9R9jr1Zv0NflutSZDFmf+WIV2XyVEPaJmxT3vH3xwC/F2+8Xk4EUU3Y= 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 1771405780903181.82410394151304; Wed, 18 Feb 2026 01:09:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdW0-0000IL-30; Wed, 18 Feb 2026 04:06: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 1vsdVu-00009s-B4 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06: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 1vsdVr-0002Mw-5J for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06: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-563-WN3C0sQkPt-IblpH4dxejQ-1; Wed, 18 Feb 2026 04:06: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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8321E1956060; Wed, 18 Feb 2026 09:06:23 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8C0691800348; Wed, 18 Feb 2026 09:06:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405586; 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=Tk654wl+PvyQ4J6lUNI04kd1+Vrj0gf8H0DZMRjDrxbzc3xs/pbN6UUFW6hxXoq+DIRs0M 1Skx+ArRaqwPlQG565Vnm3PI9GCe8Vq8qQUsc3a4jlC3D/F9LNEjxyrQV+7NL9Caq7n/8P 6CpnffzfgXZdpTz41fxJvp0oz7ygVk0= X-MC-Unique: WN3C0sQkPt-IblpH4dxejQ-1 X-Mimecast-MFC-AGG-ID: WN3C0sQkPt-IblpH4dxejQ_1771405584 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 56/85] audio: remove audio_driver Date: Wed, 18 Feb 2026 10:02:56 +0100 Message-ID: <20260218090330.1476169-57-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405782389158500 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 04:24:18 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=1771405708; cv=none; d=zohomail.com; s=zohoarc; b=JkPMerKRe4V6engoNdRqq75R4i/UsSxJj+cObgQWBKx/EafO/qYjAgqjRpGLk758RqWkyeZwJJ/PwGQpscwRYaale4W8XqTCZJzegLIpTUMkA/EV6hU3j1AesXfdjJLVLQfwn+fvNu4c1ye4PsXg2hPLfebOyun7MdoguZHbcjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405708; 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=aEztZfXrdpfpnXSZSh7/KbizN5RnN0ota38Sn8LJbXlQO/nOg6A7av8Wd2Tp5bsR2mwHrqv4zXBXLRfuLt/RyhwiaxVsrUEilR0DKfT0iW6TlJIqlPvi2Qqpt3uqweRVow0HcBZEu59crau8eNAO0C/1p96C+O3hl0E8cX/emxE= 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 1771405708628395.61647544912705; Wed, 18 Feb 2026 01:08:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdWS-0000c2-Si; Wed, 18 Feb 2026 04:07: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 1vsdW2-0000OM-LR for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06: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 1vsdVy-0002O4-4W for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:38 -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-650-xaXBa5cROSylbTG-De49kA-1; Wed, 18 Feb 2026 04:06: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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3F6D4180061D; Wed, 18 Feb 2026 09:06:26 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6BFE6180066D; Wed, 18 Feb 2026 09:06:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405593; 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=B6a4byOiZRz5Kx0eilu3HPjZKFuV/n6CJQAR8dIrF//Sf5LiVTLcvcZ8jI9vxML94XfzVz Py21r2ZXtGNnus/e1sRgh9QdGtsjGg6951n0PvgEhiqj4yN5cj8ABNwX9w7kNloOq6uOAq ISre0I50tKQ6P5P/Mke3KMJnuXo2IYM= X-MC-Unique: xaXBa5cROSylbTG-De49kA-1 X-Mimecast-MFC-AGG-ID: xaXBa5cROSylbTG-De49kA_1771405586 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 57/85] audio: move pcm_ops into AudioMixengBackendClass Date: Wed, 18 Feb 2026 10:02:57 +0100 Message-ID: <20260218090330.1476169-58-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405710052158500 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 04:24:18 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=1771405767; cv=none; d=zohomail.com; s=zohoarc; b=VkMdD51KshGdXPZegBs+0Bt6fxB6LiyCCbX53eQmkuYHLV6zz/yP+XuSFI3S9Wmu6z0PKHvOXAdjTI2OCQLcRS/59fPZE5qZqn/OSbyP9KYSSjo91v3Bkq+NkLSa/tR0e51URbLYxg3i8Gt3kvdIOzntcuXmCOIOP4IOTq1wn4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405767; 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=hU6/N1L48SSzfVVoPcECxgYnNmDdWyf+zqPgEgFYENQ7L2aGYgDqVTZatVb7V4oy3WBncxgZ6KtwFT2Y8YerITi1kSUpuJ2I7RXan90c415bQgxvkyxKfCBmPh/Ud09kWvA0ZjCVssYQxla6G3YnM7O3cYRmnQ5HTyG4aPYTcUA= 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 1771405767945813.0250570276007; Wed, 18 Feb 2026 01:09:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdWM-0000XX-O2; Wed, 18 Feb 2026 04:06:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdVz-0000IQ-8q for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06: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 1vsdVx-0002Nr-8y for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:34 -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-661-nWTzUi4-PJWetTmT7NU28A-1; Wed, 18 Feb 2026 04:06:30 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5A30C1956094; Wed, 18 Feb 2026 09:06:29 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8ABEA19560AD; Wed, 18 Feb 2026 09:06:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405592; 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=OsjPihEsMoEBhtNcIqibPALuKxp5JtFOujHhDo0LeF60NIrSRb+BptZ1l7SvWYhQ2t8Frp 5ZFwqZWpfeNBzCfuwW5lA9VCwRXXl77GwDozJtqnuZQZafOvXyFWV+bV3Ke9bosenBLWPG p0AFB+mGrHdF9AUI4kFFmeaABdmTygs= X-MC-Unique: nWTzUi4-PJWetTmT7NU28A-1 X-Mimecast-MFC-AGG-ID: nWTzUi4-PJWetTmT7NU28A_1771405589 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 58/85] audio: constify some add_capture() arguments Date: Wed, 18 Feb 2026 10:02:58 +0100 Message-ID: <20260218090330.1476169-59-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405769981154100 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 04:24:18 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=1771405687; cv=none; d=zohomail.com; s=zohoarc; b=bp5sXejk7FhjImUojPNPWhxoHR2dyTx3ZjDBMzGDWot4qaIvThh6FTIsuceA9Z8pg2ZgCcMkE4Mlc+mMZN+CWJxUdG/xWHwpd/kQkOR5QxMiGOjlNlpR65srOGZt8FXomSqEz58gJeGAP+nF5nFkdHSjGWosa5lZkEDGf5BA+8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405687; 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=d2eX/LoYUc/5ivVj8UxebWH2p8LAP6KYTIuplub+C2gJQQWWlf5DKgRDm5JezZr/Us7kK2G3wOFNLiLY9yCiFvwsMN2vCXWP/TBgVQ0PLk9g1+l2AJmvV9Ya0yVQMDTzqmRfFVXY2aCTVqBf1VqScMIK1LAroZ98j9OKHe/NNNE= 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 1771405687384680.161729894766; Wed, 18 Feb 2026 01:08:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdWz-0000sN-HJ; Wed, 18 Feb 2026 04:07: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 1vsdW3-0000OS-JY for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdW0-0002OP-VA for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:39 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-152-2f4deptLND2nDM9gK6Im-Q-1; Wed, 18 Feb 2026 04:06:33 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2ED62180034A; Wed, 18 Feb 2026 09:06:32 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 150291956095; Wed, 18 Feb 2026 09:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405596; 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=ZzYj30ikH8rHl0bPdMr/BINkk7RDQEgWv6eylapsoypztnYymLqzC/a2M+oPaXJ2Und7r5 RSakubJbwm2Au+ddPsNxI9P26qgiuUN0XD6bscNMsk39U8nRhvnrLq3MZlkaPZFKKHwNnK EM7UDcReSzNd6nHXnw9Jg9tLCnoiWNI= X-MC-Unique: 2f4deptLND2nDM9gK6Im-Q-1 X-Mimecast-MFC-AGG-ID: 2f4deptLND2nDM9gK6Im-Q_1771405592 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 59/85] audio/alsa: replace custom logging with error_report and trace events Date: Wed, 18 Feb 2026 10:02:59 +0100 Message-ID: <20260218090330.1476169-60-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405687778158500 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 04:24:18 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=1771405681; cv=none; d=zohomail.com; s=zohoarc; b=mU9LiLYHE5SSf9LsXkMYvlagT9cRVL9E+lmmA9MIIVSvIQFLMYtmhtoGwd7jFtcCiPilwk63qBY8D51xWGgIsPauDqee5RMb8ROBNUphRoSwrRucLPDqGOgiznTYpRY1iqIsHCd5Vg+MOJKjyS/XVWFDC34a6A6LDW/hdPdQm18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405681; 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=OGK3XfjN2qy5bCF4w1MiVGV3CtJsSo5AbRCCP/QTXHeWs6SFH+UNS470ZYi1NfRGjm97nhkJm23AP91J4HixDXvV4w+xz9si4MvfAcNSyZiqWbn1kpWOjOwQerO27cZ2kO7Y5baYlx7Gc7VNYjDsofarw1avNbjvK4IbAaMlbAU= 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 177140568120276.95911460971956; Wed, 18 Feb 2026 01:08:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdWS-0000c1-SS; Wed, 18 Feb 2026 04:07: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 1vsdW7-0000Rs-JQ for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06: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 1vsdW5-0002Oe-4U for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06: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-347-wrmIKO0qPPKOGzQ0nv_uxw-1; Wed, 18 Feb 2026 04:06:36 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 40820195FDEC; Wed, 18 Feb 2026 09:06:35 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3F2C81800361; Wed, 18 Feb 2026 09:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405600; 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=PoKvJUYq1Ix5CHOWf1yDbLkEmga27G1iOVRjG870/JIWSmapCoUyPiBUdLKercTFGAfk+Q 4mxxpHJ0+mhyMj+2dW+sdK2LBfKRfhMJzCxYNZ/MihlVtfS3Tl941SiTcbk+oRtl2RBAAZ F9vHNcma4x/5Cf/2b97IlhGXeF9Wwnk= X-MC-Unique: wrmIKO0qPPKOGzQ0nv_uxw-1 X-Mimecast-MFC-AGG-ID: wrmIKO0qPPKOGzQ0nv_uxw_1771405595 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 60/85] audio/coreaudio: replace custom logging with error_report Date: Wed, 18 Feb 2026 10:03:00 +0100 Message-ID: <20260218090330.1476169-61-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405683177154100 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 04:24:18 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=1771405735; cv=none; d=zohomail.com; s=zohoarc; b=nHIrXMMI8SRuP6Dy3PpgruvPuelS4pKP2lce9Uo9HWGth5VxSo0LxSxJKyRWgbzYjMPPKlr1xQqR2xFzSBsMa40653BNODI2MHQ+MLx9nufA2rlJ/ASjmly0XAyXE2CAdtJO+5+QYH3wpAxz9XnTEtpCgAPT9Zs7kxRXNEZ0pjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405735; 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=IEH+eYzTq82f5cFrskLf2unJrRSRUFKYJrF3RODCstmgOvpkhxz4GNL3bJjp5oSnQhK5GX+yQ0IHHg4QEdNxs1xkcxriYHhABajw24RaOnGerpWXLYqV40FR+GgtWT8dF0d0peTYNZGM4dy29wX4DY+Kom1NzhUDoFQGRfgCRps= 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 1771405735434839.7949512253847; Wed, 18 Feb 2026 01:08:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdX5-0001FR-Kh; Wed, 18 Feb 2026 04:07:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdW6-0000Ro-V5 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06: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 1vsdW5-0002Ol-MG for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:06:42 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-25-tYA5MEG-NUSWT-ynX9AmsQ-1; Wed, 18 Feb 2026 04:06:39 -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 2C8071800370; Wed, 18 Feb 2026 09:06:38 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1F1DC30001B9; Wed, 18 Feb 2026 09:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405600; 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=B8GNXfoUzpAtv93r99yXTsM0EBiuwB++jh0seVHc1c+/zlEMNjEnbKvPW+QiJm1aJfIDXo 6hLFNzGCr4NbtIh3FSERMYSwfGCECfvauT29Y2z8ovWTEoJMrx5lu0LZH5mIJQmujnBSiG ZmbIFgjuEMEMA6RDyeVXs8daBZI1G1E= X-MC-Unique: tYA5MEG-NUSWT-ynX9AmsQ-1 X-Mimecast-MFC-AGG-ID: tYA5MEG-NUSWT-ynX9AmsQ_1771405598 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 61/85] audio/dbus: remove unused AUDIO_CAP macro Date: Wed, 18 Feb 2026 10:03:01 +0100 Message-ID: <20260218090330.1476169-62-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405735793158500 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 04:24:18 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=1771405909; cv=none; d=zohomail.com; s=zohoarc; b=DivQIjmb+3X48tQPO66PWtpvxtPDkrqlK/BHN3RJVGMNSns1YbMr7TqZWyFK2i8nb9t7EYCbjSvdIbpfdnTXb3Kn/trSTH2jygbjVD1X9DxU87n8IZqL/VqIIrhdnZHX8qRRPCyEVaBfjDIFMS4UiaQq1/ipeVuxGbrl8LPmOec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405909; 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=DZ2KmBUqcRpvUK5kBU9UYTwwoF8WGLNrs4kyjsIihfS7g40+fq5SDhcmMyjI2AiEbJFZtKe8SO14p3wc/I+bI71vskaug+8w08+EJhDSMDMurotT61S8C/1CG+0bIykdabBT8nYMl5yB0pCH/YejeZFXKHl22a1jjRf1U0gPq74= 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 1771405909483707.099247825619; Wed, 18 Feb 2026 01:11:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXE-0001lx-VU; Wed, 18 Feb 2026 04:07:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdWP-0000gU-Af for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdWL-0002PG-C8 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:00 -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-61-4JvG_hQCP0GFG7IRbEsUXw-1; Wed, 18 Feb 2026 04:06:41 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E55CE18004A9; Wed, 18 Feb 2026 09:06:40 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 47CF930001A5; Wed, 18 Feb 2026 09:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405605; 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=aonj24oGmrEelz+4Jpds7bl/PV9WcxrdKJCc6u3AhO4XEyemKMDWJy5FIwDOYj721syXRe UEu4UknmmD4vZMqxIMaKDqGqnmZbVRrK/Sp1m/N2l7RHN9gZ3c/ytVxkFQkDPtSSPXt9rF 6xehEtaRnMwhhYQTzosekl6BVKXXKHo= X-MC-Unique: 4JvG_hQCP0GFG7IRbEsUXw-1 X-Mimecast-MFC-AGG-ID: 4JvG_hQCP0GFG7IRbEsUXw_1771405601 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 62/85] audio/dsound: replace custom logging with error_report & trace Date: Wed, 18 Feb 2026 10:03:02 +0100 Message-ID: <20260218090330.1476169-63-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405910500158500 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 04:24:18 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=1771405715; cv=none; d=zohomail.com; s=zohoarc; b=NIpOnpnY1iajGLBUQMnOk3cPmLKYJlpZ+zzhkbBG62c5iP2J590jZkqvTNSlgGTtLt3YUf2OctEoeGB5mHr0dWw+M4on9FtxRa6oH3BI6kfHLTSNpyrRN9+TuHjzV/eSHLZhahOmODWiYTUQWerT9mRROJxODNcAXNbTL3fu9tY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405715; 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=iT3wM7k6X1gjXb4nDaq21fBshJ8vusu5QxGo9B8xs8JojB84wY4LfFO0uSv4lWnQJIZQTeB0UTN8V2Rx8+RuqAe6+nyuD60flRdMw9qyi0FCfJoDzT1V9hp7hqjq628jCVtEAqwxgK9bqBohPumsJyavP5ZjJsCQGO6uWhoqEBc= 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 1771405715805997.8071417912545; Wed, 18 Feb 2026 01:08:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdX3-00017Y-FL; Wed, 18 Feb 2026 04:07:43 -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 1vsdWR-0000h6-V4 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdWM-0002PQ-PA for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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-597-ge6swgX8MJa6MsRS-Ezk0g-1; Wed, 18 Feb 2026 04:06:44 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 300D4195606E; Wed, 18 Feb 2026 09:06:43 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9F3A91956095; Wed, 18 Feb 2026 09:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405607; 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=HCo0Fu9b3DlWxjTiug1GgNAQjYd2NcNAG4dHD1xjtS0SwzCfK403lMTkhtqh9pHJViauIs hUHB2z/7EbNf23lJs9zFcGm2gz3FE75H4AIePiUms7WvB6S65CCgTCa+qO/s/Z1QMGK1vx tTax+HnHRlGeEc8IWZt5ClNGLU1kVbI= X-MC-Unique: ge6swgX8MJa6MsRS-Ezk0g-1 X-Mimecast-MFC-AGG-ID: ge6swgX8MJa6MsRS-Ezk0g_1771405603 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 63/85] audio/jack: replace custom logging with report & trace Date: Wed, 18 Feb 2026 10:03:03 +0100 Message-ID: <20260218090330.1476169-64-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405717828158500 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 04:24:18 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=1771405830; cv=none; d=zohomail.com; s=zohoarc; b=lp6Ae86VrxYgo485DMU/xdQo5XtJsao4AxdCcnw3tBZgVSxLnm9DY8I/pDuW7qjkppaGZusZWsqvJVPIuJ217mpPGMB/IIGFvDoHtF9aOxwBWadhe0d3mZI9VS+l/Kurpwxv3q2GT0s/5hfphu3w4WYVr/mc8rNch6y3a/0S5O8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405830; 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=GbFKYP93b8/Qrigw/HQc99nL3FXUdwT6iqhQl3Go7kWSyDEMBeLhbbhCFmCW24fq/mZwaa65BpPJo4EqWsNKOGY4GQESW/y0DWOXV0um8mUGalycA45nT5lcrumfsHb1uGYiPY5ScRBxNo5DU8no/PgbBaEzn3uhqD3IWXtV1OQ= 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 1771405830489963.4359789905338; Wed, 18 Feb 2026 01:10:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXB-0001UE-Jf; Wed, 18 Feb 2026 04:07: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 1vsdWP-0000gV-VA for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdWM-0002PX-Iv for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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-345-gsy7b8_9PfGt0JrW_LSXBA-1; Wed, 18 Feb 2026 04:06:48 -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 2CE691955D8F; Wed, 18 Feb 2026 09:06:47 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4E0B7180066B; Wed, 18 Feb 2026 09:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405609; 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=J78ryaDB12hFahknYb+40BwWGjDMDxstkyRQzMjjubueRiaFt9qIvLCqqSwXx90HgzZF+N ZyxqVSWZyBdPGfXH1Iv2noaunPeeZXESWmq4NVqET8mabZ7+KW5NxueELVYhttYCiyp6Sc nBedVdv4U00KExOFEDBTpaPozAhhoD0= X-MC-Unique: gsy7b8_9PfGt0JrW_LSXBA-1 X-Mimecast-MFC-AGG-ID: gsy7b8_9PfGt0JrW_LSXBA_1771405607 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 64/85] audio/noaudio: remove unused AUDIO_CAP macro Date: Wed, 18 Feb 2026 10:03:04 +0100 Message-ID: <20260218090330.1476169-65-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405832256158500 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 04:24:18 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=1771405801; cv=none; d=zohomail.com; s=zohoarc; b=IUmRqxWK/8ixHQduEsEwrwL0jP6vVSAU7hRNiNn7qowe0Wn1AWiU6ltx7OoLwL06RwhLgsrLDTX8au/GqzU+vwtyvVS5IdyaWPttD/lM3Rx8mbVbAw4EKcu3r4DqiaOVbMB7gpcneRG9aP7fews6HgEPgqXezC8RKcBKVoywwLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405801; 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=aFYpUPvwe8yl6FVKwAwADvOgUUjKv3RdM3lrAjieCc4beZO7/yc6rC0MTM2HHbX4fWVc4V7JGE2JqM2SBMwWfSZiRyBVcZ76V76xiZBudoDf8j/sTrXRe+9DEA8lZL+x+t2eYHXwi5VO2mi9bHx5qvaMik4if4im6BPsnsY1YFM= 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 1771405801765374.77496124990705; Wed, 18 Feb 2026 01:10:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXF-0001rR-Lk; Wed, 18 Feb 2026 04:07:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdWR-0000h3-Ug for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:05 -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 1vsdWM-0002Pe-Mb for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:02 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-426-MRySYup8NFqrBvsloceegg-1; Wed, 18 Feb 2026 04:06:51 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 344681955D42; Wed, 18 Feb 2026 09:06:50 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 65104180066F; Wed, 18 Feb 2026 09:06:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405614; 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=DNv2oQ3sByfPqVO4xblICuAYZHY0B7DOwhKhvUNRHHY8l9ICf9OsrDgLHJQ3JgFBXeQKNp Em5XLKb0XRaL1C+N1KiBFV3log5eT/WhWFQQ9HyMP1j1gae/E+bpguK0a/EG0kAM+phw1x f164qc9A88Lhi9Q6Pdhl58kCeXrRZ08= X-MC-Unique: MRySYup8NFqrBvsloceegg-1 X-Mimecast-MFC-AGG-ID: MRySYup8NFqrBvsloceegg_1771405610 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 65/85] audio/oss: replace custom logging with report & trace Date: Wed, 18 Feb 2026 10:03:05 +0100 Message-ID: <20260218090330.1476169-66-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405802719154100 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 04:24:18 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=1771405751; cv=none; d=zohomail.com; s=zohoarc; b=VnMoQex0BjoupOoJXFcVBPb55w5M6n0Nwhw3VM16tXSMey8pm1nIVg8HPdMXy3HqIgQJGIA0tQJQhdrWY7FZ449qqxiJ8Y33qeVrzrwB/lHRGfX2jmhaR0LGbVUFdm/amNjhUQcwcGkKPTTfKuLqv/BbzqnfE8Qqo8gATucS6FI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405751; 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=lr29T3eU3+Mo1Y3SXnc/gh8ALi5TSjF2QrTSpqBShKRY47WBtBip20Br4fcjF+ozsN4y9P0ztgpeLQ3ioX4zxbUtu7js44Dl1GUI6sOO1cu+P91fGK8MjMRX9HBlIfzluA+wjT5ffeCnuP2zDkQsg9XqpoKLgPIP0y1Bj5I2p/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 1771405750994794.8784663513161; Wed, 18 Feb 2026 01:09:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXF-0001rD-KA; Wed, 18 Feb 2026 04:07:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdWR-0000h1-UZ for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdWM-0002Pk-KD for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:02 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-470-hpvIIToWNEqgZ2-S2KGveA-1; Wed, 18 Feb 2026 04:06:53 -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 848A61955BC4; Wed, 18 Feb 2026 09:06:52 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D528130001A5; Wed, 18 Feb 2026 09:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405616; 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=GLbnujCiW6qHMLueVA+QJeOrdYfbGCt/RJaYWA7JEcdiqrGYFtEy2vLVzS2VSgUchZ1NNe Wvj2hDwbu/waajhUC8uDPYrNsDIlFXAn3W8qXSt1qUC43aliIXLLY/Qm0zy1gCZpdMLZ5a emGtQWGOHe3KD8ops1K3rX2xwAFMQLU= X-MC-Unique: hpvIIToWNEqgZ2-S2KGveA-1 X-Mimecast-MFC-AGG-ID: hpvIIToWNEqgZ2-S2KGveA_1771405612 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 66/85] audio/pa: replace custom logging with report & trace Date: Wed, 18 Feb 2026 10:03:06 +0100 Message-ID: <20260218090330.1476169-67-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405752005158500 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 04:24:18 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=1771405815; cv=none; d=zohomail.com; s=zohoarc; b=RETTkTLYOk8kryEqFnx9/6elNaVi+sIJ4TO4fhgiRfPBLEcKBS9LtM7zCMYsKGorw3riDEtxLEtqUHf67pbG0bvNhVthuYcu/9veqHKS0SuWPTmwzKVduWdnkW6iNiT7dI35515T0dLt2ybKOJBNCry25OZtufCoYrkm8DSU1DI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405815; 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=YOKg2H9AAOWj+i3eWwwIpPqvW7CUMNwNiqQ6aKP8PMsBYr8w8f1vg38wLRQCl43pD/y8YDfU6f8e0xrIvr2DWA65gR5I1MTHBfpRaFGDeuWZYpaOnXpRqPP+Lg/dEVySnGFda3KdXncwDYyMet9CbaY7qbeRlUgqtqGG0B4iHxA= 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 1771405815888505.68898075545167; Wed, 18 Feb 2026 01:10:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXF-0001nm-5d; Wed, 18 Feb 2026 04:07:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdWR-0000h5-V9 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdWM-0002Pr-U4 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:02 -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-325-aP-akWQOOJmoWr56arU3kg-1; Wed, 18 Feb 2026 04:06:56 -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 5435A180034D; Wed, 18 Feb 2026 09:06:55 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 52E263000223; Wed, 18 Feb 2026 09:06:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405617; 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=O2rna3TqE9/F1XYyhkQqqtUH4Nh9nCzD5hnLC8zZOw7o7sHSdcsmwzm8HAHSdYh/4dISre XEaTP0l5MdB60eaGImO6rpm1kwqYkCNR3+wEUspa92PNc/dJmW7MNKMVVf03ztbOefwvuP l2wanhE+jaEalfc+OyL6blYyBZBVJ+o= X-MC-Unique: aP-akWQOOJmoWr56arU3kg-1 X-Mimecast-MFC-AGG-ID: aP-akWQOOJmoWr56arU3kg_1771405615 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 67/85] audio/pw: replace custom logging with error_report Date: Wed, 18 Feb 2026 10:03:07 +0100 Message-ID: <20260218090330.1476169-68-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405816519154100 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 04:24:18 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=1771405901; cv=none; d=zohomail.com; s=zohoarc; b=YbDBkE8ATfwBd0L8li62GE+leUITv7qH1FL6EKK8zhbVrpMTyZfnJKRugIi5jjfQm7p91c56OKTqmxa48hd6eakYi5To3CgNNLK7nnjaQsZSi9WEERxKlFrfb/bM2IquoGn5yCSGWyEnx90V1a/dJLMdZdduMvieiTeUQDk5l58= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405901; 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=QCo5XsOGzCuhJ+igfZYj+rdRDV2HDZmn4GdRnLv5Aa6W5FDVrDJgvbihw0J5NcjfxDfNch6VSejRwcSqXzDGQ8ORjOxTn/xpMG4yBE7Ma9+AefJ3+Brh8SDIm92Wx3jG8xBwbEJ46lXN1Knsp3uL30o9vGjTNpGTXFjZvsgO9uk= 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 17714059015371.6514872403380423; Wed, 18 Feb 2026 01:11:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXE-0001fh-96; Wed, 18 Feb 2026 04:07: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 1vsdWT-0000hk-Sj for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdWR-0002QN-M4 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:05 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-170-qwcz4-uVMUuItwpZUvPO0A-1; Wed, 18 Feb 2026 04:06:59 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1031C18004A9; Wed, 18 Feb 2026 09:06:58 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 49A2619560B5; Wed, 18 Feb 2026 09:06:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405622; 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=QlUXKGAcgHGIVTqm11LRIjs7Ms3ioB4cCU96PMbgTvyeCMaBCtifX3xyyaTNSuo+xKs6vT QSDwKQCMRoIu7G/J4876RVdD1SifaxduHj7VregKgciuUltv6tHVFvUzoR4Fd+VFFlb/Cl TyVMjabG0FtjP2C4ImglgOkjcWarrJQ= X-MC-Unique: qwcz4-uVMUuItwpZUvPO0A-1 X-Mimecast-MFC-AGG-ID: qwcz4-uVMUuItwpZUvPO0A_1771405618 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 68/85] audio/sdl: replace custom logging with error_report Date: Wed, 18 Feb 2026 10:03:08 +0100 Message-ID: <20260218090330.1476169-69-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405904157154100 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 04:24:18 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=1771405947; cv=none; d=zohomail.com; s=zohoarc; b=U6m3bWl7NWRw5qFeBs3+OCdHfMSiErDyHCbsUnNullePYEKCWKwtHC4SCCgyHydjii/ByI16/HWEVKqeGfCx9SYIzPSG7RxoIx7erOXEKpsOtyCJGhwSg2FtmzAOfimzQq4u7YN2bmcYE7PJLey22fDWH0QfvAdVsyBcEEBPSbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405947; 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=PCftkolhUWhc1nqOpxDiWFnKjwyoMdUGjqCRz8AFAwSfAyUoJCsNJhEqJDQCUBeArIeI9fgS5i3O+fTLfR8yH/B4IxvBFcYiInmnz83+Cz5MMsRj78BvRzIHX44PBQvvWl3O2Xdv1P+rVIFj6lokJj70EoLIcMNG8N+deTc9UWA= 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 177140594768994.10107828296657; Wed, 18 Feb 2026 01:12:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXH-00020W-2W; Wed, 18 Feb 2026 04:07: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 1vsdWV-0000iZ-NB for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdWS-0002Qn-Nc for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:06 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-320-NHEkdn9-MUufyGRcEunZeA-1; Wed, 18 Feb 2026 04:07:02 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1B6AA1956067; Wed, 18 Feb 2026 09:07:01 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 28F0B19560AD; Wed, 18 Feb 2026 09:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405624; 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=RaAzuwp5yAXW36ySbL7JikyVkBX4vRynZD1kateQeeKs8wgR2qRS7PQIvR5QW8yFFBE75y YhMvwG7F6CE+hjSWHa3jkXn3ewW9oD1U4KASB2pHHvsJmplh9laqnraA/qv/8bv5TpA25E l0/Z+rTOnQWbu1Yhiv8znjI86qtkXSI= X-MC-Unique: NHEkdn9-MUufyGRcEunZeA-1 X-Mimecast-MFC-AGG-ID: NHEkdn9-MUufyGRcEunZeA_1771405621 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 69/85] audio/sndio: replace custom logging with error_report Date: Wed, 18 Feb 2026 10:03:09 +0100 Message-ID: <20260218090330.1476169-70-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405950440154100 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 04:24:18 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=1771405713; cv=none; d=zohomail.com; s=zohoarc; b=iLe8tdFuGfU6Mk2xAYE0KaHhfrUcETay+oKIW8JiVbHNhyeXzei7j2M5RlaY9koD/SR+bZZpVVBifByFGFMpGiJ3QFHZhrLt9Cb/ba429KTJKLG2lNQnbVMdZv99IX4vxZ0nlFyXZkt4TI7/XkdpCHL9KXW2tomh4UbOevd2wsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405713; 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=VLdqM5AmRTH0DEuIWUcK2g+/hQtGEaoGV/Jt5NY6pNVFj4OPTXbkE8f7rU6RY61gsZICaSx6u3JVb1zGWUIlNP4Lw/JucQbaplioJG+nhh6v3JslUbtgZ9IajWHf1mCir17RZgl1rV0t4wDzIZxYU+MFSLwNR0Jj7X9fyzZjaFw= 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 1771405713078885.8721704451515; Wed, 18 Feb 2026 01:08:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXG-0001vg-7W; Wed, 18 Feb 2026 04:07: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 1vsdWX-0000j6-SH for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdWV-0002R2-GL for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:08 -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-99-FqF5EJOEN-SyFC6Ey5bQJw-1; Wed, 18 Feb 2026 04:07:04 -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 A32C0180057E; Wed, 18 Feb 2026 09:07:03 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E3685180066B; Wed, 18 Feb 2026 09:07:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405626; 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=dm2bJ+bcOzJlIRGpiSm2tA1CPmfPngX9N/g2K8zMf5AgNgUqw/bdHAsW5I4h4DdatEpmif 5dzkycvZOUHt69qB1AR8o7eIBnS0FAKy++fZ3N+rCeca5xXnSgtT4iP3EiKGJ3QnB7fkLd M/EvRdBqr77p6G9viwhKXuq4vensXeQ= X-MC-Unique: FqF5EJOEN-SyFC6Ey5bQJw-1 X-Mimecast-MFC-AGG-ID: FqF5EJOEN-SyFC6Ey5bQJw_1771405623 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL 70/85] audio/spice: remove unused AUDIO_CAP macro Date: Wed, 18 Feb 2026 10:03:10 +0100 Message-ID: <20260218090330.1476169-71-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405713724158500 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 04:24:18 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=1771405791; cv=none; d=zohomail.com; s=zohoarc; b=Iq7PEFOFV85VX8fVvLvP9eLygRFznL85vAyyG6tBuJwyvQ5ESptdo+YFK/b/NImWa9LoD3Fu3yBLKlNh/4REW0eEN4zyCdg8d7bME8cCgxRSgkzWdKSg34yUXd2wx8kMWG4dXrI8B5ZskFhRcbYDKY+mG3AFk04eamdIIqRwGjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405791; 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=k2ZVei5nGExICbmbiQMBQLv/fFcShVHlXBowx02YwLMP3PTL7Qn1cHnuzQjKQtxO/ciIO7tVI6i5i5c4ut9z4rC4qqWsT18lY6On3StOLA/+/72HI9vDZ3eRNMiDmzseaPs5rc/gJN6c2oAg6+wofmZBuQlk4dQ+46azOuyeFJA= 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 17714057914141014.8057137093691; Wed, 18 Feb 2026 01:09:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXH-00024r-SV; Wed, 18 Feb 2026 04:07: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 1vsdWr-0000pl-6k for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdWb-0002Rg-Dh for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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-185-U1aRwp93M-KW4w17OsSrWg-1; Wed, 18 Feb 2026 04:07:07 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 842841955D7F; Wed, 18 Feb 2026 09:07:06 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DC5AB19560AD; Wed, 18 Feb 2026 09:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405631; 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=g3pFqaZoOD7Sd6Hbv3MFALVfQ38MHt/gYQbrKbrh0Fjjnz80J0m3GH06c9IIwfewMiYY8I RGrelyzng6uNlb2rNvujkxKCyVCIScTlR6PmSFu3SI369g3rWt4WID0kEwfniZAGhoUO6f w6C/mAg68LfIiVOQW2+dBDWqtrQR5H8= X-MC-Unique: U1aRwp93M-KW4w17OsSrWg-1 X-Mimecast-MFC-AGG-ID: U1aRwp93M-KW4w17OsSrWg_1771405626 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 71/85] audio/wav: replace custom logging with error_report Date: Wed, 18 Feb 2026 10:03:11 +0100 Message-ID: <20260218090330.1476169-72-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405798581158500 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 04:24:18 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=1771405921; cv=none; d=zohomail.com; s=zohoarc; b=jVuz4n5oRgZXiOSVpBHOMS3riZZBJlG+QDwioMeJuelTJVhDnhbxJONO8hbVJsgLbXBzaqtbhjYpgCLWUGA8u/g/sNrqcGnHII9PazuzwumwfJRxwAcYH2XYNM+q1qDmYat66Pi9rA9UraSdza6Cjy6Z1eMPZ8pEOZR4VnC2GGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405921; 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=IU7+udlYmUWlPc900SgTwZP7i5yWO4VzhMx9qEjzi4b1rtxaWIGiQ3BK6gzOuyK5yvACEPl4m59sPs5K5F0UrcBhFccfOLEl2Io5zdSFtr79EHnueZSdbiJ+W2AT7V7nxx17fPiaqfw90ZA64yktuSD4R+qS2EHGoJAy33HApSM= 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 1771405921987757.2415642963808; Wed, 18 Feb 2026 01:12:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXE-0001fA-85; Wed, 18 Feb 2026 04:07: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 1vsdWt-0000sV-Fe for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdWi-0002Ry-Ko for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:30 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-18-KgLv-7ZxPRKVJM3KZj99PQ-1; Wed, 18 Feb 2026 04:07:10 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 07FB41955D76; Wed, 18 Feb 2026 09:07:09 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 57DBB19560AD; Wed, 18 Feb 2026 09:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405634; 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=NCdv0IRQlpkor+tZpAWiP5Ll2ZPDk6RO13V7sNV+badleLfeIJKwkf7hUJAxtR79lNamQv f26jHde6XZ0HuvZZ1kNrTbbir85PIxx1tNH3jwl94DpoDp3lQpLARhaKc4qA+XgFDPBDEC qnIhKTn5Nh1aH2m8sUi/Uh/9D6+POz4= X-MC-Unique: KgLv-7ZxPRKVJM3KZj99PQ-1 X-Mimecast-MFC-AGG-ID: KgLv-7ZxPRKVJM3KZj99PQ_1771405629 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 72/85] audio/mixeng: replace redundant pcm_info fields with AudioFormat Date: Wed, 18 Feb 2026 10:03:12 +0100 Message-ID: <20260218090330.1476169-73-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405924200154100 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 04:24:18 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=1771405938; cv=none; d=zohomail.com; s=zohoarc; b=hUqs+ij9y6Mk6KGT0FNe1L6TM9ZMJUFL9MK+i/+D5MjSG+OV9RFIsWWiYz4vO8mS0npMkHydt+n6NkRSc/BM96pim2UninRBW+oPNQ3y5Tctq/cUo8ZCLqy3qzqsSdlck5fvpoGoGGCC6XNH80Gtrp87FNkhibWXu4bO03Nh7Us= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405938; 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=Mgd3P6dkLNsduVNsx6ihUeQKhJVlrP6oVA2XILqCCoOGiWkJOVFmeVdslAYBjd8fErihZ/Ta7IjDmc+7ItZz8lf4p85/P0n3wNTxoYhp3qCJ0/Zzw+mUDG7vvBRl+V7xmbAbxqk3l4xcK8VKSf4DYFGU3PEhGXgCU6GKRHhMMrc= 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 1771405938623152.84641427676786; Wed, 18 Feb 2026 01:12:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXH-00020I-1G; Wed, 18 Feb 2026 04:07: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 1vsdWw-0000zm-M9 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdWr-0002S3-1C for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:34 -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-493-ko4ycjNWM-q5MaSBRIdXFA-1; Wed, 18 Feb 2026 04:07: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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E8727180025A; Wed, 18 Feb 2026 09:07:12 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B4240195410D; Wed, 18 Feb 2026 09:07:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405637; 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=X6ltN1mKne3SKSj4rOfkLc+6jaCznxj82XTNAdE1fg/1IGw3m57Rqtwr1CQuNURukGYVU+ KhEpynook5WZwK0OS356npvBqEVs1kfTaS2qr99gu9kr3h2reXVxSxJJNrIqO9oake98wj FI/5p9dQzUSJr/5JPohLo1WpoORSono= X-MC-Unique: ko4ycjNWM-q5MaSBRIdXFA-1 X-Mimecast-MFC-AGG-ID: ko4ycjNWM-q5MaSBRIdXFA_1771405633 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 , Manos Pitsidianakis , "Michael S. Tsirkin" , Alistair Francis , "Edgar E. Iglesias" , qemu-arm@nongnu.org (open list:Xilinx ZynqMP and...) Subject: [PULL 73/85] audio: replace int endianness with bool big_endian in audsettings Date: Wed, 18 Feb 2026 10:03:13 +0100 Message-ID: <20260218090330.1476169-74-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405940821158500 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 04:24:18 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=1771405844; cv=none; d=zohomail.com; s=zohoarc; b=VVdhsxJ/fMVcsOlVP5hP2NO1rQ4BNnmW7mEu6IKNim/9/vt0B7cT8SNDK2h9IDFuRKG67qWVVcwl4b/GjVYRurZtbKeJlFkvcawbY1giAodlT9DmklnkxH4bEo30xJWR7Bj3EzpnQzJ8AuLgMQMuQ/cdLjY0DWO6XbpMAOq9MHQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405844; 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=RhRdxX+YWfdjE0rUWxTZmd25nlZ13cAs2sNblaJwDFqjPmtJZgsvnTGCnwZo3/VPK1gVmweRGj6P/u+3ASRGl9cz73+UQtNcDQkVQMr8AjIC1PtjmgYGNg5B+Q09cvTvI2sgQcoz0NykBdWLFWD+As52PQTMQ79tHcO87ReqzO8= 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 1771405844213696.7308971033825; Wed, 18 Feb 2026 01:10:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXI-000268-0W; Wed, 18 Feb 2026 04:07:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdWw-0000zl-8p for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdWr-0002SC-0L for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:32 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-47-4LaR5YZ7POaRzCTt5H-SMg-1; Wed, 18 Feb 2026 04:07:16 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B8D0218003F6; Wed, 18 Feb 2026 09:07:15 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0069C180034A; Wed, 18 Feb 2026 09:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405638; 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=dbAdmN81UpqG2EcVMhU9MdFQJkv+qmYldG80qSOwyICd9dBc5wiRbJNMdE3GjdUc3iPNyV oRC9bXb4WT/KG2ZVSIyZ8Obm+L9HcckKFVd6SjaBMKNvcE3IJ850LyjGFYtSIFCG6wOQ/t 0E0xlw30Fvs2TDymgBWL2sfuSZprV4w= X-MC-Unique: 4LaR5YZ7POaRzCTt5H-SMg-1 X-Mimecast-MFC-AGG-ID: 4LaR5YZ7POaRzCTt5H-SMg_1771405635 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 74/85] audio: replace ldebug with trace events Date: Wed, 18 Feb 2026 10:03:14 +0100 Message-ID: <20260218090330.1476169-75-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405846921154100 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 04:24:18 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=1771405734; cv=none; d=zohomail.com; s=zohoarc; b=UEYR0E0I0ZQjxM2Z9SHiaW47ZaH+a1IsB+wfETGpj4LJqP+or1AdagKcapNqMOT6aW2UUkqCrD3oflemIhBAHimf98MtaM6Eh3diDZ+IQIYlOQ0kLCZAyJJ85RbJ85k8fPDWfH9LnDcsxySBpmSmlXEGJzW6Z5JhtUR+6OPLDFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405734; 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=aNusAslSBTzgVSvq6o3VWImdItpMkAIvb2CiKDFkNbgJ5fSYlYi7coxiP9W774ncKriiNtxLH7WZsss9H2VBhhfjQLO7NgW6pOxlgMSW+jdcH9Ju2PrUzyR67WcN24dgmZWXg3ftc4jmxf7W+4gfZlnuVsoq6Wz9Qs3DiMK5aqY= 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 1771405734524356.2348639196134; Wed, 18 Feb 2026 01:08:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXk-0003QL-PN; Wed, 18 Feb 2026 04:08: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 1vsdWw-0000zk-8c for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdWq-0002SS-VE for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:32 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-494-gUsjpi9ZMzyle-JnViteLg-1; Wed, 18 Feb 2026 04:07:19 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 668811800365; Wed, 18 Feb 2026 09:07:18 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8C65D30001A5; Wed, 18 Feb 2026 09:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405642; 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=NKmiY+9YfV9HH9G3SbyHWA4s3KMn3/oDfzfXZrGvwx+9u1z/HdTryb8++6ET/V8V0aRNjv TehoqaW8M44Lt3UGJlEAIr0EAiDoMoBORpE35uWW3HBePRZDZ5GUDU3oKz3xSa/mLwjZ3I 3kvPdXuXWc9RXLZZeTUMhyuUx8g9ccQ= X-MC-Unique: gUsjpi9ZMzyle-JnViteLg-1 X-Mimecast-MFC-AGG-ID: gUsjpi9ZMzyle-JnViteLg_1771405638 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 75/85] audio: rework DEBUG_POLL Date: Wed, 18 Feb 2026 10:03:15 +0100 Message-ID: <20260218090330.1476169-76-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405735845158500 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 04:24:18 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=1771405815; cv=none; d=zohomail.com; s=zohoarc; b=ljZcYeM6E3B96o5/lBwD6L+ofRGv0AlV5sZ+Jz5624dhqNRLj4Ifb0RZLtseJbr6uhW8FU1D1ccjyLCABXugTPE2vtNTTqEtdJEo13eDCZVfyySZoBU3xzcXsEHQMBpMT2N24/6pA1RYiqn+xsJeSSPTXBhzj6c8wl/k/Hvu9LI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405815; 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=DubLewk4ggBBFBGhc/x6PBsn7KcT7ZbMyBC4sXOAk0cMWmytFHVfd83NSTKmsL6wnzbEzlOQZxF8zoUZiyiIZ84YoMKTjjy20tguI8F0UX+jlFrAKWqXfBhzRjjQ4J3+mAiHpi3PVA2ZJLJDlTPDtZg9Hx70J8tNCV03o86eano= 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 1771405815586852.5655646331414; Wed, 18 Feb 2026 01:10:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXG-0001vy-8h; Wed, 18 Feb 2026 04:07: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 1vsdWw-0000zY-34 for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdWq-0002Sl-ST for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:32 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-JEgfJhPvPxGI53WBnyeZlA-1; Wed, 18 Feb 2026 04:07:22 -0500 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 45D4519560AA; Wed, 18 Feb 2026 09:07:21 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 82508180034A; Wed, 18 Feb 2026 09:07:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405643; 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=CKcpOiHeknu9DbBp0OcmJrlSZhckZKKwlN1cG9X6nh087GvcXtaOQQS3SqsdcWE9lONsis 65L2vLr4wic2HnJpGZ6YyuNGzVRcmne4yTvFFt/2NUXmCC2xWM6kDbJM3iQiGKkCY5Pvao gqEeWUBbKSFlYhx7912zJyDJh3OuZV0= X-MC-Unique: JEgfJhPvPxGI53WBnyeZlA-1 X-Mimecast-MFC-AGG-ID: JEgfJhPvPxGI53WBnyeZlA_1771405641 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 76/85] audio: replace DEBUG_CAPTURE with traces Date: Wed, 18 Feb 2026 10:03:16 +0100 Message-ID: <20260218090330.1476169-77-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405816119158500 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 04:24:18 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=1771405738; cv=none; d=zohomail.com; s=zohoarc; b=hVwv3iKwutdjQsAlqR9V+mmqMzZLSKdMWMATm9WWskcxxYD+Vbv1/Y8QdIhYx0+4Bha3Bj2ScvI//6V3abwTOwyzCmu0OCCnTPdwd5wlwTb7hLjuwlTgl0fgfQLi1uS5vbMDbI1jTTuFJ9SEFWdTcITX4QaYqBinIx+do5j3A7k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405738; 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=cVmCmQErDUZxVA+wLgayeKdqbCb+s2HkMFv4OzrqoUGDnuCbxPeEvAGc8xF1k0isbLr2IS+5o6B+AllNeicpoLv1TNthbAX5QeTyOj3EM7I8jYCK7weE9O1eDMiLQbh7aVs8sEhyV7ZnBde3HAGC8qBQz768gEstnMdPns1e0Iw= 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 177140573874667.31138882012829; Wed, 18 Feb 2026 01:08:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXB-0001U6-Ja; Wed, 18 Feb 2026 04:07: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 1vsdWw-0000zj-8S for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdWr-0002T4-DB for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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-184-bCu0sJmaMXKE0_wTrNawjg-1; Wed, 18 Feb 2026 04:07:25 -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 716EE18002DE; Wed, 18 Feb 2026 09:07:24 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 334041956095; Wed, 18 Feb 2026 09:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405648; 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=Bnc7MkcyU+qH2bDRRaYVPdsaCBfQqJypnbHhnYuOjbT3OUnAyLNi9p/8cK0T64QoJh9KYx Jb09zZhblls8OX//ENUyzOFUhn3mB1d9smE+xMBCrk+fu4f6Pf9mMoF9hYzF01/gUasrT6 hwkE8E5bFWVLHDdGgysg0RGBi4TAWok= X-MC-Unique: bCu0sJmaMXKE0_wTrNawjg-1 X-Mimecast-MFC-AGG-ID: bCu0sJmaMXKE0_wTrNawjg_1771405644 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 77/85] audio: replace DEBUG_OUT with traces Date: Wed, 18 Feb 2026 10:03:17 +0100 Message-ID: <20260218090330.1476169-78-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405739855158500 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 04:24:18 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=1771405730; cv=none; d=zohomail.com; s=zohoarc; b=ISKERku+Wju2vxrQ50E3PjH8pGT1HdmYtyUTg1OFRY7+KmJdqgshJxBSBJLVGU9CQXs33W/xD6R7GgS1svx6qJCCVqIYXlwNxlcZR3JFswwHnn9sOEUDdxBhboWSzHA++uYC1FaRYSF6E1NKBoj5Kt3Pox6NvQODdtAmUUFBtqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405730; 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=CW+KYoIJg32IVYRsksczJLAlmgwS/MS/B8BEYZTAnzirFEwfcEKHTtBZ3VN4C112n5T2okzpk5fXdITXhh6yTxm97po1ssaz2YeONJ0M1xzzhXhrhMVZ147oa5TOOnlNdlOy9no5RDlkMImisCE41LnbLxwcycM/fbZmyECcUG4= 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 1771405730142331.16269552773724; Wed, 18 Feb 2026 01:08:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXJ-0002Pc-RU; Wed, 18 Feb 2026 04:07: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 1vsdWx-00010V-Sz for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdWv-0002Tn-SB for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:35 -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-205-E_sIsE8XPDWZM_lzlpWcYw-1; Wed, 18 Feb 2026 04:07:28 -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 9A00118002C2; Wed, 18 Feb 2026 09:07:27 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9E16E1800296; Wed, 18 Feb 2026 09:07:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405651; 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=Qt4uMMlAYypX3ml5mA8rSa22wXrsgFyspKGhg5CLiloSk0I0EF0hWnNZqlUB3XG2Bpej/g AVzfYG8oGjECo9Czu6rHRyElewtugbpEdtBl89CHXd5jI6aDFEh/MDt3k0UBW3iaHLIdMk 3GRNZmUxLBcis4LCMkBTtlpCQIUPrKw= X-MC-Unique: E_sIsE8XPDWZM_lzlpWcYw-1 X-Mimecast-MFC-AGG-ID: E_sIsE8XPDWZM_lzlpWcYw_1771405647 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 78/85] audio: replace DEBUG_AUDIO with trace Date: Wed, 18 Feb 2026 10:03:18 +0100 Message-ID: <20260218090330.1476169-79-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405731835158500 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 04:24:18 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=1771405737; cv=none; d=zohomail.com; s=zohoarc; b=EXnWvxymRMK62wUtGllyDe2CjmlLW9IWLqiR+zKfED9/VMYfWf9XmsSaf0lKf7zc6JITwhSa2YW29VYczU6cltrV9GWhTu4Gs1Y+eqS5L6jtaxdBXUSzHmF2aDOonhyUBI8LyjTVmffv2zcw7DB15XGmrfbDXQ0SON5FA3j4wNM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405737; 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=EGv42VqNaSwrcOhW/RHv8iBiH3zTD3FW+J5KPD/NAwmFrfwya3YXbr6hCVMPv058TJZJRYNvMGTc8L4dMrYmB4/dyCnrfJ15Empl4LO/9EsFAHhV8iQxKlBzYB4DOIEUvXF70SqcIIITCu3cdSXwU3LHa24KxXxWr4EcgIX9AiQ= 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 1771405737544846.3740336196561; Wed, 18 Feb 2026 01:08:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXG-0001vM-6p; Wed, 18 Feb 2026 04:07: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 1vsdWz-00011p-Po for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdWx-0002UZ-2y for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:36 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-GYx36QpUPlKyy4LiNgTLIA-1; Wed, 18 Feb 2026 04:07:31 -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 158301800348; Wed, 18 Feb 2026 09:07:30 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6EB07180066D; Wed, 18 Feb 2026 09:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405654; 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=Jd4FrZINbbV16dvlJ19e0bkzigUYZswOg5EJ91ciJakVxRPbCMPn4iSUAdBlPIZvrAKGaR CKqyilcDpcpFU8h3KZYZ2jaaT/CnPoNw5fG138k+YoQ5Sqf69Cx3NNxx1xVqR460ITS/Mg ajQlNgc8LI6ozWtIkGI/aHNZopjoRmw= X-MC-Unique: GYx36QpUPlKyy4LiNgTLIA-1 X-Mimecast-MFC-AGG-ID: GYx36QpUPlKyy4LiNgTLIA_1771405650 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 79/85] tests/audio: add an invalid settings test Date: Wed, 18 Feb 2026 10:03:19 +0100 Message-ID: <20260218090330.1476169-80-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405739422154100 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 04:24:18 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=1771405894; cv=none; d=zohomail.com; s=zohoarc; b=PC1KifknJAo9GEQLzWwrnBDnk+VRkMwv9/zNGy3gO+X0aCgwUvq3zQLL0R7eEqVTNegjYzs9Xe+gc6x3EY97rG8Pk7AEwTxzzB18EBLjnCGX0pvbxEjV9zlWfB1WMvecSmwRIvbL3a7hKIhqEZvEFVS6zAM/QcyTOe+nU3Ht4jY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405894; 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=UnOXsapcHPL+nJMjlSNnxcaaX+0qU6ADS6yfB2ERmqaL7QWNJidVjLRovCuy1872obDHL/eEeEWasaKv48Wstml1YZ33JbDR2L9Ora/UX9Qlz6f00cJtP5VaVa4ORj2TF3WqfSP01ho36ysBLrx6Tc/4nTo0Hy8HkzNyoo5XgX8= 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 1771405894563818.7761709097693; Wed, 18 Feb 2026 01:11:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXI-0002AJ-Iv; Wed, 18 Feb 2026 04:07:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdX1-00017U-Lb for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdX0-0002V4-6x for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:39 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-ZZmxsoz1PWGplW4LIMz0Jw-1; Wed, 18 Feb 2026 04:07:33 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 21879180034A; Wed, 18 Feb 2026 09:07:33 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4E86719560AD; Wed, 18 Feb 2026 09:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405657; 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=XjaIZQWmoyXAe3bZ+9GEZeyDiGhcy4Fl+pbR1wmynMqMV6v3Gga984ADVvb24yirah0AKJ E2LQiQJnCygMhhYYJxU8mBbWHmBAZADNF2NKYxOlVeK2KVYhM78Mvgz4DL5bWrJn1ofGUd 86A419UUK/CqrSh9BxK59qRuSrTGyAM= X-MC-Unique: ZZmxsoz1PWGplW4LIMz0Jw-1 X-Mimecast-MFC-AGG-ID: ZZmxsoz1PWGplW4LIMz0Jw_1771405653 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 80/85] audio: rework invalid audsettings error Date: Wed, 18 Feb 2026 10:03:20 +0100 Message-ID: <20260218090330.1476169-81-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405896409158500 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 04:24:18 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=1771405713; cv=none; d=zohomail.com; s=zohoarc; b=l3TDLlGEPhb5nqUaCd0/yjcUV9LHFoRZLwbypJyH9uj8/eVjmH8RtfLi6C2PaXhT/oBtnYCf1eNV/iUsaUk+u+Ow9Zczw4m6Yxu1MqLlr7B/rEEg5Bc4+v3pkQXHUZqwLmgxDMWtF4+Pwq2L34lcLrQcin+22L3ikQpId1wWTvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405713; 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=lAwwc77QI2D2u0T13W/kiitw5beQedSaw9kw70Gokp/qPvpIetELAahONQ4N1fSames6rvotMd3Aitp+ZInn1bJiIZQwBBXI1olGBdwUAPlFSyUBb/21YcpB9YdjvMSGOiHnT1TukbG3wCXYsHGiTgLDdtGridd8B01HUFI1dh0= 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 1771405713457376.08741505694695; Wed, 18 Feb 2026 01:08:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXL-0002bD-1v; Wed, 18 Feb 2026 04:07: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 1vsdX5-0001Fb-Gw for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdX3-0002VO-BN for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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-178-wv5qVG65M--zPsHfxNmm3w-1; Wed, 18 Feb 2026 04:07:36 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A19B21956089; Wed, 18 Feb 2026 09:07:35 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BE1021955F43; Wed, 18 Feb 2026 09:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405660; 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=dNPIHEqhK58YwBB0Qf/Sx8S3KM598t4ZJTPr5WjC7TwaTrlD3H72Tw3qLsXLGcVeSTNbkm rV2YDcC69eoQhJ2Pnz0xz5O9f+fRohwOi+mI3xkFpHJQE2I/TVI0ujyvWEO7zTQuej7/TY /9ho6RsKVWpu2Uv/pgFgH4yVTecRasw= X-MC-Unique: wv5qVG65M--zPsHfxNmm3w-1 X-Mimecast-MFC-AGG-ID: wv5qVG65M--zPsHfxNmm3w_1771405655 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 81/85] audio: rework audio_bug() Date: Wed, 18 Feb 2026 10:03:21 +0100 Message-ID: <20260218090330.1476169-82-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405713856158500 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 04:24:18 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=1771405831; cv=none; d=zohomail.com; s=zohoarc; b=DR/s0bvV3CMdE3QRTDfRqwkiNdptEyW7N433uwc1LULZc8ePAr9ksjDM9fSeNA0XX0Ah2ivHqWe82xnz3g/ze15omFPhEAKMWiI3JmP6YW44OGpaaa0Um9SAasWT3coSs5UnrmI/lPgZsGhl0T+rIZhVcOnRTgaxZihju/JHxgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405831; 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=m1aKwGlVNJPbRFKu/+leYesIAPZHjqFEF5U/Ova2igBUjNNGuVk7Dex2xD4PFI55UXC52s2f3iCkohh2scRg/Ud+lWJqhaYq3iCY7Q6R0cUC0dm8W8GN1tBFZAGxqw8Lb+gsPxGFu6/0/Rq7k+MZBt3w+vdnLfkiv8hHHOzNs7A= 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 1771405831872696.1803720898832; Wed, 18 Feb 2026 01:10:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXN-0002qD-Dc; Wed, 18 Feb 2026 04:08:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdX6-0001IM-PN for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdX3-0002VS-CO for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:44 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-104-T8Dl6c_hNDSGSw6EU1n4rA-1; Wed, 18 Feb 2026 04:07: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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5D4F01800464; Wed, 18 Feb 2026 09:07:38 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B43C91800351; Wed, 18 Feb 2026 09:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405660; 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=UHgkR5LMr5BFmbxBXIM78GS9uzy1OhTISvfkRsm66jwIYssTFJW+CMR59QhS7p8dgAAKME 8wTXVZXquLXS7K+ydifUaQM1LgNOc1rEPyFYGbFbqDKavH6KvH5jYpeO3UKf+kDCJGtEOD ntbaofisPcNfJdHSQB6ESlgnrNpFvdw= X-MC-Unique: T8Dl6c_hNDSGSw6EU1n4rA-1 X-Mimecast-MFC-AGG-ID: T8Dl6c_hNDSGSw6EU1n4rA_1771405658 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 82/85] audio: replace remaining dolog() and AUD_log Date: Wed, 18 Feb 2026 10:03:22 +0100 Message-ID: <20260218090330.1476169-83-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405832330158500 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 04:24:18 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=1771405903; cv=none; d=zohomail.com; s=zohoarc; b=j7gfK74TVAlXXmMUuyVuyB9pTAiWdLg5E6YmVRNMHlrb7fKFyqXr34YEllflvH2yH9wiTCIR12iFSUi/BV5+3VzTL1FZ7kkb2NwDuehwXl5RLWI+K3+CEssaxRrMljGmlug9FfFKjKguwIQzvgq7k4ThAyixL88g3clL6esJ6HQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405903; 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=DI8WKYjXWEJfwdPkn/bTS+hwtAssJ4IHPE5wuMWCW2VCtpwyM6SWNbJwUeXJr40Y23CGPyxZFw0d6NLkKghaH0ydWJU8p7h4/7c5SyOlEHE13J4Tfb8/rQOi1AYLri0Rx5AG9LKdlvAo+gJzScsZzbWOmbEXKdjn5l7LgIoJugw= 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 1771405903206525.6617087996746; Wed, 18 Feb 2026 01:11:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXR-0002yk-MM; Wed, 18 Feb 2026 04:08: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 1vsdX9-0001Qo-Dg for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdX7-0002WE-RW for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:47 -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-307-8u1agj3lMIellcyjnXMOyg-1; Wed, 18 Feb 2026 04:07:41 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CE15F1955BC7; Wed, 18 Feb 2026 09:07:40 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1940030001B9; Wed, 18 Feb 2026 09:07:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405665; 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=jBykzf6LbjM5EofNBDw8k1P+ZZfYca9Cm3kEo2V8+WGUE5yD3YPhBmLZuwJd7Pf+JO8lBc 0PV7VLC+SmK6Q2iM/DeNhOuiRC6oJQvd04l3K1X6jqfL7OzP1YpzEtLrKTb6Llf7O9EE3i db8m5t1yFWgI++Ur6503Lt6zkHh/cUQ= X-MC-Unique: 8u1agj3lMIellcyjnXMOyg-1 X-Mimecast-MFC-AGG-ID: 8u1agj3lMIellcyjnXMOyg_1771405660 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 83/85] audio: remove AUD_log/ldebug Date: Wed, 18 Feb 2026 10:03:23 +0100 Message-ID: <20260218090330.1476169-84-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405905799154100 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 04:24:18 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=1771405746; cv=none; d=zohomail.com; s=zohoarc; b=PX+SFFhYsAGZ687AIfM1miVbOrSoQsQLFytVBxE/RjC5LFdiEJFfpWu6XjBEMeVx51vfOKX/j03XGwijbP6hNcaC1XdYJW8v6jzqf9xJyajuLTf+0U1UQxFIdYSOGJwJDXw+DLb22+b5xmI+URTYyyuejEX3YtHtAiKgatad30M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405746; 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=cdk/mkEocY7V4kDwZLouet1J578Rh7QOdZkAXNIEpJEVGoktAIh7SxUAUvcdD/hsn/6o/Ub9UMqe8coEIb4DXNmQcp6jshkE2IDQwl39ytpSgCI6j3HtNJbyINDPXOwKKBq9g56tV4UthSAJpX5eRuTDJ4HCG2psjGHXUlxEGKk= 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 1771405746064548.7059810765949; Wed, 18 Feb 2026 01:09:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXJ-0002K0-75; Wed, 18 Feb 2026 04:07: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 1vsdXF-0001pm-Bp for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdXD-0002Ww-Dx for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:53 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-462-wTYji9ghP02CNsRfH-67BQ-1; Wed, 18 Feb 2026 04:07:45 -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 049B81955BF9; Wed, 18 Feb 2026 09:07:44 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 11C871955F43; Wed, 18 Feb 2026 09:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405669; 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=F74hFpz0FbVlp+gIs56QzmO0odGvAlimsbJULFHMiRFn6P+v7v4avkhlujLBSYOiOhgZGe 3FutF1M1AXrUXXbbaP2ucf21e9BmycJjAXVJM1yCEhCrQN2rCTjvdr5HPzq/0WsmLhIzVl S/412yzF4hEql5EcRPQ9iKF7CyUQrDc= X-MC-Unique: wTYji9ghP02CNsRfH-67BQ-1 X-Mimecast-MFC-AGG-ID: wTYji9ghP02CNsRfH-67BQ_1771405664 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 84/85] audio: remove AudioMixengBackendClass.name Date: Wed, 18 Feb 2026 10:03:24 +0100 Message-ID: <20260218090330.1476169-85-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405749024158500 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 04:24:18 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=1771405937; cv=none; d=zohomail.com; s=zohoarc; b=SgRPbjTLuzeV8VhV53YIv6KQ4/EgEzpzMAoVeqHtsAwXdLJBX/eT52zu9vpiYJAmwMGEt4Yigc1wnJYkGWGEcj7pFS9z0aXMkknWgso7h9uSvD9SWuJC2aSh4ZS0LHHIhZeDUpbmys1Lf6Qb+hzhd5mF+HiSAs/0Qq/9gHMOUiM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771405937; 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=g5OOzSk6+aH11uNf1F3T7FP+KBY5IDJL1CwH82FF/sE9s8Gmz9esQKPmXT8IbVSZri9H4uw7Pq7Npbq4g3CQqClnJ24i84eV6megfU069vf+U3pyT5ksgWNSRnfN82pOuArAstkMhgOoWo4SqAi8bQYagIJEvcxiUqqVknf4pbQ= 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 1771405937220576.5928481567821; Wed, 18 Feb 2026 01:12:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vsdXK-0002YV-F3; Wed, 18 Feb 2026 04:07:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vsdXD-0001b3-Lu for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07: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 1vsdXB-0002Wm-DE for qemu-devel@nongnu.org; Wed, 18 Feb 2026 04:07:50 -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-306-9apPZUvOMdKfyXlAOfb7aw-1; Wed, 18 Feb 2026 04:07:47 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C1E818002C2; Wed, 18 Feb 2026 09:07:46 +0000 (UTC) Received: from localhost (unknown [10.45.242.26]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CA05A19560AD; Wed, 18 Feb 2026 09:07:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771405668; 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=VO3NZwEDZi7mXeWyzSgt5XKAGtCdHKIeiWwikBX/HS9bTTdfWjqo8jTHONm44dE4qPEQQi PgpRGLCEr5EEFHKa1hFoa7wQP+bH2zv4pGFltS6/8WIzudSmosiAYjhTu93Wy0pLT1ExsV DwTlag8PchKUYrOWAbklkDOl6B9zcgc= X-MC-Unique: 9apPZUvOMdKfyXlAOfb7aw-1 X-Mimecast-MFC-AGG-ID: 9apPZUvOMdKfyXlAOfb7aw_1771405666 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 85/85] audio: fix leak of audio capture name Date: Wed, 18 Feb 2026 10:03:25 +0100 Message-ID: <20260218090330.1476169-86-marcandre.lureau@redhat.com> In-Reply-To: <20260218090330.1476169-1-marcandre.lureau@redhat.com> References: <20260218090330.1476169-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.043, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1771405938232154100 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