| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/audio_modem/audio_player_impl.h" | 5 #include "components/audio_modem/audio_player_impl.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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 stream_ = nullptr; | 127 stream_ = nullptr; |
| 128 } | 128 } |
| 129 | 129 |
| 130 void AudioPlayerImpl::FinalizeOnAudioThread() { | 130 void AudioPlayerImpl::FinalizeOnAudioThread() { |
| 131 DCHECK(media::AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread()); | 131 DCHECK(media::AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread()); |
| 132 StopAndCloseOnAudioThread(); | 132 StopAndCloseOnAudioThread(); |
| 133 delete this; | 133 delete this; |
| 134 } | 134 } |
| 135 | 135 |
| 136 int AudioPlayerImpl::OnMoreData(media::AudioBus* dest, | 136 int AudioPlayerImpl::OnMoreData(media::AudioBus* dest, |
| 137 uint32_t /* total_bytes_delay */, | 137 uint32 /* total_bytes_delay */) { |
| 138 uint32_t /* frames_skipped */) { | |
| 139 base::AutoLock al(state_lock_); | 138 base::AutoLock al(state_lock_); |
| 140 // Continuously play our samples till explicitly told to stop. | 139 // Continuously play our samples till explicitly told to stop. |
| 141 const int leftover_frames = samples_->frames() - frame_index_; | 140 const int leftover_frames = samples_->frames() - frame_index_; |
| 142 const int frames_to_copy = std::min(dest->frames(), leftover_frames); | 141 const int frames_to_copy = std::min(dest->frames(), leftover_frames); |
| 143 | 142 |
| 144 samples_->CopyPartialFramesTo(frame_index_, frames_to_copy, 0, dest); | 143 samples_->CopyPartialFramesTo(frame_index_, frames_to_copy, 0, dest); |
| 145 frame_index_ += frames_to_copy; | 144 frame_index_ += frames_to_copy; |
| 146 | 145 |
| 147 // If we didn't fill the destination audio bus, wrap around and fill the rest. | 146 // If we didn't fill the destination audio bus, wrap around and fill the rest. |
| 148 if (leftover_frames <= dest->frames()) { | 147 if (leftover_frames <= dest->frames()) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 171 base::RunLoop rl; | 170 base::RunLoop rl; |
| 172 media::AudioManager::Get()->GetTaskRunner()->PostTaskAndReply( | 171 media::AudioManager::Get()->GetTaskRunner()->PostTaskAndReply( |
| 173 FROM_HERE, | 172 FROM_HERE, |
| 174 base::Bind(base::IgnoreResult(&AudioPlayerImpl::FlushAudioLoopForTesting), | 173 base::Bind(base::IgnoreResult(&AudioPlayerImpl::FlushAudioLoopForTesting), |
| 175 base::Unretained(this)), | 174 base::Unretained(this)), |
| 176 rl.QuitClosure()); | 175 rl.QuitClosure()); |
| 177 rl.Run(); | 176 rl.Run(); |
| 178 } | 177 } |
| 179 | 178 |
| 180 } // namespace audio_modem | 179 } // namespace audio_modem |
| OLD | NEW |