What seems to be going on here is that the loop in capture() is
expecting pcm_read() to return the passed-in count, while pcm_read() is
insisting that the count be equal to the chunk size. Thus the last read
for the timelimit is considered to have failed, and it then gets stuck
in a loop creating more-and-more numbered files.

The attached patch seems to fix things, although I don't know if it's
optimal or if this bug exists elsewhere in the code too.
--- aplay/aplay.c.orig  2015-03-31 10:12:12.267580577 -0400
+++ aplay/aplay.c       2015-03-31 10:12:14.319613606 -0400
@@ -2998,7 +2998,7 @@
                        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)
+                       if (pcm_read(audiobuf, f) < f)
                                break;
                        if (write(fd, audiobuf, c) != c) {
                                perror(name);

Reply via email to