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

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: Fix ClocklessAudioSink 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
« no previous file with comments | « media/base/mock_filters.h ('k') | media/base/pipeline_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.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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 // Seek demuxer. 487 // Seek demuxer.
488 bound_fns.Push(base::Bind( 488 bound_fns.Push(base::Bind(
489 &Demuxer::Seek, base::Unretained(demuxer_), seek_timestamp)); 489 &Demuxer::Seek, base::Unretained(demuxer_), seek_timestamp));
490 490
491 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb); 491 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb);
492 } 492 }
493 493
494 void Pipeline::DoStop(const PipelineStatusCB& done_cb) { 494 void Pipeline::DoStop(const PipelineStatusCB& done_cb) {
495 DCHECK(task_runner_->BelongsToCurrentThread()); 495 DCHECK(task_runner_->BelongsToCurrentThread());
496 DCHECK(!pending_callbacks_.get()); 496 DCHECK(!pending_callbacks_.get());
497
498 audio_renderer_.reset();
499
497 SerialRunner::Queue bound_fns; 500 SerialRunner::Queue bound_fns;
498 501
499 if (demuxer_) { 502 if (demuxer_) {
500 bound_fns.Push(base::Bind( 503 bound_fns.Push(base::Bind(
501 &Demuxer::Stop, base::Unretained(demuxer_))); 504 &Demuxer::Stop, base::Unretained(demuxer_)));
502 } 505 }
503 506
504 if (audio_renderer_) {
505 bound_fns.Push(base::Bind(
506 &AudioRenderer::Stop, base::Unretained(audio_renderer_.get())));
507 }
508
509 if (video_renderer_) { 507 if (video_renderer_) {
510 bound_fns.Push(base::Bind( 508 bound_fns.Push(base::Bind(
511 &VideoRenderer::Stop, base::Unretained(video_renderer_.get()))); 509 &VideoRenderer::Stop, base::Unretained(video_renderer_.get())));
512 } 510 }
513 511
514 if (text_renderer_) { 512 if (text_renderer_) {
515 bound_fns.Push(base::Bind( 513 bound_fns.Push(base::Bind(
516 &TextRenderer::Stop, base::Unretained(text_renderer_.get()))); 514 &TextRenderer::Stop, base::Unretained(text_renderer_.get())));
517 } 515 }
518 516
519 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb); 517 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb);
520 } 518 }
521 519
522 void Pipeline::OnStopCompleted(PipelineStatus status) { 520 void Pipeline::OnStopCompleted(PipelineStatus status) {
523 DCHECK(task_runner_->BelongsToCurrentThread()); 521 DCHECK(task_runner_->BelongsToCurrentThread());
524 DCHECK_EQ(state_, kStopping); 522 DCHECK_EQ(state_, kStopping);
523 DCHECK(!audio_renderer_);
525 { 524 {
526 base::AutoLock l(lock_); 525 base::AutoLock l(lock_);
527 running_ = false; 526 running_ = false;
528 } 527 }
529 528
530 SetState(kStopped); 529 SetState(kStopped);
531 pending_callbacks_.reset(); 530 pending_callbacks_.reset();
532 filter_collection_.reset(); 531 filter_collection_.reset();
533 audio_renderer_.reset();
534 video_renderer_.reset(); 532 video_renderer_.reset();
535 text_renderer_.reset(); 533 text_renderer_.reset();
536 demuxer_ = NULL; 534 demuxer_ = NULL;
537 535
538 // If we stop during initialization/seeking we want to run |seek_cb_| 536 // If we stop during initialization/seeking we want to run |seek_cb_|
539 // followed by |stop_cb_| so we don't leave outstanding callbacks around. 537 // followed by |stop_cb_| so we don't leave outstanding callbacks around.
540 if (!seek_cb_.is_null()) { 538 if (!seek_cb_.is_null()) {
541 base::ResetAndReturn(&seek_cb_).Run(status_); 539 base::ResetAndReturn(&seek_cb_).Run(status_);
542 error_cb_.Reset(); 540 error_cb_.Reset();
543 } 541 }
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { 913 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() {
916 lock_.AssertAcquired(); 914 lock_.AssertAcquired();
917 if (interpolation_state_ != INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE) 915 if (interpolation_state_ != INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE)
918 return; 916 return;
919 917
920 interpolation_state_ = INTERPOLATION_STARTED; 918 interpolation_state_ = INTERPOLATION_STARTED;
921 interpolator_->StartInterpolating(); 919 interpolator_->StartInterpolating();
922 } 920 }
923 921
924 } // namespace media 922 } // namespace media
OLDNEW
« no previous file with comments | « media/base/mock_filters.h ('k') | media/base/pipeline_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698