[alsa-devel] [LAD] announcing envy24control, mudita (*) edition.

Niels Mayer nielsmayer at gmail.com
Wed Aug 4 07:55:14 CEST 2010


On Tue, Aug 3, 2010 at 10:38 PM, Raymond Yau
<superquad.vortex2 at gmail.com> wrote:
> 2010/8/4 Niels Mayer <nielsmayer at gmail.com>
>>   * fixed --card and --device to allow valid ALSA names and numbers
>>        ( https://bugzilla.redhat.com/show_bug.cgi?id=602900 ).
>
> ./envy24control -Ddefault
>
> card_number = atoi(strchr(name, ':') + sizeof(char));
>
> This bug seem still occur when name does not contain ":" since ctl device is
> "hw:n" where n is card number

I used similar code to what's in alsamixer to perform the same
functions as the old broken code. Now the code behaves as follows:

gnulem-238-~> envy24control -Dhw:default
envy24control: invalid ALSA audio device, invalid index or name for
card: hw:default
gnulem-239-~> envy24control -Dhw:M66
using	 --- input_channels: 4
	 --- output_channels: 4
	 --- pcm_output_channels: 8
	 --- spdif in/out channels: 2
gnulem-240-~> envy24control -Dhw:M66.0
envy24control: invalid ALSA audio device, invalid index or name for
card: hw:M66.0
gnulem-241-~> envy24control -Dhw:M66,0
envy24control: invalid ALSA audio device, invalid index or name for
card: hw:M66,0
gnulem-242-~> envy24control -DM66
envy24control: ALSA audio device syntax expects ':' character: M66


Current code:

	while ((c = getopt_long(argc, argv, "D:c:f:i:m:Mo:p:s:w:vt:ng:",
long_options, NULL)) != -1) {
		switch (c) {
		case 'D':
			name = optarg;
			if (!index(name, ':')) {
			  fprintf(stderr, "envy24control: ALSA audio device syntax expects
':' character: %s\n", optarg);
			  exit(1);
			}
			card_number = snd_card_get_index(strchr(name, ':') + sizeof(char));
/* NPM: use correct ALSA-specific call to fix
https://bugzilla.redhat.com/show_bug.cgi?id=602900  */
			if (card_number < 0) {		/* NPM: code orig from alsa-utils/alsamixer/cli.c */
			  fprintf(stderr, "envy24control: invalid ALSA audio device,
invalid index or name for card: %s\n", optarg);
			  exit(1);
			}
			break;
		case 'c':
			card_number = snd_card_get_index(optarg); /* NPM: use correct
ALSA-specific call to fix
https://bugzilla.redhat.com/show_bug.cgi?id=602900  */
			if (card_number < 0) {		/* NPM: code orig from alsa-utils/alsamixer/cli.c */
				fprintf(stderr, "envy24control: invalid ALSA index or name for
audio card: %s\n", optarg);
				exit(1);
			}
			sprintf(tmpname, "hw:%d", card_number);
			name = tmpname;
			break;

-- Niels
http://nielsmayer.com


More information about the Alsa-devel mailing list