mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-04 13:30:08 -05:00
Synchronized snd_pcm_write_areas and snd_pcm_read_areas with the kernel
write/read functions. Changed snd_pcm_xfer_areas_func_t to return snd_pcm_sframes_t (pass errors).
This commit is contained in:
parent
9d34cf954a
commit
b63e44aab0
5 changed files with 56 additions and 29 deletions
|
|
@ -80,12 +80,14 @@ void snd_pcm_mmap_hw_forward(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
|
|||
*pcm->hw_ptr = hw_ptr;
|
||||
}
|
||||
|
||||
static snd_pcm_uframes_t snd_pcm_mmap_write_areas(snd_pcm_t *pcm,
|
||||
static snd_pcm_sframes_t snd_pcm_mmap_write_areas(snd_pcm_t *pcm,
|
||||
const snd_pcm_channel_area_t *areas,
|
||||
snd_pcm_uframes_t offset,
|
||||
snd_pcm_uframes_t size)
|
||||
{
|
||||
snd_pcm_uframes_t xfer = size;
|
||||
snd_pcm_uframes_t xfer = 0;
|
||||
int err;
|
||||
|
||||
assert(snd_pcm_mmap_playback_avail(pcm) >= size);
|
||||
while (size > 0) {
|
||||
const snd_pcm_channel_area_t *pcm_areas;
|
||||
|
|
@ -96,31 +98,39 @@ static snd_pcm_uframes_t snd_pcm_mmap_write_areas(snd_pcm_t *pcm,
|
|||
areas, offset,
|
||||
pcm->channels,
|
||||
frames, pcm->format);
|
||||
snd_pcm_mmap_commit(pcm, pcm_offset, frames);
|
||||
err = snd_pcm_mmap_commit(pcm, pcm_offset, frames);
|
||||
if (err < 0)
|
||||
return xfer > 0 ? xfer : err;
|
||||
offset += frames;
|
||||
xfer += frames;
|
||||
size -= frames;
|
||||
}
|
||||
return xfer;
|
||||
}
|
||||
|
||||
static snd_pcm_uframes_t snd_pcm_mmap_read_areas(snd_pcm_t *pcm,
|
||||
static snd_pcm_sframes_t snd_pcm_mmap_read_areas(snd_pcm_t *pcm,
|
||||
const snd_pcm_channel_area_t *areas,
|
||||
snd_pcm_uframes_t offset,
|
||||
snd_pcm_uframes_t size)
|
||||
{
|
||||
snd_pcm_uframes_t xfer = size;
|
||||
snd_pcm_uframes_t xfer = 0;
|
||||
int err;
|
||||
|
||||
assert(snd_pcm_mmap_capture_avail(pcm) >= size);
|
||||
while (size > 0) {
|
||||
const snd_pcm_channel_area_t *pcm_areas;
|
||||
snd_pcm_uframes_t pcm_offset;
|
||||
snd_pcm_uframes_t frames = size;
|
||||
snd_pcm_mmap_begin(pcm, &pcm_areas, &pcm_offset, &frames);
|
||||
snd_pcm_areas_copy(areas, offset,
|
||||
snd_pcm_areas_copy(areas, offset,
|
||||
pcm_areas, pcm_offset,
|
||||
pcm->channels,
|
||||
frames, pcm->format);
|
||||
snd_pcm_mmap_commit(pcm, pcm_offset, frames);
|
||||
err = snd_pcm_mmap_commit(pcm, pcm_offset, frames);
|
||||
if (err < 0)
|
||||
return xfer > 0 ? xfer : err;
|
||||
offset += frames;
|
||||
xfer += frames;
|
||||
size -= frames;
|
||||
}
|
||||
return xfer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue