From b0e4652881f883023d2b190cf3897b7494d8d0ed Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 27 Feb 2017 09:25:24 +0100 Subject: [PATCH 33/43] pcm_plugin: unify the snd_pcm_mmap_begin result value checking --- src/pcm/pcm_plugin.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) --- a/src/pcm/pcm_plugin.c +++ b/src/pcm/pcm_plugin.c @@ -251,8 +251,12 @@ static snd_pcm_sframes_t snd_pcm_plugin_ snd_pcm_uframes_t slave_offset; snd_pcm_uframes_t slave_frames = ULONG_MAX; - err = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames); - if (err < 0 || slave_frames == 0) + result = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames); + if (result < 0) { + err = result; + goto error; + } + if (slave_frames == 0) break; frames = plugin->write(pcm, areas, offset, frames, slave_areas, slave_offset, &slave_frames); @@ -304,7 +308,11 @@ static snd_pcm_sframes_t snd_pcm_plugin_ snd_pcm_uframes_t slave_offset; snd_pcm_uframes_t slave_frames = ULONG_MAX; - snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames); + result = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames); + if (result < 0) { + err = result; + goto error; + } if (slave_frames == 0) break; frames = (plugin->read)(pcm, areas, offset, frames, @@ -409,9 +417,11 @@ snd_pcm_plugin_mmap_commit(snd_pcm_t *pc snd_pcm_uframes_t slave_frames = ULONG_MAX; snd_pcm_sframes_t result; - err = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames); - if (err < 0) + result = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames); + if (result < 0) { + err = result; goto error; + } if (frames > cont) frames = cont; frames = plugin->write(pcm, areas, appl_offset, frames, @@ -481,9 +491,11 @@ static snd_pcm_sframes_t snd_pcm_plugin_ snd_pcm_uframes_t slave_frames = ULONG_MAX; snd_pcm_sframes_t result; - err = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames); - if (err < 0) + result = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames); + if (result < 0) { + err = result; goto error; + } if (frames > cont) frames = cont; frames = (plugin->read)(pcm, areas, hw_offset, frames,