From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3435CC433E7 for ; Fri, 9 Oct 2020 15:36:37 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9720121D6C for ; Fri, 9 Oct 2020 15:36:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="LF1fz0Zy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9720121D6C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D7DFD1663; Fri, 9 Oct 2020 17:35:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D7DFD1663 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1602257793; bh=uFCuywGEBhzmRWeYRvH+cFyj3b1OXjwYKiIfw31xyiE=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LF1fz0ZyzBatQAoaaTokLqNiD2PHnLu3QQQQg0vv65tkehwQmr3riudfRiUqzdPY0 DIDCgpMmFQwe1P1EXHtVGBXyF+CfKLDZqpjhARGhnAwGqlEFpRQpYTxbP9/26cT3WU OfxZrXK3MqfW1w71VKUraAnPof2P6yp43tJxQB2g= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 63085F8014D; Fri, 9 Oct 2020 17:35:43 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 60834F8015B; Fri, 9 Oct 2020 17:35:41 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3EB03F800BF for ; Fri, 9 Oct 2020 17:35:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3EB03F800BF X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3C64AB25D; Fri, 9 Oct 2020 15:35:37 +0000 (UTC) Date: Fri, 09 Oct 2020 17:35:37 +0200 Message-ID: From: Takashi Iwai To: info Subject: Re: Discover a microphone device, to later discover if it is receiving input In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: alsa-devel@alsa-project.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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