diff options
author | Glenn Kasten <gkasten@google.com> | 2012-11-28 14:37:36 -0800 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2014-03-28 16:52:40 -0700 |
commit | 37967d46f40c8c52c88ff8c011972a1489d465ec (patch) | |
tree | deec507ff288ddf736c9bf4e0bea0bc2189b3962 | |
parent | 08c96b5515f061f61e13b348f6022ce7c586e4c4 (diff) | |
download | frameworks_base-37967d46f40c8c52c88ff8c011972a1489d465ec.zip frameworks_base-37967d46f40c8c52c88ff8c011972a1489d465ec.tar.gz frameworks_base-37967d46f40c8c52c88ff8c011972a1489d465ec.tar.bz2 |
Use memcpy_to_i16_from_u8 from audioutils instead of C loop
This function may be optimized in the future,
and it will make it easier to search for audio sample
format-specific code when we need add support for more formats.
Change-Id: Iad0585c35ddd2d12857164ed1effcce75f77920c
-rw-r--r-- | core/jni/Android.mk | 6 | ||||
-rw-r--r-- | core/jni/android_media_AudioTrack.cpp | 7 |
2 files changed, 7 insertions, 6 deletions
diff --git a/core/jni/Android.mk b/core/jni/Android.mk index 51c5a86..52c463d 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -177,7 +177,8 @@ LOCAL_C_INCLUDES += \ external/harfbuzz_ng/src \ external/zlib \ frameworks/opt/emoji \ - libcore/include + libcore/include \ + $(call include-path-for, audio-utils) \ LOCAL_SHARED_LIBRARIES := \ libmemtrack \ @@ -213,7 +214,8 @@ LOCAL_SHARED_LIBRARIES := \ libjpeg \ libusbhost \ libharfbuzz_ng \ - libz + libz \ + libaudioutils \ ifeq ($(USE_OPENGL_RENDERER),true) LOCAL_SHARED_LIBRARIES += libhwui diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp index 3a5b566..17afea2 100644 --- a/core/jni/android_media_AudioTrack.cpp +++ b/core/jni/android_media_AudioTrack.cpp @@ -26,6 +26,7 @@ #include <utils/Log.h> #include <media/AudioSystem.h> #include <media/AudioTrack.h> +#include <audio_utils/primitives.h> #include <binder/MemoryHeapBase.h> #include <binder/MemoryBase.h> @@ -546,10 +547,8 @@ jint writeToTrack(const sp<AudioTrack>& track, jint audioFormat, const jbyte* da } int count = sizeInBytes; int16_t *dst = (int16_t *)track->sharedBuffer()->pointer(); - const int8_t *src = (const int8_t *)(data + offsetInBytes); - while (count--) { - *dst++ = (int16_t)(*src++^0x80) << 8; - } + const uint8_t *src = (const uint8_t *)(data + offsetInBytes); + memcpy_to_i16_from_u8(dst, src, count); // even though we wrote 2*sizeInBytes, we only report sizeInBytes as written to hide // the 8bit mixer restriction from the user of this function written = sizeInBytes; |