From 436b33787ddfb71f355f2a0b3a14d571c91d7127 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 19 Mar 2003 14:42:00 +0000 Subject: [PATCH] - fixed the capture to stdout in WAV. - allow more than 32bit int in the raw capture mode. --- aplay/aplay.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/aplay/aplay.c b/aplay/aplay.c index 929eb4c..d355745 100644 --- a/aplay/aplay.c +++ b/aplay/aplay.c @@ -1527,6 +1527,10 @@ static void begin_wave(int fd, size_t cnt) u_int tmp; u_short tmp2; + /* WAVE cannot handle greater than 32bit (signed?) int */ + if (cnt == (size_t)-2) + cnt = 0x7fffff00; + bits = 8; switch ((unsigned long) hwparams.format) { case SND_PCM_FORMAT_U8: @@ -1754,28 +1758,29 @@ void playback_go(int fd, size_t loaded, size_t count, int rtype, char *name) void capture_go(int fd, size_t count, int rtype, char *name) { - size_t c; + size_t c, cur; ssize_t r, err; header(rtype, name); set_params(); - while (count > 0) { - c = count; - if (c > chunk_bytes) - c = chunk_bytes; - c = c * 8 / bits_per_frame; - if ((size_t)(r = pcm_read(audiobuf, c)) != c) - break; - r = r * bits_per_frame / 8; - if ((err = write(fd, audiobuf, r)) != r) { - perror(name); - exit(EXIT_FAILURE); + do { + for (cur = count; cur > 0; cur -= r) { + c = cur; + if (c > chunk_bytes) + c = chunk_bytes; + c = c * 8 / bits_per_frame; + if ((size_t)(r = pcm_read(audiobuf, c)) != c) + break; + r = r * bits_per_frame / 8; + if ((err = write(fd, audiobuf, r)) != r) { + perror(name); + exit(EXIT_FAILURE); + } + if (err > 0) + fdcount += err; } - if (err > 0) - fdcount += err; - count -= r; - } + } while (rtype == FORMAT_RAW && !timelimit); } /*