1a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org/*
2a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org *
4a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org *  Use of this source code is governed by a BSD-style license
5a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org *  that can be found in the LICENSE file in the root of the source
6a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org *  tree. An additional intellectual property rights grant can be found
7a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org *  in the file PATENTS.  All contributing project authors may
8a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
9a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org */
10a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org
11a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org// This utility will portably force the volume of the default microphone to max.
12a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org
133f45c2e0ac4cb280f941efa3a3476895795e3dd6pbos@webrtc.org#include <stdio.h>
14a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org
15a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org#include "webrtc/system_wrappers/interface/scoped_ptr.h"
16a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org#include "webrtc/test/channel_transport/include/channel_transport.h"
17a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org#include "webrtc/voice_engine/include/voe_audio_processing.h"
18a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org#include "webrtc/voice_engine/include/voe_base.h"
19a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org#include "webrtc/voice_engine/include/voe_volume_control.h"
20a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org
21a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.orgint main(int argc, char** argv) {
22a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org  webrtc::VoiceEngine* voe = webrtc::VoiceEngine::Create();
23a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org  if (voe == NULL) {
24a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org    fprintf(stderr, "Failed to initialize voice engine.\n");
25a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org    return 1;
26a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org  }
27a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org
28a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org  webrtc::VoEBase* base = webrtc::VoEBase::GetInterface(voe);
29a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org  webrtc::VoEVolumeControl* volume_control =
30a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org      webrtc::VoEVolumeControl::GetInterface(voe);
31a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org
32a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org  if (base->Init() != 0) {
33a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org    fprintf(stderr, "Failed to initialize voice engine base.\n");
34a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org    return 1;
35a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org  }
36a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org  // Set to 0 first in case the mic is above 100%.
37a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org  if (volume_control->SetMicVolume(0) != 0) {
38a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org    fprintf(stderr, "Failed set volume to 0.\n");
39a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org    return 1;
40a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org  }
41a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org  if (volume_control->SetMicVolume(255) != 0) {
42a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org    fprintf(stderr, "Failed set volume to 255.\n");
43a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org    return 1;
44a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org  }
45a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org
46a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org  return 0;
47a4f0d20eb79269d2d649b3f062b70fc9b6dbbe65phoglund@webrtc.org}
48