On Mon, 22 Feb 2021 16:34:40 +0100, Anton Yakovlev wrote: > > +void virtsnd_pcm_event(struct virtio_snd *snd, struct virtio_snd_event *event) > +{ > + struct virtio_pcm_substream *vss; > + u32 sid = le32_to_cpu(event->data); > + > + if (sid >= snd->nsubstreams) > + return; > + > + vss = &snd->substreams[sid]; > + > + switch (le32_to_cpu(event->hdr.code)) { > + case VIRTIO_SND_EVT_PCM_PERIOD_ELAPSED: > + /* TODO: deal with shmem elapsed period */ > + break; > + case VIRTIO_SND_EVT_PCM_XRUN: > + spin_lock(&vss->lock); > + if (vss->xfer_enabled) > + vss->xfer_xrun = true; > + spin_unlock(&vss->lock); You can stop the stream at xrun, too. But it often messes up with the locking, so it's no mandatory implementation. You seem to pass the xrun state at the pointer callback, and this should be enough for normal uses. thanks, Takashi