All of lore.kernel.org
 help / color / mirror / Atom feed
* the ALSA state machine
@ 2026-08-08 22:47 dave
  2026-08-12  9:37 ` Jaroslav Kysela
  0 siblings, 1 reply; 2+ messages in thread
From: dave @ 2026-08-08 22:47 UTC (permalink / raw)
  To: alsa-devel

Hello,
	I am trying to debug some ALSA playback code. I have two playback
devices,. The first is A USB sound bar and the second is A Bluetooth sound
bar. The issue I am debugging is truncated output on the Bluetooth sound
bar. The USB sound bar works fine. I've added assertions to understand how
my code may be getting out of sync with the ALSA state machine.
	For reference, I am using the documentation at
https://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html
	After opening the device, I check its state and it is always in the
SND_PCM_STATE_OPEN state, as expected. After initializing the h/w and s/w
params, however, the document says I should be in the SND_PCM_STATE_SETUP
state. Instead, however, I am in the SND_PCM_STATE_PREPARED state. I then
call snd_pcm_prepare() and remain in the SND_PCM_STATE_PREPARED state. I
then call snd_pcm_start(). In the USB version I get an -EPIPE error. In the
Bluetooth code I do not get an error. Finally, I check the state before I
exit my initialization code and I am in the SND_PCM_STATE_PREPARED, not the
SND_PCM_STATE_RUNNING state. Evidently, the documentation and the code do
not agree. Which is correct? It would be trivial to check the state and omit
the snd_pcm_prepare() call if it is already in the prepared state. But I am
trying to follow the document as closely as possible.
	Thoughts?
	David




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: the ALSA state machine
  2026-08-08 22:47 the ALSA state machine dave
@ 2026-08-12  9:37 ` Jaroslav Kysela
  0 siblings, 0 replies; 2+ messages in thread
From: Jaroslav Kysela @ 2026-08-12  9:37 UTC (permalink / raw)
  To: dave; +Cc: ALSA development

On 8/9/26 00:47, dave@synergy.org wrote:
> Hello,
> 	I am trying to debug some ALSA playback code. I have two playback
> devices,. The first is A USB sound bar and the second is A Bluetooth sound
> bar. The issue I am debugging is truncated output on the Bluetooth sound
> bar. The USB sound bar works fine. I've added assertions to understand how
> my code may be getting out of sync with the ALSA state machine.
> 	For reference, I am using the documentation at
> https://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html
> 	After opening the device, I check its state and it is always in the
> SND_PCM_STATE_OPEN state, as expected. After initializing the h/w and s/w
> params, however, the document says I should be in the SND_PCM_STATE_SETUP
> state. Instead, however, I am in the SND_PCM_STATE_PREPARED state. I then

It's correct per snd_pcm_hw_params() documentation:

"""
  * After this call, #snd_pcm_prepare() is called automatically and
  * the stream is brought to \c #SND_PCM_STATE_PREPARED state.
"""

> call snd_pcm_prepare() and remain in the SND_PCM_STATE_PREPARED state. I
> then call snd_pcm_start(). In the USB version I get an -EPIPE error. In the

EPIPE usually means that there are not enough data (samples) in the ring buffer.

				Jaroslav

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-12  9:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-08 22:47 the ALSA state machine dave
2026-08-12  9:37 ` Jaroslav Kysela

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.