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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_util.cc
===================================================================
--- media/audio/audio_util.cc (revision 70546)
+++ media/audio/audio_util.cc (working copy)
@@ -204,4 +204,23 @@
return false;
}
+void InterleaveFloatToInt16(const std::vector<float*>& source,
+ int16* destination,
+ size_t number_of_frames) {
+ const float kScale = 32768.0f;
+ int channels = source.size();
+ for (int i = 0; i < channels; ++i) {
+ float* channel_data = source[i];
+ for (size_t j = 0; j < number_of_frames; ++j) {
+ float sample = kScale * channel_data[j];
+ if (sample < -32768.0)
+ sample = -32768.0;
+ else if (sample > 32767.0)
+ sample = 32767.0;
+
+ destination[j * channels + i] = static_cast<int16>(sample);
+ }
+ }
+}
+
} // namespace media
« 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