Re: [PATCH v3] ALSA: virtio: use ack callback

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

 



On Mon, 23 Oct 2023 17:06:57 +0200,
Matias Ezequiel Vara Larsen wrote:
> 
> +static int virtsnd_pcm_ack(struct snd_pcm_substream *substream)
> +{
> +	struct virtio_pcm_substream *vss = snd_pcm_substream_chip(substream);
> +	struct virtio_snd_queue *queue = virtsnd_pcm_queue(vss);
> +	unsigned long flags;
> +	struct snd_pcm_runtime *runtime = vss->substream->runtime;
> +	ssize_t appl_pos = frames_to_bytes(runtime, runtime->control->appl_ptr);
> +	ssize_t buf_size = frames_to_bytes(runtime, runtime->buffer_size);
> +	int rc;
> +
> +	spin_lock_irqsave(&queue->lock, flags);
> +	spin_lock(&vss->lock);
> +
> +	ssize_t bytes = (appl_pos - vss->appl_ptr) % buf_size;

The variable declaration should be moved to the beginning of the
function.

Also, there can be a overlap beyond runtime->boundary (which easily
happens for 32bit apps), so the calculation can be a bit more complex
with conditional.


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