[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87ttqgurm2.wl-tiwai@suse.de>
Date: Tue, 24 Oct 2023 14:33:57 +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 Tue, 24 Oct 2023 13:12:35 +0200,
Matias Ezequiel Vara Larsen wrote:
>
> On Mon, Oct 23, 2023 at 05:50:00PM +0200, Takashi Iwai wrote:
> > 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.
> >
>
> Should I use as an example `cs46xx_playback/capture_transfer()` which relies on
> the `snd_pcm_indirect_playback/capture_transfer()`? It looks like it
> does already that calculation.
Yes, using the existing helper is a good idea.
The only problem is that this helper isn't well documented ;-<
thanks,
Takashi
Powered by blists - more mailing lists