mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-09-21 02:29:57 +02:00
aplay: Fix parsing of format with WAV_FMT_EXTENSIBLE header
WAV_FMT_EXTENSIBLE header contains valid bits per sample, which can be different than bits per sample. Make sure it is taken into account when parsing headers and choosing playback format. BugLink: https://github.com/alsa-project/alsa-utils/pull/178 Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
f67b3ed002
commit
4f7e1af85a
1 changed files with 20 additions and 4 deletions
|
@ -1002,6 +1002,7 @@ static ssize_t test_wavefile(int fd, u_char *_buffer, size_t size)
|
||||||
u_int type, len;
|
u_int type, len;
|
||||||
unsigned short format, channels;
|
unsigned short format, channels;
|
||||||
int big_endian, native_format;
|
int big_endian, native_format;
|
||||||
|
u_char vbps = 0;
|
||||||
|
|
||||||
if (size < sizeof(WaveHeader))
|
if (size < sizeof(WaveHeader))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1058,6 +1059,7 @@ static ssize_t test_wavefile(int fd, u_char *_buffer, size_t size)
|
||||||
error(_("wrong format tag in extensible 'fmt ' chunk"));
|
error(_("wrong format tag in extensible 'fmt ' chunk"));
|
||||||
prg_exit(EXIT_FAILURE);
|
prg_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
vbps = TO_CPU_SHORT(fe->bit_p_spl, big_endian);
|
||||||
format = TO_CPU_SHORT(fe->guid_format, big_endian);
|
format = TO_CPU_SHORT(fe->guid_format, big_endian);
|
||||||
}
|
}
|
||||||
if (format != WAV_FMT_PCM &&
|
if (format != WAV_FMT_PCM &&
|
||||||
|
@ -1071,6 +1073,10 @@ static ssize_t test_wavefile(int fd, u_char *_buffer, size_t size)
|
||||||
prg_exit(EXIT_FAILURE);
|
prg_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
hwparams.channels = channels;
|
hwparams.channels = channels;
|
||||||
|
if (vbps > TO_CPU_SHORT(f->bit_p_spl, big_endian)) {
|
||||||
|
error(_("valid bps greater than bps: %d > %d"), vbps, TO_CPU_SHORT(f->bit_p_spl, big_endian));
|
||||||
|
prg_exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
switch (TO_CPU_SHORT(f->bit_p_spl, big_endian)) {
|
switch (TO_CPU_SHORT(f->bit_p_spl, big_endian)) {
|
||||||
case 8:
|
case 8:
|
||||||
if (hwparams.format != DEFAULT_FORMAT &&
|
if (hwparams.format != DEFAULT_FORMAT &&
|
||||||
|
@ -1123,10 +1129,20 @@ static ssize_t test_wavefile(int fd, u_char *_buffer, size_t size)
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
if (format == WAV_FMT_PCM) {
|
if (format == WAV_FMT_PCM) {
|
||||||
|
switch (vbps) {
|
||||||
|
case 24:
|
||||||
|
if (big_endian)
|
||||||
|
native_format = SND_PCM_FORMAT_S24_BE;
|
||||||
|
else
|
||||||
|
native_format = SND_PCM_FORMAT_S24_LE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
if (big_endian)
|
if (big_endian)
|
||||||
native_format = SND_PCM_FORMAT_S32_BE;
|
native_format = SND_PCM_FORMAT_S32_BE;
|
||||||
else
|
else
|
||||||
native_format = SND_PCM_FORMAT_S32_LE;
|
native_format = SND_PCM_FORMAT_S32_LE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
hwparams.format = native_format;
|
hwparams.format = native_format;
|
||||||
} else if (format == WAV_FMT_IEEE_FLOAT) {
|
} else if (format == WAV_FMT_IEEE_FLOAT) {
|
||||||
if (big_endian)
|
if (big_endian)
|
||||||
|
|
Loading…
Reference in a new issue