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

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

Issue 10825280: Merge Pipeline's kError state with kStopped: a baby step towards bringing sanity to shutdown. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: maybe this time Created 8 years, 4 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 | « webkit/media/webmediaplayer_impl.h ('k') | no next file » | 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 "webkit/media/webmediaplayer_impl.h" 5 #include "webkit/media/webmediaplayer_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 WebKit::WebAudioSourceProvider* audio_source_provider, 108 WebKit::WebAudioSourceProvider* audio_source_provider,
109 media::AudioRendererSink* audio_renderer_sink, 109 media::AudioRendererSink* audio_renderer_sink,
110 media::MessageLoopFactory* message_loop_factory, 110 media::MessageLoopFactory* message_loop_factory,
111 MediaStreamClient* media_stream_client, 111 MediaStreamClient* media_stream_client,
112 media::MediaLog* media_log) 112 media::MediaLog* media_log)
113 : frame_(frame), 113 : frame_(frame),
114 network_state_(WebMediaPlayer::NetworkStateEmpty), 114 network_state_(WebMediaPlayer::NetworkStateEmpty),
115 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), 115 ready_state_(WebMediaPlayer::ReadyStateHaveNothing),
116 main_loop_(MessageLoop::current()), 116 main_loop_(MessageLoop::current()),
117 filter_collection_(collection), 117 filter_collection_(collection),
118 started_(false),
119 message_loop_factory_(message_loop_factory), 118 message_loop_factory_(message_loop_factory),
120 paused_(true), 119 paused_(true),
121 seeking_(false), 120 seeking_(false),
122 playback_rate_(0.0f), 121 playback_rate_(0.0f),
123 pending_seek_(false), 122 pending_seek_(false),
124 pending_seek_seconds_(0.0f), 123 pending_seek_seconds_(0.0f),
125 client_(client), 124 client_(client),
126 proxy_(new WebMediaPlayerProxy(main_loop_->message_loop_proxy(), this)), 125 proxy_(new WebMediaPlayerProxy(main_loop_->message_loop_proxy(), this)),
127 delegate_(delegate), 126 delegate_(delegate),
128 media_stream_client_(media_stream_client), 127 media_stream_client_(media_stream_client),
129 media_log_(media_log), 128 media_log_(media_log),
130 accelerated_compositing_reported_(false), 129 accelerated_compositing_reported_(false),
131 incremented_externally_allocated_memory_(false), 130 incremented_externally_allocated_memory_(false),
132 audio_source_provider_(audio_source_provider), 131 audio_source_provider_(audio_source_provider),
133 audio_renderer_sink_(audio_renderer_sink), 132 audio_renderer_sink_(audio_renderer_sink),
134 is_local_source_(false), 133 is_local_source_(false),
135 decryptor_(proxy_.get(), client, frame) { 134 decryptor_(proxy_.get(), client, frame) {
136 media_log_->AddEvent( 135 media_log_->AddEvent(
137 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); 136 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED));
138 137
139 MessageLoop* pipeline_message_loop = 138 MessageLoop* pipeline_message_loop =
140 message_loop_factory_->GetMessageLoop("PipelineThread"); 139 message_loop_factory_->GetMessageLoop("PipelineThread");
141 pipeline_ = new media::Pipeline(pipeline_message_loop, media_log_); 140 pipeline_ = new media::Pipeline(pipeline_message_loop, media_log_);
Ami GONE FROM CHROMIUM 2012/08/09 22:14:19 This could be in the initializer list just as well
scherkus (not reviewing) 2012/08/09 22:18:33 it's ref-counted!
142 141
143 // Let V8 know we started new thread if we did not did it yet. 142 // Let V8 know we started new thread if we did not did it yet.
144 // Made separate task to avoid deletion of player currently being created. 143 // Made separate task to avoid deletion of player currently being created.
145 // Also, delaying GC until after player starts gets rid of starting lag -- 144 // Also, delaying GC until after player starts gets rid of starting lag --
146 // collection happens in parallel with playing. 145 // collection happens in parallel with playing.
147 // 146 //
148 // TODO(enal): remove when we get rid of per-audio-stream thread. 147 // TODO(enal): remove when we get rid of per-audio-stream thread.
149 MessageLoop::current()->PostTask( 148 MessageLoop::current()->PostTask(
150 FROM_HERE, 149 FROM_HERE,
151 base::Bind(&WebMediaPlayerImpl::IncrementExternallyAllocatedMemory, 150 base::Bind(&WebMediaPlayerImpl::IncrementExternallyAllocatedMemory,
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 SetNetworkState(WebMediaPlayer::NetworkStateIdle); 952 SetNetworkState(WebMediaPlayer::NetworkStateIdle);
954 else if (is_downloading && network_state_ == WebMediaPlayer::NetworkStateIdle) 953 else if (is_downloading && network_state_ == WebMediaPlayer::NetworkStateIdle)
955 SetNetworkState(WebMediaPlayer::NetworkStateLoading); 954 SetNetworkState(WebMediaPlayer::NetworkStateLoading);
956 media_log_->AddEvent( 955 media_log_->AddEvent(
957 media_log_->CreateBooleanEvent( 956 media_log_->CreateBooleanEvent(
958 media::MediaLogEvent::NETWORK_ACTIVITY_SET, 957 media::MediaLogEvent::NETWORK_ACTIVITY_SET,
959 "is_downloading_data", is_downloading)); 958 "is_downloading_data", is_downloading));
960 } 959 }
961 960
962 void WebMediaPlayerImpl::StartPipeline() { 961 void WebMediaPlayerImpl::StartPipeline() {
963 started_ = true;
964 pipeline_->Start( 962 pipeline_->Start(
965 filter_collection_.Pass(), 963 filter_collection_.Pass(),
966 base::Bind(&WebMediaPlayerProxy::PipelineEndedCallback, proxy_.get()), 964 base::Bind(&WebMediaPlayerProxy::PipelineEndedCallback, proxy_.get()),
967 base::Bind(&WebMediaPlayerProxy::PipelineErrorCallback, proxy_.get()), 965 base::Bind(&WebMediaPlayerProxy::PipelineErrorCallback, proxy_.get()),
968 base::Bind(&WebMediaPlayerProxy::PipelineInitializationCallback, 966 base::Bind(&WebMediaPlayerProxy::PipelineInitializationCallback,
969 proxy_.get())); 967 proxy_.get()));
970 } 968 }
971 969
972 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) { 970 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) {
973 DCHECK_EQ(main_loop_, MessageLoop::current()); 971 DCHECK_EQ(main_loop_, MessageLoop::current());
(...skipping 16 matching lines...) Expand all
990 988
991 // Tell the data source to abort any pending reads so that the pipeline is 989 // Tell the data source to abort any pending reads so that the pipeline is
992 // not blocked when issuing stop commands to the other filters. 990 // not blocked when issuing stop commands to the other filters.
993 if (proxy_) { 991 if (proxy_) {
994 proxy_->AbortDataSource(); 992 proxy_->AbortDataSource();
995 proxy_->DemuxerShutdown(); 993 proxy_->DemuxerShutdown();
996 } 994 }
997 995
998 // Make sure to kill the pipeline so there's no more media threads running. 996 // Make sure to kill the pipeline so there's no more media threads running.
999 // Note: stopping the pipeline might block for a long time. 997 // Note: stopping the pipeline might block for a long time.
1000 if (started_) { 998 base::WaitableEvent waiter(false, false);
1001 base::WaitableEvent waiter(false, false); 999 pipeline_->Stop(base::Bind(
1002 pipeline_->Stop(base::Bind( 1000 &base::WaitableEvent::Signal, base::Unretained(&waiter)));
1003 &base::WaitableEvent::Signal, base::Unretained(&waiter))); 1001 waiter.Wait();
1004 waiter.Wait();
1005 started_ = false;
1006 }
1007 1002
1008 // Let V8 know we are not using extra resources anymore. 1003 // Let V8 know we are not using extra resources anymore.
1009 if (incremented_externally_allocated_memory_) { 1004 if (incremented_externally_allocated_memory_) {
1010 v8::V8::AdjustAmountOfExternalAllocatedMemory(-kPlayerExtraMemory); 1005 v8::V8::AdjustAmountOfExternalAllocatedMemory(-kPlayerExtraMemory);
1011 incremented_externally_allocated_memory_ = false; 1006 incremented_externally_allocated_memory_ = false;
1012 } 1007 }
1013 1008
1014 message_loop_factory_.reset(); 1009 message_loop_factory_.reset();
1015 1010
1016 // And then detach the proxy, it may live on the render thread for a little 1011 // And then detach the proxy, it may live on the render thread for a little
(...skipping 14 matching lines...) Expand all
1031 return audio_source_provider_; 1026 return audio_source_provider_;
1032 } 1027 }
1033 1028
1034 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { 1029 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() {
1035 DCHECK_EQ(main_loop_, MessageLoop::current()); 1030 DCHECK_EQ(main_loop_, MessageLoop::current());
1036 incremented_externally_allocated_memory_ = true; 1031 incremented_externally_allocated_memory_ = true;
1037 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); 1032 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory);
1038 } 1033 }
1039 1034
1040 } // namespace webkit_media 1035 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698