Skip to contentSkip to conversation

aplay: capture: write only the amount of read frames

PATCH New Rajwa, Marcin 1 participant 1 message Aug 7, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aplay: capture: write only the amount of read frames

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.

aplay/aplay.c +0 -0
index 6836558..f5010dc 100644
@@ -3204,11 +3204,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 / 8 * bits_per_frame; +                       if (xwrite(fd, audiobuf, save) != save) { perror(name); in_aborting = 1;
                                break;