pcm: pcm_ioplug - fix the avail_update mmap capture copy issue

It seems that the commit "pcm: ioplug: Transfer all available data"
introduced new regressions (wrong memory access). The second issue
is that the avail_update in ioplug does not move appl_ptr nor hw_ptr,
so it's possible that the transfers may be repetitive.

This patch moves the transfer calls to mmap_begin callback where it
should be. The pointer wraps are handled by design now.

Fixes: 1714332719 ("pcm: ioplug: Transfer all available data")
BugLink: https://github.com/alsa-project/alsa-lib/pull/103
Tested-by: Andreas Pape <apape@de.adit-jv.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-01-21 15:45:49 +01:00
parent 55d59821ff
commit 00eafe98ee
3 changed files with 50 additions and 32 deletions

View file

@ -7218,9 +7218,8 @@ int snd_pcm_mmap_begin(snd_pcm_t *pcm,
}
#ifndef DOC_HIDDEN
/* locked version */
int __snd_pcm_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas,
snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames)
int __snd_pcm_mmap_begin_generic(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas,
snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames)
{
snd_pcm_uframes_t cont;
snd_pcm_uframes_t f;
@ -7229,9 +7228,6 @@ int __snd_pcm_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas,
assert(pcm && areas && offset && frames);
if (pcm->fast_ops->mmap_begin)
return pcm->fast_ops->mmap_begin(pcm->fast_op_arg, areas, offset, frames);
/* fallback for plugins that do not specify new callback */
xareas = snd_pcm_mmap_areas(pcm);
if (xareas == NULL)
@ -7250,6 +7246,18 @@ int __snd_pcm_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas,
*frames = f;
return 0;
}
/* locked version */
int __snd_pcm_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas,
snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames)
{
assert(pcm && areas && offset && frames);
if (pcm->fast_ops->mmap_begin)
return pcm->fast_ops->mmap_begin(pcm->fast_op_arg, areas, offset, frames);
return __snd_pcm_mmap_begin_generic(pcm, areas, offset, frames);
}
#endif
/**