Playback states

Let's consider the state transitions for a PCM device during playback.

Figure 1. State diagram for PCM devices during playback.

In the figure above, the oval groups the Underrun, Error, and Unsecure states together to indicate that each state can 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_channel_prepare(), snd_pcm_playback_prepare(), or snd_pcm_plugin_prepare()
PREPARED RUNNING Calling snd_pcm_playback_go(), snd_pcm_channel_go(), snd_pcm_write() or snd_pcm_plugin_write()
RUNNING PAUSED Calling snd_pcm_channel_pause() or snd_pcm_playback_pause()
PAUSED RUNNING Calling snd_pcm_channel_resume() or snd_pcm_playback_resume()
PAUSED SUSPENDED While the subchannel was paused, a higher priority or same priority subchannel preempted the paused subchannel (volume was ducked to zero). For that reason, the stream moves to the suspended (SND_PCM_STATUS_SUSPENDED) state.
RUNNING UNDERRUN The hardware buffer became empty during playback
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 CHANGED The stream changed
RUNNING ERROR A hardware error occurred
RUNNING SUSPENDED Audio management has suspended the subchannel because a higher or same priority subchannel has run.
SUSPENDED RUNNING Audio management has moved the previously suspended subchannel back to the running (SND_PCM_STATUS_RUNNING) state and the subchannel starts to play again. The application must start writing data, otherwise an underrun condition can occur.

This transition may also occur if a subchannel is in a soft suspended (SND_PCM_STATUS_SUSPENDED) state and calls snd_pcm_channel_resume() or snd_pcm_playback_resume(). For more information, see Understanding preemption section in the Audio Management chapter of this guide.

SUSPENDED PAUSED The state occurred because the audio management policy in place is configured to pause, which means when audio management clears the suspension, a transition was made to the PAUSED (SND_PCM_STATUS_PAUSED) state rather the RUNNING (SND_PCM_STATUS_RUNNING) state.

If you were previously in the PAUSED state before the suspension occurs, after suspension is lifted, you return back to the PAUSED state.

While in the SUSPENDED state, if a snd_pcm_*_pause() call was made, you would transition to the PAUSED state when the suspension is lifted.

UNDERRUN, UNSECURE, or ERROR PREPARED Calling snd_pcm_channel_prepare(), snd_pcm_playback_prepare(), or snd_pcm_plugin_prepare()
RUNNING PREEMPTED Audio is blocked because another libasound session has initiated playback, but there aren't enough system resources available; as a result the audio driver has determined that session has higher priority

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