mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-23 00:46:32 +01:00
speaker-test: fix option ordering
The -c and -s options needed to be provided in a specific order for the -s option to work correctly. This pulls the speaker option check outside of the option parsing so that all the options have been parsed before checking to see if the parameter to -s is correct. Signed-off-by: Ken Benoit <kbenoit@redhat.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
0e864e1a3a
commit
4482cc7cfe
1 changed files with 10 additions and 5 deletions
|
@ -1041,6 +1041,7 @@ int main(int argc, char *argv[]) {
|
||||||
double time1,time2,time3;
|
double time1,time2,time3;
|
||||||
unsigned int n, nloops;
|
unsigned int n, nloops;
|
||||||
struct timeval tv1,tv2;
|
struct timeval tv1,tv2;
|
||||||
|
int speakeroptset = 0;
|
||||||
#ifdef CONFIG_SUPPORT_CHMAP
|
#ifdef CONFIG_SUPPORT_CHMAP
|
||||||
const char *chmap = NULL;
|
const char *chmap = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1162,11 +1163,7 @@ int main(int argc, char *argv[]) {
|
||||||
case 's':
|
case 's':
|
||||||
speaker = atoi(optarg);
|
speaker = atoi(optarg);
|
||||||
speaker = speaker < 1 ? 0 : speaker;
|
speaker = speaker < 1 ? 0 : speaker;
|
||||||
speaker = speaker > channels ? 0 : speaker;
|
speakeroptset = 1;
|
||||||
if (speaker==0) {
|
|
||||||
fprintf(stderr, _("Invalid parameter for -s option.\n"));
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
given_test_wav_file = optarg;
|
given_test_wav_file = optarg;
|
||||||
|
@ -1200,6 +1197,14 @@ int main(int argc, char *argv[]) {
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (speakeroptset) {
|
||||||
|
speaker = speaker > channels ? 0 : speaker;
|
||||||
|
if (speaker==0) {
|
||||||
|
fprintf(stderr, _("Invalid parameter for -s option.\n"));
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!force_frequency) {
|
if (!force_frequency) {
|
||||||
freq = freq < 30.0 ? 30.0 : freq;
|
freq = freq < 30.0 ? 30.0 : freq;
|
||||||
freq = freq > 8000.0 ? 8000.0 : freq;
|
freq = freq > 8000.0 ? 8000.0 : freq;
|
||||||
|
|
Loading…
Reference in a new issue