Let's consider the state transitions for PCM devices during capture.
The state diagram for a PCM device during capture is shown below.
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_capture_resume() or snd_pcm_channel_resume() |
RUNNING | READY | Calling snd_pcm_channel_flush() or snd_pcm_plugin_flush(). Capture stops and the stream moves to the READY state. |
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.