Opened 4 years ago

Closed 3 years ago

#40 closed defect (fixed)

Alsa microphone is not working

Reported by: iNPUTmice Owned by: vadim
Priority: critical Milestone: QuteCom 2.2-RC4
Component: misc Version: 2.2
Keywords: Cc: cavedon

Description

Hi
with RC3 (don't know about earlier) my mircophone is not working. Everytime I do something mic related (eg accessing the mic volume mixer) or selecting my input device in the settings I get

16:11:28 [Common] int set_mixer_level_private(snd_mixer_t*, const char*, mixer_element_type, int): failed to find snd_mixer_elem_t: Capture
(warn) 16:11:28 [Common] int get_mixer_level_private(snd_mixer_t*, const char*, mixer_element_type): failed to find snd_mixer_elem_t: Capture

I can use the mic with audacity or something so it is somehow supported by alsa. Maybe this bug is somehow related to the fact that i have actual three microphones in my alsa mixer (integrated (which i wanna use), external and docking)

I dont know anything about audio under Linux so please tell me what kind of further debug info do you need.

Attachments (3)

alsa-default-device.patch (1.2 KB) - added by cavedon 4 years ago.
fix-alsa-mixer.patch (3.3 KB) - added by cavedon 4 years ago.
alsa-hw-mixer.patch (2.4 KB) - added by cavedon 4 years ago.

Download all attachments as: .zip

Change History (23)

comment:1 Changed 4 years ago by vadim

  • Milestone changed from QuteCom 2.2-RC2 to QuteCom 2.2-RC4

comment:2 Changed 4 years ago by cavedon

  • Cc cavedon added

comment:3 Changed 4 years ago by cavedon

iNPUTmice,
some useful information would be:

  • which distribution are you using, 32 or 64 bit?
  • output of aplay -L
  • output of aplay -l
  • output of aplay --version
  • content of ~/.asoundrc (if any)
  • content of /etc/asound.conf (if any)

Thanks!

comment:4 Changed 4 years ago by cavedon

And also, please:

  • what are your audio settings of qutecom? default? Is it not working with any of the 3 microphones? Does if work if you leave it to "default"?
  • output of running "OWLOGGER_DEFAULT=debug qutecom" and starting a phone call with non-working mic.

Thanks!

comment:5 Changed 4 years ago by cavedon

Mhm, there is some incomplete code in the mixer management:
libs/sound/src/linux/LinuxVolumeControl.cpp:

int LinuxVolumeControl::getLevel() {
        int level;
	// TODO: retrieve the sound card name from the AudioDevice
        if (_strDeviceType == "pcm") {
                get_mixer_level("hw:0", PCM_VOLUME, &level);
                return level;
        } else if (_strDeviceType == "capture") {
                get_mixer_level("hw:0", CAPTURE_VOLUME, &level);
                return level;
        }

There are a couple of things here:

  • as the comment says, this code does not get the device that in the user settings
  • I do not why "hw:0" was chosen, but a more sensible choice should be "default"
  • I think that "Master" value instead of "PCM" volume should be used for playback, the first one should be always present (e.g. both hw:0 and and pulseaudio), the latter is "hw:0" specific
  • the capture mixer device is somehat more difficult to choose; right know it is set to "Capture", but e.g. my hw:0 as only "Int Mic" and "Ext Mic" (and therefore I also see the messages reported by iNPUTmice). However my "default" device (i.e. pulseaudio) has "Capture", so I would leave it so

That said, I am not sure what sould be the right way do deal with the mixer. For example, some cards have two capture volumes, like mine. How do you choose the right one? Ask the user? This should not be a concern of the application... I believe that pulseaudio is the right way to go...

comment:6 Changed 4 years ago by cavedon

  • Status changed from new to assigned

Handling of mixer under linux was broken: even if the mixer name was correct, the slides would never move away from the minimum.

I am attaching a patch which:

  • fixes the GUI slides
  • use the correct device from the user settings
  • use Master and Capture as mixer names; will not work in all cases, but I think it is the best guess, so far

Changed 4 years ago by cavedon

comment:7 Changed 4 years ago by cavedon

Sorry, forget alsa-default-device.patch, I have lost the correct one... I'll post it shortly

Changed 4 years ago by cavedon

comment:8 Changed 4 years ago by cavedon

The good patch is fix-alsa-mixer.patch, *not* alsa-default-device.patch.

There is still an issue: the mixer will not work if the selected device is not "default".

comment:9 Changed 4 years ago by vadim

I've applied it

comment:10 Changed 4 years ago by cavedon

Vadim, thanks for promptly merging the patches!

Here is another one:

  • rewrite device names like "hw:0,1", "plughw:0", "dmix:0" to "hw:0" in order to be able to open the mixer
  • if the mixer name "Capture" is not available, try with "Mic".

This should cover most of the sound cards. Still I have not figured it out what is the standard way (if any!) to get the mixer. Here is my request to alsa-devel:
http://thread.gmane.org/gmane.linux.alsa.devel/62253

comment:11 follow-up: Changed 4 years ago by vadim

Could you please, rewrite your patch without using boost?

Thanks
Vadim

comment:12 in reply to: ↑ 11 Changed 4 years ago by cavedon

Replying to vadim:

Could you please, rewrite your patch without using boost?

well, yes I can.

I thought that as qutecom is already linking against boost, a one-line call to a boost working directly on std::string would have been better...
Anyway, I see that adding one more .so to load at startup just for doing some search and replace is arguable :)

Changed 4 years ago by cavedon

comment:13 Changed 4 years ago by cavedon

Here is the patch without using boost

comment:14 Changed 4 years ago by vadim

  • Resolution set to fixed
  • Status changed from assigned to closed

committed

comment:15 Changed 3 years ago by christian_bay

  • Resolution fixed deleted
  • Status changed from closed to reopened

I have one of those soundcards not covered by this fix. I experience the same thing as mentioned above, cannot unmute Microphone mixer, on the console qutecom prints:

(warn) 22:00:47 [Common] int get_mixer_level_private(snd_mixer_t*, const char*, mixer_element_type): failed to find snd_mixer_elem_t: Capture
(warn) 22:00:47 [Common] int get_mixer_level_private(snd_mixer_t*, const char*, mixer_element_type): failed to find snd_mixer_elem_t: Mic

I am using snd_hda_intel, with Conextant Codec 5051. amixer prints the following:
Simple mixer control 'Master',0

Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 74
Mono:
Front Left: Playback 0 [0%] [-74.00dB] [off]
Front Right: Playback 0 [0%] [-74.00dB] [off]

Simple mixer control 'IEC958',0

Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [off]

Simple mixer control 'IEC958 Default PCM',0

Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]

