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

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

Issue 407583002: Fold AudioRenderer::Stop() into the dtor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 5 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 | Annotate | Revision Log
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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // Seek demuxer. 482 // Seek demuxer.
483 bound_fns.Push(base::Bind( 483 bound_fns.Push(base::Bind(
484 &Demuxer::Seek, base::Unretained(demuxer_), seek_timestamp)); 484 &Demuxer::Seek, base::Unretained(demuxer_), seek_timestamp));
485 485
486 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb); 486 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb);
487 } 487 }
488 488
489 void Pipeline::DoStop(const PipelineStatusCB& done_cb) { 489 void Pipeline::DoStop(const PipelineStatusCB& done_cb) {
490 DCHECK(task_runner_->BelongsToCurrentThread()); 490 DCHECK(task_runner_->BelongsToCurrentThread());
491 DCHECK(!pending_callbacks_.get()); 491 DCHECK(!pending_callbacks_.get());
492
493 audio_renderer_.reset();
494
492 SerialRunner::Queue bound_fns; 495 SerialRunner::Queue bound_fns;
493 496
494 if (demuxer_) { 497 if (demuxer_) {
495 bound_fns.Push(base::Bind( 498 bound_fns.Push(base::Bind(
496 &Demuxer::Stop, base::Unretained(demuxer_))); 499 &Demuxer::Stop, base::Unretained(demuxer_)));
497 } 500 }
498 501
499 if (audio_renderer_) {
500 bound_fns.Push(base::Bind(
501 &AudioRenderer::Stop, base::Unretained(audio_renderer_.get())));
502 }
503
504 if (video_renderer_) { 502 if (video_renderer_) {
505 bound_fns.Push(base::Bind( 503 bound_fns.Push(base::Bind(
506 &VideoRenderer::Stop, base::Unretained(video_renderer_.get()))); 504 &VideoRenderer::Stop, base::Unretained(video_renderer_.get())));
507 } 505 }
508 506
509 if (text_renderer_) { 507 if (text_renderer_) {
510 bound_fns.Push(base::Bind( 508 bound_fns.Push(base::Bind(
511 &TextRenderer::Stop, base::Unretained(text_renderer_.get()))); 509 &TextRenderer::Stop, base::Unretained(text_renderer_.get())));
512 } 510 }
513 511
514 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb); 512 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb);
515 } 513 }
516 514
517 void Pipeline::OnStopCompleted(PipelineStatus status) { 515 void Pipeline::OnStopCompleted(PipelineStatus status) {
518 DCHECK(task_runner_->BelongsToCurrentThread()); 516 DCHECK(task_runner_->BelongsToCurrentThread());
519 DCHECK_EQ(state_, kStopping); 517 DCHECK_EQ(state_, kStopping);
518 DCHECK(!audio_renderer_);
520 { 519 {
521 base::AutoLock l(lock_); 520 base::AutoLock l(lock_);
522 running_ = false; 521 running_ = false;
523 } 522 }
524 523
525 SetState(kStopped); 524 SetState(kStopped);
526 pending_callbacks_.reset(); 525 pending_callbacks_.reset();
527 filter_collection_.reset(); 526 filter_collection_.reset();
528 audio_renderer_.reset();
529 video_renderer_.reset(); 527 video_renderer_.reset();
530 text_renderer_.reset(); 528 text_renderer_.reset();
531 demuxer_ = NULL; 529 demuxer_ = NULL;
532 530
533 // If we stop during initialization/seeking we want to run |seek_cb_| 531 // If we stop during initialization/seeking we want to run |seek_cb_|
534 // followed by |stop_cb_| so we don't leave outstanding callbacks around. 532 // followed by |stop_cb_| so we don't leave outstanding callbacks around.
535 if (!seek_cb_.is_null()) { 533 if (!seek_cb_.is_null()) {
536 base::ResetAndReturn(&seek_cb_).Run(status_); 534 base::ResetAndReturn(&seek_cb_).Run(status_);
537 error_cb_.Reset(); 535 error_cb_.Reset();
538 } 536 }
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { 908 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() {
911 lock_.AssertAcquired(); 909 lock_.AssertAcquired();
912 if (interpolation_state_ != INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE) 910 if (interpolation_state_ != INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE)
913 return; 911 return;
914 912
915 interpolation_state_ = INTERPOLATION_STARTED; 913 interpolation_state_ = INTERPOLATION_STARTED;
916 interpolator_->StartInterpolating(); 914 interpolator_->StartInterpolating();
917 } 915 }
918 916
919 } // namespace media 917 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698