| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 int remaining_buffer_frames = buffer_->frames() - buffer_frame_index_; | 169 int remaining_buffer_frames = buffer_->frames() - buffer_frame_index_; |
| 170 int frames_to_copy = std::min(remaining_buffer_frames, source->frames()); | 170 int frames_to_copy = std::min(remaining_buffer_frames, source->frames()); |
| 171 source->CopyPartialFramesTo(0, frames_to_copy, buffer_frame_index_, | 171 source->CopyPartialFramesTo(0, frames_to_copy, buffer_frame_index_, |
| 172 buffer_.get()); | 172 buffer_.get()); |
| 173 buffer_frame_index_ += frames_to_copy; | 173 buffer_frame_index_ += frames_to_copy; |
| 174 | 174 |
| 175 // Buffer full, send it for processing. | 175 // Buffer full, send it for processing. |
| 176 if (buffer_->frames() == buffer_frame_index_) { | 176 if (buffer_->frames() == buffer_frame_index_) { |
| 177 ProcessSamples(buffer_.Pass(), decode_callback_); | 177 ProcessSamples(buffer_.Pass(), decode_callback_); |
| 178 buffer_ = media::AudioBus::Create(kDefaultChannels, total_buffer_frames_); | 178 buffer_ = media::AudioBus::Create(source->channels(), total_buffer_frames_); |
| 179 buffer_frame_index_ = 0; | 179 buffer_frame_index_ = 0; |
| 180 | 180 |
| 181 // Copy any remaining frames in the source to our buffer. | 181 // Copy any remaining frames in the source to our buffer. |
| 182 int remaining_source_frames = source->frames() - frames_to_copy; | 182 int remaining_source_frames = source->frames() - frames_to_copy; |
| 183 source->CopyPartialFramesTo(frames_to_copy, remaining_source_frames, | 183 source->CopyPartialFramesTo(frames_to_copy, remaining_source_frames, |
| 184 buffer_frame_index_, buffer_.get()); | 184 buffer_frame_index_, buffer_.get()); |
| 185 buffer_frame_index_ += remaining_source_frames; | 185 buffer_frame_index_ += remaining_source_frames; |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 | 188 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 204 media::AudioManager::Get()->GetTaskRunner()->PostTaskAndReply( | 204 media::AudioManager::Get()->GetTaskRunner()->PostTaskAndReply( |
| 205 FROM_HERE, | 205 FROM_HERE, |
| 206 base::Bind( | 206 base::Bind( |
| 207 base::IgnoreResult(&AudioRecorderImpl::FlushAudioLoopForTesting), | 207 base::IgnoreResult(&AudioRecorderImpl::FlushAudioLoopForTesting), |
| 208 base::Unretained(this)), | 208 base::Unretained(this)), |
| 209 rl.QuitClosure()); | 209 rl.QuitClosure()); |
| 210 rl.Run(); | 210 rl.Run(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace audio_modem | 213 } // namespace audio_modem |
| OLD | NEW |