From c57f9c38adf3cc63a5a34dc331324b44b2346501 Mon Sep 17 00:00:00 2001 From: "xians@webrtc.org" Date: Fri, 26 Aug 2011 12:28:33 +0000 Subject: [PATCH] Using IAudioEndpointVolume in IsSpeakerMuteAvailable and IsMicrophoneMuteAvailable to be consistent with SpeakerMute and MicrophoneMute APIs. Review URL: http://webrtc-codereview.appspot.com/112007 git-svn-id: http://webrtc.googlecode.com/svn/trunk@458 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../main/source/win/audio_device_core_win.cc | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/modules/audio_device/main/source/win/audio_device_core_win.cc b/src/modules/audio_device/main/source/win/audio_device_core_win.cc index 6866defed2..4fe4b64062 100644 --- a/src/modules/audio_device/main/source/win/audio_device_core_win.cc +++ b/src/modules/audio_device/main/source/win/audio_device_core_win.cc @@ -1079,31 +1079,26 @@ WebRtc_Word32 AudioDeviceWindowsCore::SpeakerMuteIsAvailable(bool& available) } HRESULT hr = S_OK; - IAudioSessionManager* pManager = NULL; - ISimpleAudioVolume* pVolume = NULL; + IAudioEndpointVolume* pVolume = NULL; - hr = _ptrDeviceOut->Activate(__uuidof(IAudioSessionManager), CLSCTX_ALL,NULL, (void**)&pManager); - EXIT_ON_ERROR(hr); - - hr = pManager->GetSimpleAudioVolume(NULL, FALSE, &pVolume); + // Query the speaker system mute state. + hr = _ptrDeviceOut->Activate(__uuidof(IAudioEndpointVolume), + CLSCTX_ALL, NULL, reinterpret_cast(&pVolume)); EXIT_ON_ERROR(hr); BOOL mute; hr = pVolume->GetMute(&mute); if (FAILED(hr)) - { available = false; - } - available = true; + else + available = true; - SAFE_RELEASE(pManager); SAFE_RELEASE(pVolume); return 0; Exit: _TraceCOMError(hr); - SAFE_RELEASE(pManager); SAFE_RELEASE(pVolume); return -1; } @@ -1131,6 +1126,7 @@ WebRtc_Word32 AudioDeviceWindowsCore::SetSpeakerMute(bool enable) HRESULT hr = S_OK; IAudioEndpointVolume* pVolume = NULL; + // Set the speaker system mute state. hr = _ptrDeviceOut->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, reinterpret_cast(&pVolume)); EXIT_ON_ERROR(hr); @@ -1169,6 +1165,7 @@ WebRtc_Word32 AudioDeviceWindowsCore::SpeakerMute(bool& enabled) const HRESULT hr = S_OK; IAudioEndpointVolume* pVolume = NULL; + // Query the speaker system mute state. hr = _ptrDeviceOut->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, reinterpret_cast(&pVolume)); EXIT_ON_ERROR(hr); @@ -1206,16 +1203,16 @@ WebRtc_Word32 AudioDeviceWindowsCore::MicrophoneMuteIsAvailable(bool& available) HRESULT hr = S_OK; IAudioEndpointVolume* pVolume = NULL; + // Query the microphone system mute state. hr = _ptrDeviceIn->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, reinterpret_cast(&pVolume)); EXIT_ON_ERROR(hr); BOOL mute; hr = pVolume->GetMute(&mute); if (FAILED(hr)) - { available = false; - } - available = true; + else + available = true; SAFE_RELEASE(pVolume); return 0; @@ -1247,6 +1244,7 @@ WebRtc_Word32 AudioDeviceWindowsCore::SetMicrophoneMute(bool enable) HRESULT hr = S_OK; IAudioEndpointVolume* pVolume = NULL; + // Set the microphone system mute state. hr = _ptrDeviceIn->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, reinterpret_cast(&pVolume)); EXIT_ON_ERROR(hr); @@ -1279,6 +1277,7 @@ WebRtc_Word32 AudioDeviceWindowsCore::MicrophoneMute(bool& enabled) const HRESULT hr = S_OK; IAudioEndpointVolume* pVolume = NULL; + // Query the microphone system mute state. hr = _ptrDeviceIn->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, reinterpret_cast(&pVolume)); EXIT_ON_ERROR(hr);