OLD | NEW |
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 #include "media/tools/player_wtl/movie.h" | 5 #include "media/tools/player_wtl/movie.h" |
6 | 6 |
7 #include "base/singleton.h" | 7 #include "base/singleton.h" |
8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "media/base/filter_collection.h" | 10 #include "media/base/filter_collection.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 message_loop_factory_->GetMessageLoop("VideoDecoderThread"), NULL)); | 77 message_loop_factory_->GetMessageLoop("VideoDecoderThread"), NULL)); |
78 | 78 |
79 if (enable_audio_) { | 79 if (enable_audio_) { |
80 collection->AddAudioRenderer(new AudioRendererImpl()); | 80 collection->AddAudioRenderer(new AudioRendererImpl()); |
81 } else { | 81 } else { |
82 collection->AddAudioRenderer(new media::NullAudioRenderer()); | 82 collection->AddAudioRenderer(new media::NullAudioRenderer()); |
83 } | 83 } |
84 collection->AddVideoRenderer(video_renderer); | 84 collection->AddVideoRenderer(video_renderer); |
85 | 85 |
86 // Create and start our pipeline. | 86 // Create and start our pipeline. |
87 pipeline_->Start(collection.release(), WideToUTF8(std::wstring(url)), NULL); | 87 media::PipelineStatusNotification note; |
88 while (true) { | 88 pipeline_->Start(collection.release(), WideToUTF8(std::wstring(url)), |
89 base::PlatformThread::Sleep(100); | 89 note.Callback()); |
90 if (pipeline_->IsInitialized()) | 90 // Wait until the pipeline is fully initialized. |
91 break; | 91 note.Wait(); |
92 if (pipeline_->GetError() != media::PIPELINE_OK) | 92 if (note.status() != PIPELINE_OK) |
93 return false; | 93 return false; |
94 } | |
95 pipeline_->SetPlaybackRate(play_rate_); | 94 pipeline_->SetPlaybackRate(play_rate_); |
96 return true; | 95 return true; |
97 } | 96 } |
98 | 97 |
99 void Movie::Play(float rate) { | 98 void Movie::Play(float rate) { |
100 // Begin playback. | 99 // Begin playback. |
101 if (pipeline_) | 100 if (pipeline_) |
102 pipeline_->SetPlaybackRate(enable_pause_ ? 0.0f : rate); | 101 pipeline_->SetPlaybackRate(enable_pause_ ? 0.0f : rate); |
103 if (rate > 0.0f) | 102 if (rate > 0.0f) |
104 play_rate_ = rate; | 103 play_rate_ = rate; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 void Movie::Close() { | 172 void Movie::Close() { |
174 if (pipeline_) { | 173 if (pipeline_) { |
175 pipeline_->Stop(NULL); | 174 pipeline_->Stop(NULL); |
176 pipeline_ = NULL; | 175 pipeline_ = NULL; |
177 } | 176 } |
178 | 177 |
179 message_loop_factory_.reset(); | 178 message_loop_factory_.reset(); |
180 } | 179 } |
181 | 180 |
182 } // namespace media | 181 } // namespace media |
OLD | NEW |