[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <s5h4ki0qvcr.wl-tiwai@suse.de>
Date: Thu, 25 Feb 2021 11:45:24 +0100
From: Takashi Iwai <tiwai@...e.de>
To: Anton Yakovlev <anton.yakovlev@...nsynergy.com>
Cc: <virtualization@...ts.linux-foundation.org>,
<alsa-devel@...a-project.org>, <virtio-dev@...ts.oasis-open.org>,
"Michael S. Tsirkin" <mst@...hat.com>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v5 5/9] ALSA: virtio: handling control and I/O messages for the PCM device
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
Powered by blists - more mailing lists