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_recorder_impl.h" | 5 #include "components/audio_modem/audio_recorder_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 156 } |
157 | 157 |
158 void AudioRecorderImpl::FinalizeOnAudioThread() { | 158 void AudioRecorderImpl::FinalizeOnAudioThread() { |
159 DCHECK(media::AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread()); | 159 DCHECK(media::AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread()); |
160 StopAndCloseOnAudioThread(); | 160 StopAndCloseOnAudioThread(); |
161 delete this; | 161 delete this; |
162 } | 162 } |
163 | 163 |
164 void AudioRecorderImpl::OnData(media::AudioInputStream* stream, | 164 void AudioRecorderImpl::OnData(media::AudioInputStream* stream, |
165 const media::AudioBus* source, | 165 const media::AudioBus* source, |
166 uint32 /* hardware_delay_bytes */, | 166 uint32_t /* hardware_delay_bytes */, |
167 double /* volume */) { | 167 double /* volume */) { |
168 // source->frames() == source_params.frames_per_buffer(), so we only have | 168 // source->frames() == source_params.frames_per_buffer(), so we only have |
169 // one chunk of data in the source; correspondingly set the destination | 169 // one chunk of data in the source; correspondingly set the destination |
170 // size to one chunk. | 170 // size to one chunk. |
171 | 171 |
172 int remaining_buffer_frames = buffer_->frames() - buffer_frame_index_; | 172 int remaining_buffer_frames = buffer_->frames() - buffer_frame_index_; |
173 int frames_to_copy = std::min(remaining_buffer_frames, source->frames()); | 173 int frames_to_copy = std::min(remaining_buffer_frames, source->frames()); |
174 source->CopyPartialFramesTo(0, frames_to_copy, buffer_frame_index_, | 174 source->CopyPartialFramesTo(0, frames_to_copy, buffer_frame_index_, |
175 buffer_.get()); | 175 buffer_.get()); |
176 buffer_frame_index_ += frames_to_copy; | 176 buffer_frame_index_ += frames_to_copy; |
(...skipping 30 matching lines...) Expand all Loading... |
207 media::AudioManager::Get()->GetTaskRunner()->PostTaskAndReply( | 207 media::AudioManager::Get()->GetTaskRunner()->PostTaskAndReply( |
208 FROM_HERE, | 208 FROM_HERE, |
209 base::Bind( | 209 base::Bind( |
210 base::IgnoreResult(&AudioRecorderImpl::FlushAudioLoopForTesting), | 210 base::IgnoreResult(&AudioRecorderImpl::FlushAudioLoopForTesting), |
211 base::Unretained(this)), | 211 base::Unretained(this)), |
212 rl.QuitClosure()); | 212 rl.QuitClosure()); |
213 rl.Run(); | 213 rl.Run(); |
214 } | 214 } |
215 | 215 |
216 } // namespace audio_modem | 216 } // namespace audio_modem |
OLD | NEW |