]> git.alsa-project.org Git - alsa-utils.git/commitdiff
aplay: capture: write only the amount of read frames
authorMarcin Rajwa <marcin.rajwa@linux.intel.com>
Fri, 7 Aug 2020 14:17:25 +0000 (16:17 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 6 Oct 2020 10:58:20 +0000 (12:58 +0200)
This patch changes the way aborted stream is being saved. Currently when
abort signal happens the write back of read samples is skipped but there
is no reason to not save them. Also, we need to know how much frames have
been read and write only those.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
aplay/aplay.c

index d71035c3a0591e91ddef00d28ac775bbe0810803..f71d0c9d8f3febe0d7ab7913b53604bba4577aba 100644 (file)
@@ -3206,11 +3206,12 @@ static void capture(char *orig_name)
                        size_t c = (rest <= (off64_t)chunk_bytes) ?
                                (size_t)rest : chunk_bytes;
                        size_t f = c * 8 / bits_per_frame;
-                       if (pcm_read(audiobuf, f) != f) {
+                       size_t read = pcm_read(audiobuf, f);
+                       size_t save;
+                       if (read != f)
                                in_aborting = 1;
-                               break;
-                       }
-                       if (xwrite(fd, audiobuf, c) != c) {
+                       save = read * bits_per_frame / 8;
+                       if (xwrite(fd, audiobuf, save) != save) {
                                perror(name);
                                in_aborting = 1;
                                break;