snd_pcm_peri..._stream_lock(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– snd_pcm_peri..._stream_lock(9) πŸ’–

okay bestie, welcome to the Kernel API Manual ✨ β€” today's main character is snd_pcm_peri..._stream_lock(9), and no, the ellipsis is not me being dramatic, it's literally in the name πŸ’€. Let's get into it.

🌸 NAME 🌸

snd_pcm_period_elapsed_under_stream_lock β€” update the status of runtime for the next period under acquired lock of PCM substream. That's the whole errand, and it ate. πŸ’…

✨ SYNOPSIS ✨

void snd_pcm_period_elapsed_under_stream_lock (struct snd_pcm_substream
*substream );

That's the signature, copy it exactly, no edits, iykyk 🫢.

πŸŽ€ ARGUMENTS πŸŽ€

  • substream β€” the instance of pcm substream. Your PCM substream bestie, basically.

πŸ¦‹ DESCRIPTION πŸ¦‹

So when a batch of audio data frames β€” same size as the period of buffer β€” has already been processed in audio data transmission, this is the function that gets called. Like, the audio frames have had their moment, and now this function gets the call. 🎧

Once it's called, it updates the status of runtime with the latest position of audio data transmission; it checks overrun and underrun over buffer; it awakens user processes from waiting for available audio data frames; it samples audio timestamp; and it performs stop or drain the PCM substream according to configured threshold. It's giving very busy, very iconic, very "I do five jobs in one moment" energy. 🌈

This function is intended to use for the case that PCM driver operates audio data frames under acquired lock of PCM substream β€” e.g. in callback of any operation of snd_pcm_ops in process context. In any interrupt context, it's preferrable to use snd_pcm_period_elapsed instead since lock of PCM substream should be acquired in advance. So yeah: process context with the lock already acquired? This one. Interrupt context? Take the snd_pcm_period_elapsed route, bestie. 🚦

Developer should pay enough attention that some callbacks in snd_pcm_ops are done by the call of function:

  • ⭐ (the page has an empty bullet here β€” no callback name provided)
  • ⭐ (another empty bullet β€” still no callback name)
  • ⭐ (third empty bullet β€” we are absolutely not inventing them)
Like, the original really did leave those three bullet slots blank. No cap. Don't come for me, I'm just preserving the lore. πŸ’€

Even if more than one periods have elapsed since the last call, you have to call this only once. Only once, okay? Not me spam-calling it. πŸ™ˆ

πŸ’… SEE ALSO πŸ’…

Kernel file ./sound/core/pcm_lib.c is in the mix, plus these SEE ALSO icons:


That's the page, bestie. Signing off from ./sound/core, dated October 2026, for snd_pcm_peri..._stream_lock(9) β€” mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from