Don't use VoE legacy APIs in force_mic_volume_max tool.

BUG=webrtc:4690

Review-Url: https://codereview.webrtc.org/2268183007
Cr-Commit-Position: refs/heads/master@{#14135}
This commit is contained in:
solenberg 2016-09-08 06:44:23 -07:00 committed by Commit bot
parent 49fbbe089e
commit ae9f2bdcef
2 changed files with 34 additions and 21 deletions

View File

@ -2,6 +2,7 @@ include_rules = [
"+webrtc/base", "+webrtc/base",
"+webrtc/call", "+webrtc/call",
"+webrtc/common_video", "+webrtc/common_video",
"+webrtc/modules/audio_device",
"+webrtc/modules/audio_processing", "+webrtc/modules/audio_processing",
"+webrtc/modules/congestion_controller", "+webrtc/modules/congestion_controller",
"+webrtc/modules/rtp_rtcp", "+webrtc/modules/rtp_rtcp",

View File

@ -12,33 +12,45 @@
#include <stdio.h> #include <stdio.h>
#include "webrtc/test/channel_transport/channel_transport.h" #include "webrtc/modules/audio_device/include/audio_device.h"
#include "webrtc/voice_engine/include/voe_audio_processing.h"
#include "webrtc/voice_engine/include/voe_base.h"
#include "webrtc/voice_engine/include/voe_volume_control.h"
int main(int argc, char** argv) { using webrtc::AudioDeviceModule;
webrtc::VoiceEngine* voe = webrtc::VoiceEngine::Create();
if (voe == NULL) { #if defined(_WIN32)
fprintf(stderr, "Failed to initialize voice engine.\n"); #define DEFAULT_INPUT_DEVICE (AudioDeviceModule::kDefaultCommunicationDevice)
#else
#define DEFAULT_INPUT_DEVICE (0)
#endif
int main(int /*argc*/, char** /*argv*/) {
// Create and initialize the ADM.
rtc::scoped_refptr<AudioDeviceModule> adm(
AudioDeviceModule::Create(1, AudioDeviceModule::kPlatformDefaultAudio));
if (!adm.get()) {
fprintf(stderr, "Failed to create Audio Device Module.\n");
return 1;
}
if (adm->Init() != 0) {
fprintf(stderr, "Failed to initialize Audio Device Module.\n");
return 1;
}
if (adm->SetRecordingDevice(DEFAULT_INPUT_DEVICE) != 0) {
fprintf(stderr, "Failed to set the default input device.\n");
return 1;
}
if (adm->InitMicrophone() != 0) {
fprintf(stderr, "Failed to to initialize the microphone.\n");
return 1; return 1;
} }
webrtc::VoEBase* base = webrtc::VoEBase::GetInterface(voe); // Set mic volume to max.
webrtc::VoEVolumeControl* volume_control = uint32_t max_vol = 0;
webrtc::VoEVolumeControl::GetInterface(voe); if (adm->MaxMicrophoneVolume(&max_vol) != 0) {
fprintf(stderr, "Failed to get max volume.\n");
if (base->Init() != 0) {
fprintf(stderr, "Failed to initialize voice engine base.\n");
return 1; return 1;
} }
// Set to 0 first in case the mic is above 100%. if (adm->SetMicrophoneVolume(max_vol) != 0) {
if (volume_control->SetMicVolume(0) != 0) { fprintf(stderr, "Failed to set mic volume.\n");
fprintf(stderr, "Failed set volume to 0.\n");
return 1;
}
if (volume_control->SetMicVolume(255) != 0) {
fprintf(stderr, "Failed set volume to 255.\n");
return 1; return 1;
} }