OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/audio_capturer_win.h" | 5 #include "remoting/host/audio_capturer_win.h" |
6 | 6 |
7 #include <avrt.h> | 7 #include <avrt.h> |
8 #include <mmreg.h> | 8 #include <mmreg.h> |
9 #include <mmsystem.h> | 9 #include <mmsystem.h> |
| 10 #include <objbase.h> |
10 #include <stdint.h> | 11 #include <stdint.h> |
11 #include <stdlib.h> | 12 #include <stdlib.h> |
12 #include <windows.h> | 13 #include <windows.h> |
13 | 14 |
14 #include <algorithm> | 15 #include <algorithm> |
15 #include <utility> | 16 #include <utility> |
16 | 17 |
17 #include "base/logging.h" | 18 #include "base/logging.h" |
18 #include "base/memory/ptr_util.h" | 19 #include "base/memory/ptr_util.h" |
19 #include "base/synchronization/lock.h" | 20 #include "base/synchronization/lock.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 mm_device_.Receive()); | 118 mm_device_.Receive()); |
118 if (FAILED(hr)) { | 119 if (FAILED(hr)) { |
119 LOG(ERROR) << "Failed to get IMMDevice. Error " << hr; | 120 LOG(ERROR) << "Failed to get IMMDevice. Error " << hr; |
120 return false; | 121 return false; |
121 } | 122 } |
122 | 123 |
123 // Get an audio client. | 124 // Get an audio client. |
124 hr = mm_device_->Activate(__uuidof(IAudioClient), | 125 hr = mm_device_->Activate(__uuidof(IAudioClient), |
125 CLSCTX_ALL, | 126 CLSCTX_ALL, |
126 nullptr, | 127 nullptr, |
127 audio_client_.ReceiveVoid()); | 128 &audio_client_); |
128 if (FAILED(hr)) { | 129 if (FAILED(hr)) { |
129 LOG(ERROR) << "Failed to get an IAudioClient. Error " << hr; | 130 LOG(ERROR) << "Failed to get an IAudioClient. Error " << hr; |
130 return false; | 131 return false; |
131 } | 132 } |
132 | 133 |
133 REFERENCE_TIME device_period; | 134 REFERENCE_TIME device_period; |
134 hr = audio_client_->GetDevicePeriod(&device_period, nullptr); | 135 hr = audio_client_->GetDevicePeriod(&device_period, nullptr); |
135 if (FAILED(hr)) { | 136 if (FAILED(hr)) { |
136 LOG(ERROR) << "IAudioClient::GetDevicePeriod failed. Error " << hr; | 137 LOG(ERROR) << "IAudioClient::GetDevicePeriod failed. Error " << hr; |
137 return false; | 138 return false; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 k100nsPerMillisecond, | 213 k100nsPerMillisecond, |
213 0, | 214 0, |
214 wave_format_ex_, | 215 wave_format_ex_, |
215 nullptr); | 216 nullptr); |
216 if (FAILED(hr)) { | 217 if (FAILED(hr)) { |
217 LOG(ERROR) << "Failed to initialize IAudioClient. Error " << hr; | 218 LOG(ERROR) << "Failed to initialize IAudioClient. Error " << hr; |
218 return false; | 219 return false; |
219 } | 220 } |
220 | 221 |
221 // Get an IAudioCaptureClient. | 222 // Get an IAudioCaptureClient. |
222 hr = audio_client_->GetService(__uuidof(IAudioCaptureClient), | 223 hr = audio_client_->GetService(IID_PPV_ARGS(&audio_capture_client_)); |
223 audio_capture_client_.ReceiveVoid()); | |
224 if (FAILED(hr)) { | 224 if (FAILED(hr)) { |
225 LOG(ERROR) << "Failed to get an IAudioCaptureClient. Error " << hr; | 225 LOG(ERROR) << "Failed to get an IAudioCaptureClient. Error " << hr; |
226 return false; | 226 return false; |
227 } | 227 } |
228 | 228 |
229 // Start the IAudioClient. | 229 // Start the IAudioClient. |
230 hr = audio_client_->Start(); | 230 hr = audio_client_->Start(); |
231 if (FAILED(hr)) { | 231 if (FAILED(hr)) { |
232 LOG(ERROR) << "Failed to start IAudioClient. Error " << hr; | 232 LOG(ERROR) << "Failed to start IAudioClient. Error " << hr; |
233 return false; | 233 return false; |
234 } | 234 } |
235 | 235 |
236 // Initialize IAudioEndpointVolume. | 236 // Initialize IAudioEndpointVolume. |
237 // TODO(zijiehe): Do we need to control per process volume? | 237 // TODO(zijiehe): Do we need to control per process volume? |
238 hr = mm_device_->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, nullptr, | 238 hr = mm_device_->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, nullptr, |
239 audio_volume_.ReceiveVoid()); | 239 &audio_volume_); |
240 if (FAILED(hr)) { | 240 if (FAILED(hr)) { |
241 LOG(ERROR) << "Failed to get an IAudioEndpointVolume. Error " << hr; | 241 LOG(ERROR) << "Failed to get an IAudioEndpointVolume. Error " << hr; |
242 return false; | 242 return false; |
243 } | 243 } |
244 | 244 |
245 silence_detector_.Reset(sampling_rate_, kChannels); | 245 silence_detector_.Reset(sampling_rate_, kChannels); |
246 | 246 |
247 return true; | 247 return true; |
248 } | 248 } |
249 | 249 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 | 368 |
369 bool AudioCapturer::IsSupported() { | 369 bool AudioCapturer::IsSupported() { |
370 return true; | 370 return true; |
371 } | 371 } |
372 | 372 |
373 std::unique_ptr<AudioCapturer> AudioCapturer::Create() { | 373 std::unique_ptr<AudioCapturer> AudioCapturer::Create() { |
374 return base::WrapUnique(new AudioCapturerWin()); | 374 return base::WrapUnique(new AudioCapturerWin()); |
375 } | 375 } |
376 | 376 |
377 } // namespace remoting | 377 } // namespace remoting |
OLD | NEW |