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/renderers/audio_renderer_impl.h" | 5 #include "media/renderers/audio_renderer_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 return; | 639 return; |
640 | 640 |
641 AttemptRead_Locked(); | 641 AttemptRead_Locked(); |
642 } | 642 } |
643 | 643 |
644 bool AudioRendererImpl::HandleSplicerBuffer_Locked( | 644 bool AudioRendererImpl::HandleSplicerBuffer_Locked( |
645 const scoped_refptr<AudioBuffer>& buffer) { | 645 const scoped_refptr<AudioBuffer>& buffer) { |
646 lock_.AssertAcquired(); | 646 lock_.AssertAcquired(); |
647 if (buffer->end_of_stream()) { | 647 if (buffer->end_of_stream()) { |
648 received_end_of_stream_ = true; | 648 received_end_of_stream_ = true; |
| 649 if (!algorithm_->frames_buffered()) { |
| 650 rendered_end_of_stream_ = true; |
| 651 task_runner_->PostTask(FROM_HERE, |
| 652 base::Bind(&AudioRendererImpl::OnPlaybackEnded, |
| 653 weak_factory_.GetWeakPtr())); |
| 654 } |
649 } else { | 655 } else { |
650 if (state_ == kPlaying) { | 656 if (state_ == kPlaying) { |
651 if (IsBeforeStartTime(buffer)) | 657 if (IsBeforeStartTime(buffer)) |
652 return true; | 658 return true; |
653 | 659 |
654 // Trim off any additional time before the start timestamp. | 660 // Trim off any additional time before the start timestamp. |
655 const base::TimeDelta trim_time = start_timestamp_ - buffer->timestamp(); | 661 const base::TimeDelta trim_time = start_timestamp_ - buffer->timestamp(); |
656 if (trim_time > base::TimeDelta()) { | 662 if (trim_time > base::TimeDelta()) { |
657 buffer->TrimStart(buffer->frame_count() * | 663 buffer->TrimStart(buffer->frame_count() * |
658 (static_cast<double>(trim_time.InMicroseconds()) / | 664 (static_cast<double>(trim_time.InMicroseconds()) / |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 DCHECK_NE(buffering_state_, buffering_state); | 983 DCHECK_NE(buffering_state_, buffering_state); |
978 lock_.AssertAcquired(); | 984 lock_.AssertAcquired(); |
979 buffering_state_ = buffering_state; | 985 buffering_state_ = buffering_state; |
980 | 986 |
981 task_runner_->PostTask( | 987 task_runner_->PostTask( |
982 FROM_HERE, base::Bind(&AudioRendererImpl::OnBufferingStateChange, | 988 FROM_HERE, base::Bind(&AudioRendererImpl::OnBufferingStateChange, |
983 weak_factory_.GetWeakPtr(), buffering_state_)); | 989 weak_factory_.GetWeakPtr(), buffering_state_)); |
984 } | 990 } |
985 | 991 |
986 } // namespace media | 992 } // namespace media |
OLD | NEW |