From: Geraldo Nascimento <geraldogabriel@gmail.com>
To: Zhang Boyang <zhangboyang.id@gmail.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: [BUG?] Setting (start_threshold > stop_threshold) makes snd_pcm_writei(a_small_buffer) XRUN immediately
Date: Fri, 1 Oct 2021 20:33:20 -0300 [thread overview]
Message-ID: <YVeawIksIf1wKa2s@geday> (raw)
In-Reply-To: <0b00ad37-41a3-f078-6600-d3580ad903a1@gmail.com>
On Sat, Oct 02, 2021 at 01:31:12AM +0800, Zhang Boyang wrote:
> Hello,
Hello, Zhang!
>
> I'm using ALSA to develop an audio-streaming application. I try to
> use start_threshold and stop_threshold in combination with small
> buffers. However, I think I probably found a bug about this.
> I'm setting start_threshold=100 and stop_threshold=50. I'm also using
> a buffer of 44 frames. When I call
> snd_pcm_writei(the_small_44_frames_buffer), pcm state came to XRUN from
> PREPARED directly. I think this is a bug because the stream hasn't
> started. It's hard to say a xrun occurred while stream not started.
> I'm wondering if this is a ALSA-bug or a misuse of ALSA. A simple bug
> test program is attached.
No, I don't think it's a bug. You're bound to run into problems with a
period size of only 44 frames.
Moreover, working with the code you provided, I was able to get a RUNNING
state without XRUNs with a period size of 4410 frames (100 milliseconds of
audio) but I had to comment out snd_pcm_sw_params_set_stop_threshold() for
it to work or I'd have those instant XRUNs.
That's how snd_pcm_sw_params_set_stop_threshold() is supposed to work by
the way. It creates a XRUN once the threshold is hit.
Thanks!
Geraldo Nascimento
> Thank you very much!
>
> Zhang Boyang
>
> p.s.
> I dug into kernel code. After writting hardware buffer,
> __snd_pcm_lib_xfer() called snd_pcm_update_state(), which set the XRUN
> state.
next prev parent reply other threads:[~2021-10-01 23:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-01 17:31 [BUG?] Setting (start_threshold > stop_threshold) makes snd_pcm_writei(a_small_buffer) XRUN immediately Zhang Boyang
2021-10-01 23:33 ` Geraldo Nascimento [this message]
2021-10-02 1:01 ` Geraldo Nascimento
2021-10-02 4:45 ` Geraldo Nascimento
2021-10-04 9:48 ` Zhang Boyang
2021-10-04 21:24 ` Geraldo Nascimento
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=YVeawIksIf1wKa2s@geday \
--to=geraldogabriel@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=zhangboyang.id@gmail.com \
/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