Microphone volume on Mac not being printed properly due
to a mismatch in variable type. Additionally, now printing
a volume that will range from 0 - 255
Review URL: http://webrtc-codereview.appspot.com/267016
git-svn-id: http://webrtc.googlecode.com/svn/trunk@951 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/src/modules/audio_device/main/source/mac/audio_mixer_manager_mac.cc b/src/modules/audio_device/main/source/mac/audio_mixer_manager_mac.cc
index 5f70c40..ee35dd8 100644
--- a/src/modules/audio_device/main/source/mac/audio_mixer_manager_mac.cc
+++ b/src/modules/audio_device/main/source/mac/audio_mixer_manager_mac.cc
@@ -1045,7 +1045,7 @@
UInt32 size = 0;
unsigned int channels = 0;
Float32 channelVol = 0;
- Float32 vol = 0;
+ Float32 volFloat32 = 0;
// Does the device have a master volume control?
// If so, use it exclusively.
@@ -1056,16 +1056,16 @@
&propertyAddress);
if (hasProperty)
{
- size = sizeof(vol);
+ size = sizeof(volFloat32);
WEBRTC_CA_RETURN_ON_ERR(AudioObjectGetPropertyData(_inputDeviceID,
- &propertyAddress, 0, NULL, &size, &vol));
+ &propertyAddress, 0, NULL, &size, &volFloat32));
// vol 0.0 to 1.0 -> convert to 0 - 255
- volume = static_cast<WebRtc_UWord32> (vol * 255 + 0.5);
+ volume = static_cast<WebRtc_UWord32> (volFloat32 * 255 + 0.5);
} else
{
// Otherwise get the average volume across channels.
- vol = 0;
+ volFloat32 = 0;
for (UInt32 i = 1; i <= _noInputChannels; i++)
{
channelVol = 0;
@@ -1078,7 +1078,7 @@
WEBRTC_CA_RETURN_ON_ERR(AudioObjectGetPropertyData(_inputDeviceID,
&propertyAddress, 0, NULL, &size, &channelVol));
- vol += channelVol;
+ volFloat32 += channelVol;
channels++;
}
}
@@ -1092,12 +1092,13 @@
assert(channels > 0);
// vol 0.0 to 1.0 -> convert to 0 - 255
- volume = static_cast<WebRtc_UWord32> (255 * vol / channels + 0.5);
+ volume = static_cast<WebRtc_UWord32>
+ (255 * volFloat32 / channels + 0.5);
}
WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
- " AudioMixerManagerMac::MicrophoneVolume() => vol=%i",
- vol);
+ " AudioMixerManagerMac::MicrophoneVolume() => vol=%u",
+ volume);
return 0;
}