summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2012-10-29 17:13:16 -0700
committerMathias Agopian <mathias@google.com>2012-10-29 17:13:16 -0700
commit3e48fd11e3fca5c1d03354a99657298e110be56a (patch)
tree137d322b97e3655d6dc50d8ec492239907336a80
parent856d2116bf4bfed20b7df113dadf6e0555994b42 (diff)
downloadframeworks_av-3e48fd11e3fca5c1d03354a99657298e110be56a.zip
frameworks_av-3e48fd11e3fca5c1d03354a99657298e110be56a.tar.gz
frameworks_av-3e48fd11e3fca5c1d03354a99657298e110be56a.tar.bz2
test-resample: clip instead of overflowing
Change-Id: I550e5a59e51c11e1095ca338222b094f92b96878
-rw-r--r--services/audioflinger/test-resample.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/services/audioflinger/test-resample.cpp b/services/audioflinger/test-resample.cpp
index a55a32b..a8e23e4 100644
--- a/services/audioflinger/test-resample.cpp
+++ b/services/audioflinger/test-resample.cpp
@@ -206,7 +206,10 @@ int main(int argc, char* argv[]) {
int32_t* out = (int32_t*) output_vaddr;
int16_t* convert = (int16_t*) malloc(out_frames * sizeof(int16_t));
for (size_t i = 0; i < out_frames; i++) {
- convert[i] = out[i * 2] >> 12;
+ int32_t s = out[i * 2] >> 12;
+ if (s > 32767) s = 32767;
+ else if (s < -32768) s = -32768;
+ convert[i] = int16_t(s);
}
// write output to disk