Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Side by Side Diff: components/audio_modem/audio_recorder_impl.cc

Issue 1020683002: Fixing mono/stereo crash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/audio_modem/constants.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | components/audio_modem/constants.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698