Discover a microphone device, to later discover if it is receiving input

Takashi Iwai tiwai at suse.de
Fri Oct 9 17:35:37 CEST 2020


On Sun, 04 Oct 2020 18:22:43 +0200,
info wrote:
> 
> Hi all,
> 
> 
> I am writing a program that aims to auto-discover the microphone
> device that the user is speaking into. I started off by querying
> device hints and collected all devices with the IO types of null,
> since I have not found any devices with the type of Input. I am
> puzzled how it is possible that there is no Input, where a microphone
> device should not be able to emit sound. This is the list on my
> particular machine:
> 
> Name of device: sysdefault:CARD=SB
> Description of device: HDA ATI SB, ALC892 Analog
> Default Audio Device
> I/O type of device: (null)
> 
> Name of device: front:CARD=SB,DEV=0
> Description of device: HDA ATI SB, ALC892 Analog
> Front speakers
> I/O type of device: (null)
> 
> Name of device: surround21:CARD=SB,DEV=0
> Description of device: HDA ATI SB, ALC892 Analog
> 2.1 Surround output to Front and Subwoofer speakers
> I/O type of device: Output
> 
> Name of device: surround41:CARD=SB,DEV=0
> Description of device: HDA ATI SB, ALC892 Analog
> 4.1 Surround output to Front, Rear and Subwoofer speakers
> I/O type of device: Output
> 
> Name of device: surround50:CARD=SB,DEV=0
> Description of device: HDA ATI SB, ALC892 Analog
> 5.0 Surround output to Front, Center and Rear speakers
> I/O type of device: Output
> 
> Name of device: surround71:CARD=SB,DEV=0
> Description of device: HDA ATI SB, ALC892 Analog
> 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
> I/O type of device: Output
> 
> Name of device: sysdefault:CARD=SB
> Description of device: HDA ATI SB, ALC892 Analog
> Default Audio Device
> I/O type of device: (null)
> 
> Name of device: front:CARD=SB,DEV=0
> Description of device: HDA ATI SB, ALC892 Analog
> Front speakers
> I/O type of device: (null)
> 
> Now, I am more puzzled, because none of them is a microphone device
> explicitly. How can my program determine which of them is actually a
> microphone?
> 
> Also, why are devices are duplicated in the output from
> snd_device_name_hint()? The very first device is also repeated as the
> 2nd last one...

Apart from the lack of the Input direction (maybe a bug in the hint
code), the fundamental problem is that the driver cannot tell always
the device type at all for each PCM stream.  It's simply because a
stream may give you any input type depending on the mixer route; it's
the case of HD-audio.  So, the same PCM device may be a mic, or a
headset mic, or a line-in, or whatever.

Sometimes there are dedicated PCM devices for certain inputs, but most
of the PCM streams are generic purpose.


Takashi


More information about the Alsa-devel mailing list