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

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

Issue 1094783002: Switch to double for time calculations using playback rate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Making changes at chromecast side to fix trybots Created 5 years, 8 months 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
« no previous file with comments | « media/renderers/audio_renderer_impl.h ('k') | media/renderers/audio_renderer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 media::AudioRendererSink* sink, 45 media::AudioRendererSink* sink,
46 ScopedVector<AudioDecoder> decoders, 46 ScopedVector<AudioDecoder> decoders,
47 const AudioHardwareConfig& hardware_config, 47 const AudioHardwareConfig& hardware_config,
48 const scoped_refptr<MediaLog>& media_log) 48 const scoped_refptr<MediaLog>& media_log)
49 : task_runner_(task_runner), 49 : task_runner_(task_runner),
50 expecting_config_changes_(false), 50 expecting_config_changes_(false),
51 sink_(sink), 51 sink_(sink),
52 audio_buffer_stream_( 52 audio_buffer_stream_(
53 new AudioBufferStream(task_runner, decoders.Pass(), media_log)), 53 new AudioBufferStream(task_runner, decoders.Pass(), media_log)),
54 hardware_config_(hardware_config), 54 hardware_config_(hardware_config),
55 playback_rate_(0), 55 playback_rate_(0.0),
56 state_(kUninitialized), 56 state_(kUninitialized),
57 buffering_state_(BUFFERING_HAVE_NOTHING), 57 buffering_state_(BUFFERING_HAVE_NOTHING),
58 rendering_(false), 58 rendering_(false),
59 sink_playing_(false), 59 sink_playing_(false),
60 pending_read_(false), 60 pending_read_(false),
61 received_end_of_stream_(false), 61 received_end_of_stream_(false),
62 rendered_end_of_stream_(false), 62 rendered_end_of_stream_(false),
63 weak_factory_(this) { 63 weak_factory_(this) {
64 audio_buffer_stream_->set_splice_observer(base::Bind( 64 audio_buffer_stream_->set_splice_observer(base::Bind(
65 &AudioRendererImpl::OnNewSpliceBuffer, weak_factory_.GetWeakPtr())); 65 &AudioRendererImpl::OnNewSpliceBuffer, weak_factory_.GetWeakPtr()));
(...skipping 27 matching lines...) Expand all
93 } 93 }
94 94
95 StartRendering_Locked(); 95 StartRendering_Locked();
96 } 96 }
97 97
98 void AudioRendererImpl::StartRendering_Locked() { 98 void AudioRendererImpl::StartRendering_Locked() {
99 DVLOG(1) << __FUNCTION__; 99 DVLOG(1) << __FUNCTION__;
100 DCHECK(task_runner_->BelongsToCurrentThread()); 100 DCHECK(task_runner_->BelongsToCurrentThread());
101 DCHECK_EQ(state_, kPlaying); 101 DCHECK_EQ(state_, kPlaying);
102 DCHECK(!sink_playing_); 102 DCHECK(!sink_playing_);
103 DCHECK_NE(playback_rate_, 0); 103 DCHECK_NE(playback_rate_, 0.0);
104 lock_.AssertAcquired(); 104 lock_.AssertAcquired();
105 105
106 sink_playing_ = true; 106 sink_playing_ = true;
107 107
108 base::AutoUnlock auto_unlock(lock_); 108 base::AutoUnlock auto_unlock(lock_);
109 sink_->Play(); 109 sink_->Play();
110 } 110 }
111 111
112 void AudioRendererImpl::StopTicking() { 112 void AudioRendererImpl::StopTicking() {
113 DVLOG(1) << __FUNCTION__; 113 DVLOG(1) << __FUNCTION__;
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 return false; 528 return false;
529 529
530 case kPlaying: 530 case kPlaying:
531 break; 531 break;
532 } 532 }
533 533
534 return !pending_read_ && !received_end_of_stream_ && 534 return !pending_read_ && !received_end_of_stream_ &&
535 !algorithm_->IsQueueFull(); 535 !algorithm_->IsQueueFull();
536 } 536 }
537 537
538 void AudioRendererImpl::SetPlaybackRate(float playback_rate) { 538 void AudioRendererImpl::SetPlaybackRate(double playback_rate) {
539 DVLOG(1) << __FUNCTION__ << "(" << playback_rate << ")"; 539 DVLOG(1) << __FUNCTION__ << "(" << playback_rate << ")";
540 DCHECK(task_runner_->BelongsToCurrentThread()); 540 DCHECK(task_runner_->BelongsToCurrentThread());
541 DCHECK_GE(playback_rate, 0); 541 DCHECK_GE(playback_rate, 0);
542 DCHECK(sink_.get()); 542 DCHECK(sink_.get());
543 543
544 base::AutoLock auto_lock(lock_); 544 base::AutoLock auto_lock(lock_);
545 545
546 // We have two cases here: 546 // We have two cases here:
547 // Play: current_playback_rate == 0 && playback_rate != 0 547 // Play: current_playback_rate == 0 && playback_rate != 0
548 // Pause: current_playback_rate != 0 && playback_rate == 0 548 // Pause: current_playback_rate != 0 && playback_rate == 0
549 float current_playback_rate = playback_rate_; 549 double current_playback_rate = playback_rate_;
550 playback_rate_ = playback_rate; 550 playback_rate_ = playback_rate;
551 551
552 if (!rendering_) 552 if (!rendering_)
553 return; 553 return;
554 554
555 if (current_playback_rate == 0 && playback_rate != 0) { 555 if (current_playback_rate == 0 && playback_rate != 0) {
556 StartRendering_Locked(); 556 StartRendering_Locked();
557 return; 557 return;
558 } 558 }
559 559
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 << buffering_state; 750 << buffering_state;
751 DCHECK_NE(buffering_state_, buffering_state); 751 DCHECK_NE(buffering_state_, buffering_state);
752 lock_.AssertAcquired(); 752 lock_.AssertAcquired();
753 buffering_state_ = buffering_state; 753 buffering_state_ = buffering_state;
754 754
755 task_runner_->PostTask(FROM_HERE, 755 task_runner_->PostTask(FROM_HERE,
756 base::Bind(buffering_state_cb_, buffering_state_)); 756 base::Bind(buffering_state_cb_, buffering_state_));
757 } 757 }
758 758
759 } // namespace media 759 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/audio_renderer_impl.h ('k') | media/renderers/audio_renderer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698