Codebase list alsa-lib / 1714332
pcm: ioplug: Transfer all available data The snd_pcm_mmap_begin() call returns the amount of contiguous data, which is less than the total available if it wraps around the buffer boundary. If we don't handle this split we leave stale data in the buffer that should have been overwritten, as well as unread data in the io_plugin that gets transferred on a subsequent call at the wrong offset. Signed-off-by: Rob Duncan <rduncan@teslamotors.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Rob Duncan authored 5 years ago Takashi Iwai committed 5 years ago
1 changed file(s) with 13 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
715715 snd_pcm_ioplug_hw_ptr_update(pcm);
716716 if (io->data->state == SND_PCM_STATE_XRUN)
717717 return -EPIPE;
718
719 avail = snd_pcm_mmap_avail(pcm);
718720 if (pcm->stream == SND_PCM_STREAM_CAPTURE &&
719721 pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED &&
720722 pcm->access != SND_PCM_ACCESS_RW_NONINTERLEAVED) {
727729 result = io->data->callback->transfer(io->data, areas, offset, size);
728730 if (result < 0)
729731 return result;
732
733 /* If the available data doesn't fit in the
734 contiguous area at the end of the mmap we
735 must transfer the remaining data to the
736 beginning of the mmap. */
737 if (size < avail) {
738 result = io->data->callback->transfer(io->data, areas,
739 0, avail - size);
740 if (result < 0)
741 return result;
742 }
730743 }
731744 }
732 avail = snd_pcm_mmap_avail(pcm);
733745 if (avail > io->avail_max)
734746 io->avail_max = avail;
735747 return (snd_pcm_sframes_t)avail;