| 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 "media/base/pipeline_impl.h" | 5 #include "media/base/pipeline_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 SetState(kSuspending); | 356 SetState(kSuspending); |
| 357 | 357 |
| 358 // Freeze playback and record the media time before destroying the renderer. | 358 // Freeze playback and record the media time before destroying the renderer. |
| 359 shared_state_.renderer->SetPlaybackRate(0.0); | 359 shared_state_.renderer->SetPlaybackRate(0.0); |
| 360 { | 360 { |
| 361 base::AutoLock auto_lock(shared_state_lock_); | 361 base::AutoLock auto_lock(shared_state_lock_); |
| 362 shared_state_.suspend_timestamp = shared_state_.renderer->GetMediaTime(); | 362 shared_state_.suspend_timestamp = shared_state_.renderer->GetMediaTime(); |
| 363 DCHECK(shared_state_.suspend_timestamp != kNoTimestamp); | 363 DCHECK(shared_state_.suspend_timestamp != kNoTimestamp); |
| 364 } | 364 } |
| 365 | 365 |
| 366 // Abort any reads the renderer may be blocked on. | |
| 367 demuxer_->AbortPendingReads(); | |
| 368 | |
| 369 // Queue the asynchronous actions required to stop playback. | 366 // Queue the asynchronous actions required to stop playback. |
| 370 SerialRunner::Queue fns; | 367 SerialRunner::Queue fns; |
| 371 | 368 |
| 372 if (text_renderer_) { | 369 if (text_renderer_) { |
| 373 fns.Push(base::Bind(&TextRenderer::Pause, | 370 fns.Push(base::Bind(&TextRenderer::Pause, |
| 374 base::Unretained(text_renderer_.get()))); | 371 base::Unretained(text_renderer_.get()))); |
| 375 } | 372 } |
| 376 | 373 |
| 377 // No need to flush the renderer since it's going to be destroyed. | 374 // No need to flush the renderer since it's going to be destroyed. |
| 378 pending_callbacks_ = SerialRunner::Run( | 375 pending_callbacks_ = SerialRunner::Run( |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 LOG_IF(WARNING, status != PIPELINE_OK) | 792 LOG_IF(WARNING, status != PIPELINE_OK) |
| 796 << "Encountered pipeline error while suspending: " << status; | 793 << "Encountered pipeline error while suspending: " << status; |
| 797 | 794 |
| 798 DestroyRenderer(); | 795 DestroyRenderer(); |
| 799 { | 796 { |
| 800 base::AutoLock auto_lock(shared_state_lock_); | 797 base::AutoLock auto_lock(shared_state_lock_); |
| 801 shared_state_.statistics.audio_memory_usage = 0; | 798 shared_state_.statistics.audio_memory_usage = 0; |
| 802 shared_state_.statistics.video_memory_usage = 0; | 799 shared_state_.statistics.video_memory_usage = 0; |
| 803 } | 800 } |
| 804 | 801 |
| 802 // Abort any reads the renderer may have kicked off. |
| 803 demuxer_->AbortPendingReads(); |
| 804 |
| 805 SetState(kSuspended); | 805 SetState(kSuspended); |
| 806 main_task_runner_->PostTask( | 806 main_task_runner_->PostTask( |
| 807 FROM_HERE, base::Bind(&PipelineImpl::OnSuspendDone, weak_pipeline_)); | 807 FROM_HERE, base::Bind(&PipelineImpl::OnSuspendDone, weak_pipeline_)); |
| 808 } | 808 } |
| 809 | 809 |
| 810 void PipelineImpl::RendererWrapper::InitializeDemuxer( | 810 void PipelineImpl::RendererWrapper::InitializeDemuxer( |
| 811 const PipelineStatusCB& done_cb) { | 811 const PipelineStatusCB& done_cb) { |
| 812 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 812 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
| 813 | 813 |
| 814 demuxer_->Initialize(this, done_cb, !!text_renderer_); | 814 demuxer_->Initialize(this, done_cb, !!text_renderer_); |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 void PipelineImpl::OnSuspendDone() { | 1253 void PipelineImpl::OnSuspendDone() { |
| 1254 DVLOG(3) << __func__; | 1254 DVLOG(3) << __func__; |
| 1255 DCHECK(thread_checker_.CalledOnValidThread()); | 1255 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1256 DCHECK(IsRunning()); | 1256 DCHECK(IsRunning()); |
| 1257 | 1257 |
| 1258 DCHECK(!suspend_cb_.is_null()); | 1258 DCHECK(!suspend_cb_.is_null()); |
| 1259 base::ResetAndReturn(&suspend_cb_).Run(PIPELINE_OK); | 1259 base::ResetAndReturn(&suspend_cb_).Run(PIPELINE_OK); |
| 1260 } | 1260 } |
| 1261 | 1261 |
| 1262 } // namespace media | 1262 } // namespace media |
| OLD | NEW |