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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 | 414 |
415 case kStarting: | 415 case kStarting: |
416 return DoPlay(done_cb); | 416 return DoPlay(done_cb); |
417 | 417 |
418 case kStarted: | 418 case kStarted: |
419 { | 419 { |
420 base::AutoLock l(lock_); | 420 base::AutoLock l(lock_); |
421 // We use audio stream to update the clock. So if there is such a | 421 // We use audio stream to update the clock. So if there is such a |
422 // stream, we pause the clock until we receive a valid timestamp. | 422 // stream, we pause the clock until we receive a valid timestamp. |
423 waiting_for_clock_update_ = true; | 423 waiting_for_clock_update_ = true; |
424 if (!audio_renderer_) { | 424 if (audio_renderer_) { |
| 425 audio_renderer_->StartRendering(); |
| 426 } else { |
425 clock_->SetMaxTime(clock_->Duration()); | 427 clock_->SetMaxTime(clock_->Duration()); |
426 StartClockIfWaitingForTimeUpdate_Locked(); | 428 StartClockIfWaitingForTimeUpdate_Locked(); |
427 } | 429 } |
428 } | 430 } |
429 | 431 |
430 DCHECK(!seek_cb_.is_null()); | 432 DCHECK(!seek_cb_.is_null()); |
431 DCHECK_EQ(status_, PIPELINE_OK); | 433 DCHECK_EQ(status_, PIPELINE_OK); |
432 | 434 |
433 // Fire canplaythrough immediately after playback begins because of | 435 // Fire canplaythrough immediately after playback begins because of |
434 // crbug.com/106480. | 436 // crbug.com/106480. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 } | 477 } |
476 | 478 |
477 void Pipeline::DoSeek( | 479 void Pipeline::DoSeek( |
478 base::TimeDelta seek_timestamp, | 480 base::TimeDelta seek_timestamp, |
479 const PipelineStatusCB& done_cb) { | 481 const PipelineStatusCB& done_cb) { |
480 DCHECK(task_runner_->BelongsToCurrentThread()); | 482 DCHECK(task_runner_->BelongsToCurrentThread()); |
481 DCHECK(!pending_callbacks_.get()); | 483 DCHECK(!pending_callbacks_.get()); |
482 SerialRunner::Queue bound_fns; | 484 SerialRunner::Queue bound_fns; |
483 | 485 |
484 // Pause. | 486 // Pause. |
485 if (audio_renderer_) { | |
486 bound_fns.Push(base::Bind( | |
487 &AudioRenderer::Pause, base::Unretained(audio_renderer_.get()))); | |
488 } | |
489 if (text_renderer_) { | 487 if (text_renderer_) { |
490 bound_fns.Push(base::Bind( | 488 bound_fns.Push(base::Bind( |
491 &TextRenderer::Pause, base::Unretained(text_renderer_.get()))); | 489 &TextRenderer::Pause, base::Unretained(text_renderer_.get()))); |
492 } | 490 } |
493 | 491 |
494 // Flush. | 492 // Flush. |
495 if (audio_renderer_) { | 493 if (audio_renderer_) { |
496 bound_fns.Push(base::Bind( | 494 bound_fns.Push(base::Bind( |
497 &AudioRenderer::Flush, base::Unretained(audio_renderer_.get()))); | 495 &AudioRenderer::Flush, base::Unretained(audio_renderer_.get()))); |
498 } | 496 } |
(...skipping 27 matching lines...) Expand all Loading... |
526 } | 524 } |
527 | 525 |
528 void Pipeline::DoPlay(const PipelineStatusCB& done_cb) { | 526 void Pipeline::DoPlay(const PipelineStatusCB& done_cb) { |
529 DCHECK(task_runner_->BelongsToCurrentThread()); | 527 DCHECK(task_runner_->BelongsToCurrentThread()); |
530 DCHECK(!pending_callbacks_.get()); | 528 DCHECK(!pending_callbacks_.get()); |
531 SerialRunner::Queue bound_fns; | 529 SerialRunner::Queue bound_fns; |
532 | 530 |
533 PlaybackRateChangedTask(GetPlaybackRate()); | 531 PlaybackRateChangedTask(GetPlaybackRate()); |
534 VolumeChangedTask(GetVolume()); | 532 VolumeChangedTask(GetVolume()); |
535 | 533 |
536 if (audio_renderer_) { | |
537 bound_fns.Push(base::Bind( | |
538 &AudioRenderer::Play, base::Unretained(audio_renderer_.get()))); | |
539 } | |
540 | |
541 if (video_renderer_) { | 534 if (video_renderer_) { |
542 bound_fns.Push(base::Bind( | 535 bound_fns.Push(base::Bind( |
543 &VideoRenderer::Play, base::Unretained(video_renderer_.get()))); | 536 &VideoRenderer::Play, base::Unretained(video_renderer_.get()))); |
544 } | 537 } |
545 | 538 |
546 if (text_renderer_) { | 539 if (text_renderer_) { |
547 bound_fns.Push(base::Bind( | 540 bound_fns.Push(base::Bind( |
548 &TextRenderer::Play, base::Unretained(text_renderer_.get()))); | 541 &TextRenderer::Play, base::Unretained(text_renderer_.get()))); |
549 } | 542 } |
550 | 543 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 | 744 |
752 SetState(kSeeking); | 745 SetState(kSeeking); |
753 base::TimeDelta seek_timestamp = std::max(time, demuxer_->GetStartTime()); | 746 base::TimeDelta seek_timestamp = std::max(time, demuxer_->GetStartTime()); |
754 seek_cb_ = seek_cb; | 747 seek_cb_ = seek_cb; |
755 audio_ended_ = false; | 748 audio_ended_ = false; |
756 video_ended_ = false; | 749 video_ended_ = false; |
757 text_ended_ = false; | 750 text_ended_ = false; |
758 | 751 |
759 // Kick off seeking! | 752 // Kick off seeking! |
760 { | 753 { |
| 754 if (audio_renderer_) |
| 755 audio_renderer_->StopRendering(); |
| 756 |
761 base::AutoLock auto_lock(lock_); | 757 base::AutoLock auto_lock(lock_); |
762 if (clock_->IsPlaying()) | 758 if (clock_->IsPlaying()) |
763 clock_->Pause(); | 759 clock_->Pause(); |
764 clock_->SetTime(seek_timestamp, seek_timestamp); | 760 clock_->SetTime(seek_timestamp, seek_timestamp); |
765 } | 761 } |
766 DoSeek(seek_timestamp, base::Bind( | 762 DoSeek(seek_timestamp, base::Bind( |
767 &Pipeline::OnStateTransition, base::Unretained(this))); | 763 &Pipeline::OnStateTransition, base::Unretained(this))); |
768 } | 764 } |
769 | 765 |
770 void Pipeline::DoAudioRendererEnded() { | 766 void Pipeline::DoAudioRendererEnded() { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { | 894 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { |
899 lock_.AssertAcquired(); | 895 lock_.AssertAcquired(); |
900 if (!waiting_for_clock_update_) | 896 if (!waiting_for_clock_update_) |
901 return; | 897 return; |
902 | 898 |
903 waiting_for_clock_update_ = false; | 899 waiting_for_clock_update_ = false; |
904 clock_->Play(); | 900 clock_->Play(); |
905 } | 901 } |
906 | 902 |
907 } // namespace media | 903 } // namespace media |
OLD | NEW |