[alsa-devel] usb-audio: I'd like to change two things in usb audio, but I'm not sure if it's right

Takashi Iwai tiwai at suse.de
Fri Dec 5 18:01:35 CET 2014


At Mon, 24 Nov 2014 22:16:37 +0100,
Johan Aires Rastén wrote:
> 
> So I'll try again, this time with the proper cc:s and a second question.
> 
> I've come across two issues in the usb audio module that are causing
> problems with my sound card, but I'm thinking that changing them might
> break something for some other card.
> 
> In sound/usb/mixer.c function check_input_term(...), for the case
> UAC_INPUT_TERMINAL and UAC_VERSION_2:
> 
> The recursive call to get clock selectors messes up the naming of my
> terminals. At this stage the terminals are already properly named Mic and
> Line but the call overwrites them both with the unnamed clock selector
> "Unit 22". Are other UAC2 cards different, so that the clock selector
> contains the correct terminal name, or is there some other reasoning here
> that I'm not seeing?
> 
> Could the call be removed, or perhaps only done if no terminal name has
> been found yet?
>
> In sound/usb/stream.c function snd_usb_add_audio_stream(...), near the end
> of the function:
> 
> A newly created pcm is added with "list_add(&as->list, &chip->pcm_list);"
> which causes devices to be listed in reverse order, i.e. device 0 will be
> at the end of the list, and this leads to that capture streams end up in
> the wrong device under certain circumstances.

> The problem arises when the code under "look for an empty stream" earlier
> in the same function executes. It will attach the capture stream to the
> first compatible existing stream, but since they are reversed it will find
> the highest numbered device. In my case analog input will be grouped with
> digital out (device 1) instead of analog out (device 0).
> 
> This is assuming that playback streams are defined before capture streams
> but it could happen in the other direction as long as there are several
> streams of one type.
> 
> I also suspect that this is what causes the M-Audio Audiophile USB to have
> swapped inputs, for which there's a fix in USB-Audio.conf (
> http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/conf/cards/USB-Audio.conf#l70
> ). Thanks to debianuser on IRC for helping me find it.
> 
> I would like to change this call to use list_add_tail for adding new items
> instead, but I'm worried that there are quirks or other fixes that expect
> the current behaviour. There are very few other references to pcm_list and
> none of them seem to care about ordering.

Both points you suggested can't be changed unconditionally,
unfortunately.  These would break the existing configuration.  So, if
any, doing it with some flags or a bit more cleverly.

I guess the latter one should be changed to list_add_tail() as
default, but use list_add() for the dedicated device (Audiophile) so
that it'll keep working with the current alsa-lib config.

The former one is difficult to say; I guess it rather depends on the
firmware which one to pick up.  We may compare two strings and pick up
a better one, too...


Takashi


More information about the Alsa-devel mailing list