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

Side by Side Diff: content/renderer/media/webrtc_audio_device_impl.cc

Issue 675013005: Split libjingle's signaling thread from the UI thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update tests, remove circular dependency Created 6 years, 1 month 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/media/webrtc_audio_device_impl.h" 5 #include "content/renderer/media/webrtc_audio_device_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
(...skipping 14 matching lines...) Expand all
25 audio_transport_callback_(NULL), 25 audio_transport_callback_(NULL),
26 input_delay_ms_(0), 26 input_delay_ms_(0),
27 output_delay_ms_(0), 27 output_delay_ms_(0),
28 initialized_(false), 28 initialized_(false),
29 playing_(false), 29 playing_(false),
30 recording_(false), 30 recording_(false),
31 microphone_volume_(0), 31 microphone_volume_(0),
32 is_audio_track_processing_enabled_( 32 is_audio_track_processing_enabled_(
33 MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled()) { 33 MediaStreamAudioProcessor::IsAudioTrackProcessingEnabled()) {
34 DVLOG(1) << "WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()"; 34 DVLOG(1) << "WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()";
35 // TODO(tommi): This object can be constructed on either the signaling thread 35 // This object can be constructed on either the signaling thread or the main
36 // or the main thread. As is, those threads are one and the same so we don't 36 // thread, so we need to detach these thread checkers here and have them
37 // detach either thread checkers, but once they're separate, we need to detach 37 // initialize automatically when the first methods are called.
38 // here: 38 signaling_thread_checker_.DetachFromThread();
39 // signaling_thread_checker_.DetachFromThread(); 39 main_thread_checker_.DetachFromThread();
40 // main_thread_checker_.DetachFromThread();
41 40
42 worker_thread_checker_.DetachFromThread(); 41 worker_thread_checker_.DetachFromThread();
43 } 42 }
44 43
45 WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl() { 44 WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl() {
46 DVLOG(1) << "WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl()"; 45 DVLOG(1) << "WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl()";
47 DCHECK(main_thread_checker_.CalledOnValidThread()); 46 DCHECK(main_thread_checker_.CalledOnValidThread());
48 Terminate(); 47 Terminate();
49 } 48 }
50 49
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 // initialize worker_thread_checker_ on the signaling thread. 366 // initialize worker_thread_checker_ on the signaling thread.
368 DCHECK(signaling_thread_checker_.CalledOnValidThread() || 367 DCHECK(signaling_thread_checker_.CalledOnValidThread() ||
369 worker_thread_checker_.CalledOnValidThread()); 368 worker_thread_checker_.CalledOnValidThread());
370 369
371 base::AutoLock auto_lock(lock_); 370 base::AutoLock auto_lock(lock_);
372 recording_ = false; 371 recording_ = false;
373 return 0; 372 return 0;
374 } 373 }
375 374
376 bool WebRtcAudioDeviceImpl::Recording() const { 375 bool WebRtcAudioDeviceImpl::Recording() const {
377 DCHECK(!main_thread_checker_.CalledOnValidThread());
378 DCHECK(!signaling_thread_checker_.CalledOnValidThread());
379 DCHECK(worker_thread_checker_.CalledOnValidThread()); 376 DCHECK(worker_thread_checker_.CalledOnValidThread());
380 base::AutoLock auto_lock(lock_); 377 base::AutoLock auto_lock(lock_);
381 return recording_; 378 return recording_;
382 } 379 }
383 380
384 int32_t WebRtcAudioDeviceImpl::SetMicrophoneVolume(uint32_t volume) { 381 int32_t WebRtcAudioDeviceImpl::SetMicrophoneVolume(uint32_t volume) {
385 DVLOG(1) << "WebRtcAudioDeviceImpl::SetMicrophoneVolume(" << volume << ")"; 382 DVLOG(1) << "WebRtcAudioDeviceImpl::SetMicrophoneVolume(" << volume << ")";
386 DCHECK(signaling_thread_checker_.CalledOnValidThread()); 383 DCHECK(signaling_thread_checker_.CalledOnValidThread());
387 DCHECK(initialized_); 384 DCHECK(initialized_);
388 385
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 base::AutoLock auto_lock(lock_); 510 base::AutoLock auto_lock(lock_);
514 DCHECK(std::find(capturers_.begin(), capturers_.end(), capturer) == 511 DCHECK(std::find(capturers_.begin(), capturers_.end(), capturer) ==
515 capturers_.end()); 512 capturers_.end());
516 capturers_.push_back(capturer); 513 capturers_.push_back(capturer);
517 } 514 }
518 515
519 void WebRtcAudioDeviceImpl::RemoveAudioCapturer( 516 void WebRtcAudioDeviceImpl::RemoveAudioCapturer(
520 const scoped_refptr<WebRtcAudioCapturer>& capturer) { 517 const scoped_refptr<WebRtcAudioCapturer>& capturer) {
521 DCHECK(main_thread_checker_.CalledOnValidThread()); 518 DCHECK(main_thread_checker_.CalledOnValidThread());
522 DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()"; 519 DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()";
523 // Called on the main render thread.
524 DCHECK(capturer.get()); 520 DCHECK(capturer.get());
525 base::AutoLock auto_lock(lock_); 521 base::AutoLock auto_lock(lock_);
526 capturers_.remove(capturer); 522 capturers_.remove(capturer);
527 } 523 }
528 524
529 scoped_refptr<WebRtcAudioCapturer> 525 scoped_refptr<WebRtcAudioCapturer>
530 WebRtcAudioDeviceImpl::GetDefaultCapturer() const { 526 WebRtcAudioDeviceImpl::GetDefaultCapturer() const {
531 // Called on either the signaling thread (during initialization) or worker 527 // Called on the signaling thread (during initialization), worker
532 // thread during capture. 528 // thread during capture or main thread for a WebAudio source.
529 // We can't DCHECK on those three checks here since GetDefaultCapturer
530 // may be the first call and therefore could incorrectly initialize the
531 // thread checkers.
533 DCHECK(initialized_); 532 DCHECK(initialized_);
534 DCHECK(signaling_thread_checker_.CalledOnValidThread() ||
535 worker_thread_checker_.CalledOnValidThread());
536 base::AutoLock auto_lock(lock_); 533 base::AutoLock auto_lock(lock_);
537 // Use the last |capturer| which is from the latest getUserMedia call as 534 // Use the last |capturer| which is from the latest getUserMedia call as
538 // the default capture device. 535 // the default capture device.
539 return capturers_.empty() ? NULL : capturers_.back(); 536 return capturers_.empty() ? NULL : capturers_.back();
540 } 537 }
541 538
542 void WebRtcAudioDeviceImpl::AddPlayoutSink( 539 void WebRtcAudioDeviceImpl::AddPlayoutSink(
543 WebRtcPlayoutDataSource::Sink* sink) { 540 WebRtcPlayoutDataSource::Sink* sink) {
544 DCHECK(main_thread_checker_.CalledOnValidThread()); 541 DCHECK(main_thread_checker_.CalledOnValidThread());
545 DCHECK(sink); 542 DCHECK(sink);
(...skipping 20 matching lines...) Expand all
566 // If there is no capturer or there are more than one open capture devices, 563 // If there is no capturer or there are more than one open capture devices,
567 // return false. 564 // return false.
568 if (capturers_.size() != 1) 565 if (capturers_.size() != 1)
569 return false; 566 return false;
570 567
571 return capturers_.back()->GetPairedOutputParameters( 568 return capturers_.back()->GetPairedOutputParameters(
572 session_id, output_sample_rate, output_frames_per_buffer); 569 session_id, output_sample_rate, output_frames_per_buffer);
573 } 570 }
574 571
575 } // namespace content 572 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698