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

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

Issue 512973002: Avoid deadlock between Pipeline and RendererImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reenable tests 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
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 volume_ = volume; 146 volume_ = volume;
147 if (running_) { 147 if (running_) {
148 task_runner_->PostTask( 148 task_runner_->PostTask(
149 FROM_HERE, 149 FROM_HERE,
150 base::Bind( 150 base::Bind(
151 &Pipeline::VolumeChangedTask, weak_factory_.GetWeakPtr(), volume)); 151 &Pipeline::VolumeChangedTask, weak_factory_.GetWeakPtr(), volume));
152 } 152 }
153 } 153 }
154 154
155 TimeDelta Pipeline::GetMediaTime() const { 155 TimeDelta Pipeline::GetMediaTime() const {
156 if (!renderer_)
157 return TimeDelta();
158
159 TimeDelta media_time = renderer_->GetMediaTime();
160
156 base::AutoLock auto_lock(lock_); 161 base::AutoLock auto_lock(lock_);
157 return renderer_ ? std::min(renderer_->GetMediaTime(), duration_) 162 return std::min(media_time, duration_);
158 : TimeDelta();
159 } 163 }
160 164
161 Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() const { 165 Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() const {
162 base::AutoLock auto_lock(lock_); 166 base::AutoLock auto_lock(lock_);
163 return buffered_time_ranges_; 167 return buffered_time_ranges_;
164 } 168 }
165 169
166 TimeDelta Pipeline::GetMediaDuration() const { 170 TimeDelta Pipeline::GetMediaDuration() const {
167 base::AutoLock auto_lock(lock_); 171 base::AutoLock auto_lock(lock_);
168 return duration_; 172 return duration_;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 } 436 }
433 437
434 void Pipeline::OnStopCompleted(PipelineStatus status) { 438 void Pipeline::OnStopCompleted(PipelineStatus status) {
435 DVLOG(2) << __FUNCTION__; 439 DVLOG(2) << __FUNCTION__;
436 DCHECK(task_runner_->BelongsToCurrentThread()); 440 DCHECK(task_runner_->BelongsToCurrentThread());
437 DCHECK_EQ(state_, kStopping); 441 DCHECK_EQ(state_, kStopping);
438 DCHECK(!renderer_); 442 DCHECK(!renderer_);
439 DCHECK(!text_renderer_); 443 DCHECK(!text_renderer_);
440 444
441 { 445 {
442 base::AutoLock l(lock_); 446 base::AutoLock auto_lock(lock_);
443 running_ = false; 447 running_ = false;
444 } 448 }
445 449
446 SetState(kStopped); 450 SetState(kStopped);
447 filter_collection_.reset(); 451 filter_collection_.reset();
448 demuxer_ = NULL; 452 demuxer_ = NULL;
449 453
450 // If we stop during initialization/seeking we want to run |seek_cb_| 454 // If we stop during initialization/seeking we want to run |seek_cb_|
451 // followed by |stop_cb_| so we don't leave outstanding callbacks around. 455 // followed by |stop_cb_| so we don't leave outstanding callbacks around.
452 if (!seek_cb_.is_null()) { 456 if (!seek_cb_.is_null()) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 base::Bind(&Pipeline::GetMediaDuration, base::Unretained(this))); 673 base::Bind(&Pipeline::GetMediaDuration, base::Unretained(this)));
670 } 674 }
671 675
672 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { 676 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) {
673 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; 677 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") ";
674 DCHECK(task_runner_->BelongsToCurrentThread()); 678 DCHECK(task_runner_->BelongsToCurrentThread());
675 buffering_state_cb_.Run(new_buffering_state); 679 buffering_state_cb_.Run(new_buffering_state);
676 } 680 }
677 681
678 } // namespace media 682 } // namespace media
OLDNEW
« no previous file with comments | « content/browser/media/media_source_browsertest.cc ('k') | media/filters/pipeline_integration_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698