]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Added abort when no more frames can be processed
authorJaroslav Kysela <perex@perex.cz>
Sun, 3 Mar 2002 09:24:14 +0000 (09:24 +0000)
committerJaroslav Kysela <perex@perex.cz>
Sun, 3 Mar 2002 09:24:14 +0000 (09:24 +0000)
src/pcm/pcm_plugin.c

index 53635cf28955157f655bdb3a058f34ad8d9aa485..e1d53f8c341da636b37cc0910e28e78b3235f58f 100644 (file)
@@ -324,7 +324,10 @@ static snd_pcm_sframes_t snd_pcm_plugin_write_areas(snd_pcm_t *pcm,
                const snd_pcm_channel_area_t *slave_areas;
                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);
+               if (slave_frames == 0)
+                       break;
                frames = plugin->write(pcm, areas, offset, frames,
                                       slave_areas, slave_offset, &slave_frames);
                assert(slave_frames <= snd_pcm_mmap_playback_avail(slave));
@@ -332,7 +335,7 @@ static snd_pcm_sframes_t snd_pcm_plugin_write_areas(snd_pcm_t *pcm,
                snd_pcm_mmap_appl_forward(pcm, frames);
                result = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
                snd_atomic_write_end(&plugin->watom);
-               if (result < 0)
+               if (result <= 0)
                        return xfer > 0 ? xfer : result;
                offset += result;
                xfer += result;
@@ -356,7 +359,10 @@ static snd_pcm_sframes_t snd_pcm_plugin_read_areas(snd_pcm_t *pcm,
                const snd_pcm_channel_area_t *slave_areas;
                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);
+               if (slave_frames == 0)
+                       break;
                frames = plugin->read(pcm, areas, offset, frames,
                                      slave_areas, slave_offset, &slave_frames);
                assert(slave_frames <= snd_pcm_mmap_capture_avail(slave));
@@ -364,7 +370,7 @@ static snd_pcm_sframes_t snd_pcm_plugin_read_areas(snd_pcm_t *pcm,
                snd_pcm_mmap_appl_forward(pcm, frames);
                result = snd_pcm_mmap_commit(slave, slave_offset, slave_frames);
                snd_atomic_write_end(&plugin->watom);
-               if (result < 0)
+               if (result <= 0)
                        return xfer > 0 ? xfer : result;
                offset += result;
                xfer += result;