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

Unified Diff: content/renderer/media/webrtc_audio_capturer.cc

Issue 15031003: Fixed the crash when the WebRtcAudioCapturer::|buffer_| is NULL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed the bots 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/renderer/media/webrtc_local_audio_track.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webrtc_audio_capturer.cc
diff --git a/content/renderer/media/webrtc_audio_capturer.cc b/content/renderer/media/webrtc_audio_capturer.cc
index 92951e25ea9b7a75aa6bb8030194ae080afb0e4d..14faf1e351b8f5f38bb0e85329e5f5e58bfc049d 100644
--- a/content/renderer/media/webrtc_audio_capturer.cc
+++ b/content/renderer/media/webrtc_audio_capturer.cc
@@ -201,12 +201,21 @@ WebRtcAudioCapturer::~WebRtcAudioCapturer() {
void WebRtcAudioCapturer::AddSink(
WebRtcAudioCapturerSink* track) {
DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(track);
DVLOG(1) << "WebRtcAudioCapturer::AddSink()";
base::AutoLock auto_lock(lock_);
// Verify that |track| is not already added to the list.
DCHECK(std::find_if(
tracks_.begin(), tracks_.end(),
WebRtcAudioCapturerSinkOwner::WrapsSink(track)) == tracks_.end());
+
+ if (buffer_.get()) {
+ track->SetCaptureFormat(buffer_->params());
+ } else {
+ DLOG(WARNING) << "The format of the capturer has not been correctly "
+ << "initialized";
+ }
+
// Create (and add to the list) a new WebRtcAudioCapturerSinkOwner which owns
// the |track| and delagates all calls to the WebRtcAudioCapturerSink
// interface.
@@ -379,7 +388,9 @@ void WebRtcAudioCapturer::OnCaptureError() {
media::AudioParameters WebRtcAudioCapturer::audio_parameters() const {
base::AutoLock auto_lock(lock_);
- return buffer_->params();
+ // |buffer_| can be NULL when SetCapturerSource() or Initialize() has not
+ // been called.
+ return buffer_.get() ? buffer_->params() : media::AudioParameters();
}
} // namespace content
« 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