pcm_file: report write output file error to api user

when writing to output file fails, api user is notified and can handle
recovery

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:
Adam Miartus 2019-06-12 08:48:28 +02:00 committed by Takashi Iwai
parent 6ecd330fb8
commit 2a800c0c4f

View file

@ -572,7 +572,10 @@ static snd_pcm_sframes_t snd_pcm_file_writei(snd_pcm_t *pcm, const void *buffer,
if (n > 0) {
snd_pcm_areas_from_buf(pcm, areas, (void*) buffer);
__snd_pcm_lock(pcm);
snd_pcm_file_add_frames(pcm, areas, 0, n);
if (snd_pcm_file_add_frames(pcm, areas, 0, n) < 0) {
__snd_pcm_unlock(pcm);
return -EPIPE;
}
__snd_pcm_unlock(pcm);
}
return n;
@ -587,7 +590,10 @@ static snd_pcm_sframes_t snd_pcm_file_writen(snd_pcm_t *pcm, void **bufs, snd_pc
if (n > 0) {
snd_pcm_areas_from_bufs(pcm, areas, bufs);
__snd_pcm_lock(pcm);
snd_pcm_file_add_frames(pcm, areas, 0, n);
if (snd_pcm_file_add_frames(pcm, areas, 0, n) < 0) {
__snd_pcm_unlock(pcm);
return -EPIPE;
}
__snd_pcm_unlock(pcm);
}
return n;
@ -608,6 +614,11 @@ static snd_pcm_sframes_t snd_pcm_file_readi(snd_pcm_t *pcm, void *buffer, snd_pc
snd_pcm_file_areas_read_infile(pcm, areas, 0, frames);
__snd_pcm_lock(pcm);
snd_pcm_file_add_frames(pcm, areas, 0, frames);
if (snd_pcm_file_add_frames(pcm, areas, 0, frames) < 0) {
__snd_pcm_unlock(pcm);
return -EPIPE;
}
__snd_pcm_unlock(pcm);
return frames;
@ -627,7 +638,11 @@ static snd_pcm_sframes_t snd_pcm_file_readn(snd_pcm_t *pcm, void **bufs, snd_pcm
snd_pcm_areas_from_bufs(pcm, areas, bufs);
snd_pcm_file_areas_read_infile(pcm, areas, 0, frames);
__snd_pcm_lock(pcm);
snd_pcm_file_add_frames(pcm, areas, 0, frames);
if (snd_pcm_file_add_frames(pcm, areas, 0, frames) < 0) {
__snd_pcm_unlock(pcm);
return -EPIPE;
}
__snd_pcm_unlock(pcm);
return frames;
@ -649,8 +664,10 @@ static snd_pcm_sframes_t snd_pcm_file_mmap_commit(snd_pcm_t *pcm,
if (result >= 0) {
assert(ofs == offset && siz == size);
result = snd_pcm_mmap_commit(file->gen.slave, ofs, siz);
if (result > 0)
snd_pcm_file_add_frames(pcm, areas, ofs, result);
if (result > 0) {
if (snd_pcm_file_add_frames(pcm, areas, ofs, result) < 0)
return -EPIPE;
}
}
return result;
}