| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 base::AutoLock auto_lock(lock_); | 57 base::AutoLock auto_lock(lock_); |
| 58 state_ = kStopped; | 58 state_ = kStopped; |
| 59 algorithm_.reset(NULL); | 59 algorithm_.reset(NULL); |
| 60 } | 60 } |
| 61 if (callback) { | 61 if (callback) { |
| 62 callback->Run(); | 62 callback->Run(); |
| 63 delete callback; | 63 delete callback; |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 void AudioRendererBase::Seek(base::TimeDelta time, FilterCallback* callback) { | 67 void AudioRendererBase::Seek(base::TimeDelta time, const FilterStatusCB& cb) { |
| 68 base::AutoLock auto_lock(lock_); | 68 base::AutoLock auto_lock(lock_); |
| 69 DCHECK_EQ(kPaused, state_); | 69 DCHECK_EQ(kPaused, state_); |
| 70 DCHECK_EQ(0u, pending_reads_) << "Pending reads should have completed"; | 70 DCHECK_EQ(0u, pending_reads_) << "Pending reads should have completed"; |
| 71 DCHECK(seek_cb_.is_null()); |
| 71 state_ = kSeeking; | 72 state_ = kSeeking; |
| 72 seek_callback_.reset(callback); | 73 seek_cb_ = cb; |
| 73 seek_timestamp_ = time; | 74 seek_timestamp_ = time; |
| 74 | 75 |
| 75 // Throw away everything and schedule our reads. | 76 // Throw away everything and schedule our reads. |
| 76 last_fill_buffer_time_ = base::TimeDelta(); | 77 last_fill_buffer_time_ = base::TimeDelta(); |
| 77 recieved_end_of_stream_ = false; | 78 recieved_end_of_stream_ = false; |
| 78 rendered_end_of_stream_ = false; | 79 rendered_end_of_stream_ = false; |
| 79 | 80 |
| 80 // |algorithm_| will request more reads. | 81 // |algorithm_| will request more reads. |
| 81 algorithm_->FlushBuffers(); | 82 algorithm_->FlushBuffers(); |
| 82 } | 83 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 (buffer_in->GetTimestamp() + buffer_in->GetDuration()) < | 153 (buffer_in->GetTimestamp() + buffer_in->GetDuration()) < |
| 153 seek_timestamp_) { | 154 seek_timestamp_) { |
| 154 ScheduleRead_Locked(); | 155 ScheduleRead_Locked(); |
| 155 } else { | 156 } else { |
| 156 // Note: Calling this may schedule more reads. | 157 // Note: Calling this may schedule more reads. |
| 157 algorithm_->EnqueueBuffer(buffer_in); | 158 algorithm_->EnqueueBuffer(buffer_in); |
| 158 } | 159 } |
| 159 | 160 |
| 160 // Check for our preroll complete condition. | 161 // Check for our preroll complete condition. |
| 161 if (state_ == kSeeking) { | 162 if (state_ == kSeeking) { |
| 162 DCHECK(seek_callback_.get()); | 163 DCHECK(!seek_cb_.is_null()); |
| 163 if (algorithm_->IsQueueFull() || recieved_end_of_stream_) { | 164 if (algorithm_->IsQueueFull() || recieved_end_of_stream_) { |
| 164 // Transition into paused whether we have data in |algorithm_| or not. | 165 // Transition into paused whether we have data in |algorithm_| or not. |
| 165 // FillBuffer() will play silence if there's nothing to fill. | 166 // FillBuffer() will play silence if there's nothing to fill. |
| 166 state_ = kPaused; | 167 state_ = kPaused; |
| 167 seek_callback_->Run(); | 168 RunAndResetCB(&seek_cb_, PIPELINE_OK); |
| 168 seek_callback_.reset(); | |
| 169 } | 169 } |
| 170 } else if (state_ == kPaused && pending_reads_ == 0) { | 170 } else if (state_ == kPaused && pending_reads_ == 0) { |
| 171 // No more pending reads! We're now officially "paused". | 171 // No more pending reads! We're now officially "paused". |
| 172 if (pause_callback_.get()) { | 172 if (pause_callback_.get()) { |
| 173 pause_callback_->Run(); | 173 pause_callback_->Run(); |
| 174 pause_callback_.reset(); | 174 pause_callback_.reset(); |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 249 |
| 250 void AudioRendererBase::SetPlaybackRate(float playback_rate) { | 250 void AudioRendererBase::SetPlaybackRate(float playback_rate) { |
| 251 algorithm_->set_playback_rate(playback_rate); | 251 algorithm_->set_playback_rate(playback_rate); |
| 252 } | 252 } |
| 253 | 253 |
| 254 float AudioRendererBase::GetPlaybackRate() { | 254 float AudioRendererBase::GetPlaybackRate() { |
| 255 return algorithm_->playback_rate(); | 255 return algorithm_->playback_rate(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 } // namespace media | 258 } // namespace media |
| OLD | NEW |