From nobody Fri May 17 10:44:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695977634; cv=none; d=zohomail.com; s=zohoarc; b=dlmwcj4DDnUErHaUfdfzPZndjrXun/kbXuDqObgdJVfAUdQg4M8Qy8iZv55iRci+6IX2qQClirtoR5QUX9hO8egaSoYhqgQV8Bube12ue/ScM8y++aBnUW+aVYxm/czGcFMa9Hfw/iQMIEbvh1gsgMT9/70QGNxWUYO6YjKVATA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695977634; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=062lQOPC+PhYZGAGOhww6XlMuZlq/6DlQrwBd4uWz6k=; b=WFpC0zJUpJ/VMb1lT6pVCleuLRN2LqKoCbtvF9nmxkEiGtG1jJXrNbPuBmIz+BjTi4JtCyl4PffotcA4NZRt08Sf1sdmgZ6X50fEUvLFtCFGur8Y71J92lF3aGwjhH22TjYjZ7Lrqs03RlN1Mlb+PFhxAV3Kp2bj9mzyhd2g41c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695977634708294.4770194974624; Fri, 29 Sep 2023 01:53:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qm9EC-0005nt-Ei; Fri, 29 Sep 2023 04:52:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qm9Dj-0005I0-M2 for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:51:35 -0400 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 1qm9DU-0005iA-IQ for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:51:35 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-175-wcuXOiItNNaNFhPIxA3NDg-1; Fri, 29 Sep 2023 04:51:17 -0400 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-530f2ccceeeso10954867a12.3 for ; Fri, 29 Sep 2023 01:51:17 -0700 (PDT) Received: from [192.168.1.174] ([151.48.237.81]) by smtp.gmail.com with ESMTPSA id v10-20020aa7dbca000000b005330b2d1904sm10711131edt.71.2023.09.29.01.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 01:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695977479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=062lQOPC+PhYZGAGOhww6XlMuZlq/6DlQrwBd4uWz6k=; b=NyftmxXBmNuQ7i2gK1B//6L66IRGpzZyuKRX+PGQ4FufQJTXcvmuz8n0AhICYj0+OlRDFo cq4+cPyNSRc6kKu5tR0MUssKan5IUgIIyVzySXPh8iw79Vn8YkGyUvldAgMIITrhQ73RkD fjIQhTGwP56hB0jYluBVWmt1Q664TP0= X-MC-Unique: wcuXOiItNNaNFhPIxA3NDg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695977476; x=1696582276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=062lQOPC+PhYZGAGOhww6XlMuZlq/6DlQrwBd4uWz6k=; b=O5hYp1EsbMBnOCfeyhSUunIOFiKvO5+y8ybkWRlJGqtKnAR+ft7fRzvzlhzGUUH/17 /L8YycllhfLjIs0uiCrXULLLGmF1QCVcNAh8n6ZKYVJyCBW7pNwknAE6r27Pc+rNfhvt G94MuHufBuqCSp7629nzqTFxG3Wr9nvjPWFt/wnYhcC4NidX+GpDiSpz4UKjmEJayrXe qE8Xo92dwuRGeH6zeovgue3LjqzBUVM3DjudRptMeSfHXIi3jNOubUMzI32HzgEvaaaZ jfnxF1OtzfVjLfgQAV73aHv4d1OWsZd1YgWaHD9uUa37aiuS05eCFRex/35Kco66amba 91mg== X-Gm-Message-State: AOJu0Yw4m1wY9apl7XNMZIRYb0wqzoWawqr7syFMzZcrWYHx5dfup8Iy w6Glc57W15Q8SNCXSu2PvEhocfco01ZKlHJUhgGRyS9AuY24qQ+3Nk6PkUdbEUyp03SI6ziPzBY Qv4CpapqaIjmfKJE/ox17jgPYc3DuGxf88vLX44uCwRYzBx4DVgSGPGgbo7QZfox3+ZU368JP2j U= X-Received: by 2002:a05:6402:3458:b0:532:e6c8:128d with SMTP id l24-20020a056402345800b00532e6c8128dmr3746297edc.24.1695977476313; Fri, 29 Sep 2023 01:51:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGMK/rmwUYHGT8Hu+EoTBDBnH2MQ4IMtTpn+15zHijg2jX0tPkqUI7PE+OWiHfAMSVds7BOaw== X-Received: by 2002:a05:6402:3458:b0:532:e6c8:128d with SMTP id l24-20020a056402345800b00532e6c8128dmr3746284edc.24.1695977476001; Fri, 29 Sep 2023 01:51:16 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, balaton@eik.bme.hu Subject: [PATCH v3 01/14] ui/vnc: Require audiodev= to enable audio Date: Fri, 29 Sep 2023 10:50:54 +0200 Message-ID: <20230929085112.983957-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929085112.983957-1-pbonzini@redhat.com> References: <20230929085112.983957-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695977636125100007 If there is no audiodev do not send the audio ack in response to VNC_ENCODING_AUDIO, so that clients aren't told audio exists, and immediately drop the client if they try to send any audio control messages when audio is not advertised. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- docs/about/deprecated.rst | 8 +++----- docs/about/removed-features.rst | 6 ++++++ ui/vnc.c | 11 ++++++++++- ui/vnc.h | 2 ++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 8f3fef97bd4..c07bf58dde1 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -45,13 +45,11 @@ backend settings instead of environment variables. To = ease migration to the new format, the ``-audiodev-help`` option can be used to convert the current values of the environment variables to ``-audiodev`` options. =20 -Creating sound card devices and vnc without ``audiodev=3D`` property (sinc= e 4.2) -''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''= '''' +Creating sound card devices without ``audiodev=3D`` property (since 4.2) +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' =20 When not using the deprecated legacy audio config, each sound card -should specify an ``audiodev=3D`` property. Additionally, when using -vnc, you should specify an ``audiodev=3D`` property if you plan to -transmit audio through the VNC protocol. +should specify an ``audiodev=3D`` property. =20 Short-form boolean options (since 6.0) '''''''''''''''''''''''''''''''''''''' diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.= rst index 97ec47f1d25..276060b320c 100644 --- a/docs/about/removed-features.rst +++ b/docs/about/removed-features.rst @@ -436,6 +436,12 @@ the process listing. This was replaced by the new ``pa= ssword-secret`` option which lets the password be securely provided on the command line using a ``secret`` object instance. =20 +Creating vnc without ``audiodev=3D`` property (removed in 8.2) +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +When using vnc, you should specify an ``audiodev=3D`` property if +you plan to transmit audio through the VNC protocol. + QEMU Machine Protocol (QMP) commands ------------------------------------ =20 diff --git a/ui/vnc.c b/ui/vnc.c index c302bb07a5b..acb56461b2d 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2195,7 +2195,10 @@ static void set_encodings(VncState *vs, int32_t *enc= odings, size_t n_encodings) send_ext_key_event_ack(vs); break; case VNC_ENCODING_AUDIO: - send_ext_audio_ack(vs); + if (vs->vd->audio_state) { + vs->features |=3D VNC_FEATURE_AUDIO_MASK; + send_ext_audio_ack(vs); + } break; case VNC_ENCODING_WMVi: vs->features |=3D VNC_FEATURE_WMVI_MASK; @@ -2502,6 +2505,12 @@ static int protocol_client_msg(VncState *vs, uint8_t= *data, size_t len) read_u32(data, 4), read_u32(data, 8)); break; case VNC_MSG_CLIENT_QEMU_AUDIO: + if (!vnc_has_feature(vs, VNC_FEATURE_AUDIO)) { + error_report("Audio message %d with audio disabled", read_= u8(data, 2)); + vnc_client_error(vs); + break; + } + if (len =3D=3D 2) return 4; =20 diff --git a/ui/vnc.h b/ui/vnc.h index 757fa83044e..96d19dce199 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -464,6 +464,7 @@ enum VncFeatures { VNC_FEATURE_LED_STATE, VNC_FEATURE_XVP, VNC_FEATURE_CLIPBOARD_EXT, + VNC_FEATURE_AUDIO, }; =20 #define VNC_FEATURE_RESIZE_MASK (1 << VNC_FEATURE_RESIZE) @@ -481,6 +482,7 @@ enum VncFeatures { #define VNC_FEATURE_LED_STATE_MASK (1 << VNC_FEATURE_LED_STATE) #define VNC_FEATURE_XVP_MASK (1 << VNC_FEATURE_XVP) #define VNC_FEATURE_CLIPBOARD_EXT_MASK (1 << VNC_FEATURE_CLIPBOARD_= EXT) +#define VNC_FEATURE_AUDIO_MASK (1 << VNC_FEATURE_AUDIO) =20 =20 /* Client -> Server message IDs */ --=20 2.41.0 From nobody Fri May 17 10:44:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695977828; cv=none; d=zohomail.com; s=zohoarc; b=XWt/W3Mqg6wx1ZUjtzYiffvBVd2iDq42P1qEAnjfTMWB+pt73cJ3xjf6dKBzAdyAQKNeJ9DPC7NhI+eqS1oHjTv0rZ1r2pHnYmHFotPKX5kXgBDzJzZz+o2varZlltMqdKmf06RVnAoJx/fNVIP6gMEtHZTSJfSrTu5fzfX0VCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695977828; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JMRKISlM1zzvlrL63i/7up7pyLzmuYdCsyEbrLNbyC0=; b=Y9NHh1jfXOI/83Ahy3CF/9ycb+SW7xaQDcnakYrm58EliaXqL2FHlAM/Pb6POntNPy2JLIsq+c0tznIfaoX6P+ZmdNGvs8szGwez9WQOEaU0tpNI3G6smnnaoj4GybUR4dB+VutT8P2TcU42GWwymBDvckES/cTvp7terOOIaBY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695977828520154.7298233538553; Fri, 29 Sep 2023 01:57:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qm9EG-0006B1-0m; Fri, 29 Sep 2023 04:52:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qm9E8-0005fQ-Au for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:03 -0400 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 1qm9DW-0005ij-35 for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:51:51 -0400 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-383-Arhb1a48Pai6zh1peuKSlg-1; Fri, 29 Sep 2023 04:51:19 -0400 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-533f8bc82a8so8501362a12.0 for ; Fri, 29 Sep 2023 01:51:19 -0700 (PDT) Received: from [192.168.1.174] ([151.48.237.81]) by smtp.gmail.com with ESMTPSA id cy23-20020a0564021c9700b005362c9905b2sm1893055edb.35.2023.09.29.01.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 01:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695977481; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JMRKISlM1zzvlrL63i/7up7pyLzmuYdCsyEbrLNbyC0=; b=BS/irB5aC+XBAyND/vUY4eyEfJAOOA94XstzWx6xxUXonhu/w1hhFt+R+zIIt1B1D4VAv2 sGUwtNNMUQF7luTrz/rO9Y02fGM5Vus3AAk+A1+szrmdxy1NzxvjQOSzCStEQDYRiTW/IF 95EiD4KonrjaosfdOTBwcGYSD3d9iKs= X-MC-Unique: Arhb1a48Pai6zh1peuKSlg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695977478; x=1696582278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JMRKISlM1zzvlrL63i/7up7pyLzmuYdCsyEbrLNbyC0=; b=pNWv8sRqVRhNSPlIWBwkYKtlfMygBa9skUx2yyMFcbrYV1tuH6tPZtu66wnGsAcu8k 8Xt2TiSmiubL2b9FMoHzFgCw8P2peeDmvCixiH5PA2h37TywAEplj9rOOBNoVT6tuPz9 jg2da4T6aW1mplYt57f+36VXmPAlcyT1wk92OFAfOAZf16uYZpIKZ77gCEr6a6v26SHJ 8p43C31x3oIcsTAHWhybtyMvraEtC1fdZSCaxBjpYlpmbHsFh5NNyjY6RXTg4L1+Oae1 M6IDWve2zHYaoRH30UNNwuSWr/Px9hWnNehFu6DuOhTvQlPso1FyCCZ/S3CRiVW5nTgD lP+w== X-Gm-Message-State: AOJu0YwD4OwH//UFX9F0AXox8ymMY1Lpi1gj54q6XmNUlhn1+8VVGdrf 0qk8I+EZSw+4aV/rrJiRALkzNDr7xRq8iYZ5+V7TEFbY9Zza5KSQvOBGc35+SIQ+bVEtc2TziS6 mC5ZP1cv3CZKym5k260YVlKr+YmiBVsde0haTEWK8aHcDJZqsv4OwFLbp+MIaIsv1nF9vzhHmuq U= X-Received: by 2002:aa7:d5c4:0:b0:533:4f9b:67c8 with SMTP id d4-20020aa7d5c4000000b005334f9b67c8mr3189069eds.16.1695977478280; Fri, 29 Sep 2023 01:51:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmDoR0yppC90CNYD/bdVfPaQdb9Xt9TRlOOYNwRwR5py+ythrsj6JHbknGxJIEs5x6ZABvLw== X-Received: by 2002:aa7:d5c4:0:b0:533:4f9b:67c8 with SMTP id d4-20020aa7d5c4000000b005334f9b67c8mr3189060eds.16.1695977478043; Fri, 29 Sep 2023 01:51:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, balaton@eik.bme.hu, Martin Kletzander Subject: [PATCH v3 02/14] audio: Require AudioState in AUD_add_capture Date: Fri, 29 Sep 2023 10:50:55 +0200 Message-ID: <20230929085112.983957-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929085112.983957-1-pbonzini@redhat.com> References: <20230929085112.983957-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695977829388100001 Content-Type: text/plain; charset="utf-8" From: Martin Kletzander Since all callers require a valid audiodev this function can now safely abort in case of missing AudioState. Signed-off-by: Martin Kletzander Message-ID: Signed-off-by: Paolo Bonzini --- audio/audio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 2f479657117..4332c4c6ce8 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1876,10 +1876,9 @@ CaptureVoiceOut *AUD_add_capture( struct capture_callback *cb; =20 if (!s) { - if (!legacy_config) { - dolog("Capturing without setting an audiodev is deprecated\n"); - } - s =3D audio_init(NULL, NULL); + error_setg(&error_abort, + "Capturing without setting an audiodev is not supported= "); + abort(); } =20 if (!audio_get_pdo_out(s->dev)->mixing_engine) { --=20 2.41.0 From nobody Fri May 17 10:44:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695977640; cv=none; d=zohomail.com; s=zohoarc; b=TUYQwM33Zq0nPCbeddzuwp44mSGzj10zxQv62VdsYW2awwzVK0XFIHQGp/cU2VxnEh3scJvr1PaUN8feqVHZ10ge4BI271JhXxcDEh82Tu6a9piMUa1X/wIJkjLXwnSsCqllQuhy8Fa7QLNMXtjGhBug56Vfx4CeksulIUIPuBs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695977640; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=42BKwR9boJnqSTyQtjOimETiRg2ddeniC2cVZYNUqso=; b=YBkIeOidGfSYEejyHRkZNIxgXfEuFEljjfw5kS/Czk/TgJt9uWiPr+FSMrbq6v0RRqqlzcwVWH3x1pKDr+QEJqzfc0OM3xMY/1AaIaGXrNXrGfDn75/avuVeNVDjMC6oCk9872LZoUZBEt5wB73PODK0/plr69C0B9r3UPeFih4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695977640623892.734110119662; Fri, 29 Sep 2023 01:54:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qm9EE-00061j-5V; Fri, 29 Sep 2023 04:52:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qm9Dw-0005VI-SF for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:51:56 -0400 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 1qm9DZ-0005kD-Bc for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:51:44 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-5--d44L_klPKu-HRuVHR0oBw-1; Fri, 29 Sep 2023 04:51:23 -0400 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-533d8a785a5so8815382a12.3 for ; Fri, 29 Sep 2023 01:51:22 -0700 (PDT) Received: from [192.168.1.174] ([151.48.237.81]) by smtp.gmail.com with ESMTPSA id u7-20020a05640207c700b005311e934765sm10896353edy.27.2023.09.29.01.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 01:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695977484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=42BKwR9boJnqSTyQtjOimETiRg2ddeniC2cVZYNUqso=; b=CrczEUFvdaEIoVGn+s6dly6XCiZMgOP7t3oAo3sW4r+VqWcaByLs901DaBw2xcfeZOiFyH ZCUApQIPYT8sRC1/emT/Gr46A590uCd1ASEFRF6jVYa8x1FQLawOMlPsaMDDuzAfqQ+hDZ egezIPEOxE2nCiRgn3s3XyvWnBC9usE= X-MC-Unique: -d44L_klPKu-HRuVHR0oBw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695977481; x=1696582281; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=42BKwR9boJnqSTyQtjOimETiRg2ddeniC2cVZYNUqso=; b=jIOoTvoxIwp1lypHkuj/Ugcpw71T+i73m1zHa05XKI/VSUsxaebpZ9dnkLg8Ppp5SC MQGTGmsi9SRuk6TMFsJb/3Ryw3WffubzS926Rqo0sgol7W+V3EyWvG74D2qqeJvJc6gG fnSzNO2JH1vv5UyazqmdfNBQ8omtnz224CeMgRRJxnGRcgOTDUe/piF0kQmGi9TgihJI kDj8f3tkLaRC4ZvXR4cxC2gPlN1xwDYpwl4kjqmIbDUteS80szfNO/Kz5S4ZSnhxWhxK 6M+G5svzmKcrFOg0h21Mq8GfAYqkARi8S5INim40FD2bGUZ2lLRDklH5luSCiNMrpHCK JOcA== X-Gm-Message-State: AOJu0YwptpHsljFk7t3oCkyWsGjSaACPDos/grM/ltGcsAShV9JBI/Pm ct7Z3oDw5q8sRN/HtWrFtcuP1b5SSJ6QxLJ6LxjKXkmLCt2XRWm6a+sj5VEm9YnPF0yUVyXeIG0 1qOJtcppk1LTp6xTW98s6hSaDjchd86pN1o7W5DzLTbtRx6zwBbmEIYzk5p6FyhSZWQ1AzvizUw 0= X-Received: by 2002:aa7:d793:0:b0:523:3754:a4e1 with SMTP id s19-20020aa7d793000000b005233754a4e1mr3180054edq.22.1695977480825; Fri, 29 Sep 2023 01:51:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGow9uzLVHOqKDS/LxyEPFTFgvhUq4YvNs+Jo9TR+L7ijg0dwZn9RuYp3X1jCVdpA88b2i6BA== X-Received: by 2002:aa7:d793:0:b0:523:3754:a4e1 with SMTP id s19-20020aa7d793000000b005233754a4e1mr3180033edq.22.1695977480328; Fri, 29 Sep 2023 01:51:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, balaton@eik.bme.hu Subject: [PATCH v3 03/14] audio: allow returning an error from the driver init Date: Fri, 29 Sep 2023 10:50:56 +0200 Message-ID: <20230929085112.983957-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929085112.983957-1-pbonzini@redhat.com> References: <20230929085112.983957-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695977642132100005 An error is already printed by audio_driver_init, but we can make it more precise if the driver can return an Error *. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Paolo Bonzini --- audio/alsaaudio.c | 2 +- audio/audio.c | 13 ++++++++++--- audio/audio_int.h | 2 +- audio/coreaudio.m | 2 +- audio/dbusaudio.c | 2 +- audio/dsoundaudio.c | 2 +- audio/jackaudio.c | 2 +- audio/noaudio.c | 2 +- audio/ossaudio.c | 11 ++++++++--- audio/paaudio.c | 7 +++++-- audio/pwaudio.c | 16 +++++++++------- audio/sdlaudio.c | 5 +++-- audio/sndioaudio.c | 2 +- audio/spiceaudio.c | 5 ++++- audio/wavaudio.c | 2 +- 15 files changed, 48 insertions(+), 27 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 057571dd1e0..6fb78e5b972 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -904,7 +904,7 @@ static void alsa_init_per_direction(AudiodevAlsaPerDire= ctionOptions *apdo) } } =20 -static void *alsa_audio_init(Audiodev *dev) +static void *alsa_audio_init(Audiodev *dev, Error **errp) { AudiodevAlsaOptions *aopts; assert(dev->driver =3D=3D AUDIODEV_DRIVER_ALSA); diff --git a/audio/audio.c b/audio/audio.c index 4332c4c6ce8..3d664503521 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -33,6 +33,7 @@ #include "qapi/qapi-visit-audio.h" #include "qapi/qapi-commands-audio.h" #include "qemu/cutils.h" +#include "qemu/error-report.h" #include "qemu/log.h" #include "qemu/module.h" #include "qemu/help_option.h" @@ -1555,7 +1556,9 @@ size_t audio_generic_read(HWVoiceIn *hw, void *buf, s= ize_t size) static int audio_driver_init(AudioState *s, struct audio_driver *drv, bool msg, Audiodev *dev) { - s->drv_opaque =3D drv->init(dev); + Error *local_err =3D NULL; + + s->drv_opaque =3D drv->init(dev, &local_err); =20 if (s->drv_opaque) { if (!drv->pcm_ops->get_buffer_in) { @@ -1572,8 +1575,12 @@ static int audio_driver_init(AudioState *s, struct a= udio_driver *drv, s->drv =3D drv; return 0; } else { - if (msg) { - dolog("Could not init `%s' audio driver\n", drv->name); + if (!msg) { + error_free(local_err); + } else if (local_err) { + error_report_err(local_err); + } else { + error_report("Could not init `%s' audio driver", drv->name); } return -1; } diff --git a/audio/audio_int.h b/audio/audio_int.h index e57ff50155a..06e815de9f6 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -140,7 +140,7 @@ typedef struct audio_driver audio_driver; struct audio_driver { const char *name; const char *descr; - void *(*init) (Audiodev *); + void *(*init) (Audiodev *, Error **); void (*fini) (void *); #ifdef CONFIG_GIO void (*set_dbus_server) (AudioState *s, GDBusObjectManagerServer *mana= ger, bool p2p); diff --git a/audio/coreaudio.m b/audio/coreaudio.m index 4695291621a..7cfb38fb6ae 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -644,7 +644,7 @@ static void coreaudio_enable_out(HWVoiceOut *hw, bool e= nable) update_device_playback_state(core); } =20 -static void *coreaudio_audio_init(Audiodev *dev) +static void *coreaudio_audio_init(Audiodev *dev, Error **errp) { return dev; } diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index 7a11fbfb420..310ca997ff4 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -395,7 +395,7 @@ dbus_enable_in(HWVoiceIn *hw, bool enable) } =20 static void * -dbus_audio_init(Audiodev *dev) +dbus_audio_init(Audiodev *dev, Error **errp) { DBusAudio *da =3D g_new0(DBusAudio, 1); =20 diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 3fb67ec3eed..eefde88edcb 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -619,7 +619,7 @@ static void dsound_audio_fini (void *opaque) g_free(s); } =20 -static void *dsound_audio_init(Audiodev *dev) +static void *dsound_audio_init(Audiodev *dev, Error **errp) { int err; HRESULT hr; diff --git a/audio/jackaudio.c b/audio/jackaudio.c index e1eaa3477dc..823e7d96bae 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -645,7 +645,7 @@ static int qjack_thread_creator(jack_native_thread_t *t= hread, } #endif =20 -static void *qjack_init(Audiodev *dev) +static void *qjack_init(Audiodev *dev, Error **errp) { assert(dev->driver =3D=3D AUDIODEV_DRIVER_JACK); return dev; diff --git a/audio/noaudio.c b/audio/noaudio.c index 4fdee5adecf..a36bfeffd14 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -104,7 +104,7 @@ static void no_enable_in(HWVoiceIn *hw, bool enable) } } =20 -static void *no_audio_init(Audiodev *dev) +static void *no_audio_init(Audiodev *dev, Error **errp) { return &no_audio_init; } diff --git a/audio/ossaudio.c b/audio/ossaudio.c index e8d732b612c..ec4448d573d 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -28,6 +28,7 @@ #include "qemu/main-loop.h" #include "qemu/module.h" #include "qemu/host-utils.h" +#include "qapi/error.h" #include "audio.h" #include "trace.h" =20 @@ -736,7 +737,7 @@ static void oss_init_per_direction(AudiodevOssPerDirect= ionOptions *opdo) } } =20 -static void *oss_audio_init(Audiodev *dev) +static void *oss_audio_init(Audiodev *dev, Error **errp) { AudiodevOssOptions *oopts; assert(dev->driver =3D=3D AUDIODEV_DRIVER_OSS); @@ -745,8 +746,12 @@ static void *oss_audio_init(Audiodev *dev) oss_init_per_direction(oopts->in); oss_init_per_direction(oopts->out); =20 - if (access(oopts->in->dev ?: "/dev/dsp", R_OK | W_OK) < 0 || - access(oopts->out->dev ?: "/dev/dsp", R_OK | W_OK) < 0) { + 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; + } + 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; } return dev; diff --git a/audio/paaudio.c b/audio/paaudio.c index 529b39daacc..39bd6cfa38a 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -3,7 +3,7 @@ #include "qemu/osdep.h" #include "qemu/module.h" #include "audio.h" -#include "qapi/opts-visitor.h" +#include "qapi/error.h" =20 #include =20 @@ -818,7 +818,7 @@ fail: return NULL; } =20 -static void *qpa_audio_init(Audiodev *dev) +static void *qpa_audio_init(Audiodev *dev, Error **errp) { paaudio *g; AudiodevPaOptions *popts =3D &dev->u.pa; @@ -834,10 +834,12 @@ static void *qpa_audio_init(Audiodev *dev) =20 runtime =3D getenv("XDG_RUNTIME_DIR"); if (!runtime) { + error_setg(errp, "XDG_RUNTIME_DIR not set"); return NULL; } 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; } } @@ -867,6 +869,7 @@ static void *qpa_audio_init(Audiodev *dev) } if (!g->conn) { g_free(g); + error_setg(errp, "could not connect to PulseAudio server"); return NULL; } =20 diff --git a/audio/pwaudio.c b/audio/pwaudio.c index b6a38738ee9..1020cb11df1 100644 --- a/audio/pwaudio.c +++ b/audio/pwaudio.c @@ -13,6 +13,7 @@ #include "audio.h" #include #include "qemu/error-report.h" +#include "qapi/error.h" #include #include #include @@ -736,7 +737,7 @@ static const struct pw_core_events core_events =3D { }; =20 static void * -qpw_audio_init(Audiodev *dev) +qpw_audio_init(Audiodev *dev, Error **errp) { g_autofree pwaudio *pw =3D g_new0(pwaudio, 1); =20 @@ -748,19 +749,19 @@ qpw_audio_init(Audiodev *dev) pw->dev =3D dev; pw->thread_loop =3D pw_thread_loop_new("PipeWire thread loop", NULL); if (pw->thread_loop =3D=3D NULL) { - error_report("Could not create PipeWire loop: %s", g_strerror(errn= o)); + error_setg_errno(errp, errno, "Could not create PipeWire loop"); goto fail; } =20 pw->context =3D pw_context_new(pw_thread_loop_get_loop(pw->thread_loop), NULL, 0); if (pw->context =3D=3D NULL) { - error_report("Could not create PipeWire context: %s", g_strerror(e= rrno)); + error_setg_errno(errp, errno, "Could not create PipeWire context"); goto fail; } =20 if (pw_thread_loop_start(pw->thread_loop) < 0) { - error_report("Could not start PipeWire loop: %s", g_strerror(errno= )); + error_setg_errno(errp, errno, "Could not start PipeWire loop"); goto fail; } =20 @@ -769,13 +770,13 @@ qpw_audio_init(Audiodev *dev) pw->core =3D pw_context_connect(pw->context, NULL, 0); if (pw->core =3D=3D NULL) { pw_thread_loop_unlock(pw->thread_loop); - goto fail; + goto fail_error; } =20 if (pw_core_add_listener(pw->core, &pw->core_listener, &core_events, pw) < 0) { pw_thread_loop_unlock(pw->thread_loop); - goto fail; + goto fail_error; } if (wait_resync(pw) < 0) { pw_thread_loop_unlock(pw->thread_loop); @@ -785,8 +786,9 @@ qpw_audio_init(Audiodev *dev) =20 return g_steal_pointer(&pw); =20 +fail_error: + error_setg(errp, "Failed to initialize PW context"); fail: - AUD_log(AUDIO_CAP, "Failed to initialize PW context"); if (pw->thread_loop) { pw_thread_loop_stop(pw->thread_loop); } diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 68a237b76b4..4d8473d9ece 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -26,6 +26,7 @@ #include #include #include "qemu/module.h" +#include "qapi/error.h" #include "audio.h" =20 #ifndef _WIN32 @@ -449,10 +450,10 @@ static void sdl_enable_in(HWVoiceIn *hw, bool enable) SDL_PauseAudioDevice(sdl->devid, !enable); } =20 -static void *sdl_audio_init(Audiodev *dev) +static void *sdl_audio_init(Audiodev *dev, Error **errp) { if (SDL_InitSubSystem (SDL_INIT_AUDIO)) { - sdl_logerr ("SDL failed to initialize audio subsystem\n"); + error_setg(errp, "SDL failed to initialize audio subsystem"); return NULL; } =20 diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c index 3fde01fdbd5..1e35925a497 100644 --- a/audio/sndioaudio.c +++ b/audio/sndioaudio.c @@ -518,7 +518,7 @@ static void sndio_fini_in(HWVoiceIn *hw) sndio_fini(self); } =20 -static void *sndio_audio_init(Audiodev *dev) +static void *sndio_audio_init(Audiodev *dev, Error **errp) { assert(dev->driver =3D=3D AUDIODEV_DRIVER_SNDIO); return dev; diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index d17ef1a25ef..7f02f7285cf 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -22,6 +22,7 @@ #include "qemu/module.h" #include "qemu/error-report.h" #include "qemu/timer.h" +#include "qapi/error.h" #include "ui/qemu-spice.h" =20 #define AUDIO_CAP "spice" @@ -71,11 +72,13 @@ static const SpiceRecordInterface record_sif =3D { .base.minor_version =3D SPICE_INTERFACE_RECORD_MINOR, }; =20 -static void *spice_audio_init(Audiodev *dev) +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; } =20 diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 6445a2cb90c..26b03906d59 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -182,7 +182,7 @@ static void wav_enable_out(HWVoiceOut *hw, bool enable) } } =20 -static void *wav_audio_init(Audiodev *dev) +static void *wav_audio_init(Audiodev *dev, Error **errp) { assert(dev->driver =3D=3D AUDIODEV_DRIVER_WAV); return dev; --=20 2.41.0 From nobody Fri May 17 10:44:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695977831; cv=none; d=zohomail.com; s=zohoarc; b=M7q+eI8isHJvr8cKwjfCyKAkIkq81x+7ZSkAzkGG1FwEvCDMofrZ6B3/q0PutFCS3L9j+9EKZiDwJMvGeQfd3a5ZDvx6HaQGKS2E3LLON4Yzq8oF6hO6UQUn6A0W66nmlQK+H3VqSBw5QU03WEAB5zj/Nae504mH97pEuW2NZRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695977831; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lfSsdCVQj7Q5V/xwxYYL14JcsNV1/hYptBm9881blPI=; b=cY8YsXDwzhlfgAetwZ153n8gL5ULd/Py4YQt62tnjPtPAvzZ2BxzYAN9RwR1sEq+aAHsjAMm8FsRwHG3h13SnYhyCPMsuEda5XB28PDcbh6RF2kiC9WP9fBi1RMHCj8iVUIq8Ee7zPiuFrJfJYDgKdurEdTqEKW22FBD9T+OBMY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169597783179697.22481187047515; Fri, 29 Sep 2023 01:57:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qm9EI-0006Gk-Uh; Fri, 29 Sep 2023 04:52:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qm9E9-0005fR-Bi for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:03 -0400 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 1qm9Db-0005kd-Cm for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:51:51 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-aGZQmDgWMAKEUdIiEV_ccA-1; Fri, 29 Sep 2023 04:51:25 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-99bcb13d8ddso1177835466b.0 for ; Fri, 29 Sep 2023 01:51:25 -0700 (PDT) Received: from [192.168.1.174] ([151.48.237.81]) by smtp.gmail.com with ESMTPSA id hs35-20020a1709073ea300b009b28ad521f4sm6692848ejc.4.2023.09.29.01.51.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 01:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695977486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lfSsdCVQj7Q5V/xwxYYL14JcsNV1/hYptBm9881blPI=; b=HEGfDvQUxjjYWNKRiNiBF4spcd75+f7o6c/+1P8WTyzQ9xPKlLO0E51cSKyKwuJxy6sFC9 f7HIg2AjgL/ujzZ/Zm7kR01Js5abph7WEq5Ix7QmNDPnmXmmEG7gjJOPnrDd222vkJiEXV jL3SlG3013NCPQe8pJr7ovFWVB5ep5c= X-MC-Unique: aGZQmDgWMAKEUdIiEV_ccA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695977483; x=1696582283; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lfSsdCVQj7Q5V/xwxYYL14JcsNV1/hYptBm9881blPI=; b=ulqiNRc9ESJBN3PdESAOpFJ0ls7PLUGeXHxhCUmTBMEk4Zuld5LhffQ+S22+3YlLcv wF6fTKqND0EwlPoXNspArRp6r8ckW2D8ioRqhSlYkQ667kRw7mRbNEVRvcH8n9Wm2lXA BEJLkXnSFjo9XU2yu+g7nt5oxDQ51onQY66KckMSxuFimLHrThMfPN8AnDgpVZwXUNvX 87e2dkhd5mjUQThOOWEXMAjF7S705FEna2FvBQVwrxejVLHG8P3UNPaaCTBHYlwu3IQQ NzUYFznD8eB8pziKoeh0ZhQpOPZ+vOEdbKenXO7Cc3mqRX1zxEWPoo5HAnAXnGdlC9yZ hNVw== X-Gm-Message-State: AOJu0Yw+9p0LzARD9z+UHY5rflQwe2GQI/dfPkYm8NI2gNL3gVJUBG+4 78d5Ffcre7hFu+eazz5McsSwqb+z2SB6oSI83bkp3GV051R137s1yS9oBTmrf4AFplEHzmllmsE G0lUSvRpGLtPDhtq6gnkQyvar6vlsUM1WTkZLNXdxPPxvmxeAuabTgMwKj/lAbYjWkPbFvP0vpe o= X-Received: by 2002:a17:906:3041:b0:9a5:b1cd:bdf2 with SMTP id d1-20020a170906304100b009a5b1cdbdf2mr3282705ejd.51.1695977483315; Fri, 29 Sep 2023 01:51:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEpTbxOzebwEoYDdPK9xFJYm8LLViEOv0X8t4nj8QPg6/qSO5ov0uZNfbRuY0TlBEelkcPRg== X-Received: by 2002:a17:906:3041:b0:9a5:b1cd:bdf2 with SMTP id d1-20020a170906304100b009a5b1cdbdf2mr3282687ejd.51.1695977482836; Fri, 29 Sep 2023 01:51:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, balaton@eik.bme.hu Subject: [PATCH v3 04/14] audio: return Error ** from audio_state_by_name Date: Fri, 29 Sep 2023 10:50:57 +0200 Message-ID: <20230929085112.983957-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929085112.983957-1-pbonzini@redhat.com> References: <20230929085112.983957-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695977833866100015 Content-Type: text/plain; charset="utf-8" Remove duplicate error formatting code. Signed-off-by: Paolo Bonzini --- audio/audio-hmp-cmds.c | 6 ++++-- audio/audio.c | 3 ++- audio/audio.h | 2 +- hw/core/qdev-properties-system.c | 16 ++++------------ ui/dbus.c | 3 +-- ui/vnc.c | 3 +-- 6 files changed, 13 insertions(+), 20 deletions(-) diff --git a/audio/audio-hmp-cmds.c b/audio/audio-hmp-cmds.c index 1237ce9e750..c9608b715b8 100644 --- a/audio/audio-hmp-cmds.c +++ b/audio/audio-hmp-cmds.c @@ -26,6 +26,7 @@ #include "audio/audio.h" #include "monitor/hmp.h" #include "monitor/monitor.h" +#include "qapi/error.h" #include "qapi/qmp/qdict.h" =20 static QLIST_HEAD (capture_list_head, CaptureState) capture_head; @@ -65,10 +66,11 @@ void hmp_wavcapture(Monitor *mon, const QDict *qdict) int nchannels =3D qdict_get_try_int(qdict, "nchannels", 2); const char *audiodev =3D qdict_get_str(qdict, "audiodev"); CaptureState *s; - AudioState *as =3D audio_state_by_name(audiodev); + Error *local_err =3D NULL; + AudioState *as =3D audio_state_by_name(audiodev, &local_err); =20 if (!as) { - monitor_printf(mon, "Audiodev '%s' not found\n", audiodev); + error_report_err(local_err); return; } =20 diff --git a/audio/audio.c b/audio/audio.c index 3d664503521..d4263976a5b 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -2261,7 +2261,7 @@ int audio_buffer_bytes(AudiodevPerDirectionOptions *p= do, audioformat_bytes_per_sample(as->fmt); } =20 -AudioState *audio_state_by_name(const char *name) +AudioState *audio_state_by_name(const char *name, Error **errp) { AudioState *s; QTAILQ_FOREACH(s, &audio_states, list) { @@ -2270,6 +2270,7 @@ AudioState *audio_state_by_name(const char *name) return s; } } + error_setg(errp, "audiodev '%s' not found", name); return NULL; } =20 diff --git a/audio/audio.h b/audio/audio.h index 01bdc567fb1..e0c13b5dcdf 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -174,7 +174,7 @@ bool audio_init_audiodevs(void); void audio_help(void); void audio_legacy_help(void); =20 -AudioState *audio_state_by_name(const char *name); +AudioState *audio_state_by_name(const char *name, Error **errp); const char *audio_get_id(QEMUSoundCard *card); =20 #define DEFINE_AUDIO_PROPERTIES(_s, _f) \ diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index 41b7e682c78..688340610ec 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -480,24 +480,16 @@ static void set_audiodev(Object *obj, Visitor *v, con= st char* name, Property *prop =3D opaque; QEMUSoundCard *card =3D object_field_prop_ptr(obj, prop); AudioState *state; - int err =3D 0; - char *str; + g_autofree char *str =3D NULL; =20 if (!visit_type_str(v, name, &str, errp)) { return; } =20 - state =3D audio_state_by_name(str); - - if (!state) { - err =3D -ENOENT; - goto out; + state =3D audio_state_by_name(str, errp); + if (state) { + card->state =3D state; } - card->state =3D state; - -out: - error_set_from_qdev_prop_error(errp, err, obj, name, str); - g_free(str); } =20 const PropertyInfo qdev_prop_audiodev =3D { diff --git a/ui/dbus.c b/ui/dbus.c index 32f1bbe81ae..866467ad2e3 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -220,9 +220,8 @@ dbus_display_complete(UserCreatable *uc, Error **errp) } =20 if (dd->audiodev && *dd->audiodev) { - AudioState *audio_state =3D audio_state_by_name(dd->audiodev); + AudioState *audio_state =3D audio_state_by_name(dd->audiodev, errp= ); if (!audio_state) { - error_setg(errp, "Audiodev '%s' not found", dd->audiodev); return; } if (!g_str_equal(audio_state->drv->name, "dbus")) { diff --git a/ui/vnc.c b/ui/vnc.c index acb56461b2d..82929469130 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -4181,9 +4181,8 @@ void vnc_display_open(const char *id, Error **errp) =20 audiodev =3D qemu_opt_get(opts, "audiodev"); if (audiodev) { - vd->audio_state =3D audio_state_by_name(audiodev); + vd->audio_state =3D audio_state_by_name(audiodev, errp); if (!vd->audio_state) { - error_setg(errp, "Audiodev '%s' not found", audiodev); goto fail; } } --=20 2.41.0 From nobody Fri May 17 10:44:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695977615; cv=none; d=zohomail.com; s=zohoarc; b=lngI95AIkas+VAJhKG5SubScPHe0/Hb2xcJPb7Ivv88Yw71gZst6w9VrJHSB1RXp+KXVSgbobDWV9HUur8Oewtc4bXEfpEN2s/iOLPBTQN7zVNGkpj1nrF74UjnkXevkhTD8U0S8HVyXBSsCEQi6a6p9fSBBFHlnTkKWEgFigSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695977615; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q/cjiD8zcK3q6uQaQzwkdfO4D5tuO2wkAY58seJFlMA=; b=Q47o/IkSc2YiQMFVWPnyWegFlCwb8zLSggZo6j9kYYeYf9bF5DEl2mpI8qgkS7mAUy7YSLWF3Bv2zcS2OJhxMa/eps6ecjOjfbvycRgyi1IsfXn6cUUInSdQfElQICWJY1DuU8BiTf2MKZTgBBppsmR2w9nfPquDTIHMaiBQyvs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695977615870925.3315241805932; Fri, 29 Sep 2023 01:53:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qm9EK-0006Le-LO; Fri, 29 Sep 2023 04:52:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qm9EB-0005iM-K0 for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:03 -0400 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 1qm9Dg-0005lV-OS for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:51:54 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-107-QHypU5UhNnC7l41XNmAf_g-1; Fri, 29 Sep 2023 04:51:27 -0400 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-534695ab33eso5300773a12.0 for ; Fri, 29 Sep 2023 01:51:26 -0700 (PDT) Received: from [192.168.1.174] ([151.48.237.81]) by smtp.gmail.com with ESMTPSA id l14-20020aa7cace000000b0053331f9094dsm10843915edt.52.2023.09.29.01.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 01:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695977490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q/cjiD8zcK3q6uQaQzwkdfO4D5tuO2wkAY58seJFlMA=; b=YhawEy9/BorQi9ctnntUKwhKdgLnlQ/D0JoDxc7JxG3mgOeeQC8d+CibKJzmVFiycY8nY2 ZHNf7zLngzP52ArcwrRrt43HCJXQOjr0gOQ/jrkY0G7av4fGDR9B37QVwpdQZOXPYqpGIZ jwZFW07k2bkGSeGb1JoY7bRmw/2UreU= X-MC-Unique: QHypU5UhNnC7l41XNmAf_g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695977485; x=1696582285; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q/cjiD8zcK3q6uQaQzwkdfO4D5tuO2wkAY58seJFlMA=; b=CwruvrnLvzL+2jroCkzinPyaHoYpOwI+ZAb7ChBHdbAc5nDbwrn+TrZ7d7cLroH/V0 x5Y9IRLNuy43rIw158GjS62vkMN/GLZjeOntHigDUQvWEmulJ9bxde19VAw7IZYG69g1 qu46/VdmweIbP8p8fY67jRskWihwcxBnSMeeNIUrnQGHV+1FbSHUQxMFW9vzmsnp6otu DfEE3Uqh/lZLE4fD2Fs+zMjrCgdPgUxCb8ebwK065IrQYlYJyLk2dnmLfD8dwaZ87bQV Yvnm240kCyli7x/Dp3jw0DGGSF2xAhGpOiU5qe24rOAQUQHLK+xDk2uj6Vas3CUh4gqO PZ7w== X-Gm-Message-State: AOJu0YwDbGXpMLzjgWcMq4B1ozOc9UETeuGY+YO0Mj2PmxfMSELyLcFp 80zeV5Go6X7wKrnymAwIt2+2YiNEcphe8kRwGFKgl4k20LXImSY94Uzk+UN/Srv187G4KMEOtLw IUv47P3LfwzibC7sK/5JRGnV8YoCq0ek/Jd1RLn9kQ+9T94oGLX79wj41goMzBkPmMX7MWOJSMu Y= X-Received: by 2002:a05:6402:1846:b0:523:bfec:4915 with SMTP id v6-20020a056402184600b00523bfec4915mr3741541edy.0.1695977485164; Fri, 29 Sep 2023 01:51:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzfDZvcu1eaGnU+DXnJfc2piIvjm93oir8fiYCUzAaScLIp5hAa2YfUPA/ou6sI94vkwdD+Q== X-Received: by 2002:a05:6402:1846:b0:523:bfec:4915 with SMTP id v6-20020a056402184600b00523bfec4915mr3741525edy.0.1695977484847; Fri, 29 Sep 2023 01:51:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, balaton@eik.bme.hu Subject: [PATCH v3 05/14] audio: commonize voice initialization Date: Fri, 29 Sep 2023 10:50:58 +0200 Message-ID: <20230929085112.983957-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929085112.983957-1-pbonzini@redhat.com> References: <20230929085112.983957-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695977617784100001 Content-Type: text/plain; charset="utf-8" Move some mostly irrelevant code out of audio_init. Signed-off-by: Paolo Bonzini --- audio/audio.c | 19 ++----------------- audio/audio_template.h | 9 ++++++++- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index d4263976a5b..2014a2904e8 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1570,8 +1570,8 @@ static int audio_driver_init(AudioState *s, struct au= dio_driver *drv, drv->pcm_ops->put_buffer_out =3D audio_generic_put_buffer_out; } =20 - audio_init_nb_voices_out(s, drv); - audio_init_nb_voices_in(s, drv); + audio_init_nb_voices_out(s, drv, 1); + audio_init_nb_voices_in(s, drv, 0); s->drv =3D drv; return 0; } else { @@ -1774,21 +1774,6 @@ static AudioState *audio_init(Audiodev *dev, const c= har *name) =20 s->ts =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s); =20 - s->nb_hw_voices_out =3D audio_get_pdo_out(dev)->voices; - s->nb_hw_voices_in =3D audio_get_pdo_in(dev)->voices; - - if (s->nb_hw_voices_out < 1) { - dolog ("Bogus number of playback voices %d, setting to 1\n", - s->nb_hw_voices_out); - s->nb_hw_voices_out =3D 1; - } - - if (s->nb_hw_voices_in < 0) { - dolog ("Bogus number of capture voices %d, setting to 0\n", - s->nb_hw_voices_in); - s->nb_hw_voices_in =3D 0; - } - if (drvname) { driver =3D audio_driver_lookup(drvname); if (driver) { diff --git a/audio/audio_template.h b/audio/audio_template.h index dc0c74aa746..7ccfec01168 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -37,11 +37,12 @@ #endif =20 static void glue(audio_init_nb_voices_, TYPE)(AudioState *s, - struct audio_driver *drv) + struct audio_driver *drv, in= t min_voices) { int max_voices =3D glue (drv->max_voices_, TYPE); size_t voice_size =3D glue(drv->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) { if (!max_voices) { #ifdef DAC @@ -56,6 +57,12 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioState= *s, 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); + } + if (audio_bug(__func__, !voice_size && max_voices)) { dolog ("drv=3D`%s' voice_size=3D0 max_voices=3D%d\n", drv->name, max_voices); --=20 2.41.0 From nobody Fri May 17 10:44:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695977685; cv=none; d=zohomail.com; s=zohoarc; b=fFtsxCQpAvD+amq2ZjayCYMQsLzSXLSfqcqYuaINWaXRpR3ocL83cBHbRkHVxxPO9+tlyvHFppXgFzo2PssUdlZBdcMWJq/4i5tD9q3aw2PEvgHDBKg5upOMsIj4DVXwROaSgfsN3ICJsTBVW1pncZK6SmxRzaOUocWkBgan6Mg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695977685; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UGH+M0fuvIFCi6QOwPCOQd0lXkYR3OEDHngCBdZqUDI=; b=FDKu9MZfvpMGeot8hmRAV0x1xAikKVV7E/NplioxEDOsJ7mYAIl26DYPn+xBFv2zTtVROMNzUBOT+MYUBHz4ox1vRaGJ3V8wl3e0s6GTWJmENfL61+f8EINRR05CCwwpLlgQk6kRcZExpinubNfJS11XxnvfHWB/oz4VWwiJjtU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695977685144358.23901668544204; Fri, 29 Sep 2023 01:54:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qm9EE-00062Q-BL; Fri, 29 Sep 2023 04:52:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qm9EB-0005jI-NH for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:03 -0400 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 1qm9Dg-0005lh-Bm for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:03 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-abmnIz6UOSikmZJRHpIdXQ-1; Fri, 29 Sep 2023 04:51:29 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-9b2cf504e3aso60003866b.2 for ; Fri, 29 Sep 2023 01:51:28 -0700 (PDT) Received: from [192.168.1.174] ([151.48.237.81]) by smtp.gmail.com with ESMTPSA id md1-20020a170906ae8100b009a1be9c29d7sm12126529ejb.179.2023.09.29.01.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 01:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695977490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UGH+M0fuvIFCi6QOwPCOQd0lXkYR3OEDHngCBdZqUDI=; b=DEY9IXGhGnX7zOPPXCymf4YinogIuVGlhbHqKWNDTUTKomWhtXqPQdVS5OLEsiGUSp/KUv fmbLd4C5fCIgCZ4fKGtJitymNFdTn3e9tzFI2NeiwfCrMXTfA0aUFEy3hdL30Dc+YTTcXk GWhoIbcC52rzFj9JPY44fq1tw06x2X0= X-MC-Unique: abmnIz6UOSikmZJRHpIdXQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695977487; x=1696582287; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UGH+M0fuvIFCi6QOwPCOQd0lXkYR3OEDHngCBdZqUDI=; b=NgWD7ydTpnqxoI43Y/n8aycaKyXWYZdoz4H+rYnWfC0WsrRwD/ZfCnxtXokXCWIdo+ imMimfCH808kc6/2fyJHk86nbBRVRTM2ILU6jEF9YJVOavjQAY/jGhMTHoDdOQMyyXko fCjv0Q3iauY1lb5qdHmi+lyl0DrxNFik8/le1ZS6k1cZG887zLdcZVgH0NS+VHCihIBU DOV6KYuiDO/AOmFAYmwP6s5Anwc9nW8xwtzLIZR8rvBwwPFltsjBxzqXSHj4XY2B6toX dnyv4jRuVlgqyufnz1zMFCoEhtCR1Tc6Dzx4NlSG5FDO2EgUpRnPkaAEguiWpITO7Nwg yfoA== X-Gm-Message-State: AOJu0YyNKbv+xLIqlk1QNI47OgP4UFAGtDQT2PaBVAvkbNSQl0tWGhh1 FdGVWcQ4ZIDEKx0lBOtJnZRjLgH26CDCVYw7l+vMRroSbtmSfZMdMDYXYWnPfL9aiPS+IrCvwlF vrONFTHVjNefQCJ/nUR1s/GnGtImmPq+TnuQQd8lQ0vZo171Z7pKTn1rBSC8QEJL7pioabVlfW4 U= X-Received: by 2002:a17:906:20ce:b0:9b2:b71f:83be with SMTP id c14-20020a17090620ce00b009b2b71f83bemr3589431ejc.1.1695977487112; Fri, 29 Sep 2023 01:51:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCkTBnNTGvBRxr8xZSrMnRzPKnRxsnjl3oOE6NXyy5bbXz3YLZVQX09l0Txl3FTuuttCx6aQ== X-Received: by 2002:a17:906:20ce:b0:9b2:b71f:83be with SMTP id c14-20020a17090620ce00b009b2b71f83bemr3589417ejc.1.1695977486772; Fri, 29 Sep 2023 01:51:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, balaton@eik.bme.hu Subject: [PATCH v3 06/14] audio: simplify flow in audio_init Date: Fri, 29 Sep 2023 10:50:59 +0200 Message-ID: <20230929085112.983957-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929085112.983957-1-pbonzini@redhat.com> References: <20230929085112.983957-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695977687022100003 Content-Type: text/plain; charset="utf-8" Merge two ifs into one. Signed-off-by: Paolo Bonzini --- audio/audio.c | 76 +++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 2014a2904e8..e3ca5fe65ec 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1707,12 +1707,12 @@ static AudiodevListEntry *audiodev_find( * if dev =3D=3D NULL =3D> legacy implicit initialization, return the alre= ady created * state or create a new one */ -static AudioState *audio_init(Audiodev *dev, const char *name) +static AudioState *audio_init(Audiodev *dev) { static bool atexit_registered; size_t i; int done =3D 0; - const char *drvname =3D NULL; + const char *drvname; VMChangeStateEntry *vmse; AudioState *s; struct audio_driver *driver; @@ -1736,17 +1736,32 @@ static AudioState *audio_init(Audiodev *dev, const = char *name) } } =20 + s =3D g_new0(AudioState, 1); + + QLIST_INIT (&s->hw_head_out); + QLIST_INIT (&s->hw_head_in); + QLIST_INIT (&s->cap_head); + if (!atexit_registered) { + atexit(audio_cleanup); + atexit_registered =3D true; + } + + s->ts =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s); + if (dev) { /* -audiodev option */ - legacy_config =3D false; + s->dev =3D dev; drvname =3D AudiodevDriver_str(dev->driver); - } else if (!QTAILQ_EMPTY(&audio_states)) { - if (!legacy_config) { - dolog("Device %s: audiodev default parameter is deprecated, pl= ease " - "specify audiodev=3D%s\n", name, - QTAILQ_FIRST(&audio_states)->dev->id); + driver =3D audio_driver_lookup(drvname); + if (driver) { + done =3D !audio_driver_init(s, driver, true, dev); + } else { + dolog ("Unknown audio driver `%s'\n", drvname); + } + if (!done) { + free_audio_state(s); + return NULL; } - return QTAILQ_FIRST(&audio_states); } else { /* legacy implicit initialization */ head =3D audio_handle_legacy_opts(); @@ -1759,33 +1774,7 @@ static AudioState *audio_init(Audiodev *dev, const c= har *name) */ dev =3D QSIMPLEQ_FIRST(&head)->dev; audio_validate_opts(dev, &error_abort); - } =20 - s =3D g_new0(AudioState, 1); - s->dev =3D dev; - - QLIST_INIT (&s->hw_head_out); - QLIST_INIT (&s->hw_head_in); - QLIST_INIT (&s->cap_head); - if (!atexit_registered) { - atexit(audio_cleanup); - atexit_registered =3D true; - } - - s->ts =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s); - - if (drvname) { - driver =3D audio_driver_lookup(drvname); - if (driver) { - done =3D !audio_driver_init(s, driver, true, dev); - } else { - dolog ("Unknown audio driver `%s'\n", drvname); - } - if (!done) { - free_audio_state(s); - return NULL; - } - } else { for (i =3D 0; audio_prio_list[i]; i++) { AudiodevListEntry *e =3D audiodev_find(&head, audio_prio_list[= i]); driver =3D audio_driver_lookup(audio_prio_list[i]); @@ -1800,8 +1789,9 @@ static AudioState *audio_init(Audiodev *dev, const ch= ar *name) } } } + + audio_free_audiodev_list(&head); } - audio_free_audiodev_list(&head); =20 if (!done) { driver =3D audio_driver_lookup("none"); @@ -1841,7 +1831,16 @@ void audio_free_audiodev_list(AudiodevListHead *head) void AUD_register_card (const char *name, QEMUSoundCard *card) { if (!card->state) { - card->state =3D audio_init(NULL, name); + if (!QTAILQ_EMPTY(&audio_states)) { + if (!legacy_config) { + dolog("Device %s: audiodev default parameter is deprecated= , please " + "specify audiodev=3D%s\n", name, + QTAILQ_FIRST(&audio_states)->dev->id); + } + card->state =3D QTAILQ_FIRST(&audio_states); + } else { + card->state =3D audio_init(NULL); + } } =20 card->name =3D g_strdup (name); @@ -2172,6 +2171,7 @@ void audio_define(Audiodev *dev) e =3D g_new0(AudiodevListEntry, 1); e->dev =3D dev; QSIMPLEQ_INSERT_TAIL(&audiodevs, e, next); + legacy_config =3D false; } =20 bool audio_init_audiodevs(void) @@ -2179,7 +2179,7 @@ bool audio_init_audiodevs(void) AudiodevListEntry *e; =20 QSIMPLEQ_FOREACH(e, &audiodevs, next) { - if (!audio_init(e->dev, NULL)) { + if (!audio_init(e->dev)) { return false; } } --=20 2.41.0 From nobody Fri May 17 10:44:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695977723; cv=none; d=zohomail.com; s=zohoarc; b=XW+3GTq46H3eFyphKkTXMfARpVGdmvVrHpDvdySOg9nucAzlrBXkMbZnX7L8A+KFsQZD8TC56s/DgqOi9v726wdC2T/3W33GMuSPxAyIVJJtSMGpKn5TmUC2oKzNbN6va5jqkXGwZPwNt/HQHh+KKKekRkc9h/sph7Hm+WWWaA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695977723; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WotoPOUV4DXC4On1WuAyhCRE6nYTRy0oVk8tT33JYIk=; b=MerY4acRuEmA5C/KV1Z8V+wyjKMW0iGQCdjAfl8ArxTqU2tLufixWKEWkG/QTlRCC/OZJvR+itmXUnoZS1/SKQDCafavAeep/QI4TdPgANSeT+MU1zdjNGd/S7PpZbkLHWFGXLekV4PEBYjgQFCMOwK6/8oJplsS119w1jkkyJU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695977723336553.5858155583802; Fri, 29 Sep 2023 01:55:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qm9EH-0006E7-QV; Fri, 29 Sep 2023 04:52:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qm9EC-0005pN-Gx for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:04 -0400 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 1qm9Di-0005m6-K7 for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:00 -0400 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-656-xO8DRIdMO4CQCUVwkBtYVw-1; Fri, 29 Sep 2023 04:51:32 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9a647551b7dso56796266b.1 for ; Fri, 29 Sep 2023 01:51:32 -0700 (PDT) Received: from [192.168.1.174] ([151.48.237.81]) by smtp.gmail.com with ESMTPSA id h21-20020a170906591500b0099bd0b5a2bcsm12059776ejq.101.2023.09.29.01.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 01:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695977493; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WotoPOUV4DXC4On1WuAyhCRE6nYTRy0oVk8tT33JYIk=; b=b6nqEwKJkDwo1oiJkAA9giEFUlpGcOTeLj/7nYVUyG3RNxyJg/OTa2faq27SwiI9Ftr/2L Zo6Zd4Y78m6c1vwf8weUvXj5/y2VLAB9z1LiiwXsGffApp+sd/BFzEkMSxASMyDvZrQh5U abMqrO1mv7JdVblyURdnqRb9tO27/uM= X-MC-Unique: xO8DRIdMO4CQCUVwkBtYVw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695977490; x=1696582290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WotoPOUV4DXC4On1WuAyhCRE6nYTRy0oVk8tT33JYIk=; b=hOkEp8pnp7zJQ9etKApDqj6saI0Js+oUalzXIbYoG0oQpWefQVkU8ZRmSxpwjVD/r/ cJKJN2fhNH5KXDJzsBi1pMZWA6aThqeXeHbTvljXLmHD+9adTI0offaLHSvdkCVIkgTP EFk3jnVnCGrmR4T4TtSNCgFghJ6U+WBWtc7VrnO3xDTlZkqr6CtXSq1Wose+5Uf+Kllq LQ+/7fKUNMllIHcsN/9jwtBEo3QCuYYvjqUjo42PBfvDQHxvy1buSgagAHEO+8OJ9t1h Uuw4s6PQgAgILkGQwjAD+EtRME7r17Vvz5Kj2QhNdaDIjWigfvW2wYFUyl33crn/t/XS ZlQA== X-Gm-Message-State: AOJu0YxzzZWgIbuebT3rlkmFMWW9WFHG4D/8a9r+iOkG1YIcGZNsuUNj 8JfoBFi7EiAEENYBnJFM+G4sCUei/r4vQcGBkWLEtSfgquvUJOELjlbQffQILSzcJ/0zuH9YN/7 2JBs0NzhSgYbYfoZai3d6tT33VBcd00URw/5LvnQw89cw2ct625QJikas40z4XzmeHCzTUDt21u A= X-Received: by 2002:a17:907:1c09:b0:9a9:405b:26d1 with SMTP id nc9-20020a1709071c0900b009a9405b26d1mr3318457ejc.5.1695977489983; Fri, 29 Sep 2023 01:51:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMgg89eIFEtOkEpMr26oMm4q0/L9K5d2RUDe2nTkJ8UjhI9gHpDaZmJ/su4lHsQVXhJptXmQ== X-Received: by 2002:a17:907:1c09:b0:9a9:405b:26d1 with SMTP id nc9-20020a1709071c0900b009a9405b26d1mr3318419ejc.5.1695977489134; Fri, 29 Sep 2023 01:51:29 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, balaton@eik.bme.hu Subject: [PATCH v3 07/14] audio: remove QEMU_AUDIO_* and -audio-help support Date: Fri, 29 Sep 2023 10:51:00 +0200 Message-ID: <20230929085112.983957-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929085112.983957-1-pbonzini@redhat.com> References: <20230929085112.983957-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695977725555100001 These have been deprecated for a long time, and the introduction of -audio in 7.1.0 has cemented the new way of specifying an audio backend's parameters. However, there is still a need for simple configuration of the audio backend in the desktop case; therefore, if no audiodev is passed to audio_init(), go through a bunch of simple Audiodev* structures and pick the first that can be initialized successfully. The only QEMU_AUDIO_* option that is left in, waiting for a better idea, is QEMU_AUDIO_DRV=3Dnone which is used by qtest. Remove all the parsing code, including the concept of "can_be_default" audio drivers: now that audio_prio_list[] is only used in a single place, wav can be excluded directly in that function. Signed-off-by: Paolo Bonzini --- audio/alsaaudio.c | 1 - audio/audio.c | 131 +++---- audio/audio.h | 1 - audio/audio_int.h | 5 - audio/audio_legacy.c | 591 -------------------------------- audio/coreaudio.m | 1 - audio/dbusaudio.c | 1 - audio/dsoundaudio.c | 1 - audio/jackaudio.c | 1 - audio/meson.build | 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/wavaudio.c | 1 - docs/about/deprecated.rst | 8 - docs/about/removed-features.rst | 6 + qemu-options.hx | 10 - softmmu/vl.c | 4 - 21 files changed, 60 insertions(+), 709 deletions(-) delete mode 100644 audio/audio_legacy.c diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 6fb78e5b972..cacae1ea59c 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -960,7 +960,6 @@ static struct audio_driver alsa_audio_driver =3D { .init =3D alsa_audio_init, .fini =3D alsa_audio_fini, .pcm_ops =3D &alsa_pcm_ops, - .can_be_default =3D 1, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, .voice_size_out =3D sizeof (ALSAVoiceOut), diff --git a/audio/audio.c b/audio/audio.c index e3ca5fe65ec..9da2eaece03 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -32,6 +32,7 @@ #include "qapi/qobject-input-visitor.h" #include "qapi/qapi-visit-audio.h" #include "qapi/qapi-commands-audio.h" +#include "qapi/qmp/qdict.h" #include "qemu/cutils.h" #include "qemu/error-report.h" #include "qemu/log.h" @@ -62,19 +63,22 @@ const char *audio_prio_list[] =3D { "spice", CONFIG_AUDIO_DRIVERS "none", - "wav", NULL }; =20 static QLIST_HEAD(, audio_driver) audio_drivers; -static AudiodevListHead audiodevs =3D QSIMPLEQ_HEAD_INITIALIZER(audiodevs); +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); } =20 -audio_driver *audio_driver_lookup(const char *name) +static audio_driver *audio_driver_lookup(const char *name) { struct audio_driver *d; Error *local_err =3D NULL; @@ -112,8 +116,6 @@ const struct mixeng_volume nominal_volume =3D { #endif }; =20 -static bool legacy_config =3D true; - int audio_bug (const char *funcname, int cond) { if (cond) { @@ -1688,17 +1690,41 @@ static const VMStateDescription vmstate_audio =3D { =20 static void audio_validate_opts(Audiodev *dev, Error **errp); =20 -static AudiodevListEntry *audiodev_find( - AudiodevListHead *head, const char *drvname) +static void audio_create_default_audiodevs(void) { - AudiodevListEntry *e; - QSIMPLEQ_FOREACH(e, head, next) { - if (strcmp(AudiodevDriver_str(e->dev->driver), drvname) =3D=3D 0) { - return e; - } + const char *drvname =3D getenv("QEMU_AUDIO_DRV"); + + /* QEMU_AUDIO_DRV=3Dnone is used by libqtest. */ + if (drvname && !g_str_equal(drvname, "none")) { + error_report("Please use -audiodev instead of QEMU_AUDIO_*"); + exit(1); } =20 - return NULL; + for (int i =3D 0; audio_prio_list[i]; i++) { + if (drvname && !g_str_equal(drvname, audio_prio_list[i])) { + continue; + } + + if (audio_driver_lookup(audio_prio_list[i])) { + QDict *dict =3D qdict_new(); + Audiodev *dev =3D NULL; + AudiodevListEntry *e; + Visitor *v; + + qdict_put_str(dict, "driver", audio_prio_list[i]); + qdict_put_str(dict, "id", "#default"); + + v =3D qobject_input_visitor_new_keyval(QOBJECT(dict)); + qobject_unref(dict); + visit_type_Audiodev(v, NULL, &dev, &error_fatal); + visit_free(v); + + audio_validate_opts(dev, &error_abort); + e =3D g_new0(AudiodevListEntry, 1); + e->dev =3D dev; + QSIMPLEQ_INSERT_TAIL(&default_audiodevs, e, next); + } + } } =20 /* @@ -1710,31 +1736,11 @@ static AudiodevListEntry *audiodev_find( static AudioState *audio_init(Audiodev *dev) { static bool atexit_registered; - size_t i; int done =3D 0; const char *drvname; VMChangeStateEntry *vmse; AudioState *s; struct audio_driver *driver; - /* silence gcc warning about uninitialized variable */ - AudiodevListHead head =3D QSIMPLEQ_HEAD_INITIALIZER(head); - - if (using_spice) { - /* - * When using spice allow the spice audio driver being picked - * as default. - * - * Temporary hack. Using audio devices without explicit - * audiodev=3D property is already deprecated. Same goes for - * the -soundhw switch. Once this support gets finally - * removed we can also drop the concept of a default audio - * backend and this can go away. - */ - driver =3D audio_driver_lookup("spice"); - if (driver) { - driver->can_be_default =3D 1; - } - } =20 s =3D g_new0(AudioState, 1); =20 @@ -1763,41 +1769,20 @@ static AudioState *audio_init(Audiodev *dev) return NULL; } } else { - /* legacy implicit initialization */ - head =3D audio_handle_legacy_opts(); - /* - * In case of legacy initialization, all Audiodevs in the list wil= l have - * the same configuration (except the driver), so it doesn't matte= r which - * one we chose. We need an Audiodev to set up AudioState before = we can - * init a driver. Also note that dev at this point is still in the - * list. - */ - dev =3D QSIMPLEQ_FIRST(&head)->dev; - audio_validate_opts(dev, &error_abort); - - for (i =3D 0; audio_prio_list[i]; i++) { - AudiodevListEntry *e =3D audiodev_find(&head, audio_prio_list[= i]); - driver =3D audio_driver_lookup(audio_prio_list[i]); - - if (e && driver) { - s->dev =3D dev =3D e->dev; - audio_validate_opts(dev, &error_abort); - done =3D !audio_driver_init(s, driver, false, dev); - if (done) { - e->dev =3D NULL; - break; - } + for (;;) { + AudiodevListEntry *e =3D QSIMPLEQ_FIRST(&default_audiodevs); + if (!e) { + dolog("Internal error: no default audio driver available\n= "); + exit(1); } + s->dev =3D dev =3D e->dev; + drvname =3D AudiodevDriver_str(dev->driver); + driver =3D audio_driver_lookup(drvname); + if (!audio_driver_init(s, driver, false, dev)) { + break; + } + QSIMPLEQ_REMOVE_HEAD(&default_audiodevs, next); } - - audio_free_audiodev_list(&head); - } - - if (!done) { - driver =3D audio_driver_lookup("none"); - done =3D !audio_driver_init(s, driver, false, dev); - assert(done); - dolog("warning: Using timer based audio emulation\n"); } =20 if (dev->timer_period <=3D 0) { @@ -1818,16 +1803,6 @@ static AudioState *audio_init(Audiodev *dev) return s; } =20 -void audio_free_audiodev_list(AudiodevListHead *head) -{ - AudiodevListEntry *e; - while ((e =3D QSIMPLEQ_FIRST(head))) { - QSIMPLEQ_REMOVE_HEAD(head, next); - qapi_free_Audiodev(e->dev); - g_free(e); - } -} - void AUD_register_card (const char *name, QEMUSoundCard *card) { if (!card->state) { @@ -1839,6 +1814,9 @@ void AUD_register_card (const char *name, QEMUSoundCa= rd *card) } card->state =3D QTAILQ_FIRST(&audio_states); } else { + if (QSIMPLEQ_EMPTY(&default_audiodevs)) { + audio_create_default_audiodevs(); + } card->state =3D audio_init(NULL); } } @@ -2171,7 +2149,6 @@ void audio_define(Audiodev *dev) e =3D g_new0(AudiodevListEntry, 1); e->dev =3D dev; QSIMPLEQ_INSERT_TAIL(&audiodevs, e, next); - legacy_config =3D false; } =20 bool audio_init_audiodevs(void) diff --git a/audio/audio.h b/audio/audio.h index e0c13b5dcdf..34df8962a66 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -172,7 +172,6 @@ void audio_define(Audiodev *audio); void audio_parse_option(const char *opt); bool audio_init_audiodevs(void); void audio_help(void); -void audio_legacy_help(void); =20 AudioState *audio_state_by_name(const char *name, Error **errp); const char *audio_get_id(QEMUSoundCard *card); diff --git a/audio/audio_int.h b/audio/audio_int.h index 06e815de9f6..2d079d00a25 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -146,7 +146,6 @@ struct audio_driver { void (*set_dbus_server) (AudioState *s, GDBusObjectManagerServer *mana= ger, bool p2p); #endif struct audio_pcm_ops *pcm_ops; - int can_be_default; int max_voices_out; int max_voices_in; size_t voice_size_out; @@ -243,7 +242,6 @@ extern const struct mixeng_volume nominal_volume; extern const char *audio_prio_list[]; =20 void audio_driver_register(audio_driver *drv); -audio_driver *audio_driver_lookup(const char *name); =20 void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings = *as); void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int= len); @@ -297,9 +295,6 @@ typedef struct AudiodevListEntry { } AudiodevListEntry; =20 typedef QSIMPLEQ_HEAD(, AudiodevListEntry) AudiodevListHead; -AudiodevListHead audio_handle_legacy_opts(void); - -void audio_free_audiodev_list(AudiodevListHead *head); =20 void audio_create_pdos(Audiodev *dev); AudiodevPerDirectionOptions *audio_get_pdo_in(Audiodev *dev); diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c deleted file mode 100644 index dc72ba55e9a..00000000000 --- a/audio/audio_legacy.c +++ /dev/null @@ -1,591 +0,0 @@ -/* - * QEMU Audio subsystem: legacy configuration handling - * - * Copyright (c) 2015-2019 Zolt=C3=A1n K=C5=91v=C3=A1g=C3=B3 - * - * 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 "audio.h" -#include "audio_int.h" -#include "qemu/cutils.h" -#include "qemu/timer.h" -#include "qapi/error.h" -#include "qapi/qapi-visit-audio.h" -#include "qapi/visitor-impl.h" - -#define AUDIO_CAP "audio-legacy" -#include "audio_int.h" - -static uint32_t toui32(const char *str) -{ - uint64_t ret; - if (parse_uint_full(str, 10, &ret) || ret > UINT32_MAX) { - dolog("Invalid integer value `%s'\n", str); - exit(1); - } - return ret; -} - -/* helper functions to convert env variables */ -static void get_bool(const char *env, bool *dst, bool *has_dst) -{ - const char *val =3D getenv(env); - if (val) { - *dst =3D toui32(val) !=3D 0; - *has_dst =3D true; - } -} - -static void get_int(const char *env, uint32_t *dst, bool *has_dst) -{ - const char *val =3D getenv(env); - if (val) { - *dst =3D toui32(val); - *has_dst =3D true; - } -} - -static void get_str(const char *env, char **dst) -{ - const char *val =3D getenv(env); - if (val) { - g_free(*dst); - *dst =3D g_strdup(val); - } -} - -static void get_fmt(const char *env, AudioFormat *dst, bool *has_dst) -{ - const char *val =3D getenv(env); - if (val) { - size_t i; - for (i =3D 0; AudioFormat_lookup.size; ++i) { - if (strcasecmp(val, AudioFormat_lookup.array[i]) =3D=3D 0) { - *dst =3D i; - *has_dst =3D true; - return; - } - } - - dolog("Invalid audio format `%s'\n", val); - exit(1); - } -} - - -#if defined(CONFIG_AUDIO_ALSA) || defined(CONFIG_AUDIO_DSOUND) -static void get_millis_to_usecs(const char *env, uint32_t *dst, bool *has_= dst) -{ - const char *val =3D getenv(env); - if (val) { - *dst =3D toui32(val) * 1000; - *has_dst =3D true; - } -} -#endif - -#if defined(CONFIG_AUDIO_ALSA) || defined(CONFIG_AUDIO_COREAUDIO) || \ - defined(CONFIG_AUDIO_PA) || defined(CONFIG_AUDIO_SDL) || \ - defined(CONFIG_AUDIO_DSOUND) || defined(CONFIG_AUDIO_OSS) -static uint32_t frames_to_usecs(uint32_t frames, - AudiodevPerDirectionOptions *pdo) -{ - uint32_t freq =3D pdo->has_frequency ? pdo->frequency : 44100; - return (frames * 1000000 + freq / 2) / freq; -} -#endif - -#ifdef CONFIG_AUDIO_COREAUDIO -static void get_frames_to_usecs(const char *env, uint32_t *dst, bool *has_= dst, - AudiodevPerDirectionOptions *pdo) -{ - const char *val =3D getenv(env); - if (val) { - *dst =3D frames_to_usecs(toui32(val), pdo); - *has_dst =3D true; - } -} -#endif - -#if defined(CONFIG_AUDIO_PA) || defined(CONFIG_AUDIO_SDL) || \ - defined(CONFIG_AUDIO_DSOUND) || defined(CONFIG_AUDIO_OSS) -static uint32_t samples_to_usecs(uint32_t samples, - AudiodevPerDirectionOptions *pdo) -{ - uint32_t channels =3D pdo->has_channels ? pdo->channels : 2; - return frames_to_usecs(samples / channels, pdo); -} -#endif - -#if defined(CONFIG_AUDIO_PA) || defined(CONFIG_AUDIO_SDL) -static void get_samples_to_usecs(const char *env, uint32_t *dst, bool *has= _dst, - AudiodevPerDirectionOptions *pdo) -{ - const char *val =3D getenv(env); - if (val) { - *dst =3D samples_to_usecs(toui32(val), pdo); - *has_dst =3D true; - } -} -#endif - -#if defined(CONFIG_AUDIO_DSOUND) || defined(CONFIG_AUDIO_OSS) -static uint32_t bytes_to_usecs(uint32_t bytes, AudiodevPerDirectionOptions= *pdo) -{ - AudioFormat fmt =3D pdo->has_format ? pdo->format : AUDIO_FORMAT_S16; - uint32_t bytes_per_sample =3D audioformat_bytes_per_sample(fmt); - return samples_to_usecs(bytes / bytes_per_sample, pdo); -} - -static void get_bytes_to_usecs(const char *env, uint32_t *dst, bool *has_d= st, - AudiodevPerDirectionOptions *pdo) -{ - const char *val =3D getenv(env); - if (val) { - *dst =3D bytes_to_usecs(toui32(val), pdo); - *has_dst =3D true; - } -} -#endif - -/* backend specific functions */ - -#ifdef CONFIG_AUDIO_ALSA -/* ALSA */ -static void handle_alsa_per_direction( - AudiodevAlsaPerDirectionOptions *apdo, const char *prefix) -{ - char buf[64]; - size_t len =3D strlen(prefix); - bool size_in_usecs =3D false; - bool dummy; - - memcpy(buf, prefix, len); - strcpy(buf + len, "TRY_POLL"); - get_bool(buf, &apdo->try_poll, &apdo->has_try_poll); - - strcpy(buf + len, "DEV"); - get_str(buf, &apdo->dev); - - strcpy(buf + len, "SIZE_IN_USEC"); - get_bool(buf, &size_in_usecs, &dummy); - - strcpy(buf + len, "PERIOD_SIZE"); - get_int(buf, &apdo->period_length, &apdo->has_period_length); - if (apdo->has_period_length && !size_in_usecs) { - apdo->period_length =3D frames_to_usecs( - apdo->period_length, - qapi_AudiodevAlsaPerDirectionOptions_base(apdo)); - } - - strcpy(buf + len, "BUFFER_SIZE"); - get_int(buf, &apdo->buffer_length, &apdo->has_buffer_length); - if (apdo->has_buffer_length && !size_in_usecs) { - apdo->buffer_length =3D frames_to_usecs( - apdo->buffer_length, - qapi_AudiodevAlsaPerDirectionOptions_base(apdo)); - } -} - -static void handle_alsa(Audiodev *dev) -{ - AudiodevAlsaOptions *aopt =3D &dev->u.alsa; - handle_alsa_per_direction(aopt->in, "QEMU_ALSA_ADC_"); - handle_alsa_per_direction(aopt->out, "QEMU_ALSA_DAC_"); - - get_millis_to_usecs("QEMU_ALSA_THRESHOLD", - &aopt->threshold, &aopt->has_threshold); -} -#endif - -#ifdef CONFIG_AUDIO_COREAUDIO -/* coreaudio */ -static void handle_coreaudio(Audiodev *dev) -{ - get_frames_to_usecs( - "QEMU_COREAUDIO_BUFFER_SIZE", - &dev->u.coreaudio.out->buffer_length, - &dev->u.coreaudio.out->has_buffer_length, - qapi_AudiodevCoreaudioPerDirectionOptions_base(dev->u.coreaudio.ou= t)); - get_int("QEMU_COREAUDIO_BUFFER_COUNT", - &dev->u.coreaudio.out->buffer_count, - &dev->u.coreaudio.out->has_buffer_count); -} -#endif - -#ifdef CONFIG_AUDIO_DSOUND -/* dsound */ -static void handle_dsound(Audiodev *dev) -{ - get_millis_to_usecs("QEMU_DSOUND_LATENCY_MILLIS", - &dev->u.dsound.latency, &dev->u.dsound.has_latency= ); - get_bytes_to_usecs("QEMU_DSOUND_BUFSIZE_OUT", - &dev->u.dsound.out->buffer_length, - &dev->u.dsound.out->has_buffer_length, - dev->u.dsound.out); - get_bytes_to_usecs("QEMU_DSOUND_BUFSIZE_IN", - &dev->u.dsound.in->buffer_length, - &dev->u.dsound.in->has_buffer_length, - dev->u.dsound.in); -} -#endif - -#ifdef CONFIG_AUDIO_OSS -/* OSS */ -static void handle_oss_per_direction( - AudiodevOssPerDirectionOptions *opdo, const char *try_poll_env, - const char *dev_env) -{ - get_bool(try_poll_env, &opdo->try_poll, &opdo->has_try_poll); - get_str(dev_env, &opdo->dev); - - get_bytes_to_usecs("QEMU_OSS_FRAGSIZE", - &opdo->buffer_length, &opdo->has_buffer_length, - qapi_AudiodevOssPerDirectionOptions_base(opdo)); - get_int("QEMU_OSS_NFRAGS", &opdo->buffer_count, - &opdo->has_buffer_count); -} - -static void handle_oss(Audiodev *dev) -{ - AudiodevOssOptions *oopt =3D &dev->u.oss; - handle_oss_per_direction(oopt->in, "QEMU_AUDIO_ADC_TRY_POLL", - "QEMU_OSS_ADC_DEV"); - handle_oss_per_direction(oopt->out, "QEMU_AUDIO_DAC_TRY_POLL", - "QEMU_OSS_DAC_DEV"); - - get_bool("QEMU_OSS_MMAP", &oopt->try_mmap, &oopt->has_try_mmap); - get_bool("QEMU_OSS_EXCLUSIVE", &oopt->exclusive, &oopt->has_exclusive); - get_int("QEMU_OSS_POLICY", &oopt->dsp_policy, &oopt->has_dsp_policy); -} -#endif - -#ifdef CONFIG_AUDIO_PA -/* pulseaudio */ -static void handle_pa_per_direction( - AudiodevPaPerDirectionOptions *ppdo, const char *env) -{ - get_str(env, &ppdo->name); -} - -static void handle_pa(Audiodev *dev) -{ - handle_pa_per_direction(dev->u.pa.in, "QEMU_PA_SOURCE"); - handle_pa_per_direction(dev->u.pa.out, "QEMU_PA_SINK"); - - get_samples_to_usecs( - "QEMU_PA_SAMPLES", &dev->u.pa.in->buffer_length, - &dev->u.pa.in->has_buffer_length, - qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.in)); - get_samples_to_usecs( - "QEMU_PA_SAMPLES", &dev->u.pa.out->buffer_length, - &dev->u.pa.out->has_buffer_length, - qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.out)); - - get_str("QEMU_PA_SERVER", &dev->u.pa.server); -} -#endif - -#ifdef CONFIG_AUDIO_SDL -/* SDL */ -static void handle_sdl(Audiodev *dev) -{ - /* SDL is output only */ - get_samples_to_usecs("QEMU_SDL_SAMPLES", &dev->u.sdl.out->buffer_lengt= h, - &dev->u.sdl.out->has_buffer_length, - qapi_AudiodevSdlPerDirectionOptions_base(dev->u.sdl.out)); -} -#endif - -/* wav */ -static void handle_wav(Audiodev *dev) -{ - get_int("QEMU_WAV_FREQUENCY", - &dev->u.wav.out->frequency, &dev->u.wav.out->has_frequency); - get_fmt("QEMU_WAV_FORMAT", &dev->u.wav.out->format, - &dev->u.wav.out->has_format); - get_int("QEMU_WAV_DAC_FIXED_CHANNELS", - &dev->u.wav.out->channels, &dev->u.wav.out->has_channels); - get_str("QEMU_WAV_PATH", &dev->u.wav.path); -} - -/* general */ -static void handle_per_direction( - AudiodevPerDirectionOptions *pdo, const char *prefix) -{ - char buf[64]; - size_t len =3D strlen(prefix); - - memcpy(buf, prefix, len); - strcpy(buf + len, "FIXED_SETTINGS"); - get_bool(buf, &pdo->fixed_settings, &pdo->has_fixed_settings); - - strcpy(buf + len, "FIXED_FREQ"); - get_int(buf, &pdo->frequency, &pdo->has_frequency); - - strcpy(buf + len, "FIXED_FMT"); - get_fmt(buf, &pdo->format, &pdo->has_format); - - strcpy(buf + len, "FIXED_CHANNELS"); - get_int(buf, &pdo->channels, &pdo->has_channels); - - strcpy(buf + len, "VOICES"); - get_int(buf, &pdo->voices, &pdo->has_voices); -} - -static AudiodevListEntry *legacy_opt(const char *drvname) -{ - AudiodevListEntry *e =3D g_new0(AudiodevListEntry, 1); - e->dev =3D g_new0(Audiodev, 1); - e->dev->id =3D g_strdup(drvname); - e->dev->driver =3D qapi_enum_parse( - &AudiodevDriver_lookup, drvname, -1, &error_abort); - - audio_create_pdos(e->dev); - - handle_per_direction(audio_get_pdo_in(e->dev), "QEMU_AUDIO_ADC_"); - handle_per_direction(audio_get_pdo_out(e->dev), "QEMU_AUDIO_DAC_"); - - /* Original description: Timer period in HZ (0 - use lowest possible) = */ - get_int("QEMU_AUDIO_TIMER_PERIOD", - &e->dev->timer_period, &e->dev->has_timer_period); - if (e->dev->has_timer_period && e->dev->timer_period) { - e->dev->timer_period =3D NANOSECONDS_PER_SECOND / 1000 / - e->dev->timer_period; - } - - switch (e->dev->driver) { -#ifdef CONFIG_AUDIO_ALSA - case AUDIODEV_DRIVER_ALSA: - handle_alsa(e->dev); - break; -#endif - -#ifdef CONFIG_AUDIO_COREAUDIO - case AUDIODEV_DRIVER_COREAUDIO: - handle_coreaudio(e->dev); - break; -#endif - -#ifdef CONFIG_AUDIO_DSOUND - case AUDIODEV_DRIVER_DSOUND: - handle_dsound(e->dev); - break; -#endif - -#ifdef CONFIG_AUDIO_OSS - case AUDIODEV_DRIVER_OSS: - handle_oss(e->dev); - break; -#endif - -#ifdef CONFIG_AUDIO_PA - case AUDIODEV_DRIVER_PA: - handle_pa(e->dev); - break; -#endif - -#ifdef CONFIG_AUDIO_SDL - case AUDIODEV_DRIVER_SDL: - handle_sdl(e->dev); - break; -#endif - - case AUDIODEV_DRIVER_WAV: - handle_wav(e->dev); - break; - - default: - break; - } - - return e; -} - -AudiodevListHead audio_handle_legacy_opts(void) -{ - const char *drvname =3D getenv("QEMU_AUDIO_DRV"); - AudiodevListHead head =3D QSIMPLEQ_HEAD_INITIALIZER(head); - - if (drvname) { - AudiodevListEntry *e; - audio_driver *driver =3D audio_driver_lookup(drvname); - if (!driver) { - dolog("Unknown audio driver `%s'\n", drvname); - exit(1); - } - e =3D legacy_opt(drvname); - QSIMPLEQ_INSERT_TAIL(&head, e, next); - } else { - for (int i =3D 0; audio_prio_list[i]; i++) { - audio_driver *driver =3D audio_driver_lookup(audio_prio_list[i= ]); - if (driver && driver->can_be_default) { - AudiodevListEntry *e =3D legacy_opt(driver->name); - QSIMPLEQ_INSERT_TAIL(&head, e, next); - } - } - if (QSIMPLEQ_EMPTY(&head)) { - dolog("Internal error: no default audio driver available\n"); - exit(1); - } - } - - return head; -} - -/* visitor to print -audiodev option */ -typedef struct { - Visitor visitor; - - bool comma; - GList *path; -} LegacyPrintVisitor; - -static bool lv_start_struct(Visitor *v, const char *name, void **obj, - size_t size, Error **errp) -{ - LegacyPrintVisitor *lv =3D (LegacyPrintVisitor *) v; - lv->path =3D g_list_append(lv->path, g_strdup(name)); - return true; -} - -static void lv_end_struct(Visitor *v, void **obj) -{ - LegacyPrintVisitor *lv =3D (LegacyPrintVisitor *) v; - lv->path =3D g_list_delete_link(lv->path, g_list_last(lv->path)); -} - -static void lv_print_key(Visitor *v, const char *name) -{ - GList *e; - LegacyPrintVisitor *lv =3D (LegacyPrintVisitor *) v; - if (lv->comma) { - putchar(','); - } else { - lv->comma =3D true; - } - - for (e =3D lv->path; e; e =3D e->next) { - if (e->data) { - printf("%s.", (const char *) e->data); - } - } - - printf("%s=3D", name); -} - -static bool lv_type_int64(Visitor *v, const char *name, int64_t *obj, - Error **errp) -{ - lv_print_key(v, name); - printf("%" PRIi64, *obj); - return true; -} - -static bool lv_type_uint64(Visitor *v, const char *name, uint64_t *obj, - Error **errp) -{ - lv_print_key(v, name); - printf("%" PRIu64, *obj); - return true; -} - -static bool lv_type_bool(Visitor *v, const char *name, bool *obj, Error **= errp) -{ - lv_print_key(v, name); - printf("%s", *obj ? "on" : "off"); - return true; -} - -static bool lv_type_str(Visitor *v, const char *name, char **obj, Error **= errp) -{ - const char *str =3D *obj; - lv_print_key(v, name); - - while (*str) { - if (*str =3D=3D ',') { - putchar(','); - } - putchar(*str++); - } - return true; -} - -static void lv_complete(Visitor *v, void *opaque) -{ - LegacyPrintVisitor *lv =3D (LegacyPrintVisitor *) v; - assert(lv->path =3D=3D NULL); -} - -static void lv_free(Visitor *v) -{ - LegacyPrintVisitor *lv =3D (LegacyPrintVisitor *) v; - - g_list_free_full(lv->path, g_free); - g_free(lv); -} - -static Visitor *legacy_visitor_new(void) -{ - LegacyPrintVisitor *lv =3D g_new0(LegacyPrintVisitor, 1); - - lv->visitor.start_struct =3D lv_start_struct; - lv->visitor.end_struct =3D lv_end_struct; - /* lists not supported */ - lv->visitor.type_int64 =3D lv_type_int64; - lv->visitor.type_uint64 =3D lv_type_uint64; - lv->visitor.type_bool =3D lv_type_bool; - lv->visitor.type_str =3D lv_type_str; - - lv->visitor.type =3D VISITOR_OUTPUT; - lv->visitor.complete =3D lv_complete; - lv->visitor.free =3D lv_free; - - return &lv->visitor; -} - -void audio_legacy_help(void) -{ - AudiodevListHead head; - AudiodevListEntry *e; - - printf("Environment variable based configuration deprecated.\n"); - printf("Please use the new -audiodev option.\n"); - - head =3D audio_handle_legacy_opts(); - printf("\nEquivalent -audiodev to your current environment variables:\= n"); - if (!getenv("QEMU_AUDIO_DRV")) { - printf("(Since you didn't specify QEMU_AUDIO_DRV, I'll list all " - "possibilities)\n"); - } - - QSIMPLEQ_FOREACH(e, &head, next) { - Visitor *v; - Audiodev *dev =3D e->dev; - printf("-audiodev "); - - v =3D legacy_visitor_new(); - visit_type_Audiodev(v, NULL, &dev, &error_abort); - visit_free(v); - - printf("\n"); - } - audio_free_audiodev_list(&head); -} diff --git a/audio/coreaudio.m b/audio/coreaudio.m index 7cfb38fb6ae..8cd129a27d0 100644 --- a/audio/coreaudio.m +++ b/audio/coreaudio.m @@ -673,7 +673,6 @@ static void coreaudio_audio_fini (void *opaque) .init =3D coreaudio_audio_init, .fini =3D coreaudio_audio_fini, .pcm_ops =3D &coreaudio_pcm_ops, - .can_be_default =3D 1, .max_voices_out =3D 1, .max_voices_in =3D 0, .voice_size_out =3D sizeof (coreaudioVoiceOut), diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index 310ca997ff4..60fcf643ecf 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -676,7 +676,6 @@ static struct audio_driver dbus_audio_driver =3D { .fini =3D dbus_audio_fini, .set_dbus_server =3D dbus_audio_set_server, .pcm_ops =3D &dbus_pcm_ops, - .can_be_default =3D 1, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, .voice_size_out =3D sizeof(DBusVoiceOut), diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index eefde88edcb..f3bb48d0073 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -721,7 +721,6 @@ static struct audio_driver dsound_audio_driver =3D { .init =3D dsound_audio_init, .fini =3D dsound_audio_fini, .pcm_ops =3D &dsound_pcm_ops, - .can_be_default =3D 1, .max_voices_out =3D INT_MAX, .max_voices_in =3D 1, .voice_size_out =3D sizeof (DSoundVoiceOut), diff --git a/audio/jackaudio.c b/audio/jackaudio.c index 823e7d96bae..974a3caad34 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -676,7 +676,6 @@ static struct audio_driver jack_driver =3D { .init =3D qjack_init, .fini =3D qjack_fini, .pcm_ops =3D &jack_pcm_ops, - .can_be_default =3D 1, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, .voice_size_out =3D sizeof(QJackOut), diff --git a/audio/meson.build b/audio/meson.build index df4d968c0fe..c8f658611f4 100644 --- a/audio/meson.build +++ b/audio/meson.build @@ -1,7 +1,6 @@ system_ss.add([spice_headers, files('audio.c')]) system_ss.add(files( 'audio-hmp-cmds.c', - 'audio_legacy.c', 'mixeng.c', 'noaudio.c', 'wavaudio.c', diff --git a/audio/noaudio.c b/audio/noaudio.c index a36bfeffd14..1b60d8518a4 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -135,7 +135,6 @@ static struct audio_driver no_audio_driver =3D { .init =3D no_audio_init, .fini =3D no_audio_fini, .pcm_ops =3D &no_pcm_ops, - .can_be_default =3D 1, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, .voice_size_out =3D sizeof (NoVoiceOut), diff --git a/audio/ossaudio.c b/audio/ossaudio.c index ec4448d573d..3f31852371d 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -784,7 +784,6 @@ static struct audio_driver oss_audio_driver =3D { .init =3D oss_audio_init, .fini =3D oss_audio_fini, .pcm_ops =3D &oss_pcm_ops, - .can_be_default =3D 1, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, .voice_size_out =3D sizeof (OSSVoiceOut), diff --git a/audio/paaudio.c b/audio/paaudio.c index 39bd6cfa38a..f3193b08c32 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -931,7 +931,6 @@ static struct audio_driver pa_audio_driver =3D { .init =3D qpa_audio_init, .fini =3D qpa_audio_fini, .pcm_ops =3D &qpa_pcm_ops, - .can_be_default =3D 1, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, .voice_size_out =3D sizeof (PAVoiceOut), diff --git a/audio/pwaudio.c b/audio/pwaudio.c index 1020cb11df1..3ce5f6507b4 100644 --- a/audio/pwaudio.c +++ b/audio/pwaudio.c @@ -843,7 +843,6 @@ static struct audio_driver pw_audio_driver =3D { .init =3D qpw_audio_init, .fini =3D qpw_audio_fini, .pcm_ops =3D &qpw_pcm_ops, - .can_be_default =3D 1, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, .voice_size_out =3D sizeof(PWVoiceOut), diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 4d8473d9ece..641357e5ee3 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -494,7 +494,6 @@ static struct audio_driver sdl_audio_driver =3D { .init =3D sdl_audio_init, .fini =3D sdl_audio_fini, .pcm_ops =3D &sdl_pcm_ops, - .can_be_default =3D 1, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, .voice_size_out =3D sizeof(SDLVoiceOut), diff --git a/audio/sndioaudio.c b/audio/sndioaudio.c index 1e35925a497..8eb35e1e538 100644 --- a/audio/sndioaudio.c +++ b/audio/sndioaudio.c @@ -550,7 +550,6 @@ static struct audio_driver sndio_audio_driver =3D { .init =3D sndio_audio_init, .fini =3D sndio_audio_fini, .pcm_ops =3D &sndio_pcm_ops, - .can_be_default =3D 1, .max_voices_out =3D INT_MAX, .max_voices_in =3D INT_MAX, .voice_size_out =3D sizeof(SndioVoice), diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 26b03906d59..ea20fed0ccb 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -208,7 +208,6 @@ static struct audio_driver wav_audio_driver =3D { .init =3D wav_audio_init, .fini =3D wav_audio_fini, .pcm_ops =3D &wav_pcm_ops, - .can_be_default =3D 0, .max_voices_out =3D 1, .max_voices_in =3D 0, .voice_size_out =3D sizeof (WAVVoiceOut), diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index c07bf58dde1..2f51cf770ae 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -37,14 +37,6 @@ coverage. System emulator command line arguments -------------------------------------- =20 -``QEMU_AUDIO_`` environment variables and ``-audio-help`` (since 4.0) -''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - -The ``-audiodev`` argument is now the preferred way to specify audio -backend settings instead of environment variables. To ease migration to -the new format, the ``-audiodev-help`` option can be used to convert -the current values of the environment variables to ``-audiodev`` options. - Creating sound card devices without ``audiodev=3D`` property (since 4.2) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' =20 diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.= rst index 276060b320c..e83ed087f6b 100644 --- a/docs/about/removed-features.rst +++ b/docs/about/removed-features.rst @@ -436,6 +436,12 @@ the process listing. This was replaced by the new ``pa= ssword-secret`` option which lets the password be securely provided on the command line using a ``secret`` object instance. =20 +``QEMU_AUDIO_`` environment variables and ``-audio-help`` (removed in 8.2) +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +The ``-audiodev`` and ``-audio`` command line options are now the only +way to specify audio backend settings. + Creating vnc without ``audiodev=3D`` property (removed in 8.2) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' =20 diff --git a/qemu-options.hx b/qemu-options.hx index bcd77255cbd..9ce8a5b9578 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -727,16 +727,6 @@ SRST ERST =20 =20 -HXCOMM Deprecated by -audiodev -DEF("audio-help", 0, QEMU_OPTION_audio_help, - "-audio-help show -audiodev equivalent of the currently specified = audio settings\n", - QEMU_ARCH_ALL) -SRST -``-audio-help`` - Will show the -audiodev equivalent of the currently specified - (deprecated) environment variables. -ERST - DEF("audio", HAS_ARG, QEMU_OPTION_audio, "-audio [driver=3D]driver,model=3Dvalue[,prop[=3Dvalue][,...]]\n" " specifies the audio backend and device to use;\n" diff --git a/softmmu/vl.c b/softmmu/vl.c index 59a472a0b10..cafb1a98427 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2926,10 +2926,6 @@ void qemu_init(int argc, char **argv) } break; #endif - case QEMU_OPTION_audio_help: - audio_legacy_help(); - exit (0); - break; case QEMU_OPTION_audiodev: audio_parse_option(optarg); break; --=20 2.41.0 From nobody Fri May 17 10:44:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695977800; cv=none; d=zohomail.com; s=zohoarc; b=O/PYP4ICzZECUhNbZjqxCbAImwEJsf8V+MtY6m4moTQqdoh1nugi0/OvReXGKcUEMz6IKRlLVkefGsO5ZneIIEZuz7LdJyIJwKo7fyvJYinIyyE3MFbz0PV5ypgZpcU4qQeLy+D6Z0P6rOr4FbRMvs95u3ezGLSQKLSsMB9rmGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695977800; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NGlxuLyun+dUBX7xD0BT13EOzRTwugSo2SXeCOO3kog=; b=SUTeDxxFGc17JZQVipjuselOcTqWPvgYXTsROgbtzxypakmOtPI9btFoVLTPTxjB/uFymB8ioG+Ts4sHqSTqB0ZNQqYJ/tpgFexLEQUgX4rZESSsWl/MHCVww76btLc6luebUQSOapOYgYOj+/LWcOQDDhw2h64MZODCY0Ccrcg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695977800337916.4537562126384; Fri, 29 Sep 2023 01:56:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qm9EG-0006BV-6Z; Fri, 29 Sep 2023 04:52:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qm9EB-0005iN-Jz for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:03 -0400 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 1qm9Dk-0005ma-D7 for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:51:55 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-583-7iM5YBRdNXOiXxPiIUluVw-1; Fri, 29 Sep 2023 04:51:33 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-9ae70250ef5so55121266b.0 for ; Fri, 29 Sep 2023 01:51:33 -0700 (PDT) Received: from [192.168.1.174] ([151.48.237.81]) by smtp.gmail.com with ESMTPSA id l3-20020a170906230300b009932337747esm12181485eja.86.2023.09.29.01.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 01:51:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695977495; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NGlxuLyun+dUBX7xD0BT13EOzRTwugSo2SXeCOO3kog=; b=QgkhtWmU500pEs+CD3pjUrhv+GO7IqrYEt6mw0uaOxIomamOykPSBimO1CsAiKBNzYBPcm FXIta+bJaq6zWbgCSbH1/EIudzacM8IUf7/tjdHEVqdzL09F4TDyGi908JySEtcAHucoxs L1iJHF5v+n1q8KCbaL4n2cGbNJCQA64= X-MC-Unique: 7iM5YBRdNXOiXxPiIUluVw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695977492; x=1696582292; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NGlxuLyun+dUBX7xD0BT13EOzRTwugSo2SXeCOO3kog=; b=XpmCqEBRzBDG1ueg4PipoI/I7KIKAjZw+tnaHOdWiO1uMOPdug37wYJTKqWj9U+/wh omT1GoOSkT8VPPXrjOQJuK8L69T/ownhe3VOBdwDf5xFmiW1pXAjlG4h97917ks3De6v RXVTvwj0wbrrEVmrhYzbw4QZ2ciKr3aGZL5IavTdPR6QcJZDurehI1HQi2jkJtVsxgUT tBXPCoJqBWC3fxzxjomZ/rY21fGk/5dOfFra9JulWrSVEpeME8WPLpJdr2iyUvBk0503 0xysaxiVo/gM4g/3vtwuQFKkWGaJT6RfrHEYGIRnx7uiVUdwn5Kks1ooMvFB0T6Zj9V+ 9t4A== X-Gm-Message-State: AOJu0Yx/yNQC+Ceh4YQOpXBTfzS5zDqwMkARKO87HUBoFP896Mw5xzO2 tjM8JRqlSu1CnYEr1M47rGibM/SQQ/+zjYZOOTVpm1RuV9eK2KZyrC0VNbdfgcC/zW8/8IDrQQQ bTwDja74m8HBfp1XzgrWrpqF4Z0XHj2qsAxtJJheLV3x3e++pVawqM0UOwP6Mpk5Ve0f8i22N9w s= X-Received: by 2002:a17:907:75f5:b0:9b2:bcea:e517 with SMTP id jz21-20020a17090775f500b009b2bceae517mr3334541ejc.10.1695977492010; Fri, 29 Sep 2023 01:51:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHaB+gi25z9VkJiZEqONuUW4XoEGzw8QzPjyB0o8toZd6punUGdpf1/RRsec1XhIdsiCMhRNQ== X-Received: by 2002:a17:907:75f5:b0:9b2:bcea:e517 with SMTP id jz21-20020a17090775f500b009b2bceae517mr3334529ejc.10.1695977491712; Fri, 29 Sep 2023 01:51:31 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, balaton@eik.bme.hu, Martin Kletzander Subject: [PATCH v3 08/14] Introduce machine property "audiodev" Date: Fri, 29 Sep 2023 10:51:01 +0200 Message-ID: <20230929085112.983957-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929085112.983957-1-pbonzini@redhat.com> References: <20230929085112.983957-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695977801254100003 Content-Type: text/plain; charset="utf-8" From: Martin Kletzander Many machine types have default audio devices with no way to set the underl= ying audiodev. Instead of adding an option for each and every one of them, this= new property can be used as a default during machine initialisation when creati= ng such devices. Signed-off-by: Martin Kletzander [Make the property optional, instead of including it in all machines. - Pao= lo] Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 33 +++++++++++++++++++++++++++++++++ include/hw/boards.h | 9 +++++++++ 2 files changed, 42 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index cb38b8cf4cb..6aa49c8d4f1 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -39,6 +39,7 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-pci.h" #include "hw/virtio/virtio-net.h" +#include "audio/audio.h" =20 GlobalProperty hw_compat_8_1[] =3D {}; const size_t hw_compat_8_1_len =3D G_N_ELEMENTS(hw_compat_8_1); @@ -686,6 +687,26 @@ bool device_type_is_dynamic_sysbus(MachineClass *mc, c= onst char *type) return allowed; } =20 +static char *machine_get_audiodev(Object *obj, Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + return g_strdup(ms->audiodev); +} + +static void machine_set_audiodev(Object *obj, const char *value, + Error **errp) +{ + MachineState *ms =3D MACHINE(obj); + + if (!audio_state_by_name(value, errp)) { + return; + } + + g_free(ms->audiodev); + ms->audiodev =3D g_strdup(value); +} + HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) { int i; @@ -931,6 +952,17 @@ out_free: qapi_free_BootConfiguration(config); } =20 +void machine_add_audiodev_property(MachineClass *mc) +{ + ObjectClass *oc =3D OBJECT_CLASS(mc); + + object_class_property_add_str(oc, "audiodev", + machine_get_audiodev, + machine_set_audiodev); + object_class_property_set_description(oc, "audiodev", + "Audiodev to use for default mac= hine devices"); +} + static void machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -1136,6 +1168,7 @@ static void machine_finalize(Object *obj) g_free(ms->device_memory); g_free(ms->nvdimms_state); g_free(ms->numa_state); + g_free(ms->audiodev); } =20 bool machine_usb(MachineState *machine) diff --git a/include/hw/boards.h b/include/hw/boards.h index 6c67af196a3..55a64a13fdf 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -24,6 +24,7 @@ OBJECT_DECLARE_TYPE(MachineState, MachineClass, MACHINE) =20 extern MachineState *current_machine; =20 +void machine_add_audiodev_property(MachineClass *mc); void machine_run_board_init(MachineState *machine, const char *mem_path, E= rror **errp); bool machine_usb(MachineState *machine); int machine_phandle_start(MachineState *machine); @@ -358,6 +359,14 @@ struct MachineState { MemoryRegion *ram; DeviceMemoryState *device_memory; =20 + /* + * Included in MachineState for simplicity, but not supported + * unless machine_add_audiodev_property is called. Boards + * that have embedded audio devices can call it from the + * machine init function and forward the property to the device. + */ + char *audiodev; + ram_addr_t ram_size; ram_addr_t maxram_size; uint64_t ram_slots; --=20 2.41.0 From nobody Fri May 17 10:44:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695977592; cv=none; d=zohomail.com; s=zohoarc; b=HVy3ecS/XCVtr4bQXafZucHIFSy5BiAhk0dBBArQalG9Izuz0FDOYlcxNxWdqPVzFxC4GsJex2oXR8nBy3KvYQaO95j250Mq5PPDhbBbVXIm7rq9oV7rpUYJWapZ6WQ5xkyXlYmZXi6CZ0pKhKBuocaSZ2N8mVxam48iWq2NIXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695977592; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eYUtdTr60CLv5P1H2OfOWHbBZ7FzVeIg9uSPjv5Hm2s=; b=XJ0I2c9XQAqVzZWxnN1ZwFLAEwqHARcSBFASGUBCa+FbO10E3BU6SmokFp+afFm6JK4PsQ03Auup1OpQdMOT2fatYj7Qqs7X6wp5uJP5OZAXb3yMUj35qpZlpeeyZ0S/yeY63HfeBXS4g8FEhY+vFDULFY2jCKu52KaTmYCi0RU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695977592256206.42559804211896; Fri, 29 Sep 2023 01:53:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qm9EK-0006Kt-92; Fri, 29 Sep 2023 04:52:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qm9EB-0005jJ-NI for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:03 -0400 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 1qm9Dm-0005mp-5W for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:03 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-515-0jx0XLANP56tWTmn6qH1vg-1; Fri, 29 Sep 2023 04:51:36 -0400 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-51d981149b5so10748160a12.3 for ; Fri, 29 Sep 2023 01:51:35 -0700 (PDT) Received: from [192.168.1.174] ([151.48.237.81]) by smtp.gmail.com with ESMTPSA id j6-20020aa7ca46000000b0052889d090bfsm10890314edt.79.2023.09.29.01.51.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 01:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695977497; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eYUtdTr60CLv5P1H2OfOWHbBZ7FzVeIg9uSPjv5Hm2s=; b=RXL38rOY32MUPMYC5TdnJhnMUBhIjBbYRYMirtn3yZL0nytFKSE+bGL29NDJhm02uQopYu VPPUI+PsNINYRWBFnAM7fPe9YJrwbEX4xg5tU6FQTCf5zOA4rTBBeyDAOWCwewUIlny0lQ +3WRNEN8kQtqUx//bFrfla/4sYU7PW4= X-MC-Unique: 0jx0XLANP56tWTmn6qH1vg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695977494; x=1696582294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eYUtdTr60CLv5P1H2OfOWHbBZ7FzVeIg9uSPjv5Hm2s=; b=b5ZFrtOM4D5QnZoXI4tG3r3P7CZ25BUuSd37qoDlxY4i7no97P4FLJhKSWTkg2S64K ycQ/eMDUwuDdx34xDmETrkjZwIiosNDVXVgitvyjEiLujuHN2zgI3//rPpYmX6avL1Y0 lrtA4DRs8ZiSO2kSVP/nkCK6pYIfCJVd3ApanHa0Jz8QNP2ypsqAEcLBjMQ5m3OO9Aks Cjv8VX6hWXdRS11j7xoQ7Nq6EOutzpIpuTsQFCrTEUJ1nPVwuhvBo4djJf7RoG1nwXd3 Tvta8eXBbSYzGHaI1TSGSKyFF9wvbqRymiIoHSDQ92X5v41eNbsNPBZEJw4bAId7ZizF xoDQ== X-Gm-Message-State: AOJu0YwbsRWDOGbnHZbb7PZVKqdWOFVwLe7qJFhr+TAjWFYyY2TBP9gs ZliKRZ7sE7twtoglbLacxGBbTP08n1sJNG/QV1S4iN1KeqnBrYh3pCQApA8G9z68qdhmOe6TuUz qKEzOS3bbU1Nf3nXVFW84m4F0E8LeaLk1NLFUB8UA1PWMpwG7No8lVeBR8vEd4qH/7m6iXZBeyK k= X-Received: by 2002:aa7:c157:0:b0:523:102f:3ce1 with SMTP id r23-20020aa7c157000000b00523102f3ce1mr3575975edp.10.1695977494318; Fri, 29 Sep 2023 01:51:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGnvzdwDP3RzW/Y3ldZhTVeobvWkerWAlZcS7KYf7tHmn3HvykXLZDlK6uZ2I/AO4IUhfchtA== X-Received: by 2002:aa7:c157:0:b0:523:102f:3ce1 with SMTP id r23-20020aa7c157000000b00523102f3ce1mr3575957edp.10.1695977493907; Fri, 29 Sep 2023 01:51:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, balaton@eik.bme.hu, Martin Kletzander Subject: [PATCH v3 09/14] hw/arm: Support machine-default audiodev with fallback Date: Fri, 29 Sep 2023 10:51:02 +0200 Message-ID: <20230929085112.983957-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929085112.983957-1-pbonzini@redhat.com> References: <20230929085112.983957-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695977593165100001 Content-Type: text/plain; charset="utf-8" From: Martin Kletzander Signed-off-by: Martin Kletzander Signed-off-by: Paolo Bonzini --- hw/arm/integratorcp.c | 11 ++++++++++- hw/arm/musicpal.c | 11 +++++++++-- hw/arm/nseries.c | 4 ++++ hw/arm/omap2.c | 5 +++++ hw/arm/palm.c | 2 ++ hw/arm/realview.c | 12 ++++++++++++ hw/arm/spitz.c | 17 ++++++++++++----- hw/arm/versatilepb.c | 8 ++++++++ hw/arm/vexpress.c | 5 +++++ hw/arm/xlnx-zcu102.c | 6 ++++++ hw/arm/z2.c | 15 ++++++++++++++- hw/input/tsc210x.c | 5 +++++ 12 files changed, 92 insertions(+), 9 deletions(-) diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c index b109ece3ae0..d176e9af7ee 100644 --- a/hw/arm/integratorcp.c +++ b/hw/arm/integratorcp.c @@ -27,6 +27,7 @@ #include "hw/irq.h" #include "hw/sd/sd.h" #include "qom/object.h" +#include "audio/audio.h" =20 #define TYPE_INTEGRATOR_CM "integrator_core" OBJECT_DECLARE_SIMPLE_TYPE(IntegratorCMState, INTEGRATOR_CM) @@ -660,7 +661,13 @@ static void integratorcp_init(MachineState *machine) &error_fatal); } =20 - sysbus_create_varargs("pl041", 0x1d000000, pic[25], NULL); + dev =3D qdev_new("pl041"); + if (machine->audiodev) { + qdev_prop_set_string(dev, "audiodev", machine->audiodev); + } + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0x1d000000); + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[25]); =20 if (nd_table[0].used) smc91c111_init(&nd_table[0], 0xc8000000, pic[27]); @@ -678,6 +685,8 @@ static void integratorcp_machine_init(MachineClass *mc) mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("arm926"); mc->default_ram_id =3D "integrator.ram"; + + machine_add_audiodev_property(mc); } =20 DEFINE_MACHINE("integratorcp", integratorcp_machine_init) diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index dc4e43e0ee2..9703bfb97fb 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -37,9 +37,9 @@ #include "qemu/cutils.h" #include "qom/object.h" #include "hw/net/mv88w8618_eth.h" +#include "audio/audio.h" #include "qemu/error-report.h" =20 - #define MP_MISC_BASE 0x80002000 #define MP_MISC_SIZE 0x00001000 =20 @@ -1326,7 +1326,12 @@ static void musicpal_init(MachineState *machine) qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 15)); } =20 - wm8750_dev =3D i2c_slave_create_simple(i2c, TYPE_WM8750, MP_WM_ADDR); + wm8750_dev =3D i2c_slave_new(TYPE_WM8750, MP_WM_ADDR); + if (machine->audiodev) { + qdev_prop_set_string(DEVICE(wm8750_dev), "audiodev", machine->audi= odev); + } + i2c_slave_realize_and_unref(wm8750_dev, i2c, &error_abort); + dev =3D qdev_new(TYPE_MV88W8618_AUDIO); s =3D SYS_BUS_DEVICE(dev); object_property_set_link(OBJECT(dev), "wm8750", OBJECT(wm8750_dev), @@ -1347,6 +1352,8 @@ static void musicpal_machine_init(MachineClass *mc) mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("arm926"); mc->default_ram_size =3D MP_RAM_DEFAULT_SIZE; mc->default_ram_id =3D "musicpal.ram"; + + machine_add_audiodev_property(mc); } =20 DEFINE_MACHINE("musicpal", musicpal_machine_init) diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c index 9e49e9e1776..35aff46b4b4 100644 --- a/hw/arm/nseries.c +++ b/hw/arm/nseries.c @@ -1432,6 +1432,8 @@ static void n800_class_init(ObjectClass *oc, void *da= ta) /* Actually two chips of 0x4000000 bytes each */ mc->default_ram_size =3D 0x08000000; mc->default_ram_id =3D "omap2.dram"; + + machine_add_audiodev_property(mc); } =20 static const TypeInfo n800_type =3D { @@ -1452,6 +1454,8 @@ static void n810_class_init(ObjectClass *oc, void *da= ta) /* Actually two chips of 0x4000000 bytes each */ mc->default_ram_size =3D 0x08000000; mc->default_ram_id =3D "omap2.dram"; + + machine_add_audiodev_property(mc); } =20 static const TypeInfo n810_type =3D { diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c index d5a2ae7af6e..41b1f596dca 100644 --- a/hw/arm/omap2.c +++ b/hw/arm/omap2.c @@ -37,6 +37,7 @@ #include "hw/block/flash.h" #include "hw/arm/soc_dma.h" #include "hw/sysbus.h" +#include "hw/boards.h" #include "audio/audio.h" =20 /* Enhanced Audio Controller (CODEC only) */ @@ -609,6 +610,10 @@ static struct omap_eac_s *omap_eac_init(struct omap_ta= rget_agent_s *ta, s->codec.txdrq =3D *drq; omap_eac_reset(s); =20 + if (current_machine->audiodev) { + s->codec.card.name =3D g_strdup(current_machine->audiodev); + s->codec.card.state =3D audio_state_by_name(s->codec.card.name, &e= rror_fatal); + } AUD_register_card("OMAP EAC", &s->codec.card); =20 memory_region_init_io(&s->iomem, NULL, &omap_eac_ops, s, "omap.eac", diff --git a/hw/arm/palm.c b/hw/arm/palm.c index 17c11ac4cec..b86f2c331bb 100644 --- a/hw/arm/palm.c +++ b/hw/arm/palm.c @@ -310,6 +310,8 @@ static void palmte_machine_init(MachineClass *mc) mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("ti925t"); mc->default_ram_size =3D 0x02000000; mc->default_ram_id =3D "omap1.dram"; + + machine_add_audiodev_property(mc); } =20 DEFINE_MACHINE("cheetah", palmte_machine_init) diff --git a/hw/arm/realview.c b/hw/arm/realview.c index a5aa2f046ae..8f89526596c 100644 --- a/hw/arm/realview.c +++ b/hw/arm/realview.c @@ -29,6 +29,7 @@ #include "hw/irq.h" #include "hw/i2c/arm_sbcon_i2c.h" #include "hw/sd/sd.h" +#include "audio/audio.h" =20 #define SMP_BOOT_ADDR 0xe0000000 #define SMP_BOOTREG_ADDR 0x10000030 @@ -207,6 +208,9 @@ static void realview_init(MachineState *machine, =20 pl041 =3D qdev_new("pl041"); qdev_prop_set_uint32(pl041, "nc_fifo_depth", 512); + if (machine->audiodev) { + qdev_prop_set_string(pl041, "audiodev", machine->audiodev); + } sysbus_realize_and_unref(SYS_BUS_DEVICE(pl041), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(pl041), 0, 0x10004000); sysbus_connect_irq(SYS_BUS_DEVICE(pl041), 0, pic[19]); @@ -412,6 +416,8 @@ static void realview_eb_class_init(ObjectClass *oc, voi= d *data) mc->block_default_type =3D IF_SCSI; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("arm926"); + + machine_add_audiodev_property(mc); } =20 static const TypeInfo realview_eb_type =3D { @@ -430,6 +436,8 @@ static void realview_eb_mpcore_class_init(ObjectClass *= oc, void *data) mc->max_cpus =3D 4; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("arm11mpcore"); + + machine_add_audiodev_property(mc); } =20 static const TypeInfo realview_eb_mpcore_type =3D { @@ -446,6 +454,8 @@ static void realview_pb_a8_class_init(ObjectClass *oc, = void *data) mc->init =3D realview_pb_a8_init; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a8"); + + machine_add_audiodev_property(mc); } =20 static const TypeInfo realview_pb_a8_type =3D { @@ -463,6 +473,8 @@ static void realview_pbx_a9_class_init(ObjectClass *oc,= void *data) mc->max_cpus =3D 4; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a9"); + + machine_add_audiodev_property(mc); } =20 static const TypeInfo realview_pbx_a9_type =3D { diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c index f732fe0acf9..cc268c6ac0b 100644 --- a/hw/arm/spitz.c +++ b/hw/arm/spitz.c @@ -35,6 +35,7 @@ #include "exec/address-spaces.h" #include "cpu.h" #include "qom/object.h" +#include "audio/audio.h" =20 enum spitz_model_e { spitz, akita, borzoi, terrier }; =20 @@ -774,15 +775,19 @@ static void spitz_wm8750_addr(void *opaque, int line,= int level) i2c_slave_set_address(wm, SPITZ_WM_ADDRL); } =20 -static void spitz_i2c_setup(PXA2xxState *cpu) +static void spitz_i2c_setup(MachineState *machine, PXA2xxState *cpu) { /* Attach the CPU on one end of our I2C bus. */ I2CBus *bus =3D pxa2xx_i2c_bus(cpu->i2c[0]); =20 - DeviceState *wm; - /* Attach a WM8750 to the bus */ - wm =3D DEVICE(i2c_slave_create_simple(bus, TYPE_WM8750, 0)); + I2CSlave *i2c_dev =3D i2c_slave_new(TYPE_WM8750, 0); + DeviceState *wm =3D DEVICE(i2c_dev); + + if (machine->audiodev) { + qdev_prop_set_string(wm, "audiodev", machine->audiodev); + } + i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort); =20 spitz_wm8750_addr(wm, 0, 0); qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_WM, @@ -1013,7 +1018,7 @@ static void spitz_common_init(MachineState *machine) =20 spitz_gpio_setup(mpu, (model =3D=3D akita) ? 1 : 2); =20 - spitz_i2c_setup(mpu); + spitz_i2c_setup(machine, mpu); =20 if (model =3D=3D akita) spitz_akita_i2c_setup(mpu); @@ -1037,6 +1042,8 @@ static void spitz_common_class_init(ObjectClass *oc, = void *data) mc->block_default_type =3D IF_IDE; mc->ignore_memory_transaction_failures =3D true; mc->init =3D spitz_common_init; + + machine_add_audiodev_property(mc); } =20 static const TypeInfo spitz_common_info =3D { diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c index 05b9462a5b7..2f22dc890f4 100644 --- a/hw/arm/versatilepb.c +++ b/hw/arm/versatilepb.c @@ -26,6 +26,7 @@ #include "hw/char/pl011.h" #include "hw/sd/sd.h" #include "qom/object.h" +#include "audio/audio.h" =20 #define VERSATILE_FLASH_ADDR 0x34000000 #define VERSATILE_FLASH_SIZE (64 * 1024 * 1024) @@ -343,6 +344,9 @@ static void versatile_init(MachineState *machine, int b= oard_id) /* Add PL041 AACI Interface to the LM4549 codec */ pl041 =3D qdev_new("pl041"); qdev_prop_set_uint32(pl041, "nc_fifo_depth", 512); + if (machine->audiodev) { + qdev_prop_set_string(pl041, "audiodev", machine->audiodev); + } sysbus_realize_and_unref(SYS_BUS_DEVICE(pl041), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(pl041), 0, 0x10004000); sysbus_connect_irq(SYS_BUS_DEVICE(pl041), 0, sic[24]); @@ -416,6 +420,8 @@ static void versatilepb_class_init(ObjectClass *oc, voi= d *data) mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("arm926"); mc->default_ram_id =3D "versatile.ram"; + + machine_add_audiodev_property(mc); } =20 static const TypeInfo versatilepb_type =3D { @@ -434,6 +440,8 @@ static void versatileab_class_init(ObjectClass *oc, voi= d *data) mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("arm926"); mc->default_ram_id =3D "versatile.ram"; + + machine_add_audiodev_property(mc); } =20 static const TypeInfo versatileab_type =3D { diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 56abadd9b8b..8ff37f52ca1 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -44,6 +44,7 @@ #include "hw/i2c/arm_sbcon_i2c.h" #include "hw/sd/sd.h" #include "qom/object.h" +#include "audio/audio.h" =20 #define VEXPRESS_BOARD_ID 0x8e0 #define VEXPRESS_FLASH_SIZE (64 * 1024 * 1024) @@ -613,6 +614,9 @@ static void vexpress_common_init(MachineState *machine) =20 pl041 =3D qdev_new("pl041"); qdev_prop_set_uint32(pl041, "nc_fifo_depth", 512); + if (machine->audiodev) { + qdev_prop_set_string(pl041, "audiodev", machine->audiodev); + } sysbus_realize_and_unref(SYS_BUS_DEVICE(pl041), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(pl041), 0, map[VE_PL041]); sysbus_connect_irq(SYS_BUS_DEVICE(pl041), 0, pic[11]); @@ -776,6 +780,7 @@ static void vexpress_class_init(ObjectClass *oc, void *= data) mc->ignore_memory_transaction_failures =3D true; mc->default_ram_id =3D "vexpress.highmem"; =20 + machine_add_audiodev_property(mc); object_class_property_add_bool(oc, "secure", vexpress_get_secure, vexpress_set_secure); object_class_property_set_description(oc, "secure", diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c index 21483f75fd9..c5a07cfe195 100644 --- a/hw/arm/xlnx-zcu102.c +++ b/hw/arm/xlnx-zcu102.c @@ -24,6 +24,7 @@ #include "sysemu/device_tree.h" #include "qom/object.h" #include "net/can_emu.h" +#include "audio/audio.h" =20 struct XlnxZCU102 { MachineState parent_obj; @@ -143,6 +144,10 @@ static void xlnx_zcu102_init(MachineState *machine) =20 object_initialize_child(OBJECT(machine), "soc", &s->soc, TYPE_XLNX_ZYN= QMP); =20 + if (machine->audiodev) { + qdev_prop_set_string(DEVICE(&s->soc.dp), "audiodev", machine->audi= odev); + } + object_property_set_link(OBJECT(&s->soc), "ddr-ram", OBJECT(machine->r= am), &error_abort); object_property_set_bool(OBJECT(&s->soc), "secure", s->secure, @@ -275,6 +280,7 @@ static void xlnx_zcu102_machine_class_init(ObjectClass = *oc, void *data) mc->default_cpus =3D XLNX_ZYNQMP_NUM_APU_CPUS; mc->default_ram_id =3D "ddr-ram"; =20 + machine_add_audiodev_property(mc); object_class_property_add_bool(oc, "secure", zcu102_get_secure, zcu102_set_secure); object_class_property_set_description(oc, "secure", diff --git a/hw/arm/z2.c b/hw/arm/z2.c index dc25304290a..d9a08fa67b2 100644 --- a/hw/arm/z2.c +++ b/hw/arm/z2.c @@ -27,6 +27,7 @@ #include "exec/address-spaces.h" #include "cpu.h" #include "qom/object.h" +#include "qapi/error.h" =20 #ifdef DEBUG_Z2 #define DPRINTF(fmt, ...) \ @@ -307,6 +308,7 @@ static void z2_init(MachineState *machine) void *z2_lcd; I2CBus *bus; DeviceState *wm; + I2CSlave *i2c_dev; =20 /* Setup CPU & memory */ mpu =3D pxa270_init(z2_binfo.ram_size, machine->cpu_type); @@ -328,8 +330,17 @@ static void z2_init(MachineState *machine) type_register_static(&aer915_info); z2_lcd =3D ssi_create_peripheral(mpu->ssp[1], TYPE_ZIPIT_LCD); bus =3D pxa2xx_i2c_bus(mpu->i2c[0]); + i2c_slave_create_simple(bus, TYPE_AER915, 0x55); - wm =3D DEVICE(i2c_slave_create_simple(bus, TYPE_WM8750, 0x1b)); + + i2c_dev =3D i2c_slave_new(TYPE_WM8750, 0x1b); + wm =3D DEVICE(i2c_dev); + + if (machine->audiodev) { + qdev_prop_set_string(wm, "audiodev", machine->audiodev); + } + i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort); + mpu->i2s->opaque =3D wm; mpu->i2s->codec_out =3D wm8750_dac_dat; mpu->i2s->codec_in =3D wm8750_adc_dat; @@ -348,6 +359,8 @@ static void z2_machine_init(MachineClass *mc) mc->init =3D z2_init; mc->ignore_memory_transaction_failures =3D true; mc->default_cpu_type =3D ARM_CPU_TYPE_NAME("pxa270-c5"); + + machine_add_audiodev_property(mc); } =20 DEFINE_MACHINE("z2", z2_machine_init) diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c index f568759e05a..e7960a50696 100644 --- a/hw/input/tsc210x.c +++ b/hw/input/tsc210x.c @@ -27,6 +27,7 @@ #include "sysemu/reset.h" #include "ui/console.h" #include "hw/arm/omap.h" /* For I2SCodec */ +#include "hw/boards.h" /* for current_machine */ #include "hw/input/tsc2xxx.h" #include "hw/irq.h" #include "migration/vmstate.h" @@ -1097,6 +1098,10 @@ static void tsc210x_init(TSC210xState *s, =20 qemu_add_mouse_event_handler(tsc210x_touchscreen_event, s, 1, name); =20 + if (current_machine->audiodev) { + s->card.name =3D g_strdup(current_machine->audiodev); + s->card.state =3D audio_state_by_name(s->card.name, &error_fatal); + } AUD_register_card(s->name, &s->card); =20 qemu_register_reset((void *) tsc210x_reset, s); --=20 2.41.0 From nobody Fri May 17 10:44:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695977668; cv=none; d=zohomail.com; s=zohoarc; b=ViwO40eMoZge5sBVVftOiYhpdtb5m/hr9VY8M8133tX6Nm22Q5svtFtZYrMK6SYycDAfq1lhs2RkaMJ/Z2kejKcr9/B+WZ+qxzFbHWNNFk32SolREZ/3INwCABGBO/01bMUi4h8YjVAFDgI+lIBzrvJ6B9iQ4iY91HOcHlTpLVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695977668; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5QcmQw2PVuW7Kd2iuNxUNyWZSEU9TNIASS3C9a1HLJI=; b=SbZHGVYtV1GMxIn+r/0BmIaBsxmDDvOB9ULwo/72LGqA4wcV15obpnuEVkBbRsDN7hByX7zCJwnPxTaXm16AbysktHSddnxI8aV/PAfrDkai3zPNBifODEMi1uKtbNDJWlnvoqQ6rOPNOQQCpapgppbMlUuMgb8Pxzb9CawJakI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695977668893814.0317539424809; Fri, 29 Sep 2023 01:54:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qm9EK-0006J5-FT; Fri, 29 Sep 2023 04:52:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qm9EC-0005iH-Io for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:04 -0400 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 1qm9Dp-0005n3-Te for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:02 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-504-NHGGtPyPP-yTG3pp-YRfEA-1; Fri, 29 Sep 2023 04:51:37 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-94a348facbbso1166096766b.1 for ; Fri, 29 Sep 2023 01:51:37 -0700 (PDT) Received: from [192.168.1.174] ([151.48.237.81]) by smtp.gmail.com with ESMTPSA id z27-20020a1709060adb00b00993cc1242d4sm12111608ejf.151.2023.09.29.01.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 01:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695977499; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5QcmQw2PVuW7Kd2iuNxUNyWZSEU9TNIASS3C9a1HLJI=; b=dcyxyfmae33IcjCCpnAuSye7DhgBm2ywDlLIldX8aKu8sslAB1uyf4cozkhSkR2H1MIaOF Zpun7eoOmVRme6UTcArMguopM2FK3xK/1Cu/ALKS5wPqHuNA4eQhnT85PRaM7RB9DG0Zku Xge1DJ+FSfyoKM4bKtAF92NQn+YzVnM= X-MC-Unique: NHGGtPyPP-yTG3pp-YRfEA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695977496; x=1696582296; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5QcmQw2PVuW7Kd2iuNxUNyWZSEU9TNIASS3C9a1HLJI=; b=QZedNbLtd+NxwGjzQyCiELH1xu0FP/wRY8eqjxC5TqeCxZG/Sjcthi7s5/Ds9I0Ay9 gp/PLUqn13iHee+sqIkTC7ZJKVNonP8qL0PBhw74CVgOwlDIzETs5IH7Y/l1z0Hp/Cns UDUcCSRard2lQ4NhfdVf8h2gvHIS+Q3ALyn44pgHKKnrLrVyNNtw2ES/nbgi3WqOJS8k bZoUFDSOJ2ofwoZ3mlfS/OGDM9/9EqE2Nc5yPutjjXxvjXh9ZVivOJX7bRgJGaevyIy2 qNPNURbcnQKLu2GnbWF2I9GMyouy7hSXlCmLrSKMdd6bGTR7q0vogAW9pnKWImeUPrcP 40Tg== X-Gm-Message-State: AOJu0YxQdBMNLfULBtwGoYQ0bvZe6FnuoTHdGilMTDzkvGJ1X1vydePY 4AS9BiXoQfkAYaNFxmzX/DnuA3x//i4HhA3FX49mjnOfC3veB9BfeWPdrfaOW9vOu3+1nC9m0wL X/jyY19rwwl2Bj1JYVUioac8Da/JK5DyybUJRVanpPvNm8QaCGVbkCj052MqbTiIDXeaEjdgI0Q s= X-Received: by 2002:a17:906:210a:b0:9ae:6ad0:f6db with SMTP id 10-20020a170906210a00b009ae6ad0f6dbmr3181186ejt.71.1695977496359; Fri, 29 Sep 2023 01:51:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEoADWa7rZuEBSK115eDxt6qrzUqhsEZVzFkSSoysX5OkSVhNR5ZDHBLBmz5c3gdCw0eHZdw== X-Received: by 2002:a17:906:210a:b0:9ae:6ad0:f6db with SMTP id 10-20020a170906210a00b009ae6ad0f6dbmr3181173ejt.71.1695977496035; Fri, 29 Sep 2023 01:51:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, balaton@eik.bme.hu, Martin Kletzander Subject: [PATCH v3 10/14] hw/ppc: Support machine-default audiodev with fallback Date: Fri, 29 Sep 2023 10:51:03 +0200 Message-ID: <20230929085112.983957-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929085112.983957-1-pbonzini@redhat.com> References: <20230929085112.983957-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695977670666100005 Content-Type: text/plain; charset="utf-8" From: Martin Kletzander Signed-off-by: Martin Kletzander Signed-off-by: Paolo Bonzini --- hw/ppc/prep.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index f6fd35fcb9e..137276bcb92 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -45,6 +45,7 @@ #include "trace.h" #include "elf.h" #include "qemu/units.h" +#include "audio/audio.h" =20 /* SMP is not enabled, for now */ #define MAX_CPUS 1 @@ -310,6 +311,10 @@ static void ibm_40p_init(MachineState *machine) dev =3D DEVICE(isa_dev); qdev_prop_set_uint32(dev, "iobase", 0x830); qdev_prop_set_uint32(dev, "irq", 10); + + if (machine->audiodev) { + qdev_prop_set_string(dev, "audiodev", machine->audiodev); + } isa_realize_and_unref(isa_dev, isa_bus, &error_fatal); =20 isa_dev =3D isa_new("pc87312"); @@ -426,6 +431,8 @@ static void ibm_40p_machine_init(MachineClass *mc) mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("604"); mc->default_display =3D "std"; mc->default_nic =3D "pcnet"; + + machine_add_audiodev_property(mc); } =20 DEFINE_MACHINE("40p", ibm_40p_machine_init) --=20 2.41.0 From nobody Fri May 17 10:44:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695977813; cv=none; d=zohomail.com; s=zohoarc; b=WVFBaIqyrFP49GkiVkp33SivLiO2RnJdjvqkra5YYOi1P4gR8uigNtsfpBlbuLVY9n4GLDfmfNZHOC9p4/rog5TZ9J4qAYcSLIm3Nh5yTzdIsMZi82XaG2WpPzN3739IikuWk05PDkiWiQkIn11wQZw9cvvnlc+gOMRJ+LGcXPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695977813; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=z5jMXh0AgvMSbbzSsPF24dLhbhVyf2VnDuH5Ua++icY=; b=e1L2qEsjihNUa33KEiHPU+V8VJTNV5Ax53VsAVLi+jQ8no/lVX2r+hfFgIKCTMcBRnd/4yDjOIguMKn7jfuIhg6LmPyoAPIHkSIwU4VlVJUkcHafmQx13ob4JOMc0Vgwq+mB8GXC5NXYy1A0jqQnJFl73ENOtnPm+cFq4d/oIBM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695977813814758.9163592597835; Fri, 29 Sep 2023 01:56:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qm9EG-0006Cx-Ss; Fri, 29 Sep 2023 04:52:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qm9EC-0005pM-Gv for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:04 -0400 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 1qm9Du-0005nQ-M2 for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:02 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-217-ABfsF6HGP-ia1bWzet4u0A-1; Fri, 29 Sep 2023 04:51:40 -0400 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5334e22b2dbso10918893a12.0 for ; Fri, 29 Sep 2023 01:51:40 -0700 (PDT) Received: from [192.168.1.174] ([151.48.237.81]) by smtp.gmail.com with ESMTPSA id v15-20020a056402174f00b0053631c4958asm1749629edx.22.2023.09.29.01.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 01:51:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695977501; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z5jMXh0AgvMSbbzSsPF24dLhbhVyf2VnDuH5Ua++icY=; b=DM118fjWh/78Op5dfP2tmetBj7TUS0R4EsVkmC83A4DPsNG3eOFfxYiYhaoVPJTOuzegzm rcfVDjt32PQdorJL5WefWP3RQmJuNy4wPDsl8VtDjZx0DzTrw9rx7f4INj3wKSTt4gm/Ku NVovfXsq05EvyO4SAmwJmxFNVnd8Wg4= X-MC-Unique: ABfsF6HGP-ia1bWzet4u0A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695977498; x=1696582298; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z5jMXh0AgvMSbbzSsPF24dLhbhVyf2VnDuH5Ua++icY=; b=GruHK41IM5b8l84PNxQk+yQnMXjvMp//yiKNmM6jL1Idwo5TnAMumZ9rjHtgiOk78D 5rXE3rIZbTQ/58A+s29k+TkdZFN39t7TVJelunV76N/oLwshlrTpFMHbWkkWVXUbfZE5 UID9eD7cQUVc8WFeTVxjzaRT6HCR1eu1Zc3j2UFqMDYTXAuVcHSzg+WUI8eunpauziP9 3czt53E5GLrckGXPHNq4pvvReUq572GE/lgO5VOZvTgKOtME+dzOrLpHdPT5wYxVLcVL DAGIlYosDCxFOJeNVxgGnuytIHcs0+pMxrAZAOP8keZQuAmm9ij9pWCg+c3BJ4JKh1gC CoGw== X-Gm-Message-State: AOJu0Yw4swLPzn0A0tbalhj0JtjjRZefQ35QGroqaKbMJ4QPvRB2F0vd 6IvohIe6i2cTSkKcKXjHZh6jaZK81fSgnTacMWLVMCKA7xUEPJsXMNoCZU+ibXCNn/jTHwHajc2 //T0op+5zyz3JehR9JyGzz0+cpMdfLeLODJ09mJqgvX4/m3YA/nIKI78JNVTMw5aLDLhWIpFpFA s= X-Received: by 2002:aa7:d48f:0:b0:530:a61f:ed1 with SMTP id b15-20020aa7d48f000000b00530a61f0ed1mr2954593edr.42.1695977498339; Fri, 29 Sep 2023 01:51:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1rNU9b2o1IizNvAqUoj8xO5RTaWNurb1OOeR5YjpP5MGJYYwA2p3aUqmOBkh45098IfgQmw== X-Received: by 2002:aa7:d48f:0:b0:530:a61f:ed1 with SMTP id b15-20020aa7d48f000000b00530a61f0ed1mr2954580edr.42.1695977498041; Fri, 29 Sep 2023 01:51:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, balaton@eik.bme.hu Subject: [PATCH v3 11/14] vt82c686: Support machine-default audiodev with fallback Date: Fri, 29 Sep 2023 10:51:04 +0200 Message-ID: <20230929085112.983957-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929085112.983957-1-pbonzini@redhat.com> References: <20230929085112.983957-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695977815485100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: BALATON Zoltan --- hw/mips/fuloong2e.c | 15 ++++++++++++--- hw/ppc/pegasos2.c | 12 ++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c index c827f615f3b..c6109633fee 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -295,9 +295,17 @@ static void mips_fuloong2e_init(MachineState *machine) pci_bus =3D bonito_init((qemu_irq *)&(env->irq[2])); =20 /* South bridge -> IP5 */ - pci_dev =3D pci_create_simple_multifunction(pci_bus, - PCI_DEVFN(FULOONG2E_VIA_SLOT= , 0), - TYPE_VT82C686B_ISA); + pci_dev =3D pci_new_multifunction(PCI_DEVFN(FULOONG2E_VIA_SLOT, 0), + TYPE_VT82C686B_ISA); + + /* Set properties on individual devices before realizing the south bri= dge */ + if (machine->audiodev) { + dev =3D DEVICE(object_resolve_path_component(OBJECT(pci_dev), "ac9= 7")); + qdev_prop_set_string(dev, "audiodev", machine->audiodev); + } + + pci_realize_and_unref(pci_dev, pci_bus, &error_abort); + object_property_add_alias(OBJECT(machine), "rtc-time", object_resolve_path_component(OBJECT(pci_dev= ), "rtc"), @@ -337,6 +345,7 @@ static void mips_fuloong2e_machine_init(MachineClass *m= c) mc->default_ram_size =3D 256 * MiB; mc->default_ram_id =3D "fuloong2e.ram"; mc->minimum_page_bits =3D 14; + machine_add_audiodev_property(mc); } =20 DEFINE_MACHINE("fuloong2e", mips_fuloong2e_machine_init) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index bd397cf2b5c..3203a4a7289 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -180,8 +180,15 @@ static void pegasos2_init(MachineState *machine) pci_bus_irqs(pci_bus, pegasos2_pci_irq, pm, PCI_NUM_PINS); =20 /* VIA VT8231 South Bridge (multifunction PCI device) */ - via =3D OBJECT(pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, = 0), - TYPE_VT8231_ISA)); + via =3D OBJECT(pci_new_multifunction(PCI_DEVFN(12, 0), TYPE_VT8231_ISA= )); + + /* Set properties on individual devices before realizing the south bri= dge */ + if (machine->audiodev) { + dev =3D PCI_DEVICE(object_resolve_path_component(via, "ac97")); + qdev_prop_set_string(DEVICE(dev), "audiodev", machine->audiodev); + } + + pci_realize_and_unref(PCI_DEVICE(via), pci_bus, &error_abort); for (i =3D 0; i < PCI_NUM_PINS; i++) { pm->via_pirq[i] =3D qdev_get_gpio_in_named(DEVICE(via), "pirq", i); } @@ -556,6 +563,7 @@ static void pegasos2_machine_class_init(ObjectClass *oc= , void *data) mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("7457_v1.2"); mc->default_ram_id =3D "pegasos2.ram"; mc->default_ram_size =3D 512 * MiB; + machine_add_audiodev_property(mc); =20 vhc->cpu_in_nested =3D pegasos2_cpu_in_nested; vhc->hypercall =3D pegasos2_hypercall; --=20 2.41.0 From nobody Fri May 17 10:44:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695977887; cv=none; d=zohomail.com; s=zohoarc; b=DF1EfTODkMCjHJojjQOtBELfVQzmgg87tl/6o/RWxRk3lvsIG0A2m5NPgamVGna5mJczCOw8igle4H1kfOmBZ+1C5dBDzBZoj+vu9gp72m/ngvW2DV/Xl5TuNwBSFpMDNQMqPoTxSo4dh/u8L3LI7VbOiPDWJ4ZnvT0kMKkQaAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695977887; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DmVurVNjUXg7XuqnRKl2cwWl9draGbugS16F/Ts6Uw4=; b=YtYmEG6dFBBJlrwVmxrP961sHKhrm/msEZKwcLfGeWywa/uIIWODn9fXueZniCceBUq9IyPw3vBA0/ML5alRr4jXIhtL5PLZszaVqkbv6zYKBZg+qUx/SFYfqFXPHh+UygR491mP/85Fc38jzAbqjpdJapkuhL3eV8yb9VdQlCQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695977887545643.6169383932785; Fri, 29 Sep 2023 01:58:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qm9EU-0006k1-1n; Fri, 29 Sep 2023 04:52:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qm9ER-0006au-0D for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:19 -0400 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 1qm9E3-0005nx-HO for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:18 -0400 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-694-Ob3G43jnOIGkq6gH1dSB7A-1; Fri, 29 Sep 2023 04:51:42 -0400 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-9b2c1159b0aso152615366b.3 for ; Fri, 29 Sep 2023 01:51:42 -0700 (PDT) Received: from [192.168.1.174] ([151.48.237.81]) by smtp.gmail.com with ESMTPSA id ek10-20020a056402370a00b00533dd4d2947sm7612145edb.74.2023.09.29.01.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 01:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695977504; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DmVurVNjUXg7XuqnRKl2cwWl9draGbugS16F/Ts6Uw4=; b=VvOx0+l9YLpGHLNfKFj0g+FOYpezYt1qEZPpWW1HKVNpkJF7dWTBJ3SbR1YVFeDeda8sfw DHUFOJBdmGGu0+62RjvgX3PFtu5kO0nNGwD6DpPGVWNjtjmia1ABBccTQODo/Tf2W0FRqR Rj1MRCnEyni6kIh1gBtSc+j59djI+0A= X-MC-Unique: Ob3G43jnOIGkq6gH1dSB7A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695977501; x=1696582301; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DmVurVNjUXg7XuqnRKl2cwWl9draGbugS16F/Ts6Uw4=; b=CkoeWEMg4vUEYHDYNbKidXwf9vy56oBCbDf36+sxDc2Wk/Vv0UsboxzEqGT533NJFr 2bHHSwlj1VEBaNqGUignYnCX8u0jqhHJBZR3FbIwOi8DNPn/5z59pRcB1h4a4fiw9Ino 53LECojhVSaT9uoxT4NzPAPPviwDkprUg7mJqMc9F20CjLh7x8RMuhyK3tF8TpH2m0V2 xWgYip/i1sQFNFfgO9iLSNOJ39nx9LOJtzM660R8HzUvigOYQ6vDlOXCO50k58DyyJZl nxH7cM1yGD7hNNzTXykWfVYUCpSR6scafKzzToORJB7m/Y9GPyVUC53/dd+hZG0YBqv8 Ak7g== X-Gm-Message-State: AOJu0Yz4rVDhChA3cSkftO5OCBk2cgTkktFTgofD4AvERqmaE+wKoDY4 pgRqSUgmGQ1M9o4iOcbYj1rz0r8bXOxYVRom9LTzPdSov2VWUUtIMWDQgj7viBToecpN8RU1/I7 kGYDnlKF90klruFFNPQcWnVI+UWYStOmBy6E2rgK2B0v5AvwOtxnD5uP5Fhc1wP+L8wpDOQdpQC 8= X-Received: by 2002:a05:6402:5162:b0:530:d7fe:2920 with SMTP id d2-20020a056402516200b00530d7fe2920mr2981668ede.26.1695977500895; Fri, 29 Sep 2023 01:51:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGeZeMP6dDWkIAnT5coNFejFYfC6gQE/95JIRgMk56YgtLyQd391kq1qVYqEgnFsqx/E0t//A== X-Received: by 2002:a05:6402:5162:b0:530:d7fe:2920 with SMTP id d2-20020a056402516200b00530d7fe2920mr2981652ede.26.1695977500530; Fri, 29 Sep 2023 01:51:40 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, balaton@eik.bme.hu, Martin Kletzander Subject: [PATCH v3 12/14] audio: forbid mixing default audiodev backend and -audiodev Date: Fri, 29 Sep 2023 10:51:05 +0200 Message-ID: <20230929085112.983957-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929085112.983957-1-pbonzini@redhat.com> References: <20230929085112.983957-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695977888261100001 Content-Type: text/plain; charset="utf-8" Now that all callers support setting an audiodev, forbid using the default audiodev if any audiodev is defined on the command line. To make the detection easier make AUD_register_card() return false on error. Signed-off-by: Martin Kletzander Signed-off-by: Paolo Bonzini --- audio/audio.c | 16 ++++++++++------ audio/audio.h | 2 +- hw/arm/omap2.c | 2 +- hw/audio/ac97.c | 6 +++++- hw/audio/adlib.c | 6 ++++-- hw/audio/cs4231a.c | 6 ++++-- hw/audio/es1370.c | 5 ++++- hw/audio/gus.c | 6 ++++-- hw/audio/hda-codec.c | 5 ++++- hw/audio/lm4549.c | 8 +++++--- hw/audio/pcspk.c | 4 +--- hw/audio/sb16.c | 6 ++++-- hw/audio/via-ac97.c | 6 ++++-- hw/audio/wm8750.c | 5 ++++- hw/display/xlnx_dp.c | 6 ++++-- hw/input/tsc210x.c | 2 +- hw/usb/dev-audio.c | 5 ++++- 17 files changed, 64 insertions(+), 32 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 9da2eaece03..f0788345bf8 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1803,15 +1803,17 @@ static AudioState *audio_init(Audiodev *dev) return s; } =20 -void AUD_register_card (const char *name, QEMUSoundCard *card) +bool AUD_register_card (const char *name, QEMUSoundCard *card, Error **err= p) { if (!card->state) { + if (!QSIMPLEQ_EMPTY(&audiodevs)) { + error_setg(errp, "No audiodev specified for %s", name); + error_append_hint(errp, "Perhaps you wanted to set audiodev=3D= %s?", + QSIMPLEQ_FIRST(&audiodevs)->dev->id); + return false; + } + if (!QTAILQ_EMPTY(&audio_states)) { - if (!legacy_config) { - dolog("Device %s: audiodev default parameter is deprecated= , please " - "specify audiodev=3D%s\n", name, - QTAILQ_FIRST(&audio_states)->dev->id); - } card->state =3D QTAILQ_FIRST(&audio_states); } else { if (QSIMPLEQ_EMPTY(&default_audiodevs)) { @@ -1824,6 +1826,8 @@ void AUD_register_card (const char *name, QEMUSoundCa= rd *card) card->name =3D g_strdup (name); memset (&card->entries, 0, sizeof (card->entries)); QLIST_INSERT_HEAD(&card->state->card_head, card, entries); + + return true; } =20 void AUD_remove_card (QEMUSoundCard *card) diff --git a/audio/audio.h b/audio/audio.h index 34df8962a66..70b264d897d 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -94,7 +94,7 @@ typedef struct QEMUAudioTimeStamp { void AUD_vlog (const char *cap, const char *fmt, va_list ap) G_GNUC_PRINTF= (2, 0); void AUD_log (const char *cap, const char *fmt, ...) G_GNUC_PRINTF(2, 3); =20 -void AUD_register_card (const char *name, QEMUSoundCard *card); +bool AUD_register_card (const char *name, QEMUSoundCard *card, Error **err= p); void AUD_remove_card (QEMUSoundCard *card); CaptureVoiceOut *AUD_add_capture( AudioState *s, diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c index 41b1f596dca..f170728e7ec 100644 --- a/hw/arm/omap2.c +++ b/hw/arm/omap2.c @@ -614,7 +614,7 @@ static struct omap_eac_s *omap_eac_init(struct omap_tar= get_agent_s *ta, s->codec.card.name =3D g_strdup(current_machine->audiodev); s->codec.card.state =3D audio_state_by_name(s->codec.card.name, &e= rror_fatal); } - AUD_register_card("OMAP EAC", &s->codec.card); + AUD_register_card("OMAP EAC", &s->codec.card, &error_fatal); =20 memory_region_init_io(&s->iomem, NULL, &omap_eac_ops, s, "omap.eac", omap_l4_region_size(ta, 0)); diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c index c2a5ce062a1..6a7a2dc80c4 100644 --- a/hw/audio/ac97.c +++ b/hw/audio/ac97.c @@ -1273,6 +1273,10 @@ static void ac97_realize(PCIDevice *dev, Error **err= p) AC97LinkState *s =3D AC97(dev); uint8_t *c =3D s->dev.config; =20 + if (!AUD_register_card ("ac97", &s->card, errp)) { + return; + } + /* TODO: no need to override */ c[PCI_COMMAND] =3D 0x00; /* pcicmd pci command rw, ro */ c[PCI_COMMAND + 1] =3D 0x00; @@ -1306,7 +1310,7 @@ static void ac97_realize(PCIDevice *dev, Error **errp) "ac97-nabm", 256); pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io_nam); pci_register_bar(&s->dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &s->io_nabm); - AUD_register_card("ac97", &s->card); + ac97_on_reset(DEVICE(s)); } =20 diff --git a/hw/audio/adlib.c b/hw/audio/adlib.c index 5f979b1487d..bd73806d83a 100644 --- a/hw/audio/adlib.c +++ b/hw/audio/adlib.c @@ -255,6 +255,10 @@ static void adlib_realizefn (DeviceState *dev, Error *= *errp) AdlibState *s =3D ADLIB(dev); struct audsettings as; =20 + if (!AUD_register_card ("adlib", &s->card, errp)) { + return; + } + s->opl =3D OPLCreate (3579545, s->freq); if (!s->opl) { error_setg (errp, "OPLCreate %d failed", s->freq); @@ -270,8 +274,6 @@ static void adlib_realizefn (DeviceState *dev, Error **= errp) as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D AUDIO_HOST_ENDIANNESS; =20 - AUD_register_card ("adlib", &s->card); - s->voice =3D AUD_open_out ( &s->card, s->voice, diff --git a/hw/audio/cs4231a.c b/hw/audio/cs4231a.c index 5c6d6437320..3aa105748d3 100644 --- a/hw/audio/cs4231a.c +++ b/hw/audio/cs4231a.c @@ -678,13 +678,15 @@ static void cs4231a_realizefn (DeviceState *dev, Erro= r **errp) return; } =20 + if (!AUD_register_card ("cs4231a", &s->card, errp)) { + return; + } + s->pic =3D isa_bus_get_irq(bus, s->irq); k =3D ISADMA_GET_CLASS(s->isa_dma); k->register_channel(s->isa_dma, s->dma, cs_dma_read, s); =20 isa_register_ioport (d, &s->ioports, s->port); - - AUD_register_card ("cs4231a", &s->card); } =20 static Property cs4231a_properties[] =3D { diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c index 4f738a0ad88..90f73d4c23d 100644 --- a/hw/audio/es1370.c +++ b/hw/audio/es1370.c @@ -853,6 +853,10 @@ static void es1370_realize(PCIDevice *dev, Error **err= p) ES1370State *s =3D ES1370(dev); uint8_t *c =3D s->dev.config; =20 + if (!AUD_register_card ("es1370", &s->card, errp)) { + return; + } + c[PCI_STATUS + 1] =3D PCI_STATUS_DEVSEL_SLOW >> 8; =20 #if 0 @@ -868,7 +872,6 @@ static void es1370_realize(PCIDevice *dev, Error **errp) memory_region_init_io (&s->io, OBJECT(s), &es1370_io_ops, s, "es1370",= 256); pci_register_bar (&s->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io); =20 - AUD_register_card ("es1370", &s->card); es1370_reset (s); } =20 diff --git a/hw/audio/gus.c b/hw/audio/gus.c index 787345ce543..6c2b586ca71 100644 --- a/hw/audio/gus.c +++ b/hw/audio/gus.c @@ -241,14 +241,16 @@ static void gus_realizefn (DeviceState *dev, Error **= errp) IsaDmaClass *k; struct audsettings as; =20 + if (!AUD_register_card ("gus", &s->card, errp)) { + return; + } + s->isa_dma =3D isa_bus_get_dma(bus, s->emu.gusdma); if (!s->isa_dma) { error_setg(errp, "ISA controller does not support DMA"); return; } =20 - AUD_register_card ("gus", &s->card); - as.freq =3D s->freq; as.nchannels =3D 2; as.fmt =3D AUDIO_FORMAT_S16; diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index a26048cf15e..b9ad1f4c39e 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -685,11 +685,14 @@ static void hda_audio_init(HDACodecDevice *hda, const desc_param *param; uint32_t i, type; =20 + if (!AUD_register_card("hda", &a->card, errp)) { + return; + } + a->desc =3D desc; a->name =3D object_get_typename(OBJECT(a)); dprint(a, 1, "%s: cad %d\n", __func__, a->hda.cad); =20 - AUD_register_card("hda", &a->card); for (i =3D 0; i < a->desc->nnodes; i++) { node =3D a->desc->nodes + i; param =3D hda_codec_find_param(node, AC_PAR_AUDIO_WIDGET_CAP); diff --git a/hw/audio/lm4549.c b/hw/audio/lm4549.c index 418041bc9c6..e7bfcc4b9fe 100644 --- a/hw/audio/lm4549.c +++ b/hw/audio/lm4549.c @@ -281,6 +281,11 @@ void lm4549_init(lm4549_state *s, lm4549_callback data= _req_cb, void* opaque, { struct audsettings as; =20 + /* Register an audio card */ + if (!AUD_register_card("lm4549", &s->card, errp)) { + return; + } + /* Store the callback and opaque pointer */ s->data_req_cb =3D data_req_cb; s->opaque =3D opaque; @@ -288,9 +293,6 @@ void lm4549_init(lm4549_state *s, lm4549_callback data_= req_cb, void* opaque, /* Init the registers */ lm4549_reset(s); =20 - /* Register an audio card */ - AUD_register_card("lm4549", &s->card); - /* Open a default voice */ as.freq =3D 48000; as.nchannels =3D 2; diff --git a/hw/audio/pcspk.c b/hw/audio/pcspk.c index daf92a4ce11..fe7f07ced21 100644 --- a/hw/audio/pcspk.c +++ b/hw/audio/pcspk.c @@ -123,8 +123,6 @@ static int pcspk_audio_init(PCSpkState *s) return 0; } =20 - AUD_register_card(s_spk, &s->card); - s->voice =3D AUD_open_out(&s->card, s->voice, s_spk, s, pcspk_callback= , &as); if (!s->voice) { AUD_log(s_spk, "Could not open voice\n"); @@ -191,7 +189,7 @@ static void pcspk_realizefn(DeviceState *dev, Error **e= rrp) =20 isa_register_ioport(isadev, &s->ioport, s->iobase); =20 - if (s->card.state) { + if (s->card.state && AUD_register_card(s_spk, &s->card, errp)) { pcspk_audio_init(s); } =20 diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c index 535ccccdc98..18f6d252db3 100644 --- a/hw/audio/sb16.c +++ b/hw/audio/sb16.c @@ -1402,6 +1402,10 @@ static void sb16_realizefn (DeviceState *dev, Error = **errp) SB16State *s =3D SB16 (dev); IsaDmaClass *k; =20 + if (!AUD_register_card ("sb16", &s->card, errp)) { + return; + } + s->isa_hdma =3D isa_bus_get_dma(bus, s->hdma); s->isa_dma =3D isa_bus_get_dma(bus, s->dma); if (!s->isa_dma || !s->isa_hdma) { @@ -1434,8 +1438,6 @@ static void sb16_realizefn (DeviceState *dev, Error *= *errp) k->register_channel(s->isa_dma, s->dma, SB_read_DMA, s); =20 s->can_write =3D 1; - - AUD_register_card ("sb16", &s->card); } =20 static Property sb16_properties[] =3D { diff --git a/hw/audio/via-ac97.c b/hw/audio/via-ac97.c index 676254b7a40..30095a4c7aa 100644 --- a/hw/audio/via-ac97.c +++ b/hw/audio/via-ac97.c @@ -426,6 +426,10 @@ 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_register_card ("via-ac97", &s->card, errp)) { + return; + } + /* * Command register Bus Master bit is documented to be fixed at 0 but = it's * needed for PCI DMA to work in QEMU. The pegasos2 firmware writes 0 = here @@ -445,8 +449,6 @@ static void via_ac97_realize(PCIDevice *pci_dev, Error = **errp) pci_register_bar(pci_dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &s->fm); memory_region_init_io(&s->midi, o, &midi_ops, s, "via-ac97.midi", 4); pci_register_bar(pci_dev, 2, PCI_BASE_ADDRESS_SPACE_IO, &s->midi); - - AUD_register_card ("via-ac97", &s->card); } =20 static void via_ac97_exit(PCIDevice *dev) diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c index b5722b37c36..57954a63144 100644 --- a/hw/audio/wm8750.c +++ b/hw/audio/wm8750.c @@ -624,7 +624,10 @@ static void wm8750_realize(DeviceState *dev, Error **e= rrp) { WM8750State *s =3D WM8750(dev); =20 - AUD_register_card(CODEC, &s->card); + if (!AUD_register_card(CODEC, &s->card, errp)) { + return; + } + wm8750_reset(I2C_SLAVE(s)); } =20 diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c index 341e91e886f..eee8f33a584 100644 --- a/hw/display/xlnx_dp.c +++ b/hw/display/xlnx_dp.c @@ -1302,6 +1302,10 @@ static void xlnx_dp_realize(DeviceState *dev, Error = **errp) DisplaySurface *surface; struct audsettings as; =20 + if (!AUD_register_card("xlnx_dp.audio", &s->aud_card, errp)) { + return; + } + aux_bus_realize(s->aux_bus); =20 qdev_realize(DEVICE(s->dpcd), BUS(s->aux_bus), &error_fatal); @@ -1320,8 +1324,6 @@ static void xlnx_dp_realize(DeviceState *dev, Error *= *errp) as.fmt =3D AUDIO_FORMAT_S16; as.endianness =3D 0; =20 - AUD_register_card("xlnx_dp.audio", &s->aud_card); - s->amixer_output_stream =3D AUD_open_out(&s->aud_card, s->amixer_output_stream, "xlnx_dp.audio.out", diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c index e7960a50696..950506fb382 100644 --- a/hw/input/tsc210x.c +++ b/hw/input/tsc210x.c @@ -1102,7 +1102,7 @@ static void tsc210x_init(TSC210xState *s, s->card.name =3D g_strdup(current_machine->audiodev); s->card.state =3D audio_state_by_name(s->card.name, &error_fatal); } - AUD_register_card(s->name, &s->card); + AUD_register_card(s->name, &s->card, &error_fatal); =20 qemu_register_reset((void *) tsc210x_reset, s); vmstate_register(NULL, 0, vmsd, s); diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c index 8748c1ba040..d5ac1f8962e 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -944,12 +944,15 @@ static void usb_audio_realize(USBDevice *dev, Error *= *errp) USBAudioState *s =3D USB_AUDIO(dev); int i; =20 + if (!AUD_register_card(TYPE_USB_AUDIO, &s->card, errp)) { + return; + } + dev->usb_desc =3D s->multi ? &desc_audio_multi : &desc_audio; =20 usb_desc_create_serial(dev); usb_desc_init(dev); s->dev.opaque =3D s; - AUD_register_card(TYPE_USB_AUDIO, &s->card); =20 s->out.altset =3D ALTSET_OFF; s->out.vol.mute =3D false; --=20 2.41.0 From nobody Fri May 17 10:44:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695977667; cv=none; d=zohomail.com; s=zohoarc; b=gkJoQMcMnZnI8bOQ4bfqPib+aZnRkYNDNIIUBv742IRL4aP2jEHt/eLLUr69icxvAK8VM2eg6cgfMIQ1h2aw40S+9/KnnNPV3KQQE7VLvVkyExYaNWEXGzAHyGAILOQWu/9uaHV2QnW72See6huWTMlMSlsA35DnKzGSvt2hYPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695977667; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f6lElwUIbLdoz65hukixK+VcaOx6Q0d9fx35MRKLQtU=; b=LmmJQN0f3A2GwYu0XVAAmHXZfwXMdrBDeXgXKU1GimPhQYcLzQmMFDCTj1Qb8L55X0S7utbNCNjBJYtlaaWSoem05AKL/dz153N5jPNxuOItr+s8ZrBAJx+Ebzq0CAChpng77DkPm3/EHqeTSQ9mCUtfXdchOXnUPEZv2BqUw5A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695977667591170.10404319449538; Fri, 29 Sep 2023 01:54:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qm9ET-0006fx-10; Fri, 29 Sep 2023 04:52:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qm9EQ-0006at-Vx for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:19 -0400 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 1qm9E3-0005oO-HJ for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:18 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-180-wFi-eXwuPoGLR46VFY_GPw-1; Fri, 29 Sep 2023 04:51:44 -0400 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-531373ea109so11304412a12.3 for ; Fri, 29 Sep 2023 01:51:44 -0700 (PDT) Received: from [192.168.1.174] ([151.48.237.81]) by smtp.gmail.com with ESMTPSA id j5-20020aa7c405000000b00537708be5c6sm542827edq.73.2023.09.29.01.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 01:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695977507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f6lElwUIbLdoz65hukixK+VcaOx6Q0d9fx35MRKLQtU=; b=CWS5aqcN1antLRMHVPB1c6GaaUj4AJE+UXUizW9p6IHuEYgX4TZN1kLrxkCy3bJkPnpKpk 7iiRqgljN386gjI3uIS7zDgxb76HB2UXIszRys4rX8cTcR4hN94pB5cRknPZ0XigO2vGjh VFhpSs6u2ZdgAF4ed9hx3dTbry+zgJQ= X-MC-Unique: wFi-eXwuPoGLR46VFY_GPw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695977502; x=1696582302; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f6lElwUIbLdoz65hukixK+VcaOx6Q0d9fx35MRKLQtU=; b=v+Lhyc9I6qIaMgP3NBfhYkpmeDArSGvROo7mmUTwCm1iCSrs/mXJK385j6nlAtbzp1 gCUCnhBJU+UZoVv9roZHpSmFid+ofeYdNYtuR8Khxab6dL6igHe7bVl+43OhP04XE6ND AAYJdFxG9lcSO+GAUslK/4XL4mstQ+lW9i2FgQi7I0iEGWnX8axBqLvfOUMGF2/Bw0bo vYU7ZafibDHbdi/xi3ZzKNXdLKr8MN1UIcDVMpYZkmL09tDcGWqlwtTshRNKybivQ/hc 9bGbNs6DU6CkgFT0oT/0+Y4vtDPxcWG4Jn/gh02zWfDgHpiz3Sp5J33Xthl25unqKgNj 3/pQ== X-Gm-Message-State: AOJu0Yy4Ov/DalZRPULoqo+zkydAa7I9dpJJZ6z8izaPq8nRfUA3wtlU IU35x1Z7+JzLBZmkrXDKnvFUeaL9AqDy9lKklZvBPlzXEJMhz+ehX80dKaGJdyhqQ9a+D3RU8pD 1wpOr17zwo9sxUOsDR6lKEYq3ARijfEAfInCXgqSZtRldCRSSRO3v3lgEc5PPaLK81OvlbnOiQe c= X-Received: by 2002:a05:6402:3454:b0:536:2b33:83ed with SMTP id l20-20020a056402345400b005362b3383edmr3622328edc.24.1695977502696; Fri, 29 Sep 2023 01:51:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAq+gZD2rWb+vGdqUjdiuOFd8NtFse+GDOv/rFHo2rojP9c7ctUXk27tT1jMlm0AKcnLcLnw== X-Received: by 2002:a05:6402:3454:b0:536:2b33:83ed with SMTP id l20-20020a056402345400b005362b3383edmr3622315edc.24.1695977502462; Fri, 29 Sep 2023 01:51:42 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, balaton@eik.bme.hu Subject: [PATCH v3 13/14] audio: forbid default audiodev backend with -nodefaults Date: Fri, 29 Sep 2023 10:51:06 +0200 Message-ID: <20230929085112.983957-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929085112.983957-1-pbonzini@redhat.com> References: <20230929085112.983957-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695977668783100001 Content-Type: text/plain; charset="utf-8" Now that all callers support setting an audiodev, forbid using the default audiodev if -nodefaults is provided on the command line. Signed-off-by: Paolo Bonzini --- audio/audio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index f0788345bf8..7cfcbfb6ef1 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1806,10 +1806,12 @@ static AudioState *audio_init(Audiodev *dev) bool AUD_register_card (const char *name, QEMUSoundCard *card, Error **err= p) { if (!card->state) { - if (!QSIMPLEQ_EMPTY(&audiodevs)) { + if (!QSIMPLEQ_EMPTY(&audiodevs) || !defaults_enabled()) { error_setg(errp, "No audiodev specified for %s", name); - error_append_hint(errp, "Perhaps you wanted to set audiodev=3D= %s?", - QSIMPLEQ_FIRST(&audiodevs)->dev->id); + if (!QSIMPLEQ_EMPTY(&audiodevs)) { + error_append_hint(errp, "Perhaps you wanted to set audiode= v=3D%s?", + QSIMPLEQ_FIRST(&audiodevs)->dev->id); + } return false; } =20 --=20 2.41.0 From nobody Fri May 17 10:44:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695977806; cv=none; d=zohomail.com; s=zohoarc; b=kF28Pa8zVfKWXdpNDZxm1wLL2ChLYQT0xTnbf2+E3c5LCLVoDSi/axgCFiWNVryipvw1YbMx8wVEpoOB4KHFWOSH5PGu99xSRehXZm+d1yJ1KtfxSCueZjfV92PtqQ4l7hv8sfhDTlajplfaTQQzc944Cc+PROjZ58gf9ag3lfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695977806; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w+4EgO9bvE1CYPSJHgSwK6cuXzMcRh2RzpgVET0+boo=; b=FaCzqCURvq11H0371GRd8jzuv0BabmSOznNY3G6S9r65spQplzG0NW4jVNmrEkVJnuZhQ4puFCWsFooGZR8EjeWx2mim0ukDV1rnyR86D7z355QaQu7mLasEZl2/PJehEZfUQplmuWMzuyIWS4Vw90iRM83vU0SWjzGKkRqFq3Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169597780647546.67093691405296; Fri, 29 Sep 2023 01:56:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qm9EN-0006NR-Kn; Fri, 29 Sep 2023 04:52:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qm9EG-0006BI-13 for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:08 -0400 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 1qm9E6-0005pv-MU for qemu-devel@nongnu.org; Fri, 29 Sep 2023 04:52:07 -0400 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-Gkmzx0TEP0-VK8_mbOLRsA-1; Fri, 29 Sep 2023 04:51:46 -0400 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-536294c9526so1364420a12.3 for ; Fri, 29 Sep 2023 01:51:46 -0700 (PDT) Received: from [192.168.1.174] ([151.48.237.81]) by smtp.gmail.com with ESMTPSA id fd18-20020a056402389200b005331f6d4a30sm5250038edb.56.2023.09.29.01.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 01:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695977507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w+4EgO9bvE1CYPSJHgSwK6cuXzMcRh2RzpgVET0+boo=; b=AwOwsXfrPxSClRmfhuPsfv0ETD6emGNuiDnvOW2fwOGMcUnY4CZAhGI1QJ2SzHM03mIYtY yAKMfH8B/t/fx20amX8UxCoCiYMDN+S7jPKSEN6pm6VYj1PqM9l/HQnTEAdWbpLs5N+uNp whwM9mgXQLyWv1LBoRKx3ujPWN9COFw= X-MC-Unique: Gkmzx0TEP0-VK8_mbOLRsA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695977504; x=1696582304; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w+4EgO9bvE1CYPSJHgSwK6cuXzMcRh2RzpgVET0+boo=; b=uLJx8BeSnjAKCeBMg70veQU8OV/dEzh94n7+9U3LoZlUI6VApvTPXur5ScRRFFIeKY TOXhRzJXdQyeQQlm5GVVjmS+UfwWvddv7mrkyznpgnMXa34LqmSj5oKsbX+laLuJPTNa g4ncOikJ/k9K/U+i5KcUHIx1MV3we4ns6Mv19HZI6I2LXNSkNA5+iOtf/QiUsVGQkM82 g/5k/i1w+B9zUbpL5QWtI9G9n2ZXhVGRQdw3mFByT/YsDalT7fbNVZEqPw7YFCwgzPBA 1A4wy/w76i4+gll3KymBb/5CRwu2Kij66ObhPygpQuybRGXSZekaLA6oAG6KHyYb7aaw szKw== X-Gm-Message-State: AOJu0YwiydysCg0MVYXUruwN2xSoOORqmbhyxkiShG8C+1fUXQvCd4JP X9xhtjEmYNeJThNRHDEkunqKjvzHVBBIB1Y1JjUi3mA7Ua1y2dhMZHODqyFTznMKWng1ClBoDWE f8XlProsakiXgD1Vov5rqPnBfL6H8o/IuiR4CuMMrUo0gK0KZdtpRZaUdrRr7dH/In48/8JFA7y A= X-Received: by 2002:a05:6402:d59:b0:537:821e:b8fd with SMTP id ec25-20020a0564020d5900b00537821eb8fdmr728979edb.27.1695977504577; Fri, 29 Sep 2023 01:51:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHanz6Q7xqVsktn7FtMktoPZhuZzTXtshU2u2La9ZpAFFOr6wO1dDHv/LzcvjPwmdcc9ByeRg== X-Received: by 2002:a05:6402:d59:b0:537:821e:b8fd with SMTP id ec25-20020a0564020d5900b00537821eb8fdmr728963edb.27.1695977504182; Fri, 29 Sep 2023 01:51:44 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: berrange@redhat.com, balaton@eik.bme.hu Subject: [PATCH v3 14/14] audio: propagate Error out of audio_driver_init Date: Fri, 29 Sep 2023 10:51:07 +0200 Message-ID: <20230929085112.983957-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929085112.983957-1-pbonzini@redhat.com> References: <20230929085112.983957-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695977807063100005 Content-Type: text/plain; charset="utf-8" Now that all the callers of audio_init can report failure, pass the Error from audio_driver_init to audio_init instead of reporting it directly in audio_driver_init. This eliminates more complex logic that calls error_report_err and error_init, replacing it with just &error_fatal (when creating command line audiodevs) and error propagation (when creating default audiodevs from AUD_register_card). Signed-off-by: Paolo Bonzini --- audio/audio.c | 31 ++++++++++++++----------------- audio/audio.h | 2 +- softmmu/vl.c | 4 +--- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 7cfcbfb6ef1..380da72a7b0 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1556,7 +1556,7 @@ size_t audio_generic_read(HWVoiceIn *hw, void *buf, s= ize_t size) } =20 static int audio_driver_init(AudioState *s, struct audio_driver *drv, - bool msg, Audiodev *dev) + Audiodev *dev, Error **errp) { Error *local_err =3D NULL; =20 @@ -1577,12 +1577,10 @@ static int audio_driver_init(AudioState *s, struct = audio_driver *drv, s->drv =3D drv; return 0; } else { - if (!msg) { - error_free(local_err); - } else if (local_err) { - error_report_err(local_err); + if (local_err) { + error_propagate(errp, local_err); } else { - error_report("Could not init `%s' audio driver", drv->name); + error_setg(errp, "Could not init `%s' audio driver", drv->name= ); } return -1; } @@ -1733,7 +1731,7 @@ static void audio_create_default_audiodevs(void) * if dev =3D=3D NULL =3D> legacy implicit initialization, return the alre= ady created * state or create a new one */ -static AudioState *audio_init(Audiodev *dev) +static AudioState *audio_init(Audiodev *dev, Error **errp) { static bool atexit_registered; int done =3D 0; @@ -1760,9 +1758,9 @@ static AudioState *audio_init(Audiodev *dev) drvname =3D AudiodevDriver_str(dev->driver); driver =3D audio_driver_lookup(drvname); if (driver) { - done =3D !audio_driver_init(s, driver, true, dev); + done =3D !audio_driver_init(s, driver, dev, errp); } else { - dolog ("Unknown audio driver `%s'\n", drvname); + error_setg(errp, "Unknown audio driver `%s'\n", drvname); } if (!done) { free_audio_state(s); @@ -1778,7 +1776,7 @@ static AudioState *audio_init(Audiodev *dev) s->dev =3D dev =3D e->dev; drvname =3D AudiodevDriver_str(dev->driver); driver =3D audio_driver_lookup(drvname); - if (!audio_driver_init(s, driver, false, dev)) { + if (!audio_driver_init(s, driver, dev, NULL)) { break; } QSIMPLEQ_REMOVE_HEAD(&default_audiodevs, next); @@ -1821,7 +1819,10 @@ bool AUD_register_card (const char *name, QEMUSoundC= ard *card, Error **errp) if (QSIMPLEQ_EMPTY(&default_audiodevs)) { audio_create_default_audiodevs(); } - card->state =3D audio_init(NULL); + card->state =3D audio_init(NULL, errp); + if (!card->state) { + return false; + } } } =20 @@ -2157,17 +2158,13 @@ void audio_define(Audiodev *dev) QSIMPLEQ_INSERT_TAIL(&audiodevs, e, next); } =20 -bool audio_init_audiodevs(void) +void audio_init_audiodevs(void) { AudiodevListEntry *e; =20 QSIMPLEQ_FOREACH(e, &audiodevs, next) { - if (!audio_init(e->dev)) { - return false; - } + audio_init(e->dev, &error_fatal); } - - return true; } =20 audsettings audiodev_to_audsettings(AudiodevPerDirectionOptions *pdo) diff --git a/audio/audio.h b/audio/audio.h index 70b264d897d..80f3f92124d 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -170,7 +170,7 @@ void audio_sample_from_uint64(void *samples, int pos, =20 void audio_define(Audiodev *audio); void audio_parse_option(const char *opt); -bool audio_init_audiodevs(void); +void audio_init_audiodevs(void); void audio_help(void); =20 AudioState *audio_state_by_name(const char *name, Error **errp); diff --git a/softmmu/vl.c b/softmmu/vl.c index cafb1a98427..98e071e63bb 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1962,9 +1962,7 @@ static void qemu_create_early_backends(void) * setting machine properties, so they can be referred to. */ configure_blockdev(&bdo_queue, machine_class, snapshot); - if (!audio_init_audiodevs()) { - exit(1); - } + audio_init_audiodevs(); } =20 =20 --=20 2.41.0