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 /* total_bytes_delay */) { | 137 uint32_t /* total_bytes_delay */, |
| 138 uint32_t /* frames_skipped */) { |
138 base::AutoLock al(state_lock_); | 139 base::AutoLock al(state_lock_); |
139 // Continuously play our samples till explicitly told to stop. | 140 // Continuously play our samples till explicitly told to stop. |
140 const int leftover_frames = samples_->frames() - frame_index_; | 141 const int leftover_frames = samples_->frames() - frame_index_; |
141 const int frames_to_copy = std::min(dest->frames(), leftover_frames); | 142 const int frames_to_copy = std::min(dest->frames(), leftover_frames); |
142 | 143 |
143 samples_->CopyPartialFramesTo(frame_index_, frames_to_copy, 0, dest); | 144 samples_->CopyPartialFramesTo(frame_index_, frames_to_copy, 0, dest); |
144 frame_index_ += frames_to_copy; | 145 frame_index_ += frames_to_copy; |
145 | 146 |
146 // If we didn't fill the destination audio bus, wrap around and fill the rest. | 147 // If we didn't fill the destination audio bus, wrap around and fill the rest. |
147 if (leftover_frames <= dest->frames()) { | 148 if (leftover_frames <= dest->frames()) { |
(...skipping 22 matching lines...) Expand all Loading... |
170 base::RunLoop rl; | 171 base::RunLoop rl; |
171 media::AudioManager::Get()->GetTaskRunner()->PostTaskAndReply( | 172 media::AudioManager::Get()->GetTaskRunner()->PostTaskAndReply( |
172 FROM_HERE, | 173 FROM_HERE, |
173 base::Bind(base::IgnoreResult(&AudioPlayerImpl::FlushAudioLoopForTesting), | 174 base::Bind(base::IgnoreResult(&AudioPlayerImpl::FlushAudioLoopForTesting), |
174 base::Unretained(this)), | 175 base::Unretained(this)), |
175 rl.QuitClosure()); | 176 rl.QuitClosure()); |
176 rl.Run(); | 177 rl.Run(); |
177 } | 178 } |
178 | 179 |
179 } // namespace audio_modem | 180 } // namespace audio_modem |
OLD | NEW |