mirror of
https://github.com/alsa-project/alsa-utils
synced 2025-01-03 22:16:41 +01:00
store the actual RIFF length at the wav header by arecord.
will fix the data generated withtout -d option.
This commit is contained in:
parent
f2aad9f2a6
commit
e8fd94060e
1 changed files with 9 additions and 5 deletions
|
@ -654,7 +654,7 @@ static ssize_t test_wavefile(int fd, char *_buffer, size_t size)
|
||||||
hwparams.format = SND_PCM_FORMAT_S16_LE;
|
hwparams.format = SND_PCM_FORMAT_S16_LE;
|
||||||
break;
|
break;
|
||||||
case 24:
|
case 24:
|
||||||
switch (LE_SHORT(f->byte_p_spl) / hwparams.channels) {
|
switch (LE_SHORT(f->byte_p_spl)) {
|
||||||
case 3:
|
case 3:
|
||||||
hwparams.format = SND_PCM_FORMAT_S24_3LE;
|
hwparams.format = SND_PCM_FORMAT_S24_3LE;
|
||||||
break;
|
break;
|
||||||
|
@ -662,10 +662,9 @@ static ssize_t test_wavefile(int fd, char *_buffer, size_t size)
|
||||||
hwparams.format = SND_PCM_FORMAT_S24_LE;
|
hwparams.format = SND_PCM_FORMAT_S24_LE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error(" can't play WAVE-files with sample %d bits in %d bytes wide (%d channels)", LE_SHORT(f->bit_p_spl), LE_SHORT(f->byte_p_spl), hwparams.channels);
|
error(" can't play WAVE-files with sample %d bits in %d bytes wide", LE_SHORT(f->bit_p_spl), LE_SHORT(f->byte_p_spl));
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 32:
|
case 32:
|
||||||
hwparams.format = SND_PCM_FORMAT_S32_LE;
|
hwparams.format = SND_PCM_FORMAT_S32_LE;
|
||||||
break;
|
break;
|
||||||
|
@ -1625,12 +1624,17 @@ static void end_wave(int fd)
|
||||||
{ /* only close output */
|
{ /* only close output */
|
||||||
WaveChunkHeader cd;
|
WaveChunkHeader cd;
|
||||||
off_t length_seek;
|
off_t length_seek;
|
||||||
|
u_int rifflen;
|
||||||
|
|
||||||
length_seek = sizeof(WaveHeader) +
|
length_seek = sizeof(WaveHeader) +
|
||||||
sizeof(WaveChunkHeader) +
|
sizeof(WaveChunkHeader) +
|
||||||
sizeof(WaveFmtBody);
|
sizeof(WaveFmtBody);
|
||||||
cd.type = WAV_DATA;
|
cd.type = WAV_DATA;
|
||||||
cd.length = fdcount > 0xffffffff ? 0xffffffff : LE_INT(fdcount);
|
cd.length = fdcount > 0x7fffffff ? 0x7fffffff : LE_INT(fdcount);
|
||||||
|
rifflen = fdcount + 2*sizeof(WaveChunkHeader) + sizeof(WaveFmtBody) + 4;
|
||||||
|
rifflen = rifflen > 0x7fffffff ? 0x7fffffff : LE_INT(rifflen);
|
||||||
|
if (lseek(fd, 4, SEEK_SET) == 4)
|
||||||
|
write(fd, &rifflen, 4);
|
||||||
if (lseek(fd, length_seek, SEEK_SET) == length_seek)
|
if (lseek(fd, length_seek, SEEK_SET) == length_seek)
|
||||||
write(fd, &cd, sizeof(WaveChunkHeader));
|
write(fd, &cd, sizeof(WaveChunkHeader));
|
||||||
if (fd != 1)
|
if (fd != 1)
|
||||||
|
|
Loading…
Reference in a new issue