Simple mixer control 'Docking Mic',0

Capabilities: volume pswitch
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 80
Front Left: 68 [85%] [-6.00dB] Playback [on]
Front Right: 68 [85%] [-6.00dB] Playback [on]

Simple mixer control 'External Mic',0

Capabilities: volume pswitch
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 80
Front Left: 68 [85%] [-6.00dB] Playback [on]
Front Right: 68 [85%] [-6.00dB] Playback [on]

Simple mixer control 'Internal Mic',0

Capabilities: volume pswitch
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 80
Front Left: 68 [85%] [-6.00dB] Playback [on]
Front Right: 68 [85%] [-6.00dB] Playback [on]

As you can see there are two channels (stero) for the Mic mixer which can be controlled seperately. Perhaps this is the issue? Perhaps somekind of sub-mixer must be accessed instead of of one for both channels? Or just another name for the channel?

I am using qutecom 2.2 revx86_64-pc-1-gnu-g-20091116181549, qt 4.5.3, boost 1_39, glib 2.22.2 with gcc-4.3.4 on Gentoo linux-2.6.30-r5.

comment:16 Changed 3 years ago by christian_bay

Ok, this seems to be a naming issue. I temporarily worked around by loading snd_hda_intel with options snd-hda-intel model=hp-dv6736 the model is forced to another (wrong) one without external mic input. The mic control is still stereo, for left and right but its name is "Mic":

$ amixer
Simple mixer control 'Master',0

Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 74
Mono:
Front Left: Playback 45 [61%] [-29.00dB] [on]
Front Right: Playback 45 [61%] [-29.00dB] [on]

Simple mixer control 'PCM',0

Capabilities: pvolume
Playback channels: Front Left - Front Right
Limits: Playback 0 - 255
Mono:
Front Left: Playback 255 [100%] [0.00dB]
Front Right: Playback 255 [100%] [0.00dB]

Simple mixer control 'Mic',0

Capabilities: volume pswitch
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 80
Front Left: 48 [60%] [-26.00dB] Playback [on]
Front Right: 48 [60%] [-26.00dB] Playback [on]

Simple mixer control 'IEC958',0

Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [off]

Simple mixer control 'IEC958 Default PCM',0

Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]

And voila - qutecom can control the volume as expected. I don't need the external mic yet but it would be nice if qutecom could choose the desired mic input.

comment:17 Changed 3 years ago by christian_bay

Ok, no fix. The only one mic mixer is the one for the external mic jack, not for the internal mic itself. So help would be apreciated ;)

comment:18 Changed 3 years ago by cavedon

There is deep issue here: ALSA tries to expose a mixer that is as close as possible to the hardware. So there might be multiple input mixers and switches. There is no way within an application which one is the right one, and the ALSA API gives not help in this direction. Qutecom makes two reasonable attempt with guessing. "Capture" and "Master", that it gives up. Well, it could help some people to let the qutecom user choose which mixer slider to use, but then the user need to be sure it keep that switch synchronized with the actual switch in the alsamixer choosing whcih microphone to use. On the other side, it does not make sense to replicate the whole mixer structure into qutecom.

My suggestion:
-use the ALSA mixer to adjust the volume
-and/or better: use Pulseaudio (each application will see a common interface, with a per-application and unique mic volume slider)

comment:19 Changed 3 years ago by chris-mac

  • Version changed from 2.2-RC3 to 2.2

comment:20 Changed 3 years ago by pdambc163

  • field_os set to all
  • Resolution set to fixed
  • Status changed from reopened to closed

It could help some people to let the qutecom user choose which mixer slider to use.

frontierville cheats

Note: See TracTickets for help on using tickets.