OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/blink/webmediaplayer_impl.h" | 5 #include "media/blink/webmediaplayer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <string> | 10 #include <string> |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // e.g. GetCurrentFrameFromCompositor(). See http://crbug.com/434861 | 223 // e.g. GetCurrentFrameFromCompositor(). See http://crbug.com/434861 |
224 | 224 |
225 // Use the null sink if no sink was provided. | 225 // Use the null sink if no sink was provided. |
226 audio_source_provider_ = new WebAudioSourceProviderImpl( | 226 audio_source_provider_ = new WebAudioSourceProviderImpl( |
227 params.audio_renderer_sink().get() | 227 params.audio_renderer_sink().get() |
228 ? params.audio_renderer_sink() | 228 ? params.audio_renderer_sink() |
229 : new NullAudioSink(media_task_runner_)); | 229 : new NullAudioSink(media_task_runner_)); |
230 } | 230 } |
231 | 231 |
232 WebMediaPlayerImpl::~WebMediaPlayerImpl() { | 232 WebMediaPlayerImpl::~WebMediaPlayerImpl() { |
233 client_->setWebLayer(NULL); | |
234 | |
235 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 233 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
236 | 234 |
| 235 suppress_destruction_errors_ = true; |
| 236 client_->setWebLayer(NULL); |
237 if (delegate_) { | 237 if (delegate_) { |
238 delegate_->PlayerGone(delegate_id_); | 238 delegate_->PlayerGone(delegate_id_); |
239 delegate_->RemoveObserver(delegate_id_); | 239 delegate_->RemoveObserver(delegate_id_); |
240 } | 240 } |
241 | 241 |
242 // Abort any pending IO so stopping the pipeline doesn't get blocked. | |
243 suppress_destruction_errors_ = true; | |
244 if (data_source_) | |
245 data_source_->Abort(); | |
246 if (chunk_demuxer_) { | |
247 chunk_demuxer_->Shutdown(); | |
248 chunk_demuxer_ = nullptr; | |
249 } | |
250 | |
251 renderer_factory_.reset(); | |
252 | |
253 // Pipeline must be stopped before it is destroyed. | 242 // Pipeline must be stopped before it is destroyed. |
254 pipeline_.Stop(); | 243 pipeline_.Stop(); |
255 | 244 |
256 if (last_reported_memory_usage_) | 245 if (last_reported_memory_usage_) |
257 adjust_allocated_memory_cb_.Run(-last_reported_memory_usage_); | 246 adjust_allocated_memory_cb_.Run(-last_reported_memory_usage_); |
258 | 247 |
259 compositor_task_runner_->DeleteSoon(FROM_HERE, compositor_); | 248 compositor_task_runner_->DeleteSoon(FROM_HERE, compositor_); |
260 | 249 |
261 media_log_->AddEvent( | 250 media_log_->AddEvent( |
262 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); | 251 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); |
(...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1613 << ", Video: " << stats.video_memory_usage << ", DataSource: " | 1602 << ", Video: " << stats.video_memory_usage << ", DataSource: " |
1614 << (data_source_ ? data_source_->GetMemoryUsage() : 0) | 1603 << (data_source_ ? data_source_->GetMemoryUsage() : 0) |
1615 << ", Demuxer: " << demuxer_memory_usage; | 1604 << ", Demuxer: " << demuxer_memory_usage; |
1616 | 1605 |
1617 const int64_t delta = current_memory_usage - last_reported_memory_usage_; | 1606 const int64_t delta = current_memory_usage - last_reported_memory_usage_; |
1618 last_reported_memory_usage_ = current_memory_usage; | 1607 last_reported_memory_usage_ = current_memory_usage; |
1619 adjust_allocated_memory_cb_.Run(delta); | 1608 adjust_allocated_memory_cb_.Run(delta); |
1620 } | 1609 } |
1621 | 1610 |
1622 } // namespace media | 1611 } // namespace media |
OLD | NEW |