- fixed the capture to stdout in WAV.

- allow more than 32bit int in the raw capture mode.
This commit is contained in:
Takashi Iwai 2003-03-19 14:42:00 +00:00
parent 093a701102
commit 436b33787d

View file

@ -1527,6 +1527,10 @@ static void begin_wave(int fd, size_t cnt)
u_int tmp; u_int tmp;
u_short tmp2; u_short tmp2;
/* WAVE cannot handle greater than 32bit (signed?) int */
if (cnt == (size_t)-2)
cnt = 0x7fffff00;
bits = 8; bits = 8;
switch ((unsigned long) hwparams.format) { switch ((unsigned long) hwparams.format) {
case SND_PCM_FORMAT_U8: 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) void capture_go(int fd, size_t count, int rtype, char *name)
{ {
size_t c; size_t c, cur;
ssize_t r, err; ssize_t r, err;
header(rtype, name); header(rtype, name);
set_params(); set_params();
while (count > 0) { do {
c = count; for (cur = count; cur > 0; cur -= r) {
if (c > chunk_bytes) c = cur;
c = chunk_bytes; if (c > chunk_bytes)
c = c * 8 / bits_per_frame; c = chunk_bytes;
if ((size_t)(r = pcm_read(audiobuf, c)) != c) c = c * 8 / bits_per_frame;
break; if ((size_t)(r = pcm_read(audiobuf, c)) != c)
r = r * bits_per_frame / 8; break;
if ((err = write(fd, audiobuf, r)) != r) { r = r * bits_per_frame / 8;
perror(name); if ((err = write(fd, audiobuf, r)) != r) {
exit(EXIT_FAILURE); perror(name);
exit(EXIT_FAILURE);
}
if (err > 0)
fdcount += err;
} }
if (err > 0) } while (rtype == FORMAT_RAW && !timelimit);
fdcount += err;
count -= r;
}
} }
/* /*