All of lore.kernel.org
 help / color / mirror / Atom feed
* Bug in snd_pcm_ioplug_avail_update()?
@ 2018-07-13 22:10 Rob Duncan
  2018-07-16 18:38 ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: Rob Duncan @ 2018-07-13 22:10 UTC (permalink / raw)
  To: alsa-devel@alsa-project.org

It seems to me that there's something wrong in
snd_pcm_ioplug_avail_update() for capture IO plugins.

Once a bunch of conditions are met it makes this call:

	__snd_pcm_mmap_begin(pcm, &areas, &offset, &size);
	result = io->data->callback->transfer(io->data, areas, offset, size);
	if (result < 0)
		return result;

This transfers size frames from the IO plugin, which in general is not
all the available data: it's limited by the amount of contiguous space
in the mmap.

However, the function returns like this:

	avail = snd_pcm_mmap_avail(pcm);
	if (avail > io->avail_max)
		io->avail_max = avail;
	return (snd_pcm_sframes_t)avail;

But this is all the available data in the IO plugin, without considering
the contiguous space limitation. This means that there is now
uninitialized data in the mmap, and some data still in the IO plugin
that has yet to be transferred.

I'm running into this misbehaviour with a rate conversion plugin pulling
data from an IO plugin.  I get chunks of old data showing up later in
the stream, I think because the mmap buffer is not being fully written
to.

I suspect that this avail mismatch tricks snd_pcm_rate_avail_update()
into thinking that it can grab an integral number of periods of data
from the mmap, which is not the case.

But I'm quite tangled up trying to follow the control flow here so I
could certainly be mistaken.  I'd appreciate any insight into what might
be going wrong.

Thanks,

Rob.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-07-17 15:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-13 22:10 Bug in snd_pcm_ioplug_avail_update()? Rob Duncan
2018-07-16 18:38 ` Takashi Iwai
2018-07-16 23:53   ` Rob Duncan
2018-07-17  5:04     ` Takashi Iwai
2018-07-17 15:46       ` Rob Duncan
2018-07-17 15:54         ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.