Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: media/renderers/audio_renderer_impl.cc

Issue 2440563004: Switch to using an explicit ended signal instead of time comparison. (Closed)
Patch Set: Fix ended event in ARI. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698