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

Unified Diff: media/base/audio_bus.cc

Issue 2469023002: Support floating-point audio output for Linux (Closed)
Patch Set: Implement correctly Created 4 years, 1 month 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
« media/audio/pulse/pulse_util.cc ('K') | « media/base/audio_bus.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_bus.cc
diff --git a/media/base/audio_bus.cc b/media/base/audio_bus.cc
index d261e87f8dc9f26ae29338b874343eebf728f275..bf9a7409d55ff00c6227e7e3612363467f5b1cd3 100644
--- a/media/base/audio_bus.cc
+++ b/media/base/audio_bus.cc
@@ -337,6 +337,23 @@ void AudioBus::Scale(float volume) {
}
}
+void AudioBus::Clamp() {
DaleCurtis 2016/11/01 23:07:53 No need IIRC, interleave should take care of this.
Raymond Toy 2016/11/01 23:18:50 You're right. I tested with a webaudio manual test
+ for (int ch = 0; ch < channels(); ++ch) {
+ // Replace NaN with 0 and then clamp the data to [-1, 1].
+ float* channel_data = channel(ch);
+ for (int k = 0; k < frames_; ++k) {
+ float value = channel_data[k];
+ if (value < -1)
+ value = -1;
+ else if (value > 1)
+ value = 1;
+ else if (std::isnan(value))
+ value = 0;
+ channel_data[k] = value;
+ }
+ }
+}
+
void AudioBus::SwapChannels(int a, int b) {
DCHECK(a < channels() && a >= 0);
DCHECK(b < channels() && b >= 0);
« media/audio/pulse/pulse_util.cc ('K') | « media/base/audio_bus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698