Re: [PATCH v5 5/9] ALSA: virtio: handling control and I/O messages for the PCM device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux