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

Side by Side Diff: media/audio/audio_util.cc

Issue 6002005: Implement renderer AudioDevice API for low-latency audio output... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « media/audio/audio_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // Software adjust volume of samples, allows each audio stream its own 5 // Software adjust volume of samples, allows each audio stream its own
6 // volume without impacting master volume for chrome and other applications. 6 // volume without impacting master volume for chrome and other applications.
7 7
8 // Implemented as templates to allow 8, 16 and 32 bit implementations. 8 // Implemented as templates to allow 8, 16 and 32 bit implementations.
9 // 8 bit is unsigned and biased by 128. 9 // 8 bit is unsigned and biased by 128.
10 10
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 197 }
198 return true; 198 return true;
199 } 199 }
200 200
201 default: 201 default:
202 break; 202 break;
203 } 203 }
204 return false; 204 return false;
205 } 205 }
206 206
207 void InterleaveFloatToInt16(const std::vector<float*>& source,
208 int16* destination,
209 size_t number_of_frames) {
210 const float kScale = 32768.0f;
211 int channels = source.size();
212 for (int i = 0; i < channels; ++i) {
213 float* channel_data = source[i];
214 for (size_t j = 0; j < number_of_frames; ++j) {
215 float sample = kScale * channel_data[j];
216 if (sample < -32768.0)
217 sample = -32768.0;
218 else if (sample > 32767.0)
219 sample = 32767.0;
220
221 destination[j * channels + i] = static_cast<int16>(sample);
222 }
223 }
224 }
225
207 } // namespace media 226 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698