[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87edhlwd7b.wl-tiwai@suse.de>
Date: Mon, 23 Oct 2023 17:50:00 +0200
From: Takashi Iwai <tiwai@...e.de>
To: Matias Ezequiel Vara Larsen <mvaralar@...hat.com>
Cc: anton.yakovlev@...nsynergy.com, mst@...hat.com, perex@...ex.cz,
tiwai@...e.com, virtualization@...ts.linux-foundation.org,
alsa-devel@...a-project.org, linux-kernel@...r.kernel.org,
pbonzini@...hat.com, stefanha@...hat.com, sgarzare@...hat.com,
manos.pitsidianakis@...aro.org, mripard@...hat.com
Subject: Re: [PATCH v3] ALSA: virtio: use ack callback
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
Powered by blists - more mailing lists