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

Side by Side Diff: remoting/host/audio_capturer_win.cc

Issue 866863004: Replace AudioScheduler with AudioPump. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mouse_cursor_pipe
Patch Set: Created 5 years, 10 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
« no previous file with comments | « remoting/host/audio_capturer_win.h ('k') | remoting/host/audio_pump.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <windows.h> 7 #include <windows.h>
8 #include <avrt.h> 8 #include <avrt.h>
9 #include <mmreg.h> 9 #include <mmreg.h>
10 #include <mmsystem.h> 10 #include <mmsystem.h>
(...skipping 27 matching lines...) Expand all
38 namespace remoting { 38 namespace remoting {
39 39
40 AudioCapturerWin::AudioCapturerWin() 40 AudioCapturerWin::AudioCapturerWin()
41 : sampling_rate_(AudioPacket::SAMPLING_RATE_INVALID), 41 : sampling_rate_(AudioPacket::SAMPLING_RATE_INVALID),
42 silence_detector_(kSilenceThreshold), 42 silence_detector_(kSilenceThreshold),
43 last_capture_error_(S_OK) { 43 last_capture_error_(S_OK) {
44 thread_checker_.DetachFromThread(); 44 thread_checker_.DetachFromThread();
45 } 45 }
46 46
47 AudioCapturerWin::~AudioCapturerWin() { 47 AudioCapturerWin::~AudioCapturerWin() {
48 DCHECK(thread_checker_.CalledOnValidThread());
48 } 49 }
49 50
50 bool AudioCapturerWin::Start(const PacketCapturedCallback& callback) { 51 bool AudioCapturerWin::Start(const PacketCapturedCallback& callback) {
51 DCHECK(!audio_capture_client_.get()); 52 DCHECK(!audio_capture_client_.get());
52 DCHECK(!audio_client_.get()); 53 DCHECK(!audio_client_.get());
53 DCHECK(!mm_device_.get()); 54 DCHECK(!mm_device_.get());
54 DCHECK(static_cast<PWAVEFORMATEX>(wave_format_ex_) == nullptr); 55 DCHECK(static_cast<PWAVEFORMATEX>(wave_format_ex_) == nullptr);
55 DCHECK(thread_checker_.CalledOnValidThread()); 56 DCHECK(thread_checker_.CalledOnValidThread());
56 57
57 callback_ = callback; 58 callback_ = callback;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 silence_detector_.Reset(sampling_rate_, kChannels); 194 silence_detector_.Reset(sampling_rate_, kChannels);
194 195
195 // Start capturing. 196 // Start capturing.
196 capture_timer_->Start(FROM_HERE, 197 capture_timer_->Start(FROM_HERE,
197 audio_device_period_, 198 audio_device_period_,
198 this, 199 this,
199 &AudioCapturerWin::DoCapture); 200 &AudioCapturerWin::DoCapture);
200 return true; 201 return true;
201 } 202 }
202 203
203 void AudioCapturerWin::Stop() {
204 DCHECK(thread_checker_.CalledOnValidThread());
205 DCHECK(IsStarted());
206
207 capture_timer_.reset();
208 mm_device_.Release();
209 audio_client_.Release();
210 audio_capture_client_.Release();
211 wave_format_ex_.Reset(nullptr);
212
213 thread_checker_.DetachFromThread();
214 }
215
216 bool AudioCapturerWin::IsStarted() {
217 DCHECK(thread_checker_.CalledOnValidThread());
218 return capture_timer_.get() != nullptr;
219 }
220
221 void AudioCapturerWin::DoCapture() { 204 void AudioCapturerWin::DoCapture() {
222 DCHECK(AudioCapturer::IsValidSampleRate(sampling_rate_)); 205 DCHECK(AudioCapturer::IsValidSampleRate(sampling_rate_));
223 DCHECK(thread_checker_.CalledOnValidThread()); 206 DCHECK(thread_checker_.CalledOnValidThread());
224 DCHECK(IsStarted());
225 207
226 // Fetch all packets from the audio capture endpoint buffer. 208 // Fetch all packets from the audio capture endpoint buffer.
227 HRESULT hr = S_OK; 209 HRESULT hr = S_OK;
228 while (true) { 210 while (true) {
229 UINT32 next_packet_size; 211 UINT32 next_packet_size;
230 HRESULT hr = audio_capture_client_->GetNextPacketSize(&next_packet_size); 212 HRESULT hr = audio_capture_client_->GetNextPacketSize(&next_packet_size);
231 if (FAILED(hr)) 213 if (FAILED(hr))
232 break; 214 break;
233 215
234 if (next_packet_size <= 0) { 216 if (next_packet_size <= 0) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 258
277 bool AudioCapturer::IsSupported() { 259 bool AudioCapturer::IsSupported() {
278 return true; 260 return true;
279 } 261 }
280 262
281 scoped_ptr<AudioCapturer> AudioCapturer::Create() { 263 scoped_ptr<AudioCapturer> AudioCapturer::Create() {
282 return make_scoped_ptr(new AudioCapturerWin()); 264 return make_scoped_ptr(new AudioCapturerWin());
283 } 265 }
284 266
285 } // namespace remoting 267 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/audio_capturer_win.h ('k') | remoting/host/audio_pump.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698