Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: webrtc/media/engine/adm_helpers.cc

Issue 2737633002: Remove VoEHardware interface usage. (Closed)
Patch Set: test Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/media/engine/adm_helpers.h"
12
13 #include "webrtc/base/logging.h"
14 #include "webrtc/modules/audio_device/include/audio_device.h"
15
16 namespace webrtc {
17 namespace adm_helpers {
18
19 // On Windows Vista and newer, Microsoft introduced the concept of "Default
20 // Communications Device". This means that there are two types of default
21 // devices (old Wave Audio style default and Default Communications Device).
22 //
23 // On Windows systems which only support Wave Audio style default, uses either
24 // -1 or 0 to select the default device.
25 //
26 // Using a #define for AUDIO_DEVICE since we will call *different* versions of
27 // the ADM functions, depending on the ID type.
28 #if defined(WEBRTC_WIN)
29 #define AUDIO_DEVICE_ID \
30 (AudioDeviceModule::WindowsDeviceType::kDefaultCommunicationDevice)
31 #else
32 #define AUDIO_DEVICE_ID (0u)
33 #endif // defined(WEBRTC_WIN)
34
35 void SetRecordingDevice(AudioDeviceModule* adm) {
36 RTC_DCHECK(adm);
37
38 // Save recording status and stop recording.
39 bool was_recording = adm->Recording();
henrika_webrtc 2017/03/13 11:15:55 const would not hurt
the sun 2017/03/15 12:47:57 Done.
henrika_webrtc 2017/03/15 12:50:18 Acknowledged.
40 if (was_recording && adm->StopRecording() != 0) {
41 LOG(LS_ERROR) << "Unable to stop recording.";
42 return;
43 }
44
45 // Set device and stereo mode.
46 if (adm->SetRecordingChannel(AudioDeviceModule::kChannelBoth) != 0) {
47 LOG(LS_ERROR) << "Unable to set recording channel to kChannelBoth.";
48 }
49 if (adm->SetRecordingDevice(AUDIO_DEVICE_ID) != 0) {
50 LOG(LS_ERROR) << "Unable to set recording device.";
51 return;
52 }
53
54 // Init microphone, so user can do volume settings etc.
55 if (adm->InitMicrophone() != 0) {
56 LOG(LS_ERROR) << "Unable to access microphone.";
57 }
58
59 // Set number of channels
60 bool available = false;
61 if (adm->StereoRecordingIsAvailable(&available) != 0) {
62 LOG(LS_ERROR) << "Failed to query stereo recording.";
63 }
64 if (adm->SetStereoRecording(available) != 0) {
65 LOG(LS_ERROR) << "Failed to set stereo recording mode.";
66 }
67
68 // Restore recording if it was enabled already when calling this function.
69 if (was_recording) {
70 if (adm->InitRecording() != 0) {
71 LOG(LS_ERROR) << "Failed to initialize recording.";
72 return;
73 }
74 if (adm->StartRecording() != 0) {
75 LOG(LS_ERROR) << "Failed to start recording.";
76 return;
77 }
78 }
79
80 LOG(LS_INFO) << "Set recording device.";
81 }
82
83 void SetPlayoutDevice(AudioDeviceModule* adm) {
84 RTC_DCHECK(adm);
85
86 // Save playing status and stop playout.
87 bool was_playing = adm->Playing();
88 if (was_playing && adm->StopPlayout() != 0) {
89 LOG(LS_ERROR) << "Unable to stop playout.";
90 }
91
92 // Set device.
93 if (adm->SetPlayoutDevice(AUDIO_DEVICE_ID) != 0) {
94 LOG(LS_ERROR) << "Unable to set playout device.";
95 return;
96 }
97
98 // Init speaker, so user can do volume settings etc.
99 if (adm->InitSpeaker() != 0) {
100 LOG(LS_ERROR) << "Unable to access speaker.";
101 }
102
103 // Set number of channels
104 bool available = false;
105 if (adm->StereoPlayoutIsAvailable(&available) != 0) {
106 LOG(LS_ERROR) << "Failed to query stereo playout.";
107 }
108 if (adm->SetStereoPlayout(available) != 0) {
109 LOG(LS_ERROR) << "Failed to set stereo playout mode.";
110 }
111
112 // Restore recording if it was enabled already when calling this function.
113 if (was_playing) {
114 if (adm->InitPlayout() != 0) {
115 LOG(LS_ERROR) << "Failed to initialize playout.";
116 return;
117 }
118 if (adm->StartPlayout() != 0) {
119 LOG(LS_ERROR) << "Failed to start playout.";
120 return;
121 }
122 }
123
124 LOG(LS_INFO) << "Set playout device.";
125 }
126
127 } // namespace adm_helpers
128 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698