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

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

Issue 10907041: Implement Linux audio capturer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/audio_capturer_win.h ('k') | remoting/host/chromoting_host.cc » ('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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // Start capturing. 192 // Start capturing.
193 capture_timer_->Start(FROM_HERE, 193 capture_timer_->Start(FROM_HERE,
194 audio_device_period_, 194 audio_device_period_,
195 this, 195 this,
196 &AudioCapturerWin::DoCapture); 196 &AudioCapturerWin::DoCapture);
197 return true; 197 return true;
198 } 198 }
199 199
200 void AudioCapturerWin::Stop() { 200 void AudioCapturerWin::Stop() {
201 DCHECK(thread_checker_.CalledOnValidThread()); 201 DCHECK(thread_checker_.CalledOnValidThread());
202 DCHECK(IsRunning()); 202 DCHECK(IsStarted());
203 203
204 capture_timer_.reset(); 204 capture_timer_.reset();
205 mm_device_.Release(); 205 mm_device_.Release();
206 audio_client_.Release(); 206 audio_client_.Release();
207 audio_capture_client_.Release(); 207 audio_capture_client_.Release();
208 wave_format_ex_.Reset(NULL); 208 wave_format_ex_.Reset(NULL);
209 com_initializer_.reset(); 209 com_initializer_.reset();
210 210
211 thread_checker_.DetachFromThread(); 211 thread_checker_.DetachFromThread();
212 } 212 }
213 213
214 bool AudioCapturerWin::IsRunning() { 214 bool AudioCapturerWin::IsStarted() {
215 DCHECK(thread_checker_.CalledOnValidThread()); 215 DCHECK(thread_checker_.CalledOnValidThread());
216 return capture_timer_.get() != NULL; 216 return capture_timer_.get() != NULL;
217 } 217 }
218 218
219 void AudioCapturerWin::DoCapture() { 219 void AudioCapturerWin::DoCapture() {
220 DCHECK(AudioCapturer::IsValidSampleRate(sampling_rate_)); 220 DCHECK(AudioCapturer::IsValidSampleRate(sampling_rate_));
221 DCHECK(thread_checker_.CalledOnValidThread()); 221 DCHECK(thread_checker_.CalledOnValidThread());
222 DCHECK(IsRunning()); 222 DCHECK(IsStarted());
223 223
224 // Fetch all packets from the audio capture endpoint buffer. 224 // Fetch all packets from the audio capture endpoint buffer.
225 while (true) { 225 while (true) {
226 UINT32 next_packet_size; 226 UINT32 next_packet_size;
227 HRESULT hr = audio_capture_client_->GetNextPacketSize(&next_packet_size); 227 HRESULT hr = audio_capture_client_->GetNextPacketSize(&next_packet_size);
228 if (FAILED(hr)) { 228 if (FAILED(hr)) {
229 LOG(ERROR) << "Failed to GetNextPacketSize. Error " << hr; 229 LOG(ERROR) << "Failed to GetNextPacketSize. Error " << hr;
230 return; 230 return;
231 } 231 }
232 232
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 // static 272 // static
273 bool AudioCapturerWin::IsPacketOfSilence( 273 bool AudioCapturerWin::IsPacketOfSilence(
274 const int16* samples, int number_of_samples) { 274 const int16* samples, int number_of_samples) {
275 for (int i = 0; i < number_of_samples; i++) { 275 for (int i = 0; i < number_of_samples; i++) {
276 if (abs(samples[i]) > kSilenceThreshold) 276 if (abs(samples[i]) > kSilenceThreshold)
277 return false; 277 return false;
278 } 278 }
279 return true; 279 return true;
280 } 280 }
281 281
282 bool AudioCapturer::IsSupported() {
283 return true;
284 }
285
282 scoped_ptr<AudioCapturer> AudioCapturer::Create() { 286 scoped_ptr<AudioCapturer> AudioCapturer::Create() {
283 return scoped_ptr<AudioCapturer>(new AudioCapturerWin()); 287 return scoped_ptr<AudioCapturer>(new AudioCapturerWin());
284 } 288 }
285 289
286 } // namespace remoting 290 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/audio_capturer_win.h ('k') | remoting/host/chromoting_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698