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

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

Issue 6969026: Convert Filter::Seek() to use new callback system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add files in content/renderer/media Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // TODO(scherkus): clean up PipelineImpl... too many crazy function names, 5 // TODO(scherkus): clean up PipelineImpl... too many crazy function names,
6 // potential deadlocks, etc... 6 // potential deadlocks, etc...
7 7
8 #include "media/base/pipeline_impl.h" 8 #include "media/base/pipeline_impl.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
11 11
12 #include "base/bind.h"
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
14 #include "base/stl_util-inl.h" 15 #include "base/stl_util-inl.h"
15 #include "base/synchronization/condition_variable.h" 16 #include "base/synchronization/condition_variable.h"
16 #include "media/filters/rtc_video_decoder.h" 17 #include "media/filters/rtc_video_decoder.h"
17 #include "media/base/clock.h" 18 #include "media/base/clock.h"
18 #include "media/base/filter_collection.h" 19 #include "media/base/filter_collection.h"
19 #include "media/base/media_format.h" 20 #include "media/base/media_format.h"
20 21
21 namespace media { 22 namespace media {
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 message_loop_->PostTask(FROM_HERE, 569 message_loop_->PostTask(FROM_HERE,
569 NewRunnableMethod(this, &PipelineImpl::InitializeTask)); 570 NewRunnableMethod(this, &PipelineImpl::InitializeTask));
570 } 571 }
571 572
572 // Called from any thread. 573 // Called from any thread.
573 void PipelineImpl::OnFilterStateTransition() { 574 void PipelineImpl::OnFilterStateTransition() {
574 message_loop_->PostTask(FROM_HERE, 575 message_loop_->PostTask(FROM_HERE,
575 NewRunnableMethod(this, &PipelineImpl::FilterStateTransitionTask)); 576 NewRunnableMethod(this, &PipelineImpl::FilterStateTransitionTask));
576 } 577 }
577 578
579 // Called from any thread.
580 void PipelineImpl::OnFilterStateTransitionWithStatus(PipelineStatus status) {
581 if (status != PIPELINE_OK)
582 SetError(status);
Ami GONE FROM CHROMIUM 2011/05/12 20:42:16 This is funky b/c it posts the errorchanged task,
acolwell GONE FROM CHROMIUM 2011/05/12 22:30:40 Yes. This is one of the major reasons why I want t
583 OnFilterStateTransition();
584 }
585
578 void PipelineImpl::OnTeardownStateTransition() { 586 void PipelineImpl::OnTeardownStateTransition() {
579 message_loop_->PostTask(FROM_HERE, 587 message_loop_->PostTask(FROM_HERE,
580 NewRunnableMethod(this, &PipelineImpl::TeardownStateTransitionTask)); 588 NewRunnableMethod(this, &PipelineImpl::TeardownStateTransitionTask));
581 } 589 }
582 590
583 // Called from any thread. 591 // Called from any thread.
584 void PipelineImpl::OnUpdateStatistics(const PipelineStatistics& stats) { 592 void PipelineImpl::OnUpdateStatistics(const PipelineStatistics& stats) {
585 base::AutoLock auto_lock(lock_); 593 base::AutoLock auto_lock(lock_);
586 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; 594 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded;
587 statistics_.video_bytes_decoded += stats.video_bytes_decoded; 595 statistics_.video_bytes_decoded += stats.video_bytes_decoded;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 // Initialization was successful, we are now considered paused, so it's safe 711 // Initialization was successful, we are now considered paused, so it's safe
704 // to set the initial playback rate and volume. 712 // to set the initial playback rate and volume.
705 PreloadChangedTask(GetPreload()); 713 PreloadChangedTask(GetPreload());
706 PlaybackRateChangedTask(GetPlaybackRate()); 714 PlaybackRateChangedTask(GetPlaybackRate());
707 VolumeChangedTask(GetVolume()); 715 VolumeChangedTask(GetVolume());
708 716
709 // Fire the seek request to get the filters to preroll. 717 // Fire the seek request to get the filters to preroll.
710 seek_pending_ = true; 718 seek_pending_ = true;
711 set_state(kSeeking); 719 set_state(kSeeking);
712 seek_timestamp_ = base::TimeDelta(); 720 seek_timestamp_ = base::TimeDelta();
713 pipeline_filter_->Seek(seek_timestamp_, 721 pipeline_filter_->Seek(
714 NewCallback(this, &PipelineImpl::OnFilterStateTransition)); 722 seek_timestamp_,
723 base::Bind(&PipelineImpl::OnFilterStateTransitionWithStatus, this));
715 } 724 }
716 } 725 }
717 726
718 // This method is called as a result of the client calling Pipeline::Stop() or 727 // This method is called as a result of the client calling Pipeline::Stop() or
719 // as the result of an error condition. 728 // as the result of an error condition.
720 // We stop the filters in the reverse order. 729 // We stop the filters in the reverse order.
721 // 730 //
722 // TODO(scherkus): beware! this can get posted multiple times since we post 731 // TODO(scherkus): beware! this can get posted multiple times since we post
723 // Stop() tasks even if we've already stopped. Perhaps this should no-op for 732 // Stop() tasks even if we've already stopped. Perhaps this should no-op for
724 // additional calls, however most of this logic will be changing. 733 // additional calls, however most of this logic will be changing.
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 // Carry out the action for the current state. 954 // Carry out the action for the current state.
946 if (TransientState(state_)) { 955 if (TransientState(state_)) {
947 if (state_ == kPausing) { 956 if (state_ == kPausing) {
948 pipeline_filter_->Pause( 957 pipeline_filter_->Pause(
949 NewCallback(this, &PipelineImpl::OnFilterStateTransition)); 958 NewCallback(this, &PipelineImpl::OnFilterStateTransition));
950 } else if (state_ == kFlushing) { 959 } else if (state_ == kFlushing) {
951 pipeline_filter_->Flush( 960 pipeline_filter_->Flush(
952 NewCallback(this, &PipelineImpl::OnFilterStateTransition)); 961 NewCallback(this, &PipelineImpl::OnFilterStateTransition));
953 } else if (state_ == kSeeking) { 962 } else if (state_ == kSeeking) {
954 pipeline_filter_->Seek(seek_timestamp_, 963 pipeline_filter_->Seek(seek_timestamp_,
955 NewCallback(this, &PipelineImpl::OnFilterStateTransition)); 964 base::Bind(&PipelineImpl::OnFilterStateTransitionWithStatus, this));
956 } else if (state_ == kStarting) { 965 } else if (state_ == kStarting) {
957 pipeline_filter_->Play( 966 pipeline_filter_->Play(
958 NewCallback(this, &PipelineImpl::OnFilterStateTransition)); 967 NewCallback(this, &PipelineImpl::OnFilterStateTransition));
959 } else if (state_ == kStopping) { 968 } else if (state_ == kStopping) {
960 pipeline_filter_->Stop( 969 pipeline_filter_->Stop(
961 NewCallback(this, &PipelineImpl::OnFilterStateTransition)); 970 NewCallback(this, &PipelineImpl::OnFilterStateTransition));
962 } else { 971 } else {
963 NOTREACHED() << "Unexpected state: " << state_; 972 NOTREACHED() << "Unexpected state: " << state_;
964 } 973 }
965 } else if (state_ == kStarted) { 974 } else if (state_ == kStarted) {
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 case kStopping: 1282 case kStopping:
1274 case kStopped: 1283 case kStopped:
1275 NOTREACHED() << "Unexpected state for teardown: " << state_; 1284 NOTREACHED() << "Unexpected state for teardown: " << state_;
1276 break; 1285 break;
1277 // default: intentionally left out to force new states to cause compiler 1286 // default: intentionally left out to force new states to cause compiler
1278 // errors. 1287 // errors.
1279 }; 1288 };
1280 } 1289 }
1281 1290
1282 } // namespace media 1291 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698