| 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.h" | 5 #include "media/base/pipeline.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 // Seek demuxer. | 487 // Seek demuxer. |
| 488 bound_fns.Push(base::Bind( | 488 bound_fns.Push(base::Bind( |
| 489 &Demuxer::Seek, base::Unretained(demuxer_), seek_timestamp)); | 489 &Demuxer::Seek, base::Unretained(demuxer_), seek_timestamp)); |
| 490 | 490 |
| 491 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb); | 491 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb); |
| 492 } | 492 } |
| 493 | 493 |
| 494 void Pipeline::DoStop(const PipelineStatusCB& done_cb) { | 494 void Pipeline::DoStop(const PipelineStatusCB& done_cb) { |
| 495 DCHECK(task_runner_->BelongsToCurrentThread()); | 495 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 496 DCHECK(!pending_callbacks_.get()); | 496 DCHECK(!pending_callbacks_.get()); |
| 497 |
| 498 audio_renderer_.reset(); |
| 499 |
| 497 SerialRunner::Queue bound_fns; | 500 SerialRunner::Queue bound_fns; |
| 498 | 501 |
| 499 if (demuxer_) { | 502 if (demuxer_) { |
| 500 bound_fns.Push(base::Bind( | 503 bound_fns.Push(base::Bind( |
| 501 &Demuxer::Stop, base::Unretained(demuxer_))); | 504 &Demuxer::Stop, base::Unretained(demuxer_))); |
| 502 } | 505 } |
| 503 | 506 |
| 504 if (audio_renderer_) { | |
| 505 bound_fns.Push(base::Bind( | |
| 506 &AudioRenderer::Stop, base::Unretained(audio_renderer_.get()))); | |
| 507 } | |
| 508 | |
| 509 if (video_renderer_) { | 507 if (video_renderer_) { |
| 510 bound_fns.Push(base::Bind( | 508 bound_fns.Push(base::Bind( |
| 511 &VideoRenderer::Stop, base::Unretained(video_renderer_.get()))); | 509 &VideoRenderer::Stop, base::Unretained(video_renderer_.get()))); |
| 512 } | 510 } |
| 513 | 511 |
| 514 if (text_renderer_) { | 512 if (text_renderer_) { |
| 515 bound_fns.Push(base::Bind( | 513 bound_fns.Push(base::Bind( |
| 516 &TextRenderer::Stop, base::Unretained(text_renderer_.get()))); | 514 &TextRenderer::Stop, base::Unretained(text_renderer_.get()))); |
| 517 } | 515 } |
| 518 | 516 |
| 519 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb); | 517 pending_callbacks_ = SerialRunner::Run(bound_fns, done_cb); |
| 520 } | 518 } |
| 521 | 519 |
| 522 void Pipeline::OnStopCompleted(PipelineStatus status) { | 520 void Pipeline::OnStopCompleted(PipelineStatus status) { |
| 523 DCHECK(task_runner_->BelongsToCurrentThread()); | 521 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 524 DCHECK_EQ(state_, kStopping); | 522 DCHECK_EQ(state_, kStopping); |
| 523 DCHECK(!audio_renderer_); |
| 525 { | 524 { |
| 526 base::AutoLock l(lock_); | 525 base::AutoLock l(lock_); |
| 527 running_ = false; | 526 running_ = false; |
| 528 } | 527 } |
| 529 | 528 |
| 530 SetState(kStopped); | 529 SetState(kStopped); |
| 531 pending_callbacks_.reset(); | 530 pending_callbacks_.reset(); |
| 532 filter_collection_.reset(); | 531 filter_collection_.reset(); |
| 533 audio_renderer_.reset(); | |
| 534 video_renderer_.reset(); | 532 video_renderer_.reset(); |
| 535 text_renderer_.reset(); | 533 text_renderer_.reset(); |
| 536 demuxer_ = NULL; | 534 demuxer_ = NULL; |
| 537 | 535 |
| 538 // If we stop during initialization/seeking we want to run |seek_cb_| | 536 // If we stop during initialization/seeking we want to run |seek_cb_| |
| 539 // followed by |stop_cb_| so we don't leave outstanding callbacks around. | 537 // followed by |stop_cb_| so we don't leave outstanding callbacks around. |
| 540 if (!seek_cb_.is_null()) { | 538 if (!seek_cb_.is_null()) { |
| 541 base::ResetAndReturn(&seek_cb_).Run(status_); | 539 base::ResetAndReturn(&seek_cb_).Run(status_); |
| 542 error_cb_.Reset(); | 540 error_cb_.Reset(); |
| 543 } | 541 } |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { | 913 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { |
| 916 lock_.AssertAcquired(); | 914 lock_.AssertAcquired(); |
| 917 if (interpolation_state_ != INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE) | 915 if (interpolation_state_ != INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE) |
| 918 return; | 916 return; |
| 919 | 917 |
| 920 interpolation_state_ = INTERPOLATION_STARTED; | 918 interpolation_state_ = INTERPOLATION_STARTED; |
| 921 interpolator_->StartInterpolating(); | 919 interpolator_->StartInterpolating(); |
| 922 } | 920 } |
| 923 | 921 |
| 924 } // namespace media | 922 } // namespace media |
| OLD | NEW |