Capture states

Updated: April 19, 2023

Let's consider the state transitions for PCM devices during capture.

The state diagram for a PCM device during capture is shown below.

Figure 1. State diagram for PCM devices during capture.

In the figure above, the oval groups the Overrun, Error, and Unsecure states together to indicate that each state can transition to the Prepared state

The circle surrounding Overrun, Error, and Unsecure states indicates that each state can individually transition to the Prepared state. The transition between SND_PCM_STATUS_* states is the result of executing an API call, or the result of conditions that occur in the hardware:

From To Cause
NOTREADY READY Calling snd_pcm_channel_params() or snd_pcm_plugin_params()
READY PREPARED Calling snd_pcm_capture_prepare(), snd_pcm_channel_prepare(), or snd_pcm_plugin_prepare()
PREPARED RUNNING Calling snd_pcm_capture_go(), snd_pcm_channel_go(), snd_pcm_read(), or snd_pcm_plugin_read(), or calling select() against the capture file descriptors
RUNNING PAUSED Calling snd_pcm_capture_pause() or snd_pcm_channel_pause()
PAUSED RUNNING Calling snd_pcm_channel_drain(), snd_pcm_plugin_drain(), snd_pcm_capture_resume(), or snd_pcm_channel_resume()
RUNNING READY One of the following:
  • If you call snd_pcm_*_drain(), capture stops, the stream moves to the READY state, and the buffered data is preserved.
  • If you call snd_pcm_*_drop(), capture stops and the stream moves to the READY state. Buffered data is discarded.
RUNNING OVERRUN The hardware buffer became full during capture; snd_pcm_read() and snd_pcm_plugin_read() fail
RUNNING UNSECURE The application marked the stream as protected, the hardware level supports a secure transport (e.g., HDCP for HDMI), and authentication was lost
RUNNING CHANGE The stream changed
RUNNING ERROR A hardware error occurred
OVERRUN, UNSECURE, or ERROR PREPARED Calling snd_pcm_capture_prepare(), snd_pcm_channel_prepare(), or snd_pcm_plugin_prepare()

For more details on these transitions, see the description of each function in the Audio Library chapter.