alsa: guard agaist NULL areas

snd_pcm_ioplug_mmap_areas() can fail and return NULL

Fixes #3600
This commit is contained in:
Wim Taymans 2023-10-22 17:26:25 +02:00
parent 7fa64a8b71
commit 920beea3eb

View file

@ -309,21 +309,21 @@ snd_pcm_pipewire_process(snd_pcm_pipewire_t *pw, struct pw_buffer *b,
xfer = nframes; xfer = nframes;
if (xfer > 0) { if (xfer > 0) {
const snd_pcm_channel_area_t *areas = snd_pcm_ioplug_mmap_areas(io); const snd_pcm_channel_area_t *areas = snd_pcm_ioplug_mmap_areas(io);
const snd_pcm_uframes_t offset = hw_ptr % io->buffer_size; if (areas != NULL) {
const snd_pcm_uframes_t offset = hw_ptr % io->buffer_size;
if (io->stream == SND_PCM_STREAM_PLAYBACK) if (io->stream == SND_PCM_STREAM_PLAYBACK)
snd_pcm_areas_copy_wrap(pwareas, 0, nframes, snd_pcm_areas_copy_wrap(pwareas, 0, nframes,
areas, offset, areas, offset,
io->buffer_size, io->buffer_size,
io->channels, xfer, io->channels, xfer,
io->format); io->format);
else else
snd_pcm_areas_copy_wrap(areas, offset, snd_pcm_areas_copy_wrap(areas, offset,
io->buffer_size, io->buffer_size,
pwareas, 0, nframes, pwareas, 0, nframes,
io->channels, xfer, io->channels, xfer,
io->format); io->format);
}
hw_ptr += xfer; hw_ptr += xfer;
if (hw_ptr >= pw->boundary) if (hw_ptr >= pw->boundary)
hw_ptr -= pw->boundary; hw_ptr -= pw->boundary;