mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 03:35:42 +01:00
Show warning if the format is changed due to the file type.
(e.g. WAV yields little-endian)
This commit is contained in:
parent
d6b7774f7f
commit
36b797f335
1 changed files with 25 additions and 3 deletions
|
@ -51,6 +51,7 @@
|
||||||
#define LLONG_MAX 9223372036854775807LL
|
#define LLONG_MAX 9223372036854775807LL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DEFAULT_FORMAT SND_PCM_FORMAT_U8
|
||||||
#define DEFAULT_SPEED 8000
|
#define DEFAULT_SPEED 8000
|
||||||
|
|
||||||
#define FORMAT_DEFAULT -1
|
#define FORMAT_DEFAULT -1
|
||||||
|
@ -359,7 +360,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk_size = -1;
|
chunk_size = -1;
|
||||||
rhwparams.format = SND_PCM_FORMAT_U8;
|
rhwparams.format = DEFAULT_FORMAT;
|
||||||
rhwparams.rate = DEFAULT_SPEED;
|
rhwparams.rate = DEFAULT_SPEED;
|
||||||
rhwparams.channels = 1;
|
rhwparams.channels = 1;
|
||||||
|
|
||||||
|
@ -693,17 +694,29 @@ static ssize_t test_wavefile(int fd, char *_buffer, size_t size)
|
||||||
hwparams.channels = LE_SHORT(f->modus);
|
hwparams.channels = LE_SHORT(f->modus);
|
||||||
switch (LE_SHORT(f->bit_p_spl)) {
|
switch (LE_SHORT(f->bit_p_spl)) {
|
||||||
case 8:
|
case 8:
|
||||||
|
if (hwparams.format != DEFAULT_FORMAT &&
|
||||||
|
hwparams.format != SND_PCM_FORMAT_U8)
|
||||||
|
fprintf(stderr, "Warning: format is changed to U8\n");
|
||||||
hwparams.format = SND_PCM_FORMAT_U8;
|
hwparams.format = SND_PCM_FORMAT_U8;
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
|
if (hwparams.format != DEFAULT_FORMAT &&
|
||||||
|
hwparams.format != SND_PCM_FORMAT_S16_LE)
|
||||||
|
fprintf(stderr, "Warning: format is changed to S16_LE\n");
|
||||||
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) / hwparams.channels) {
|
||||||
case 3:
|
case 3:
|
||||||
|
if (hwparams.format != DEFAULT_FORMAT &&
|
||||||
|
hwparams.format != SND_PCM_FORMAT_S24_3LE)
|
||||||
|
fprintf(stderr, "Warning: format is changed to S24_3LE\n");
|
||||||
hwparams.format = SND_PCM_FORMAT_S24_3LE;
|
hwparams.format = SND_PCM_FORMAT_S24_3LE;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
if (hwparams.format != DEFAULT_FORMAT &&
|
||||||
|
hwparams.format != SND_PCM_FORMAT_S24_LE)
|
||||||
|
fprintf(stderr, "Warning: format is changed to S24_LE\n");
|
||||||
hwparams.format = SND_PCM_FORMAT_S24_LE;
|
hwparams.format = SND_PCM_FORMAT_S24_LE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -769,12 +782,21 @@ static int test_au(int fd, void *buffer)
|
||||||
pbrec_count = BE_INT(ap->data_size);
|
pbrec_count = BE_INT(ap->data_size);
|
||||||
switch (BE_INT(ap->encoding)) {
|
switch (BE_INT(ap->encoding)) {
|
||||||
case AU_FMT_ULAW:
|
case AU_FMT_ULAW:
|
||||||
|
if (hwparams.format != DEFAULT_FORMAT &&
|
||||||
|
hwparams.format != SND_PCM_FORMAT_MU_LAW)
|
||||||
|
fprintf(stderr, "Warning: format is changed to MU_LAW\n");
|
||||||
hwparams.format = SND_PCM_FORMAT_MU_LAW;
|
hwparams.format = SND_PCM_FORMAT_MU_LAW;
|
||||||
break;
|
break;
|
||||||
case AU_FMT_LIN8:
|
case AU_FMT_LIN8:
|
||||||
|
if (hwparams.format != DEFAULT_FORMAT &&
|
||||||
|
hwparams.format != SND_PCM_FORMAT_U8)
|
||||||
|
fprintf(stderr, "Warning: format is changed to U8\n");
|
||||||
hwparams.format = SND_PCM_FORMAT_U8;
|
hwparams.format = SND_PCM_FORMAT_U8;
|
||||||
break;
|
break;
|
||||||
case AU_FMT_LIN16:
|
case AU_FMT_LIN16:
|
||||||
|
if (hwparams.format != DEFAULT_FORMAT &&
|
||||||
|
hwparams.format != SND_PCM_FORMAT_S16_BE)
|
||||||
|
fprintf(stderr, "Warning: format is changed to S16_BE\n");
|
||||||
hwparams.format = SND_PCM_FORMAT_S16_BE;
|
hwparams.format = SND_PCM_FORMAT_S16_BE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1330,7 +1352,7 @@ static void voc_play(int fd, int ofs, char *name)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hwparams.format = SND_PCM_FORMAT_U8;
|
hwparams.format = DEFAULT_FORMAT;
|
||||||
hwparams.channels = 1;
|
hwparams.channels = 1;
|
||||||
hwparams.rate = DEFAULT_SPEED;
|
hwparams.rate = DEFAULT_SPEED;
|
||||||
set_params();
|
set_params();
|
||||||
|
@ -1879,7 +1901,7 @@ static void playback(char *name)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (test_au(fd, audiobuf) >= 0) {
|
if (test_au(fd, audiobuf) >= 0) {
|
||||||
rhwparams.format = SND_PCM_FORMAT_MU_LAW;
|
rhwparams.format = hwparams.format;
|
||||||
pbrec_count = calc_count();
|
pbrec_count = calc_count();
|
||||||
playback_go(fd, 0, pbrec_count, FORMAT_AU, name);
|
playback_go(fd, 0, pbrec_count, FORMAT_AU, name);
|
||||||
goto __end;
|
goto __end;
|
||||||
|
|
Loading…
Reference in a new issue