| OLD | NEW |
| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 is_local_source_(false), | 143 is_local_source_(false), |
| 144 supports_save_(true), | 144 supports_save_(true), |
| 145 starting_(false), | 145 starting_(false), |
| 146 chunk_demuxer_(NULL), | 146 chunk_demuxer_(NULL), |
| 147 pending_repaint_(false), | 147 pending_repaint_(false), |
| 148 video_frame_provider_client_(NULL) { | 148 video_frame_provider_client_(NULL) { |
| 149 media_log_->AddEvent( | 149 media_log_->AddEvent( |
| 150 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); | 150 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); |
| 151 | 151 |
| 152 CHECK(media_thread_.Start()); | 152 CHECK(media_thread_.Start()); |
| 153 pipeline_ = new media::Pipeline( | 153 pipeline_.reset(new media::Pipeline( |
| 154 media_thread_.message_loop_proxy(), media_log_); | 154 media_thread_.message_loop_proxy(), media_log_)); |
| 155 | 155 |
| 156 // Let V8 know we started new thread if we did not do it yet. | 156 // Let V8 know we started new thread if we did not do it yet. |
| 157 // Made separate task to avoid deletion of player currently being created. | 157 // Made separate task to avoid deletion of player currently being created. |
| 158 // Also, delaying GC until after player starts gets rid of starting lag -- | 158 // Also, delaying GC until after player starts gets rid of starting lag -- |
| 159 // collection happens in parallel with playing. | 159 // collection happens in parallel with playing. |
| 160 // | 160 // |
| 161 // TODO(enal): remove when we get rid of per-audio-stream thread. | 161 // TODO(enal): remove when we get rid of per-audio-stream thread. |
| 162 main_loop_->PostTask( | 162 main_loop_->PostTask( |
| 163 FROM_HERE, | 163 FROM_HERE, |
| 164 base::Bind(&WebMediaPlayerImpl::IncrementExternallyAllocatedMemory, | 164 base::Bind(&WebMediaPlayerImpl::IncrementExternallyAllocatedMemory, |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 | 1197 |
| 1198 // Let V8 know we are not using extra resources anymore. | 1198 // Let V8 know we are not using extra resources anymore. |
| 1199 if (incremented_externally_allocated_memory_) { | 1199 if (incremented_externally_allocated_memory_) { |
| 1200 v8::V8::AdjustAmountOfExternalAllocatedMemory(-kPlayerExtraMemory); | 1200 v8::V8::AdjustAmountOfExternalAllocatedMemory(-kPlayerExtraMemory); |
| 1201 incremented_externally_allocated_memory_ = false; | 1201 incremented_externally_allocated_memory_ = false; |
| 1202 } | 1202 } |
| 1203 | 1203 |
| 1204 media_thread_.Stop(); | 1204 media_thread_.Stop(); |
| 1205 | 1205 |
| 1206 // Release any final references now that everything has stopped. | 1206 // Release any final references now that everything has stopped. |
| 1207 pipeline_.reset(); |
| 1207 demuxer_.reset(); | 1208 demuxer_.reset(); |
| 1208 data_source_.reset(); | 1209 data_source_.reset(); |
| 1209 } | 1210 } |
| 1210 | 1211 |
| 1211 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 1212 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
| 1212 DCHECK(main_loop_->BelongsToCurrentThread()); | 1213 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 1213 DCHECK(client_); | 1214 DCHECK(client_); |
| 1214 return client_; | 1215 return client_; |
| 1215 } | 1216 } |
| 1216 | 1217 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 | 1250 |
| 1250 if (pending_repaint_) | 1251 if (pending_repaint_) |
| 1251 return; | 1252 return; |
| 1252 | 1253 |
| 1253 pending_repaint_ = true; | 1254 pending_repaint_ = true; |
| 1254 main_loop_->PostTask(FROM_HERE, base::Bind( | 1255 main_loop_->PostTask(FROM_HERE, base::Bind( |
| 1255 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); | 1256 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); |
| 1256 } | 1257 } |
| 1257 | 1258 |
| 1258 } // namespace webkit_media | 1259 } // namespace webkit_media |
| OLD | NEW |