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

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: 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 | media/filters/renderer_impl.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 "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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 283 }
280 284
281 void Pipeline::SetDuration(TimeDelta duration) { 285 void Pipeline::SetDuration(TimeDelta duration) {
282 DCHECK(IsRunning()); 286 DCHECK(IsRunning());
283 media_log_->AddEvent( 287 media_log_->AddEvent(
284 media_log_->CreateTimeEvent( 288 media_log_->CreateTimeEvent(
285 MediaLogEvent::DURATION_SET, "duration", duration)); 289 MediaLogEvent::DURATION_SET, "duration", duration));
286 UMA_HISTOGRAM_LONG_TIMES("Media.Duration", duration); 290 UMA_HISTOGRAM_LONG_TIMES("Media.Duration", duration);
287 291
288 base::AutoLock auto_lock(lock_); 292 base::AutoLock auto_lock(lock_);
289 duration_ = duration; 293 duration_ = duration;
scherkus (not reviewing) 2014/08/27 23:41:11 I'm pretty sure this runs on the media thread It
xhwang 2014/08/28 00:46:28 That's true for FFmepgDemuxer, but not for ChunkDe
290 if (!duration_change_cb_.is_null()) 294 if (!duration_change_cb_.is_null())
291 duration_change_cb_.Run(); 295 duration_change_cb_.Run();
292 } 296 }
293 297
294 void Pipeline::OnStateTransition(PipelineStatus status) { 298 void Pipeline::OnStateTransition(PipelineStatus status) {
295 DCHECK(task_runner_->BelongsToCurrentThread()); 299 DCHECK(task_runner_->BelongsToCurrentThread());
296 // Force post to process state transitions after current execution frame. 300 // Force post to process state transitions after current execution frame.
297 task_runner_->PostTask( 301 task_runner_->PostTask(
298 FROM_HERE, 302 FROM_HERE,
299 base::Bind( 303 base::Bind(
(...skipping 132 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 | « no previous file | media/filters/renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698