From: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, mripard@redhat.com, mst@redhat.com,
linux-kernel@vger.kernel.org, tiwai@suse.com, perex@perex.cz,
stefanha@redhat.com, pbonzini@redhat.com,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH v3] ALSA: virtio: use ack callback
Date: Tue, 24 Oct 2023 13:12:35 +0200 [thread overview]
Message-ID: <ZTemo0P/kEcceK/O@fedora> (raw)
In-Reply-To: <87edhlwd7b.wl-tiwai@suse.de>
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.
Thanks, Matias.
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
prev parent reply other threads:[~2023-10-24 11:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-23 15:06 [PATCH v3] ALSA: virtio: use ack callback Matias Ezequiel Vara Larsen
2023-10-24 0:11 ` Anton Yakovlev via Virtualization
2023-10-24 11:14 ` Matias Ezequiel Vara Larsen
[not found] ` <87edhlwd7b.wl-tiwai@suse.de>
2023-10-24 11:12 ` Matias Ezequiel Vara Larsen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZTemo0P/kEcceK/O@fedora \
--to=mvaralar@redhat.com \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mripard@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=perex@perex.cz \
--cc=stefanha@redhat.com \
--cc=tiwai@suse.com \
--cc=tiwai@suse.de \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).