From: Geoffrey McRae <geoff@hostfission.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: "BALATON Zoltan" <balaton@eik.bme.hu>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Alexandre Ratchov" <alex@caoua.org>,
qemu-devel@nongnu.org, "Gerd Hoffmann" <kraxel@redhat.com>,
"Thomas Huth" <huth@tuxfamily.org>,
"Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>,
dirty.ice.hu@gmail.com,
"Christian Schoenebeck" <qemu_oss@crudebyte.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Volker Rümelin" <vr_qemu@t-online.de>
Subject: Re: [RFC 00/24] audio: add GStreamer backend
Date: Wed, 03 Dec 2025 01:43:58 +1100 [thread overview]
Message-ID: <c32f11e604bbcd86d1c2c9d2b4b57d5a@hostfission.com> (raw)
In-Reply-To: <CAJ+F1C+9eD_Qp7hGMjVHEbttbOxGpCZ4T8tVS+woAk7odWukHA@mail.gmail.com>
Hi,
On 2025-12-03 01:14, Marc-André Lureau wrote:
> Hi
>
> On Tue, Dec 2, 2025 at 5:26 PM Geoffrey McRae <geoff@hostfission.com>
> wrote:
>>
>>
>>
>> On 2025-12-02 23:44, Marc-André Lureau wrote:
>> > Hi Geoffrey
>> >
>> > On Tue, Dec 2, 2025 at 4:31 PM Geoffrey McRae
>> > <geoff@hostfission.com> wrote:
>> >
>> >> The PipeWire and PulseAudio backends are used by a large number of
>> >> users
>> >> in the VFIO community. Removing these would be an enormous determent
>> >> to
>> >> QEMU.
>> >
>> > They come with GStreamer pulse/pipe elements.
>>
>> Yes, but through another layer of abstraction/complexity with no real
>> benefit.
>
> The benefit is that QEMU would not have to maintain 10 backends and
> all the audio mixing/resampling. The QEMU code would be simpler and
> more maintainable overall. GStreamer has a clear pipeline design,
> better suited (optimized code etc) and you can easily modify the
> pipeline settings.
Yes, I suppose I can see it from that point of view provided that the
advanced features of GStreamer, such as user defined audio graphs, are
never exposed to the user to configure. I can just imagine the false bug
report nightmare this would induce (buggy plugins, etc).
>
>>
>> >
>> >> Audio output from QEMU has always been problematic, but with the
>> >> PulseAudio and later, the PipeWire interface, it became much more
>> >> user
>> >> friendly for those that wanted to configure the VM to output native
>> >> audio into their sound plumbing.
>> >
>> > Could you be more specific?
>>
>> There are clock sync/drift issues with the emulated hardware device's
>> audio clock and the real hardware audio clock. GStreamer won't solve
>> this, it requires a tuned PID loop that resamples the audio to
>> compensate for the continual drift between the emulated and hardware
>> clocks. Without this, over time, the audio can and does get wildly out
>> of sync eventually resulting in xruns.
>
> That's indeed a complicated subject and hard to test & measure. Adding
> some testing to our audio infra should help identify this better. Not
> sure when time permits though.
>
> It seems to me that the current QEMU audio code is using the
> virtual/system clock timer to pull the data at a regular pace, which
> is not in sync with the actual audio sink clock. The GStreamer
> pipeline, otoh, uses the audio sink clock. But there are other
> emulated devices related issues (like hda not sending data when asked,
> or later, it has to be pulled regularly etc). I need to study this in
> more detail, this GStreamer implementation is a bit naive there.
>
Yes, this is the primary issue here. I believe that solving this is more
complicated then it appears however as headless systems that are using
SPICE for audio wont have an audio clock to sync to.
>
>>
>> All you have to do is google for "QEMU Crackling Sound". JACK,
>> PipeWire
>> and PulseAudio manage to mostly hide (not sovle) this issue from the
>> user, but it still occurs. It's worse for SPICE clients as the audio
>> gets buffered in the network stack rather then dropped and can lead to
>> many seconds of audio latency.
>
> Yes, I think synchronization of audio/video playback for remoting is
> another issue, if QEMU has the audio & video frames in sync which can
> provide correct timestamps.
Note that I am referring to a SPICE client that only subscribes to the
audio stream and not video, as is the case for Looking Glass as it uses
an out of band mechanism to obtain the passthrough GPUs output. This is
also occurs on the local host via a unix socket.
I do not think this aspect can be solved in QEMU, but rather must be
solved in the SPICE client
See here if you're interested how we did this:
https://github.com/gnif/LookingGlass/blob/53bfb6547f2b7abd6c183192e13a57068c1677ea/client/src/audio.c
>
>>
>> As for applications, we have a large number of people using QEMU/KVM
>> with full GPU pass-through for gaming workloads, many of which route
>> the
>> QEMU audio into PipeWire/JACK directly which enables the host's sound
>> server to perform DSP and mixing, etc.
>>
>> Others are streaming the guest via Looking Glass for the video feed,
>> and
>> using PipeWire from QEMU to feed into OBS for live streaming setups.
>>
>> The flexibility that JACK & PipeWire bring to the table can not be
>> overstated. From a maintenance point of view, JACK and PipeWire are
>> only
>> ~800 lines of code each, fully self contained and very easy to debug.
>>
>> All the audio processing/mixing/resampling/routing (and any user
>> configured DSP) is fully offloaded to the host's audio server, where
>> it
>> should be.
>
> (by default QEMU is still doing resampling & mixing, and adds extra
> buffering)
>
> A GStreamer backend should not be incompatible with those use cases.
>
In that case, i'd suggest that if possible the GStreamber back end
maintains the same port and node names it presents to Jack/PipeWire to
make the transition from the other audio backends to GStreamer as
painless as possible.
> [..]
>> deprecated, I really think that effort should be put into implementing
>> a
>> WASAPI backend for QEMU.
>>
>> I really do not think that adding all the complexity of GStreamer to
>> QEMU is the right way forward. We should just hand off the audio
>> processing to the host system's sound server (as we do already),
>> whatever it might be, and let it do the heavy lifting.
>
> I agree with the goal that we should leave most of the work to the
> host, and not have to do audio mixing resampling ourself whenever
> possible. Imho, GStreamer allows us to do that in less and cleaner
> code.
Great, as long as we don't let user's configure GStreamer's more
advanced features its should be ok then.
next prev parent reply other threads:[~2025-12-02 14:44 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 11:22 [RFC 00/24] audio: add GStreamer backend marcandre.lureau
2025-12-01 11:22 ` [RFC 01/24] rust: patch thiserror to work with meson marcandre.lureau
2025-12-01 11:22 ` [RFC 02/24] audio: remove obsolete/obscure functions marcandre.lureau
2025-12-10 14:02 ` Akihiko Odaki
2025-12-01 11:22 ` [RFC 03/24] audio/dbus: make "dbus" the default backend when using -display dbus marcandre.lureau
2025-12-10 14:03 ` Akihiko Odaki
2025-12-01 11:22 ` [RFC 04/24] qemu-options.hx: clarify default audio backend selection marcandre.lureau
2025-12-01 11:22 ` [RFC 05/24] audio: introduce AudioDriver marcandre.lureau
2025-12-11 5:22 ` Akihiko Odaki
2025-12-01 11:22 ` [RFC 06/24] audio: simplify audio_init() marcandre.lureau
2025-12-01 11:22 ` [RFC 07/24] audio: move object creation to audio_driver_init() marcandre.lureau
2025-12-01 11:22 ` [RFC 08/24] audio: add QOM module-objects for each backend marcandre.lureau
2025-12-01 13:20 ` BALATON Zoltan
2025-12-01 18:43 ` Marc-André Lureau
2025-12-01 11:22 ` [RFC 09/24] audio: remove set_dbus_server from audio_driver marcandre.lureau
2025-12-01 11:22 ` [RFC 10/24] audio: lookup "audio-" object types, and realize them marcandre.lureau
2025-12-01 11:22 ` [RFC 11/24] audio: switch to module-object, drop audio driver registration marcandre.lureau
2025-12-01 11:22 ` [RFC 12/24] module: remove audio module support marcandre.lureau
2025-12-01 11:22 ` [RFC 13/24] audio: keep a strong reference on the backend marcandre.lureau
2025-12-01 11:22 ` [RFC 14/24] audio: make list type declaration private marcandre.lureau
2025-12-01 11:22 ` [RFC 15/24] audio: make create_pdos() private marcandre.lureau
2025-12-01 11:22 ` [RFC 16/24] replay: remove dependency on audio/ marcandre.lureau
2025-12-01 11:22 ` [RFC 17/24] audio: make all the backend-specific APIs take the be marcandre.lureau
2025-12-01 11:22 ` [RFC 18/24] audio: make AudioBackend truely abstract marcandre.lureau
2025-12-01 11:23 ` [RFC 19/24] audio: split AudioBackend marcandre.lureau
2025-12-01 11:23 ` [RFC 20/24] audio: AUD_ -> audio_be_ marcandre.lureau
2025-12-01 11:23 ` [RFC 21/24] audio-be: add common pre-conditions marcandre.lureau
2025-12-01 11:23 ` [RFC 22/24] audio-be: add some state trace marcandre.lureau
2025-12-01 11:23 ` [RFC 23/24] audio: split AudioDriver code in audio-driver.c marcandre.lureau
2025-12-01 11:23 ` [RFC 24/24] WIP: rust/audio: add GStreamer backend marcandre.lureau
2025-12-01 13:12 ` Markus Armbruster
2025-12-01 18:26 ` Marc-André Lureau
2025-12-01 13:02 ` [RFC 00/24] audio: " BALATON Zoltan
2025-12-01 13:41 ` Christian Schoenebeck
2025-12-01 18:20 ` Marc-André Lureau
2025-12-01 19:30 ` BALATON Zoltan
2025-12-01 19:44 ` Daniel P. Berrangé
2025-12-02 12:01 ` BALATON Zoltan
2025-12-01 20:58 ` Alexandre Ratchov
2025-12-02 7:55 ` Paolo Bonzini
2025-12-02 12:03 ` BALATON Zoltan
2025-12-02 12:25 ` Geoffrey McRae
2025-12-02 12:44 ` Marc-André Lureau
2025-12-02 13:25 ` Geoffrey McRae
2025-12-02 14:14 ` Marc-André Lureau
2025-12-02 14:33 ` Neal Gompa
2025-12-02 14:43 ` Geoffrey McRae [this message]
2025-12-02 14:52 ` Markus Armbruster
2025-12-03 9:19 ` Akihiko Odaki
2025-12-02 15:39 ` Christian Schoenebeck
2025-12-03 8:06 ` Alexandre Ratchov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c32f11e604bbcd86d1c2c9d2b4b57d5a@hostfission.com \
--to=geoff@hostfission.com \
--cc=alex@caoua.org \
--cc=balaton@eik.bme.hu \
--cc=dirty.ice.hu@gmail.com \
--cc=huth@tuxfamily.org \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu_oss@crudebyte.com \
--cc=vr_qemu@t-online.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).