mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-05 13:30:00 -05:00
pcm: file: use snd_pcm_file_areas_read_infile for readi
use previously introduced helper function, this commit unifies behavior of readi and readn corner case behavior of readi is changed by this commit, previously, in case 0 bytes were red from file (EOF), frames = 0 was returned, signaling api user as if no data was red from slave, after the patch, amount of frames red from slave with data red from slave stored in buffer is returned when EOF is reached Signed-off-by: Adam Miartus <amiartus@de.adit-jv.com> Reviewed-by: Timo Wischer <twischer@de.adit-jv.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
5f2e5af61b
commit
349b42f547
1 changed files with 13 additions and 14 deletions
|
|
@ -579,22 +579,21 @@ static snd_pcm_sframes_t snd_pcm_file_readi(snd_pcm_t *pcm, void *buffer, snd_pc
|
||||||
{
|
{
|
||||||
snd_pcm_file_t *file = pcm->private_data;
|
snd_pcm_file_t *file = pcm->private_data;
|
||||||
snd_pcm_channel_area_t areas[pcm->channels];
|
snd_pcm_channel_area_t areas[pcm->channels];
|
||||||
snd_pcm_sframes_t n;
|
snd_pcm_sframes_t frames;
|
||||||
|
|
||||||
|
__snd_pcm_lock(pcm);
|
||||||
|
|
||||||
|
frames = _snd_pcm_readi(file->gen.slave, buffer, size);
|
||||||
|
if (frames <= 0)
|
||||||
|
return frames;
|
||||||
|
|
||||||
n = _snd_pcm_readi(file->gen.slave, buffer, size);
|
|
||||||
if (n <= 0)
|
|
||||||
return n;
|
|
||||||
if (file->ifd >= 0) {
|
|
||||||
__snd_pcm_lock(pcm);
|
|
||||||
n = read(file->ifd, buffer, n * pcm->frame_bits / 8);
|
|
||||||
__snd_pcm_unlock(pcm);
|
|
||||||
if (n < 0)
|
|
||||||
return n;
|
|
||||||
n = n * 8 / pcm->frame_bits;
|
|
||||||
}
|
|
||||||
snd_pcm_areas_from_buf(pcm, areas, buffer);
|
snd_pcm_areas_from_buf(pcm, areas, buffer);
|
||||||
snd_pcm_file_add_frames(pcm, areas, 0, n);
|
snd_pcm_file_areas_read_infile(pcm, areas, 0, frames);
|
||||||
return n;
|
snd_pcm_file_add_frames(pcm, areas, 0, frames);
|
||||||
|
|
||||||
|
__snd_pcm_unlock(pcm);
|
||||||
|
|
||||||
|
return frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* locking */
|
/* locking */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue