diff options
author | Marcin Rajwa <marcin.rajwa@linux.intel.com> | 2020-08-07 15:56:05 +0200 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2020-10-06 12:58:20 +0200 |
commit | bc7a944c50239faf41619826ae914081034f83fe (patch) | |
tree | f40683bf46310a1026caefe5ffe5fcd42f78d8b3 /aplay | |
parent | 8572c0c427dec358e6070659032230966d0dd0ca (diff) | |
download | alsa-utils-bc7a944c50239faf41619826ae914081034f83fe.tar.gz |
aplay: pcm_readv(): return read samples instead of requested upon abort
This patch changes the logic of pcm_readv() when abort signal has been
detected. During such condition we should return the amount of frames
actually read instead of the size requested by caller.
Currently functions pcm_read() and pcm_readv() when aborted (in_aborting
flag set) return the amount of requested frames instead of those actually
read prior to interrupt. The consequence of this is repetition of recent X
frames where X stands for amount of frames in one period. This problem is
barely visible or rather audible when the period is small like few
milliseconds because repetition of 1 [ms] of data is not-noticeable
however if we use buffer and period sizes in seconds then the problem
becomes apparent.
Example issue -> thesofproject/sof#3189
Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'aplay')
-rw-r--r-- | aplay/aplay.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/aplay/aplay.c b/aplay/aplay.c index e8714d8..6e7f4ae 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -2174,7 +2174,9 @@ static ssize_t pcm_readv(u_char **data, unsigned int channels, size_t rcount) count = chunk_size; } - while (count > 0 && !in_aborting) { + while (count > 0) { + if (in_aborting) + goto abort; unsigned int channel; void *bufs[channels]; size_t offset = result; @@ -2206,6 +2208,7 @@ static ssize_t pcm_readv(u_char **data, unsigned int channels, size_t rcount) count -= r; } } +abort: return rcount; } |