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