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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // e.g. GetCurrentFrameFromCompositor(). See http://crbug.com/434861 | 224 // e.g. GetCurrentFrameFromCompositor(). See http://crbug.com/434861 |
225 | 225 |
226 // Use the null sink if no sink was provided. | 226 // Use the null sink if no sink was provided. |
227 audio_source_provider_ = new WebAudioSourceProviderImpl( | 227 audio_source_provider_ = new WebAudioSourceProviderImpl( |
228 params.audio_renderer_sink().get() | 228 params.audio_renderer_sink().get() |
229 ? params.audio_renderer_sink() | 229 ? params.audio_renderer_sink() |
230 : new NullAudioSink(media_task_runner_)); | 230 : new NullAudioSink(media_task_runner_)); |
231 } | 231 } |
232 | 232 |
233 WebMediaPlayerImpl::~WebMediaPlayerImpl() { | 233 WebMediaPlayerImpl::~WebMediaPlayerImpl() { |
234 client_->setWebLayer(NULL); | |
235 | |
236 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 234 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
237 | 235 |
| 236 suppress_destruction_errors_ = true; |
| 237 client_->setWebLayer(NULL); |
238 if (delegate_) { | 238 if (delegate_) { |
239 delegate_->PlayerGone(delegate_id_); | 239 delegate_->PlayerGone(delegate_id_); |
240 delegate_->RemoveObserver(delegate_id_); | 240 delegate_->RemoveObserver(delegate_id_); |
241 } | 241 } |
242 | 242 |
243 // Abort any pending IO so stopping the pipeline doesn't get blocked. | |
244 suppress_destruction_errors_ = true; | |
245 if (data_source_) | |
246 data_source_->Abort(); | |
247 if (chunk_demuxer_) { | |
248 chunk_demuxer_->Shutdown(); | |
249 chunk_demuxer_ = nullptr; | |
250 } | |
251 | |
252 renderer_factory_.reset(); | |
253 | |
254 // Pipeline must be stopped before it is destroyed. | 243 // Pipeline must be stopped before it is destroyed. |
255 pipeline_.Stop(); | 244 pipeline_.Stop(); |
256 | 245 |
257 if (last_reported_memory_usage_) | 246 if (last_reported_memory_usage_) |
258 adjust_allocated_memory_cb_.Run(-last_reported_memory_usage_); | 247 adjust_allocated_memory_cb_.Run(-last_reported_memory_usage_); |
259 | 248 |
260 compositor_task_runner_->DeleteSoon(FROM_HERE, compositor_); | 249 compositor_task_runner_->DeleteSoon(FROM_HERE, compositor_); |
261 | 250 |
262 media_log_->AddEvent( | 251 media_log_->AddEvent( |
263 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); | 252 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); |
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1649 if (isRemote()) | 1638 if (isRemote()) |
1650 return; | 1639 return; |
1651 #endif | 1640 #endif |
1652 | 1641 |
1653 // Idle timeout chosen arbitrarily. | 1642 // Idle timeout chosen arbitrarily. |
1654 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), | 1643 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), |
1655 this, &WebMediaPlayerImpl::OnPause); | 1644 this, &WebMediaPlayerImpl::OnPause); |
1656 } | 1645 } |
1657 | 1646 |
1658 } // namespace media | 1647 } // namespace media |
OLD | NEW |