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

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

Issue 15014019: Merge 198717 "Fixed the crash when the WebRtcAudioCapturer::|buf..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1500/src/
Patch Set: Created 7 years, 7 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 | « no previous file | content/renderer/media/webrtc_local_audio_track.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 "content/renderer/media/webrtc_audio_capturer.h" 5 #include "content/renderer/media/webrtc_audio_capturer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 WebRtcAudioCapturer::~WebRtcAudioCapturer() { 194 WebRtcAudioCapturer::~WebRtcAudioCapturer() {
195 DCHECK(thread_checker_.CalledOnValidThread()); 195 DCHECK(thread_checker_.CalledOnValidThread());
196 DCHECK(tracks_.empty()); 196 DCHECK(tracks_.empty());
197 DCHECK(!running_); 197 DCHECK(!running_);
198 DVLOG(1) << "WebRtcAudioCapturer::~WebRtcAudioCapturer()"; 198 DVLOG(1) << "WebRtcAudioCapturer::~WebRtcAudioCapturer()";
199 } 199 }
200 200
201 void WebRtcAudioCapturer::AddSink( 201 void WebRtcAudioCapturer::AddSink(
202 WebRtcAudioCapturerSink* track) { 202 WebRtcAudioCapturerSink* track) {
203 DCHECK(thread_checker_.CalledOnValidThread()); 203 DCHECK(thread_checker_.CalledOnValidThread());
204 DCHECK(track);
204 DVLOG(1) << "WebRtcAudioCapturer::AddSink()"; 205 DVLOG(1) << "WebRtcAudioCapturer::AddSink()";
205 base::AutoLock auto_lock(lock_); 206 base::AutoLock auto_lock(lock_);
206 // Verify that |track| is not already added to the list. 207 // Verify that |track| is not already added to the list.
207 DCHECK(std::find_if( 208 DCHECK(std::find_if(
208 tracks_.begin(), tracks_.end(), 209 tracks_.begin(), tracks_.end(),
209 WebRtcAudioCapturerSinkOwner::WrapsSink(track)) == tracks_.end()); 210 WebRtcAudioCapturerSinkOwner::WrapsSink(track)) == tracks_.end());
211
212 if (buffer_.get()) {
213 track->SetCaptureFormat(buffer_->params());
214 } else {
215 DLOG(WARNING) << "The format of the capturer has not been correctly "
216 << "initialized";
217 }
218
210 // Create (and add to the list) a new WebRtcAudioCapturerSinkOwner which owns 219 // Create (and add to the list) a new WebRtcAudioCapturerSinkOwner which owns
211 // the |track| and delagates all calls to the WebRtcAudioCapturerSink 220 // the |track| and delagates all calls to the WebRtcAudioCapturerSink
212 // interface. 221 // interface.
213 tracks_.push_back(new WebRtcAudioCapturerSinkOwner(track)); 222 tracks_.push_back(new WebRtcAudioCapturerSinkOwner(track));
214 // TODO(xians): should we call SetCapturerFormat() to each track? 223 // TODO(xians): should we call SetCapturerFormat() to each track?
215 } 224 }
216 225
217 void WebRtcAudioCapturer::RemoveSink( 226 void WebRtcAudioCapturer::RemoveSink(
218 WebRtcAudioCapturerSink* track) { 227 WebRtcAudioCapturerSink* track) {
219 DCHECK(thread_checker_.CalledOnValidThread()); 228 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 audio_delay_milliseconds, volume); 381 audio_delay_milliseconds, volume);
373 } 382 }
374 } 383 }
375 384
376 void WebRtcAudioCapturer::OnCaptureError() { 385 void WebRtcAudioCapturer::OnCaptureError() {
377 NOTIMPLEMENTED(); 386 NOTIMPLEMENTED();
378 } 387 }
379 388
380 media::AudioParameters WebRtcAudioCapturer::audio_parameters() const { 389 media::AudioParameters WebRtcAudioCapturer::audio_parameters() const {
381 base::AutoLock auto_lock(lock_); 390 base::AutoLock auto_lock(lock_);
382 return buffer_->params(); 391 // |buffer_| can be NULL when SetCapturerSource() or Initialize() has not
392 // been called.
393 return buffer_.get() ? buffer_->params() : media::AudioParameters();
383 } 394 }
384 395
385 } // namespace content 396 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/webrtc_local_audio_track.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698