From nobody Fri May 3 16:13:24 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=reject dis=none) header.from=hostfission.com ARC-Seal: i=1; a=rsa-sha256; t=1641699875; cv=none; d=zohomail.com; s=zohoarc; b=gtYKj1Lva4Yn4w7zU2W8b7JqAZJccb9hg7lO6VqfWBbj0UTTJWi7iM/u+0F1XgrA4eHNy4Ykz5TXTSYXcf1EepsrjMy+gL+wcl6HPRJLEPCB6RBiWtyxaXhs6SCHQDZQ2mqBb+1ZU4vuQTracZiVLNGQy7QiE4HJZFbz7aGuY6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641699875; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=yhX4tLivj+o3FvQEGUBQt3jPT6yOtOW76ksW5V9Z4Xc=; b=eY+KqLaR/ApJx2ZoP8ZOGnV4RKpogH0vXSYysbanUvZ0guE3LEZMTstjJ5fUNViRxgtclotyk5uKDnR4VgFms09o8iefYeZ8g+8DA1Px6s7xoWpnzeCEsQzrwfuXPncdf5e0D/n/AltXd/hdoXJ6kKlFRImljPehNuXdPT6I2Cs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641699875484637.8248179246883; Sat, 8 Jan 2022 19:44:35 -0800 (PST) Received: from localhost ([::1]:51468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6P8D-0007lB-IL for importer@patchew.org; Sat, 08 Jan 2022 22:44:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6P73-000756-Hs for qemu-devel@nongnu.org; Sat, 08 Jan 2022 22:43:21 -0500 Received: from mail1.hostfission.com ([139.99.139.48]:58560) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6P71-0004h5-Nl for qemu-devel@nongnu.org; Sat, 08 Jan 2022 22:43:21 -0500 Received: from aeryn.lan.ktmba (office.hostfission.com [220.233.29.71]) by mail1.hostfission.com (Postfix) with ESMTPS id 8DC12424E1; Sun, 9 Jan 2022 14:33:34 +1100 (AEDT) Received: by aeryn.lan.ktmba (Postfix, from userid 1000) id 70E882E2363; Sun, 9 Jan 2022 14:33:34 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hostfission.com; s=mail; t=1641699214; bh=Iyoq/BoYWUcF57f1LgWE1nzh9qw4I1xihVVqM7dRTrk=; h=From:To:Cc:Subject:Date:From; b=GLYHXEaRscJib9rpwjzkwwpthEgobLnf5UViaKpM6gaTPmDKX0nLwxrB3pdv22mQl BTKXmQCF3Q7HOlKPIpSZ8qao6T6oKwqkB2V47w2nJlqqs6FkOcBXXsFMWJcBGQ5u0g k1HkXRklx09+CwypZzt39KDwEd3vMbC/eb8EKWYQ= From: Geoffrey McRae To: qemu-devel@nongnu.org Cc: kraxel@redhat.com, Geoffrey McRae Subject: [PATCH] audio: allow spice buffer_length to be adjusted Date: Sun, 9 Jan 2022 14:33:32 +1100 Message-Id: <20220109033332.402609-1-geoff@hostfission.com> X-Mailer: git-send-email 2.30.2 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: none client-ip=139.99.139.48; envelope-from=geoff@aeryn.lan.ktmba; helo=mail1.hostfission.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NO_DNS_FOR_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_NONE=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" X-ZohoMail-DKIM: pass (identity @hostfission.com) X-ZM-MESSAGEID: 1641699878786100001 Content-Type: text/plain; charset="utf-8" Spice clients that are running directly on the host system have pratcially unlimited bandwidth so to reduce latency allow the user to configure the buffer_length to a lower value if desired. While virt-viewer can not take advantage of this, the PureSpice [1] library used by Looking Glass [2] is able to produce and consume audio at these rates, combined with the merge request for spice-server [3] this allows for latencies close to realtime. [1] https://github.com/gnif/PureSpice [2] https://github.com/gnif/LookingGlass [3] https://gitlab.freedesktop.org/spice/spice/-/merge_requests/199 Signed-off-by: Geoffrey McRae --- audio/spiceaudio.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index a8d370fe6f..0c44bbe836 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -76,7 +76,7 @@ static void *spice_audio_init(Audiodev *dev) if (!using_spice) { return NULL; } - return &spice_audio_init; + return dev; } =20 static void spice_audio_fini (void *opaque) @@ -90,6 +90,8 @@ static int line_out_init(HWVoiceOut *hw, struct audsettin= gs *as, void *drv_opaque) { SpiceVoiceOut *out =3D container_of (hw, SpiceVoiceOut, hw); + Audiodev *dev =3D (Audiodev *)drv_opaque; + struct audsettings settings; =20 #if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= =3D 3 @@ -102,7 +104,12 @@ static int line_out_init(HWVoiceOut *hw, struct audset= tings *as, settings.endianness =3D AUDIO_HOST_ENDIANNESS; =20 audio_pcm_init_info (&hw->info, &settings); - hw->samples =3D LINE_OUT_SAMPLES; + if (dev->u.none.out->has_buffer_length) { + hw->samples =3D audio_buffer_samples(dev->u.none.out, &settings, 1= 0000); + } else { + hw->samples =3D LINE_OUT_SAMPLES; + } + out->active =3D 0; =20 out->sin.base.sif =3D &playback_sif.base; @@ -199,6 +206,7 @@ static void line_out_volume(HWVoiceOut *hw, Volume *vol) static int line_in_init(HWVoiceIn *hw, struct audsettings *as, void *drv_o= paque) { SpiceVoiceIn *in =3D container_of (hw, SpiceVoiceIn, hw); + Audiodev *dev =3D (Audiodev *)drv_opaque; struct audsettings settings; =20 #if SPICE_INTERFACE_RECORD_MAJOR > 2 || SPICE_INTERFACE_RECORD_MINOR >=3D 3 @@ -211,7 +219,12 @@ static int line_in_init(HWVoiceIn *hw, struct audsetti= ngs *as, void *drv_opaque) settings.endianness =3D AUDIO_HOST_ENDIANNESS; =20 audio_pcm_init_info (&hw->info, &settings); - hw->samples =3D LINE_IN_SAMPLES; + if (dev->u.none.out->has_buffer_length) { + hw->samples =3D audio_buffer_samples(dev->u.none.in, &settings, 10= 000); + } else { + hw->samples =3D LINE_IN_SAMPLES; + } + in->active =3D 0; =20 in->sin.base.sif =3D &record_sif.base; --=20 2.30.2