summaryrefslogtreecommitdiffstats
path: root/core/jni/android_media_AudioTrack.cpp
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2014-04-01 15:31:10 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-04-01 15:31:11 +0000
commit170e0c4bf02fd236e5f992010aabdbc90b7587db (patch)
tree2307008aefe897d67cf718f58991a20553781bef /core/jni/android_media_AudioTrack.cpp
parentdf42723d6b717fd2882c98c930a0f93c75af2474 (diff)
parent37967d46f40c8c52c88ff8c011972a1489d465ec (diff)
downloadframeworks_base-170e0c4bf02fd236e5f992010aabdbc90b7587db.zip
frameworks_base-170e0c4bf02fd236e5f992010aabdbc90b7587db.tar.gz
frameworks_base-170e0c4bf02fd236e5f992010aabdbc90b7587db.tar.bz2
Merge "Use memcpy_to_i16_from_u8 from audioutils instead of C loop"
Diffstat (limited to 'core/jni/android_media_AudioTrack.cpp')
-rw-r--r--core/jni/android_media_AudioTrack.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp
index 79a46fa..1af41f2 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>
@@ -550,10 +551,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;