diff --git a/src/modules/audio_device/main/source/win/audio_mixer_manager_win.cc b/src/modules/audio_device/main/source/win/audio_mixer_manager_win.cc index 465f94c091..91afdec19c 100644 --- a/src/modules/audio_device/main/source/win/audio_mixer_manager_win.cc +++ b/src/modules/audio_device/main/source/win/audio_mixer_manager_win.cc @@ -303,7 +303,73 @@ WebRtc_Word32 AudioMixerManager::EnumerateMicrophones() _microphoneState[mixId].microphoneIsValid = true; // retrieve all controls for the identified wave-in destination - GetAllLineControls(mixId, destLine, controlArray); + if (!GetAllLineControls(mixId, destLine, controlArray)) + { + // This destination has no controls. We must try to control + // one of its sources instead. + // This is a rare state but has been found for some + // Logitech USB headsets. + + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, + "this destination has no controls => must control source"); + for (DWORD sourceId = 0; sourceId < destLine.cConnections; sourceId++) + { + GetSourceLineInfo(mixId, destId, sourceId, sourceLine, false); + if (sourceLine.dwComponentType == + MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE) + { + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, + "found microphone source ( name: %s, ID: %u)", + WideToUTF8(sourceLine.szName), sourceId); + GetAllLineControls(mixId, sourceLine, controlArray, false); + // scan the controls for this source and search for volume, + // mute and on/off (<=> boost) controls + for (UINT sc = 0; sc < sourceLine.cControls; sc++) + { + if (controlArray[sc].dwControlType == + MIXERCONTROL_CONTROLTYPE_VOLUME) + { + // store this volume control + _microphoneState[mixId].dwVolumeControlID = + controlArray[sc].dwControlID; + _microphoneState[mixId].volumeControlIsValid = true; + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, + "found volume control (name: %s, ID: %u)", + WideToUTF8(controlArray[sc].szName), + controlArray[sc].dwControlID); + } + else if (controlArray[sc].dwControlType == + MIXERCONTROL_CONTROLTYPE_MUTE) + { + // store this mute control + _microphoneState[mixId].dwMuteControlID = + controlArray[sc].dwControlID; + _microphoneState[mixId].muteControlIsValid = true; + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, + "found mute control (name: %s, ID: %u)", + WideToUTF8(controlArray[sc].szName), + controlArray[sc].dwControlID); + } + else if (controlArray[sc].dwControlType == + MIXERCONTROL_CONTROLTYPE_ONOFF || + controlArray[sc].dwControlType == + MIXERCONTROL_CONTROLTYPE_LOUDNESS) + { + // store this on/off control (most likely a Boost control) + _microphoneState[mixId].dwOnOffControlID = + controlArray[sc].dwControlID; + _microphoneState[mixId].onOffControlIsValid = true; + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, + "found on/off control (name: %s, ID: %u)", + WideToUTF8(controlArray[sc].szName), + controlArray[sc].dwControlID); + } + } + } + } + + break; + } // It seems like there are three different configurations we can find in this state: //