From: BALATON Zoltan <balaton@eik.bme.hu>
Quoting Volker Rümelin: "try-poll=on tells the ALSA backend to try to
use an event loop instead of the audio timer. This works most of the
time. But the poll event handler in the ALSA backend has a bug. For
example, if the guest can't provide enough audio frames in time, the
ALSA buffer is only partly full and the event handler will be called
again and again on every iteration of the main loop. This increases
the processor load and the guest has less processor time to provide
new audio frames in time. I have two examples where a guest can't
recover from this situation and the guest seems to hang."
One reproducer I've found is booting MorphOS demo iso on
qemu-system-ppc -machine pegasos2 -audio alsa which should play a
startup sound but instead it freezes. Even when it does not hang it
plays choppy sound. Volker suggested using command line to set
try-poll=off saying: "The try-poll=off arguments are typically
necessary, because the alsa backend has a design issue with
try-poll=on. If the guest can't provide enough audio frames, it's
really unhelpful to ask for new audio frames on every main loop
iteration until the guest can provide enough audio frames. Timer based
playback doesn't have that problem."
But users cannot easily find this option and having a non-working
default is really unhelpful so to make life easier just set it to
false by default which works until the issue with the alsa backend can
be fixed.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
[ Marc-André - Updated QAPI and CLI doc ]
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20250316002046.D066A4E6004@zero.eik.bme.hu>
---
qapi/audio.json | 2 +-
audio/alsaaudio.c | 2 +-
qemu-options.hx | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/qapi/audio.json b/qapi/audio.json
index dd5a58d13e..49633cf317 100644
--- a/qapi/audio.json
+++ b/qapi/audio.json
@@ -96,7 +96,7 @@
# @period-length: the period length in microseconds
#
# @try-poll: attempt to use poll mode, falling back to non-polling
-# access on failure (default true)
+# access on failure (default false)
#
# Since: 4.0
##
diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index cacae1ea59..9b6c01c0ef 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -899,7 +899,7 @@ static void alsa_enable_in(HWVoiceIn *hw, bool enable)
static void alsa_init_per_direction(AudiodevAlsaPerDirectionOptions *apdo)
{
if (!apdo->has_try_poll) {
- apdo->try_poll = true;
+ apdo->try_poll = false;
apdo->has_try_poll = true;
}
}
diff --git a/qemu-options.hx b/qemu-options.hx
index aab53bcfe8..7eb8e02b4b 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -965,7 +965,7 @@ SRST
Sets the period length in microseconds.
``in|out.try-poll=on|off``
- Attempt to use poll mode with the device. Default is on.
+ Attempt to use poll mode with the device. Default is off.
``threshold=threshold``
Threshold (in microseconds) when playback starts. Default is 0.
@@ -1002,7 +1002,7 @@ SRST
``in|out.buffer-count=count``
Sets the count of the buffers.
- ``in|out.try-poll=on|of``
+ ``in|out.try-poll=on|off``
Attempt to use poll mode with the device. Default is on.
``try-mmap=on|off``
--
2.49.0
marcandre.lureau@redhat.com writes: > From: BALATON Zoltan <balaton@eik.bme.hu> > > Quoting Volker Rümelin: "try-poll=on tells the ALSA backend to try to > use an event loop instead of the audio timer. This works most of the > time. But the poll event handler in the ALSA backend has a bug. For > example, if the guest can't provide enough audio frames in time, the > ALSA buffer is only partly full and the event handler will be called > again and again on every iteration of the main loop. This increases > the processor load and the guest has less processor time to provide > new audio frames in time. I have two examples where a guest can't > recover from this situation and the guest seems to hang." > > One reproducer I've found is booting MorphOS demo iso on > qemu-system-ppc -machine pegasos2 -audio alsa which should play a > startup sound but instead it freezes. Even when it does not hang it > plays choppy sound. Volker suggested using command line to set > try-poll=off saying: "The try-poll=off arguments are typically > necessary, because the alsa backend has a design issue with > try-poll=on. If the guest can't provide enough audio frames, it's > really unhelpful to ask for new audio frames on every main loop > iteration until the guest can provide enough audio frames. Timer based > playback doesn't have that problem." > > But users cannot easily find this option and having a non-working > default is really unhelpful so to make life easier just set it to > false by default which works until the issue with the alsa backend can > be fixed. > > Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> > Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com> > [ Marc-André - Updated QAPI and CLI doc ] > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > Message-Id: <20250316002046.D066A4E6004@zero.eik.bme.hu> > --- > qapi/audio.json | 2 +- > audio/alsaaudio.c | 2 +- > qemu-options.hx | 4 ++-- > 3 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/qapi/audio.json b/qapi/audio.json > index dd5a58d13e..49633cf317 100644 > --- a/qapi/audio.json > +++ b/qapi/audio.json > @@ -96,7 +96,7 @@ > # @period-length: the period length in microseconds > # > # @try-poll: attempt to use poll mode, falling back to non-polling > -# access on failure (default true) > +# access on failure (default false) > # > # Since: 4.0 > ## Missed this when it was posted (it wasn't cc'ed to me). Flipping the default is technically an incompatible change. I understand the justification, and I'm not passing judgement on its validity; that's the audio maintainers job. I just want to ask: does this need a release note? We normally record incompatible changes in docs/about/deprecated.rst and then docs/about/removed-features.rst, but these don't fit here. [...]
Hi On Mon, May 26, 2025 at 8:27 AM Markus Armbruster <armbru@redhat.com> wrote: > marcandre.lureau@redhat.com writes: > > > From: BALATON Zoltan <balaton@eik.bme.hu> > > > > Quoting Volker Rümelin: "try-poll=on tells the ALSA backend to try to > > use an event loop instead of the audio timer. This works most of the > > time. But the poll event handler in the ALSA backend has a bug. For > > example, if the guest can't provide enough audio frames in time, the > > ALSA buffer is only partly full and the event handler will be called > > again and again on every iteration of the main loop. This increases > > the processor load and the guest has less processor time to provide > > new audio frames in time. I have two examples where a guest can't > > recover from this situation and the guest seems to hang." > > > > One reproducer I've found is booting MorphOS demo iso on > > qemu-system-ppc -machine pegasos2 -audio alsa which should play a > > startup sound but instead it freezes. Even when it does not hang it > > plays choppy sound. Volker suggested using command line to set > > try-poll=off saying: "The try-poll=off arguments are typically > > necessary, because the alsa backend has a design issue with > > try-poll=on. If the guest can't provide enough audio frames, it's > > really unhelpful to ask for new audio frames on every main loop > > iteration until the guest can provide enough audio frames. Timer based > > playback doesn't have that problem." > > > > But users cannot easily find this option and having a non-working > > default is really unhelpful so to make life easier just set it to > > false by default which works until the issue with the alsa backend can > > be fixed. > > > > Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> > > Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com> > > [ Marc-André - Updated QAPI and CLI doc ] > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > > Message-Id: <20250316002046.D066A4E6004@zero.eik.bme.hu> > > --- > > qapi/audio.json | 2 +- > > audio/alsaaudio.c | 2 +- > > qemu-options.hx | 4 ++-- > > 3 files changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/qapi/audio.json b/qapi/audio.json > > index dd5a58d13e..49633cf317 100644 > > --- a/qapi/audio.json > > +++ b/qapi/audio.json > > @@ -96,7 +96,7 @@ > > # @period-length: the period length in microseconds > > # > > # @try-poll: attempt to use poll mode, falling back to non-polling > > -# access on failure (default true) > > +# access on failure (default false) > > # > > # Since: 4.0 > > ## > > Missed this when it was posted (it wasn't cc'ed to me). Flipping the > default is technically an incompatible change. I understand the > justification, and I'm not passing judgement on its validity; that's the > audio maintainers job. I just want to ask: does this need a release > note? > > I doubt anyone will care as long as it doesn't break (that we can't know). I added a note to https://wiki.qemu.org/ChangeLog/10.1#Audio We normally record incompatible changes in docs/about/deprecated.rst and > then docs/about/removed-features.rst, but these don't fit here. > > [...] > >
© 2016 - 2025 Red Hat, Inc.