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

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: '' 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
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()) {
252 fprintf(stderr, "returning early\n");
scherkus (not reviewing) 2010/12/01 06:37:55 looks like leftover debugging code
Nico 2010/12/01 06:46:04 Done.
248 NOTREACHED() << "Could not start PipelineThread"; 253 NOTREACHED() << "Could not start PipelineThread";
249 return; 254 return false;
250 } 255 }
251 256
252 pipeline_ = new media::PipelineImpl(pipeline_thread_.message_loop()); 257 pipeline_ = new media::PipelineImpl(pipeline_thread_.message_loop());
253 258
254 // Also we want to be notified of |main_loop_| destruction. 259 // Also we want to be notified of |main_loop_| destruction.
255 main_loop_->AddDestructionObserver(this); 260 main_loop_->AddDestructionObserver(this);
256 261
257 // Creates the proxy. 262 // Creates the proxy.
258 proxy_ = new Proxy(main_loop_, this); 263 proxy_ = new Proxy(main_loop_, this);
259 web_video_renderer->SetWebMediaPlayerImplProxy(proxy_); 264 web_video_renderer->SetWebMediaPlayerImplProxy(proxy_);
(...skipping 23 matching lines...) Expand all
283 } else { 288 } else {
284 filter_collection_->AddDataSource(buffered_data_source); 289 filter_collection_->AddDataSource(buffered_data_source);
285 filter_collection_->AddDataSource(simple_data_source); 290 filter_collection_->AddDataSource(simple_data_source);
286 } 291 }
287 292
288 // Add in the default filter factories. 293 // Add in the default filter factories.
289 filter_collection_->AddDemuxer(new media::FFmpegDemuxer()); 294 filter_collection_->AddDemuxer(new media::FFmpegDemuxer());
290 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder()); 295 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder());
291 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder(NULL)); 296 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder(NULL));
292 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); 297 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer());
298
299 return true;
293 } 300 }
294 301
295 WebMediaPlayerImpl::~WebMediaPlayerImpl() { 302 WebMediaPlayerImpl::~WebMediaPlayerImpl() {
296 Destroy(); 303 Destroy();
297 304
298 // Finally tell the |main_loop_| we don't want to be notified of destruction 305 // Finally tell the |main_loop_| we don't want to be notified of destruction
299 // event. 306 // event.
300 if (main_loop_) { 307 if (main_loop_) {
301 main_loop_->RemoveDestructionObserver(this); 308 main_loop_->RemoveDestructionObserver(this);
302 } 309 }
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 void WebMediaPlayerImpl::Destroy() { 776 void WebMediaPlayerImpl::Destroy() {
770 DCHECK(MessageLoop::current() == main_loop_); 777 DCHECK(MessageLoop::current() == main_loop_);
771 778
772 // Tell the data source to abort any pending reads so that the pipeline is 779 // 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. 780 // not blocked when issuing stop commands to the other filters.
774 if (proxy_) 781 if (proxy_)
775 proxy_->AbortDataSource(); 782 proxy_->AbortDataSource();
776 783
777 // Make sure to kill the pipeline so there's no more media threads running. 784 // 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. 785 // Note: stopping the pipeline might block for a long time.
779 pipeline_->Stop(NewCallback(this, 786 if (pipeline_) {
780 &WebMediaPlayerImpl::PipelineStoppedCallback)); 787 pipeline_->Stop(NewCallback(this,
781 pipeline_stopped_.Wait(); 788 &WebMediaPlayerImpl::PipelineStoppedCallback));
782 pipeline_thread_.Stop(); 789 pipeline_stopped_.Wait();
790 pipeline_thread_.Stop();
791 }
783 792
784 // And then detach the proxy, it may live on the render thread for a little 793 // And then detach the proxy, it may live on the render thread for a little
785 // longer until all the tasks are finished. 794 // longer until all the tasks are finished.
786 if (proxy_) { 795 if (proxy_) {
787 proxy_->Detach(); 796 proxy_->Detach();
788 proxy_ = NULL; 797 proxy_ = NULL;
789 } 798 }
790 } 799 }
791 800
792 void WebMediaPlayerImpl::PipelineStoppedCallback() { 801 void WebMediaPlayerImpl::PipelineStoppedCallback() {
793 pipeline_stopped_.Signal(); 802 pipeline_stopped_.Signal();
794 } 803 }
795 804
796 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { 805 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() {
797 DCHECK(MessageLoop::current() == main_loop_); 806 DCHECK(MessageLoop::current() == main_loop_);
798 DCHECK(client_); 807 DCHECK(client_);
799 return client_; 808 return client_;
800 } 809 }
801 810
802 } // namespace webkit_glue 811 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698