Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSX CoreAudio mic input mute vs. setting volume to 0.0f

I'm attempting to mute the mic on my Logitech C920 webcam (OSX 10.8.5), but both implementations that I have tried do not work 100%. I would really appreciate it if someone who has experience with Apple's CoreAudio could take a look.

Here is what I have tried:

  • Setting mute via AudioObjectSetPropertyData() using:

    address.mScope = kAudioDevicePropertyScopeInput;
    address.mElement = kAudioObjectPropertyElementMaster;
    address.mSelector = kAudioDevicePropertyMute;
    

This works, I can successfully mute/unmute but eventually I am able to get into a state where the mic is no longer receiving audio. It seems to be triggered by switching the default input to the internal mic while the C920 is in the muted state and switching back to the C920 mic. The only way that I have found to get the C920 mic back into a good state is to pull the USB cable and plug it back in.

  • Setting the volume to 0.0f via AudioObjectSetPropertyData() using:

    address.mScope = kAudioDevicePropertyScopeInput;
    address.mElement = kAudioObjectPropertyElementMaster;
    address.mSelector = kAudioDevicePropertyVolumeScalar;
    

This almost works. The OSX UI input volume slider moves all the way to the left, but the mic is still picking up a little bit of audio. Uhhhhggg so close!

Opening the "Audio MIDI setup" app shows the C920 mic. When the volume value is set to zero, the dB value is 20. When the volume value is set to 1, the db value is set to 50. This is different from the built in mic that looks like it has a dB range of -12 to 12. Not sure if this matters.

When setting mute or the volume, I've tried fetching the individual channels and setting them as well. Doesn't seem to have an impact. I think with both input devices setting the Master channel is working fine.

I was wondering if maybe this is a hardware issue. I should note that the Logitech C920 isn't officially supported on the Mac (although a ton of people use it). I'm able to control the internal mic without any issues. Hopefully I'm just overlooking something :-)

like image 213
kr4sh Avatar asked Nov 02 '22 10:11

kr4sh


1 Answers

When setting volume kAudioDevicePropertyVolumeScalar to zero. You should also set mute to true using kAudioDevicePropertyMute. When adjusting volume of inputs, be careful to check the mute status.

For example:

  1. Adjust input volume in system audio panel to 0
  2. Adjust input volume using kAudioDevicePropertyVolumeScalar to 100
  3. Look at the db indicator, it stay at zero but the slider is in 100. No sound from microphone can be captured. Use kAudioDevicePropertyMute to get mute value, we can get mute = 1

Conclusion:

There is a "Mute" status for the input in the system, but no shown in the audio setting panel. System will auto set mute to true when adjust volume to zero and disable mute when set volume larger than zero.

like image 167
yicheng Avatar answered Nov 15 '22 07:11

yicheng