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

Side by Side Diff: webkit/glue/webmediaplayer_impl.cc

Issue 5362003: Stopgap fix for crash in issue 53867 comment 15 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 10 years 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 | « webkit/glue/webmediaplayer_impl.h ('k') | webkit/support/webkit_support.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/glue/webmediaplayer_impl.h" 5 #include "webkit/glue/webmediaplayer_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 scoped_refptr<media::VideoFrame> frame) { 218 scoped_refptr<media::VideoFrame> frame) {
219 if (video_renderer_) 219 if (video_renderer_)
220 video_renderer_->PutCurrentFrame(frame); 220 video_renderer_->PutCurrentFrame(frame);
221 } 221 }
222 222
223 ///////////////////////////////////////////////////////////////////////////// 223 /////////////////////////////////////////////////////////////////////////////
224 // WebMediaPlayerImpl implementation 224 // WebMediaPlayerImpl implementation
225 225
226 WebMediaPlayerImpl::WebMediaPlayerImpl( 226 WebMediaPlayerImpl::WebMediaPlayerImpl(
227 WebKit::WebMediaPlayerClient* client, 227 WebKit::WebMediaPlayerClient* client,
228 media::MediaFilterCollection* collection, 228 media::MediaFilterCollection* collection)
229 MediaResourceLoaderBridgeFactory* bridge_factory_simple,
230 MediaResourceLoaderBridgeFactory* bridge_factory_buffered,
231 bool use_simple_data_source,
232 scoped_refptr<WebVideoRenderer> web_video_renderer)
233 : network_state_(WebKit::WebMediaPlayer::Empty), 229 : network_state_(WebKit::WebMediaPlayer::Empty),
234 ready_state_(WebKit::WebMediaPlayer::HaveNothing), 230 ready_state_(WebKit::WebMediaPlayer::HaveNothing),
235 main_loop_(NULL), 231 main_loop_(NULL),
236 filter_collection_(collection), 232 filter_collection_(collection),
233 pipeline_(NULL),
237 pipeline_thread_("PipelineThread"), 234 pipeline_thread_("PipelineThread"),
238 paused_(true), 235 paused_(true),
239 playback_rate_(0.0f), 236 playback_rate_(0.0f),
240 client_(client), 237 client_(client),
238 proxy_(NULL),
241 pipeline_stopped_(false, false) { 239 pipeline_stopped_(false, false) {
242 // Saves the current message loop. 240 // Saves the current message loop.
243 DCHECK(!main_loop_); 241 DCHECK(!main_loop_);
244 main_loop_ = MessageLoop::current(); 242 main_loop_ = MessageLoop::current();
243 }
245 244
245 bool WebMediaPlayerImpl::Initialize(
246 MediaResourceLoaderBridgeFactory* bridge_factory_simple,
247 MediaResourceLoaderBridgeFactory* bridge_factory_buffered,
248 bool use_simple_data_source,
249 scoped_refptr<WebVideoRenderer> web_video_renderer) {
246 // Create the pipeline and its thread. 250 // Create the pipeline and its thread.
247 if (!pipeline_thread_.Start()) { 251 if (!pipeline_thread_.Start()) {
248 NOTREACHED() << "Could not start PipelineThread"; 252 NOTREACHED() << "Could not start PipelineThread";
249 return; 253 return false;
250 } 254 }
251 255
252 pipeline_ = new media::PipelineImpl(pipeline_thread_.message_loop()); 256 pipeline_ = new media::PipelineImpl(pipeline_thread_.message_loop());
253 257
254 // Also we want to be notified of |main_loop_| destruction. 258 // Also we want to be notified of |main_loop_| destruction.
255 main_loop_->AddDestructionObserver(this); 259 main_loop_->AddDestructionObserver(this);
256 260
257 // Creates the proxy. 261 // Creates the proxy.
258 proxy_ = new Proxy(main_loop_, this); 262 proxy_ = new Proxy(main_loop_, this);
259 web_video_renderer->SetWebMediaPlayerImplProxy(proxy_); 263 web_video_renderer->SetWebMediaPlayerImplProxy(proxy_);
(...skipping 23 matching lines...) Expand all
283 } else { 287 } else {
284 filter_collection_->AddDataSource(buffered_data_source); 288 filter_collection_->AddDataSource(buffered_data_source);
285 filter_collection_->AddDataSource(simple_data_source); 289 filter_collection_->AddDataSource(simple_data_source);
286 } 290 }
287 291
288 // Add in the default filter factories. 292 // Add in the default filter factories.
289 filter_collection_->AddDemuxer(new media::FFmpegDemuxer()); 293 filter_collection_->AddDemuxer(new media::FFmpegDemuxer());
290 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder()); 294 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder());
291 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder(NULL)); 295 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder(NULL));
292 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); 296 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer());
297
298 return true;
293 } 299 }
294 300
295 WebMediaPlayerImpl::~WebMediaPlayerImpl() { 301 WebMediaPlayerImpl::~WebMediaPlayerImpl() {
296 Destroy(); 302 Destroy();
297 303
298 // Finally tell the |main_loop_| we don't want to be notified of destruction 304 // Finally tell the |main_loop_| we don't want to be notified of destruction
299 // event. 305 // event.
300 if (main_loop_) { 306 if (main_loop_) {
301 main_loop_->RemoveDestructionObserver(this); 307 main_loop_->RemoveDestructionObserver(this);
302 } 308 }
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 void WebMediaPlayerImpl::Destroy() { 775 void WebMediaPlayerImpl::Destroy() {
770 DCHECK(MessageLoop::current() == main_loop_); 776 DCHECK(MessageLoop::current() == main_loop_);
771 777
772 // Tell the data source to abort any pending reads so that the pipeline is 778 // Tell the data source to abort any pending reads so that the pipeline is
773 // not blocked when issuing stop commands to the other filters. 779 // not blocked when issuing stop commands to the other filters.
774 if (proxy_) 780 if (proxy_)
775 proxy_->AbortDataSource(); 781 proxy_->AbortDataSource();
776 782
777 // Make sure to kill the pipeline so there's no more media threads running. 783 // Make sure to kill the pipeline so there's no more media threads running.
778 // Note: stopping the pipeline might block for a long time. 784 // Note: stopping the pipeline might block for a long time.
779 pipeline_->Stop(NewCallback(this, 785 if (pipeline_) {
780 &WebMediaPlayerImpl::PipelineStoppedCallback)); 786 pipeline_->Stop(NewCallback(this,
781 pipeline_stopped_.Wait(); 787 &WebMediaPlayerImpl::PipelineStoppedCallback));
782 pipeline_thread_.Stop(); 788 pipeline_stopped_.Wait();
789 pipeline_thread_.Stop();
790 }
783 791
784 // And then detach the proxy, it may live on the render thread for a little 792 // And then detach the proxy, it may live on the render thread for a little
785 // longer until all the tasks are finished. 793 // longer until all the tasks are finished.
786 if (proxy_) { 794 if (proxy_) {
787 proxy_->Detach(); 795 proxy_->Detach();
788 proxy_ = NULL; 796 proxy_ = NULL;
789 } 797 }
790 } 798 }
791 799
792 void WebMediaPlayerImpl::PipelineStoppedCallback() { 800 void WebMediaPlayerImpl::PipelineStoppedCallback() {
793 pipeline_stopped_.Signal(); 801 pipeline_stopped_.Signal();
794 } 802 }
795 803
796 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { 804 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() {
797 DCHECK(MessageLoop::current() == main_loop_); 805 DCHECK(MessageLoop::current() == main_loop_);
798 DCHECK(client_); 806 DCHECK(client_);
799 return client_; 807 return client_;
800 } 808 }
801 809
802 } // namespace webkit_glue 810 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/webmediaplayer_impl.h ('k') | webkit/support/webkit_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698