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

Side by Side Diff: media/base/pipeline.cc

Issue 545943004: Protect access Pipeline::renderer_ with a lock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | no next file » | 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 "media/base/pipeline.h" 5 #include "media/base/pipeline.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 volume_ = volume; 151 volume_ = volume;
152 if (running_) { 152 if (running_) {
153 task_runner_->PostTask( 153 task_runner_->PostTask(
154 FROM_HERE, 154 FROM_HERE,
155 base::Bind( 155 base::Bind(
156 &Pipeline::VolumeChangedTask, weak_factory_.GetWeakPtr(), volume)); 156 &Pipeline::VolumeChangedTask, weak_factory_.GetWeakPtr(), volume));
157 } 157 }
158 } 158 }
159 159
160 TimeDelta Pipeline::GetMediaTime() const { 160 TimeDelta Pipeline::GetMediaTime() const {
161 base::AutoLock auto_lock(lock_);
161 if (!renderer_) 162 if (!renderer_)
162 return TimeDelta(); 163 return TimeDelta();
163 164
164 TimeDelta media_time = renderer_->GetMediaTime(); 165 TimeDelta media_time = renderer_->GetMediaTime();
165
166 base::AutoLock auto_lock(lock_);
167 return std::min(media_time, duration_); 166 return std::min(media_time, duration_);
168 } 167 }
169 168
170 Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() const { 169 Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() const {
171 base::AutoLock auto_lock(lock_); 170 base::AutoLock auto_lock(lock_);
172 return buffered_time_ranges_; 171 return buffered_time_ranges_;
173 } 172 }
174 173
175 TimeDelta Pipeline::GetMediaDuration() const { 174 TimeDelta Pipeline::GetMediaDuration() const {
176 base::AutoLock auto_lock(lock_); 175 base::AutoLock auto_lock(lock_);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 &Demuxer::Seek, base::Unretained(demuxer_), seek_timestamp)); 398 &Demuxer::Seek, base::Unretained(demuxer_), seek_timestamp));
400 399
401 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb); 400 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb);
402 } 401 }
403 402
404 void Pipeline::DoStop(const PipelineStatusCB& done_cb) { 403 void Pipeline::DoStop(const PipelineStatusCB& done_cb) {
405 DVLOG(2) << __FUNCTION__; 404 DVLOG(2) << __FUNCTION__;
406 DCHECK(task_runner_->BelongsToCurrentThread()); 405 DCHECK(task_runner_->BelongsToCurrentThread());
407 DCHECK(!pending_callbacks_.get()); 406 DCHECK(!pending_callbacks_.get());
408 407
409 renderer_.reset(); 408 {
409 base::AutoLock auto_lock(lock_);
410 renderer_.reset();
411 }
410 text_renderer_.reset(); 412 text_renderer_.reset();
411 413
412 if (demuxer_) { 414 if (demuxer_) {
413 demuxer_->Stop(); 415 demuxer_->Stop();
414 demuxer_ = NULL; 416 demuxer_ = NULL;
415 } 417 }
416 418
417 task_runner_->PostTask(FROM_HERE, base::Bind(done_cb, PIPELINE_OK)); 419 task_runner_->PostTask(FROM_HERE, base::Bind(done_cb, PIPELINE_OK));
418 } 420 }
419 421
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 void Pipeline::InitializeDemuxer(const PipelineStatusCB& done_cb) { 665 void Pipeline::InitializeDemuxer(const PipelineStatusCB& done_cb) {
664 DCHECK(task_runner_->BelongsToCurrentThread()); 666 DCHECK(task_runner_->BelongsToCurrentThread());
665 demuxer_->Initialize(this, done_cb, text_renderer_); 667 demuxer_->Initialize(this, done_cb, text_renderer_);
666 } 668 }
667 669
668 void Pipeline::InitializeRenderer(const base::Closure& done_cb) { 670 void Pipeline::InitializeRenderer(const base::Closure& done_cb) {
669 DCHECK(task_runner_->BelongsToCurrentThread()); 671 DCHECK(task_runner_->BelongsToCurrentThread());
670 672
671 if (!demuxer_->GetStream(DemuxerStream::AUDIO) && 673 if (!demuxer_->GetStream(DemuxerStream::AUDIO) &&
672 !demuxer_->GetStream(DemuxerStream::VIDEO)) { 674 !demuxer_->GetStream(DemuxerStream::VIDEO)) {
673 renderer_.reset(); 675 {
676 base::AutoLock auto_lock(lock_);
677 renderer_.reset();
678 }
674 OnError(PIPELINE_ERROR_COULD_NOT_RENDER); 679 OnError(PIPELINE_ERROR_COULD_NOT_RENDER);
675 return; 680 return;
676 } 681 }
677 682
678 base::WeakPtr<Pipeline> weak_this = weak_factory_.GetWeakPtr(); 683 base::WeakPtr<Pipeline> weak_this = weak_factory_.GetWeakPtr();
679 renderer_->Initialize( 684 renderer_->Initialize(
680 done_cb, 685 done_cb,
681 base::Bind(&Pipeline::OnUpdateStatistics, weak_this), 686 base::Bind(&Pipeline::OnUpdateStatistics, weak_this),
682 base::Bind(&Pipeline::OnRendererEnded, weak_this), 687 base::Bind(&Pipeline::OnRendererEnded, weak_this),
683 base::Bind(&Pipeline::OnError, weak_this), 688 base::Bind(&Pipeline::OnError, weak_this),
(...skipping 15 matching lines...) Expand all
699 metadata_cb_.Run(metadata); 704 metadata_cb_.Run(metadata);
700 } 705 }
701 706
702 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { 707 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) {
703 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; 708 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") ";
704 DCHECK(task_runner_->BelongsToCurrentThread()); 709 DCHECK(task_runner_->BelongsToCurrentThread());
705 buffering_state_cb_.Run(new_buffering_state); 710 buffering_state_cb_.Run(new_buffering_state);
706 } 711 }
707 712
708 } // namespace media 713 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698