From 88272c9da38a91394a7591f5b2414c96550ca85f Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 15 May 2001 12:25:25 +0000 Subject: [PATCH] Added -D option and improved -c option --- alsamixer/alsamixer.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/alsamixer/alsamixer.c b/alsamixer/alsamixer.c index ff76123..b4769ec 100644 --- a/alsamixer/alsamixer.c +++ b/alsamixer/alsamixer.c @@ -182,7 +182,7 @@ static int mixer_ofs_x = 0; static float mixer_extra_space = 0; static int mixer_cbar_height = 0; -static char* card_id = "hw:0"; +static char card_id[64] = "hw:0"; static snd_mixer_t *mixer_handle; static char mixer_card_name[128]; static char mixer_device_name[128]; @@ -1763,16 +1763,27 @@ main (int argc, */ do { - opt = getopt (argc, argv, "c:shg"); + opt = getopt (argc, argv, "c:D:shg"); switch (opt) { case '?': case 'h': fprintf (stderr, "%s %s\n", PRGNAME_UPPER, VERSION); - fprintf (stderr, "Usage: %s [-c ] [-z]\n", PRGNAME); + fprintf (stderr, "Usage: %s [-h] [-c ] [-D ] [-g] [-s]\n", PRGNAME); mixer_abort (ERR_NONE, "", 0); case 'c': - card_id = optarg; + { + int i = snd_card_get_index(optarg); + if (i < 0 || i > 31) { + fprintf (stderr, "wrong -c argument '%s'\n", optarg); + mixer_abort (ERR_NONE, "", 0); + } + sprintf(card_id, "hw:%i", i); + } + break; + case 'D': + strncpy(card_id, optarg, sizeof(card_id)); + card_id[sizeof(card_id)-1] = '\0'; break; case 'g': mixer_do_color = !mixer_do_color; -- 2.11.0