mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 00:05:42 +01:00
Here's a new batch of Debian patches, all from David B. Harris.
- add a "Press Escape to quit" string to alsamixer's title, some uses couldn't figure out how to exit the program (Debian Bug#178393). - hide the cursor, which was missplaced and wasn't goodlooking anyway (Debian Bug#81169). - remove trailing spaces from amixer's output (Debian Bug#177518). - don't ignore second -l/-L flags in aplay (Debian Bug#177521).
This commit is contained in:
parent
1bfb694bf0
commit
53fb81e39b
3 changed files with 52 additions and 41 deletions
|
@ -1029,7 +1029,7 @@ mixer_draw_frame (void)
|
||||||
|
|
||||||
/* program title
|
/* program title
|
||||||
*/
|
*/
|
||||||
sprintf (string, "%s %s", PRGNAME_UPPER, VERSION);
|
sprintf (string, "%s %s (Press Escape to quit)", PRGNAME_UPPER, VERSION);
|
||||||
max_len = strlen (string);
|
max_len = strlen (string);
|
||||||
if (mixer_max_x >= max_len + 4)
|
if (mixer_max_x >= max_len + 4)
|
||||||
{
|
{
|
||||||
|
@ -1567,6 +1567,7 @@ mixer_init_window (void)
|
||||||
/* initialize ncurses
|
/* initialize ncurses
|
||||||
*/
|
*/
|
||||||
mixer_window = initscr ();
|
mixer_window = initscr ();
|
||||||
|
curs_set (0); /* hide the cursor */
|
||||||
|
|
||||||
mixer_no_lrcorner = tigetflag ("xenl") != 1 && tigetflag ("am") != 1;
|
mixer_no_lrcorner = tigetflag ("xenl") != 1 && tigetflag ("am") != 1;
|
||||||
|
|
||||||
|
|
|
@ -561,17 +561,17 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char
|
||||||
snd_mixer_selem_get_capture_group(elem));
|
snd_mixer_selem_get_capture_group(elem));
|
||||||
if (snd_mixer_selem_has_playback_volume(elem) ||
|
if (snd_mixer_selem_has_playback_volume(elem) ||
|
||||||
snd_mixer_selem_has_playback_switch(elem)) {
|
snd_mixer_selem_has_playback_switch(elem)) {
|
||||||
printf("%sPlayback channels: ", space);
|
printf("%sPlayback channels:", space);
|
||||||
if (snd_mixer_selem_is_playback_mono(elem)) {
|
if (snd_mixer_selem_is_playback_mono(elem)) {
|
||||||
printf("Mono");
|
printf(" Mono");
|
||||||
} else {
|
} else {
|
||||||
int first = 1;
|
int first = 1;
|
||||||
for (chn = 0; chn <= SND_MIXER_SCHN_LAST; chn++){
|
for (chn = 0; chn <= SND_MIXER_SCHN_LAST; chn++){
|
||||||
if (!snd_mixer_selem_has_playback_channel(elem, chn))
|
if (!snd_mixer_selem_has_playback_channel(elem, chn))
|
||||||
continue;
|
continue;
|
||||||
if (!first)
|
if (!first)
|
||||||
printf("- ");
|
printf(" -");
|
||||||
printf("%s ", snd_mixer_selem_channel_name(chn));
|
printf(" %s", snd_mixer_selem_channel_name(chn));
|
||||||
first = 0;
|
first = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -579,17 +579,17 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char
|
||||||
}
|
}
|
||||||
if (snd_mixer_selem_has_capture_volume(elem) ||
|
if (snd_mixer_selem_has_capture_volume(elem) ||
|
||||||
snd_mixer_selem_has_capture_switch(elem)) {
|
snd_mixer_selem_has_capture_switch(elem)) {
|
||||||
printf("%sCapture channels: ", space);
|
printf("%sCapture channels:", space);
|
||||||
if (snd_mixer_selem_is_capture_mono(elem)) {
|
if (snd_mixer_selem_is_capture_mono(elem)) {
|
||||||
printf("Mono");
|
printf(" Mono");
|
||||||
} else {
|
} else {
|
||||||
int first = 1;
|
int first = 1;
|
||||||
for (chn = 0; chn <= SND_MIXER_SCHN_LAST; chn++){
|
for (chn = 0; chn <= SND_MIXER_SCHN_LAST; chn++){
|
||||||
if (!snd_mixer_selem_has_capture_channel(elem, chn))
|
if (!snd_mixer_selem_has_capture_channel(elem, chn))
|
||||||
continue;
|
continue;
|
||||||
if (!first)
|
if (!first)
|
||||||
printf("- ");
|
printf(" -");
|
||||||
printf("%s ", snd_mixer_selem_channel_name(chn));
|
printf(" %s", snd_mixer_selem_channel_name(chn));
|
||||||
first = 0;
|
first = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -597,19 +597,19 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char
|
||||||
}
|
}
|
||||||
if (snd_mixer_selem_has_playback_volume(elem) ||
|
if (snd_mixer_selem_has_playback_volume(elem) ||
|
||||||
snd_mixer_selem_has_capture_volume(elem)) {
|
snd_mixer_selem_has_capture_volume(elem)) {
|
||||||
printf("%sLimits: ", space);
|
printf("%sLimits:", space);
|
||||||
if (snd_mixer_selem_has_common_volume(elem)) {
|
if (snd_mixer_selem_has_common_volume(elem)) {
|
||||||
snd_mixer_selem_get_playback_volume_range(elem, &pmin, &pmax);
|
snd_mixer_selem_get_playback_volume_range(elem, &pmin, &pmax);
|
||||||
snd_mixer_selem_get_capture_volume_range(elem, &cmin, &cmax);
|
snd_mixer_selem_get_capture_volume_range(elem, &cmin, &cmax);
|
||||||
printf("%li - %li", pmin, pmax);
|
printf(" %li - %li", pmin, pmax);
|
||||||
} else {
|
} else {
|
||||||
if (snd_mixer_selem_has_playback_volume(elem)) {
|
if (snd_mixer_selem_has_playback_volume(elem)) {
|
||||||
snd_mixer_selem_get_playback_volume_range(elem, &pmin, &pmax);
|
snd_mixer_selem_get_playback_volume_range(elem, &pmin, &pmax);
|
||||||
printf("Playback %li - %li ", pmin, pmax);
|
printf(" Playback %li - %li", pmin, pmax);
|
||||||
}
|
}
|
||||||
if (snd_mixer_selem_has_capture_volume(elem)) {
|
if (snd_mixer_selem_has_capture_volume(elem)) {
|
||||||
snd_mixer_selem_get_capture_volume_range(elem, &cmin, &cmax);
|
snd_mixer_selem_get_capture_volume_range(elem, &cmin, &cmax);
|
||||||
printf("Capture %li - %li", cmin, cmax);
|
printf(" Capture %li - %li", cmin, cmax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -631,61 +631,61 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char
|
||||||
#endif
|
#endif
|
||||||
if (pmono || cmono) {
|
if (pmono || cmono) {
|
||||||
if (!mono_ok) {
|
if (!mono_ok) {
|
||||||
printf("%s%s: ", space, "Mono");
|
printf("%s%s:", space, "Mono");
|
||||||
mono_ok = 1;
|
mono_ok = 1;
|
||||||
}
|
}
|
||||||
if (snd_mixer_selem_has_common_volume(elem)) {
|
if (snd_mixer_selem_has_common_volume(elem)) {
|
||||||
snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, &pvol);
|
snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, &pvol);
|
||||||
printf("%s ", get_percent(pvol, pmin, pmax));
|
printf(" %s", get_percent(pvol, pmin, pmax));
|
||||||
}
|
}
|
||||||
if (snd_mixer_selem_has_common_switch(elem)) {
|
if (snd_mixer_selem_has_common_switch(elem)) {
|
||||||
snd_mixer_selem_get_playback_switch(elem, SND_MIXER_SCHN_MONO, &psw);
|
snd_mixer_selem_get_playback_switch(elem, SND_MIXER_SCHN_MONO, &psw);
|
||||||
printf("[%s] ", psw ? "on" : "off");
|
printf(" [%s]", psw ? "on" : "off");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pmono && snd_mixer_selem_has_playback_channel(elem, SND_MIXER_SCHN_MONO)) {
|
if (pmono && snd_mixer_selem_has_playback_channel(elem, SND_MIXER_SCHN_MONO)) {
|
||||||
int title = 0;
|
int title = 0;
|
||||||
if (!mono_ok) {
|
if (!mono_ok) {
|
||||||
printf("%s%s: ", space, "Mono");
|
printf("%s%s:", space, "Mono");
|
||||||
mono_ok = 1;
|
mono_ok = 1;
|
||||||
}
|
}
|
||||||
if (!snd_mixer_selem_has_common_volume(elem)) {
|
if (!snd_mixer_selem_has_common_volume(elem)) {
|
||||||
if (snd_mixer_selem_has_playback_volume(elem)) {
|
if (snd_mixer_selem_has_playback_volume(elem)) {
|
||||||
printf("Playback ");
|
printf(" Playback");
|
||||||
title = 1;
|
title = 1;
|
||||||
snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, &pvol);
|
snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, &pvol);
|
||||||
printf("%s ", get_percent(pvol, pmin, pmax));
|
printf(" %s", get_percent(pvol, pmin, pmax));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!snd_mixer_selem_has_common_switch(elem)) {
|
if (!snd_mixer_selem_has_common_switch(elem)) {
|
||||||
if (snd_mixer_selem_has_playback_switch(elem)) {
|
if (snd_mixer_selem_has_playback_switch(elem)) {
|
||||||
if (!title)
|
if (!title)
|
||||||
printf("Playback ");
|
printf(" Playback");
|
||||||
snd_mixer_selem_get_playback_switch(elem, SND_MIXER_SCHN_MONO, &psw);
|
snd_mixer_selem_get_playback_switch(elem, SND_MIXER_SCHN_MONO, &psw);
|
||||||
printf("[%s] ", psw ? "on" : "off");
|
printf(" [%s]", psw ? "on" : "off");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cmono && snd_mixer_selem_has_capture_channel(elem, SND_MIXER_SCHN_MONO)) {
|
if (cmono && snd_mixer_selem_has_capture_channel(elem, SND_MIXER_SCHN_MONO)) {
|
||||||
int title = 0;
|
int title = 0;
|
||||||
if (!mono_ok) {
|
if (!mono_ok) {
|
||||||
printf("%s%s: ", space, "Mono");
|
printf("%s%s:", space, "Mono");
|
||||||
mono_ok = 1;
|
mono_ok = 1;
|
||||||
}
|
}
|
||||||
if (!snd_mixer_selem_has_common_volume(elem)) {
|
if (!snd_mixer_selem_has_common_volume(elem)) {
|
||||||
if (snd_mixer_selem_has_capture_volume(elem)) {
|
if (snd_mixer_selem_has_capture_volume(elem)) {
|
||||||
printf("Capture ");
|
printf(" Capture");
|
||||||
title = 1;
|
title = 1;
|
||||||
snd_mixer_selem_get_capture_volume(elem, SND_MIXER_SCHN_MONO, &cvol);
|
snd_mixer_selem_get_capture_volume(elem, SND_MIXER_SCHN_MONO, &cvol);
|
||||||
printf("%s ", get_percent(cvol, cmin, cmax));
|
printf(" %s", get_percent(cvol, cmin, cmax));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!snd_mixer_selem_has_common_switch(elem)) {
|
if (!snd_mixer_selem_has_common_switch(elem)) {
|
||||||
if (snd_mixer_selem_has_capture_switch(elem)) {
|
if (snd_mixer_selem_has_capture_switch(elem)) {
|
||||||
if (!title)
|
if (!title)
|
||||||
printf("Capture ");
|
printf(" Capture");
|
||||||
snd_mixer_selem_get_capture_switch(elem, SND_MIXER_SCHN_MONO, &csw);
|
snd_mixer_selem_get_capture_switch(elem, SND_MIXER_SCHN_MONO, &csw);
|
||||||
printf("[%s] ", csw ? "on" : "off");
|
printf(" [%s]", csw ? "on" : "off");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -696,31 +696,31 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char
|
||||||
if ((pmono || !snd_mixer_selem_has_playback_channel(elem, chn)) &&
|
if ((pmono || !snd_mixer_selem_has_playback_channel(elem, chn)) &&
|
||||||
(cmono || !snd_mixer_selem_has_capture_channel(elem, chn)))
|
(cmono || !snd_mixer_selem_has_capture_channel(elem, chn)))
|
||||||
continue;
|
continue;
|
||||||
printf("%s%s: ", space, snd_mixer_selem_channel_name(chn));
|
printf("%s%s:", space, snd_mixer_selem_channel_name(chn));
|
||||||
if (!pmono && !cmono && snd_mixer_selem_has_common_volume(elem)) {
|
if (!pmono && !cmono && snd_mixer_selem_has_common_volume(elem)) {
|
||||||
snd_mixer_selem_get_playback_volume(elem, chn, &pvol);
|
snd_mixer_selem_get_playback_volume(elem, chn, &pvol);
|
||||||
printf("%s ", get_percent(pvol, pmin, pmax));
|
printf(" %s", get_percent(pvol, pmin, pmax));
|
||||||
}
|
}
|
||||||
if (!pmono && !cmono && snd_mixer_selem_has_common_switch(elem)) {
|
if (!pmono && !cmono && snd_mixer_selem_has_common_switch(elem)) {
|
||||||
snd_mixer_selem_get_playback_switch(elem, chn, &psw);
|
snd_mixer_selem_get_playback_switch(elem, chn, &psw);
|
||||||
printf("[%s] ", psw ? "on" : "off");
|
printf(" [%s]", psw ? "on" : "off");
|
||||||
}
|
}
|
||||||
if (!pmono && snd_mixer_selem_has_playback_channel(elem, chn)) {
|
if (!pmono && snd_mixer_selem_has_playback_channel(elem, chn)) {
|
||||||
int title = 0;
|
int title = 0;
|
||||||
if (!snd_mixer_selem_has_common_volume(elem)) {
|
if (!snd_mixer_selem_has_common_volume(elem)) {
|
||||||
if (snd_mixer_selem_has_playback_volume(elem)) {
|
if (snd_mixer_selem_has_playback_volume(elem)) {
|
||||||
printf("Playback ");
|
printf(" Playback");
|
||||||
title = 1;
|
title = 1;
|
||||||
snd_mixer_selem_get_playback_volume(elem, chn, &pvol);
|
snd_mixer_selem_get_playback_volume(elem, chn, &pvol);
|
||||||
printf("%s ", get_percent(pvol, pmin, pmax));
|
printf(" %s", get_percent(pvol, pmin, pmax));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!snd_mixer_selem_has_common_switch(elem)) {
|
if (!snd_mixer_selem_has_common_switch(elem)) {
|
||||||
if (snd_mixer_selem_has_playback_switch(elem)) {
|
if (snd_mixer_selem_has_playback_switch(elem)) {
|
||||||
if (!title)
|
if (!title)
|
||||||
printf("Playback ");
|
printf(" Playback");
|
||||||
snd_mixer_selem_get_playback_switch(elem, chn, &psw);
|
snd_mixer_selem_get_playback_switch(elem, chn, &psw);
|
||||||
printf("[%s] ", psw ? "on" : "off");
|
printf(" [%s]", psw ? "on" : "off");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -728,18 +728,18 @@ static int show_selem(snd_mixer_t *handle, snd_mixer_selem_id_t *id, const char
|
||||||
int title = 0;
|
int title = 0;
|
||||||
if (!snd_mixer_selem_has_common_volume(elem)) {
|
if (!snd_mixer_selem_has_common_volume(elem)) {
|
||||||
if (snd_mixer_selem_has_capture_volume(elem)) {
|
if (snd_mixer_selem_has_capture_volume(elem)) {
|
||||||
printf("Capture ");
|
printf(" Capture");
|
||||||
title = 1;
|
title = 1;
|
||||||
snd_mixer_selem_get_capture_volume(elem, chn, &cvol);
|
snd_mixer_selem_get_capture_volume(elem, chn, &cvol);
|
||||||
printf("%s ", get_percent(cvol, cmin, cmax));
|
printf(" %s", get_percent(cvol, cmin, cmax));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!snd_mixer_selem_has_common_switch(elem)) {
|
if (!snd_mixer_selem_has_common_switch(elem)) {
|
||||||
if (snd_mixer_selem_has_capture_switch(elem)) {
|
if (snd_mixer_selem_has_capture_switch(elem)) {
|
||||||
if (!title)
|
if (!title)
|
||||||
printf("Capture ");
|
printf(" Capture");
|
||||||
snd_mixer_selem_get_capture_switch(elem, chn, &csw);
|
snd_mixer_selem_get_capture_switch(elem, chn, &csw);
|
||||||
printf("[%s] ", csw ? "on" : "off");
|
printf(" [%s]", csw ? "on" : "off");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,6 +320,7 @@ int main(int argc, char *argv[])
|
||||||
};
|
};
|
||||||
char *pcm_name = "default";
|
char *pcm_name = "default";
|
||||||
int tmp, err, c;
|
int tmp, err, c;
|
||||||
|
int do_device_list = 0, do_pcm_list = 0;
|
||||||
snd_pcm_info_t *info;
|
snd_pcm_info_t *info;
|
||||||
|
|
||||||
err = snd_output_stdio_attach(&log, stderr, 0);
|
err = snd_output_stdio_attach(&log, stderr, 0);
|
||||||
|
@ -354,11 +355,11 @@ int main(int argc, char *argv[])
|
||||||
version();
|
version();
|
||||||
return 0;
|
return 0;
|
||||||
case 'l':
|
case 'l':
|
||||||
device_list();
|
do_device_list = 1;
|
||||||
return 0;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
pcm_list();
|
do_pcm_list = 1;
|
||||||
return 0;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
pcm_name = optarg;
|
pcm_name = optarg;
|
||||||
break;
|
break;
|
||||||
|
@ -464,6 +465,15 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (do_device_list) {
|
||||||
|
if (do_pcm_list) pcm_list();
|
||||||
|
device_list();
|
||||||
|
return 0;
|
||||||
|
} else if (do_pcm_list) {
|
||||||
|
pcm_list();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
err = snd_pcm_open(&handle, pcm_name, stream, open_mode);
|
err = snd_pcm_open(&handle, pcm_name, stream, open_mode);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
error("audio open error: %s", snd_strerror(err));
|
error("audio open error: %s", snd_strerror(err));
|
||||||
|
|
Loading…
Reference in a new issue