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

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

Issue 2267963002: Add support for cancellation of demuxer reads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch to using aborted status. Created 4 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 | « media/base/demuxer.h ('k') | media/base/pipeline_impl_unittest.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_impl.h" 5 #include "media/base/pipeline_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 base::TimeDelta seek_timestamp = std::max(time, demuxer_->GetStartTime()); 304 base::TimeDelta seek_timestamp = std::max(time, demuxer_->GetStartTime());
305 305
306 SetState(kSeeking); 306 SetState(kSeeking);
307 renderer_ended_ = false; 307 renderer_ended_ = false;
308 text_renderer_ended_ = false; 308 text_renderer_ended_ = false;
309 309
310 // Queue asynchronous actions required to start. 310 // Queue asynchronous actions required to start.
311 DCHECK(!pending_callbacks_); 311 DCHECK(!pending_callbacks_);
312 SerialRunner::Queue bound_fns; 312 SerialRunner::Queue bound_fns;
313 313
314 // Abort any reads the renderer may be blocked on.
315 demuxer_->AbortPendingReads();
wolenetz 2016/08/25 18:56:14 Would this be better integrated with how the MSE p
DaleCurtis 2016/08/29 21:14:58 Good point. I think we just need to add AbortPendi
wolenetz 2016/08/30 18:52:12 Acknowledged.
316
314 // Pause. 317 // Pause.
315 if (text_renderer_) { 318 if (text_renderer_) {
316 bound_fns.Push(base::Bind(&TextRenderer::Pause, 319 bound_fns.Push(base::Bind(&TextRenderer::Pause,
317 base::Unretained(text_renderer_.get()))); 320 base::Unretained(text_renderer_.get())));
318 } 321 }
319 322
320 // Flush. 323 // Flush.
321 DCHECK(shared_state_.renderer); 324 DCHECK(shared_state_.renderer);
322 bound_fns.Push(base::Bind(&Renderer::Flush, 325 bound_fns.Push(base::Bind(&Renderer::Flush,
323 base::Unretained(shared_state_.renderer.get()))); 326 base::Unretained(shared_state_.renderer.get())));
(...skipping 21 matching lines...) Expand all
345 DCHECK(state_ == kStopping || state_ == kStopped) 348 DCHECK(state_ == kStopping || state_ == kStopped)
346 << "Receive suspend in unexpected state: " << state_; 349 << "Receive suspend in unexpected state: " << state_;
347 OnPipelineError(PIPELINE_ERROR_INVALID_STATE); 350 OnPipelineError(PIPELINE_ERROR_INVALID_STATE);
348 return; 351 return;
349 } 352 }
350 DCHECK(shared_state_.renderer); 353 DCHECK(shared_state_.renderer);
351 DCHECK(!pending_callbacks_.get()); 354 DCHECK(!pending_callbacks_.get());
352 355
353 SetState(kSuspending); 356 SetState(kSuspending);
354 357
355 // Freeze playback and record the media time before flushing. (Flushing clears 358 // Freeze playback and record the media time before destroying the renderer.
356 // the value.)
357 shared_state_.renderer->SetPlaybackRate(0.0); 359 shared_state_.renderer->SetPlaybackRate(0.0);
358 { 360 {
359 base::AutoLock auto_lock(shared_state_lock_); 361 base::AutoLock auto_lock(shared_state_lock_);
360 shared_state_.suspend_timestamp = shared_state_.renderer->GetMediaTime(); 362 shared_state_.suspend_timestamp = shared_state_.renderer->GetMediaTime();
361 DCHECK(shared_state_.suspend_timestamp != kNoTimestamp); 363 DCHECK(shared_state_.suspend_timestamp != kNoTimestamp);
362 } 364 }
363 365
366 // Abort any reads the renderer may be blocked on.
367 demuxer_->AbortPendingReads();
368
364 // Queue the asynchronous actions required to stop playback. 369 // Queue the asynchronous actions required to stop playback.
365 SerialRunner::Queue fns; 370 SerialRunner::Queue fns;
366 371
367 if (text_renderer_) { 372 if (text_renderer_) {
368 fns.Push(base::Bind(&TextRenderer::Pause, 373 fns.Push(base::Bind(&TextRenderer::Pause,
369 base::Unretained(text_renderer_.get()))); 374 base::Unretained(text_renderer_.get())));
370 } 375 }
371 376
372 fns.Push(base::Bind(&Renderer::Flush, 377 // No need to flush the renderer since it's going to be destroyed.
373 base::Unretained(shared_state_.renderer.get())));
374
375 if (text_renderer_) {
376 fns.Push(base::Bind(&TextRenderer::Flush,
377 base::Unretained(text_renderer_.get())));
378 }
379
380 pending_callbacks_ = SerialRunner::Run( 378 pending_callbacks_ = SerialRunner::Run(
381 fns, base::Bind(&RendererWrapper::CompleteSuspend, weak_this_)); 379 fns, base::Bind(&RendererWrapper::CompleteSuspend, weak_this_));
382 } 380 }
383 381
384 void PipelineImpl::RendererWrapper::Resume(std::unique_ptr<Renderer> renderer, 382 void PipelineImpl::RendererWrapper::Resume(std::unique_ptr<Renderer> renderer,
385 base::TimeDelta timestamp) { 383 base::TimeDelta timestamp) {
386 DCHECK(media_task_runner_->BelongsToCurrentThread()); 384 DCHECK(media_task_runner_->BelongsToCurrentThread());
387 385
388 // Suppress resuming if we're not suspended. 386 // Suppress resuming if we're not suspended.
389 if (state_ != kSuspended) { 387 if (state_ != kSuspended) {
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 void PipelineImpl::OnSuspendDone() { 1233 void PipelineImpl::OnSuspendDone() {
1236 DVLOG(3) << __func__; 1234 DVLOG(3) << __func__;
1237 DCHECK(thread_checker_.CalledOnValidThread()); 1235 DCHECK(thread_checker_.CalledOnValidThread());
1238 DCHECK(IsRunning()); 1236 DCHECK(IsRunning());
1239 1237
1240 DCHECK(!suspend_cb_.is_null()); 1238 DCHECK(!suspend_cb_.is_null());
1241 base::ResetAndReturn(&suspend_cb_).Run(PIPELINE_OK); 1239 base::ResetAndReturn(&suspend_cb_).Run(PIPELINE_OK);
1242 } 1240 }
1243 1241
1244 } // namespace media 1242 } // namespace media
OLDNEW
« no previous file with comments | « media/base/demuxer.h ('k') | media/base/pipeline_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698