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

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

Issue 133903004: Cleaned up the WebRtcAudioCapturer a bit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed the debugging DLOG. Created 6 years, 11 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
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 429
430 renderer_ = renderer; 430 renderer_ = renderer;
431 return true; 431 return true;
432 } 432 }
433 433
434 void WebRtcAudioDeviceImpl::AddAudioCapturer( 434 void WebRtcAudioDeviceImpl::AddAudioCapturer(
435 const scoped_refptr<WebRtcAudioCapturer>& capturer) { 435 const scoped_refptr<WebRtcAudioCapturer>& capturer) {
436 DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()"; 436 DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()";
437 DCHECK(thread_checker_.CalledOnValidThread()); 437 DCHECK(thread_checker_.CalledOnValidThread());
438 DCHECK(capturer.get()); 438 DCHECK(capturer.get());
439 base::AutoLock auto_lock(lock_);
440 DCHECK(std::find(capturers_.begin(), capturers_.end(), capturer) ==
441 capturers_.end());
442 capturers_.push_back(capturer);
443 }
439 444
440 // We only support one microphone today, which means the list can contain 445 void WebRtcAudioDeviceImpl::RemoveAudioCapturer(
441 // only one capturer with a valid device id. 446 const scoped_refptr<WebRtcAudioCapturer>& capturer) {
442 DCHECK(capturer->device_id().empty() || !GetDefaultCapturer()); 447 DVLOG(1) << "WebRtcAudioDeviceImpl::AddAudioCapturer()";
448 DCHECK(thread_checker_.CalledOnValidThread());
449 DCHECK(capturer.get());
443 base::AutoLock auto_lock(lock_); 450 base::AutoLock auto_lock(lock_);
444 capturers_.push_back(capturer); 451 capturers_.remove(capturer);
445 } 452 }
446 453
447 scoped_refptr<WebRtcAudioCapturer> 454 scoped_refptr<WebRtcAudioCapturer>
448 WebRtcAudioDeviceImpl::GetDefaultCapturer() const { 455 WebRtcAudioDeviceImpl::GetDefaultCapturer() const {
449 base::AutoLock auto_lock(lock_); 456 base::AutoLock auto_lock(lock_);
450 for (CapturerList::const_iterator iter = capturers_.begin(); 457 for (CapturerList::const_iterator iter = capturers_.begin();
451 iter != capturers_.end(); ++iter) { 458 iter != capturers_.end(); ++iter) {
452 if (!(*iter)->device_id().empty()) 459 if (!(*iter)->device_id().empty())
453 return *iter; 460 return *iter;
454 } 461 }
455 462
456 return NULL; 463 return NULL;
457 } 464 }
458 465
459 } // namespace content 466 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698