Reverted back the previous read/write_areas code

This commit is contained in:
Jaroslav Kysela 2001-05-14 15:21:18 +00:00
parent 808fb82d1f
commit 00c749f080

View file

@ -86,27 +86,19 @@ static snd_pcm_uframes_t snd_pcm_mmap_write_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t size) snd_pcm_uframes_t size)
{ {
snd_pcm_uframes_t xfer = size; snd_pcm_uframes_t xfer = size;
int res; assert(snd_pcm_mmap_playback_avail(pcm) >= size);
while (size > 0) { while (size > 0) {
const snd_pcm_channel_area_t *pcm_areas; const snd_pcm_channel_area_t *pcm_areas;
snd_pcm_uframes_t pcm_offset; snd_pcm_uframes_t pcm_offset;
snd_pcm_uframes_t frames = size; snd_pcm_uframes_t frames = size;
snd_pcm_mmap_begin(pcm, &pcm_areas, &pcm_offset, &frames); snd_pcm_mmap_begin(pcm, &pcm_areas, &pcm_offset, &frames);
if (frames > 0) snd_pcm_areas_copy(pcm_areas, pcm_offset,
snd_pcm_areas_copy(pcm_areas, pcm_offset, areas, offset,
areas, offset, pcm->channels,
pcm->channels, frames, pcm->format);
frames, pcm->format);
snd_pcm_mmap_commit(pcm, pcm_offset, frames); snd_pcm_mmap_commit(pcm, pcm_offset, frames);
if (frames == 0) { offset += frames;
if (pcm->mode & SND_PCM_NONBLOCK) size -= frames;
return xfer;
if ((res = snd_pcm_wait(pcm, -1)) < 0)
return xfer > 0 ? xfer : res;
} else {
offset += frames;
size -= frames;
}
} }
return xfer; return xfer;
} }
@ -117,27 +109,19 @@ static snd_pcm_uframes_t snd_pcm_mmap_read_areas(snd_pcm_t *pcm,
snd_pcm_uframes_t size) snd_pcm_uframes_t size)
{ {
snd_pcm_uframes_t xfer = size; snd_pcm_uframes_t xfer = size;
int res; assert(snd_pcm_mmap_capture_avail(pcm) >= size);
while (size > 0) { while (size > 0) {
const snd_pcm_channel_area_t *pcm_areas; const snd_pcm_channel_area_t *pcm_areas;
snd_pcm_uframes_t pcm_offset; snd_pcm_uframes_t pcm_offset;
snd_pcm_uframes_t frames = size; snd_pcm_uframes_t frames = size;
snd_pcm_mmap_begin(pcm, &pcm_areas, &pcm_offset, &frames); snd_pcm_mmap_begin(pcm, &pcm_areas, &pcm_offset, &frames);
if (frames > 0) snd_pcm_areas_copy(areas, offset,
snd_pcm_areas_copy(areas, offset, pcm_areas, pcm_offset,
pcm_areas, pcm_offset, pcm->channels,
pcm->channels, frames, pcm->format);
frames, pcm->format);
snd_pcm_mmap_commit(pcm, pcm_offset, frames); snd_pcm_mmap_commit(pcm, pcm_offset, frames);
if (frames == 0) { offset += frames;
if (pcm->mode & SND_PCM_NONBLOCK) size -= frames;
return xfer;
if ((res = snd_pcm_wait(pcm, -1)) < 0)
return xfer > 0 ? xfer : res;
} else {
offset += frames;
size -= frames;
}
} }
return xfer; return xfer;
} }