OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/filters/audio_renderer_base.h" | 5 #include "media/filters/audio_renderer_base.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 if (buffer_more_audio) | 140 if (buffer_more_audio) |
141 algorithm_->IncreaseQueueCapacity(); | 141 algorithm_->IncreaseQueueCapacity(); |
142 | 142 |
143 state_ = kRebuffering; | 143 state_ = kRebuffering; |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
147 void AudioRendererBase::ConsumeAudioSamples(scoped_refptr<Buffer> buffer_in) { | 147 void AudioRendererBase::ConsumeAudioSamples(scoped_refptr<Buffer> buffer_in) { |
148 base::AutoLock auto_lock(lock_); | 148 base::AutoLock auto_lock(lock_); |
149 DCHECK(state_ == kPaused || state_ == kSeeking || state_ == kPlaying || | 149 DCHECK(state_ == kPaused || state_ == kSeeking || state_ == kPlaying || |
150 state_ == kUnderflow || state_ == kRebuffering); | 150 state_ == kUnderflow || state_ == kRebuffering || |
151 DCHECK_GT(pending_reads_, 0u); | 151 state_ == kStopped); |
| 152 if (!pending_reads_) |
| 153 return; |
| 154 |
152 --pending_reads_; | 155 --pending_reads_; |
153 | 156 |
154 // TODO(scherkus): this happens due to a race, primarily because Stop() is a | 157 // TODO(scherkus): this happens due to a race, primarily because Stop() is a |
155 // synchronous call when it should be asynchronous and accept a callback. | 158 // synchronous call when it should be asynchronous and accept a callback. |
156 // Refer to http://crbug.com/16059 | 159 // Refer to http://crbug.com/16059 |
157 if (state_ == kStopped) { | 160 if (state_ == kStopped) { |
158 return; | 161 return; |
159 } | 162 } |
160 | 163 |
161 // Don't enqueue an end-of-stream buffer because it has no data, otherwise | 164 // Don't enqueue an end-of-stream buffer because it has no data, otherwise |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 287 |
285 void AudioRendererBase::SetPlaybackRate(float playback_rate) { | 288 void AudioRendererBase::SetPlaybackRate(float playback_rate) { |
286 algorithm_->set_playback_rate(playback_rate); | 289 algorithm_->set_playback_rate(playback_rate); |
287 } | 290 } |
288 | 291 |
289 float AudioRendererBase::GetPlaybackRate() { | 292 float AudioRendererBase::GetPlaybackRate() { |
290 return algorithm_->playback_rate(); | 293 return algorithm_->playback_rate(); |
291 } | 294 } |
292 | 295 |
293 } // namespace media | 296 } // namespace media |
OLD | NEW |