diff options
author | Glenn Kasten <gkasten@google.com> | 2012-01-20 11:49:04 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-01-20 11:49:04 -0800 |
commit | 5ecff094f4df499f997bc9406c6e1a76a899aa12 (patch) | |
tree | 8a45863037ca9ec3e66cd77843b37e2a5f82e5a1 | |
parent | 1d98303ab6141af57dc841115486d9795fc94d02 (diff) | |
parent | cc2302d82e56ec038c7917105d6d601829c717c7 (diff) | |
download | frameworks_base-5ecff094f4df499f997bc9406c6e1a76a899aa12.zip frameworks_base-5ecff094f4df499f997bc9406c6e1a76a899aa12.tar.gz frameworks_base-5ecff094f4df499f997bc9406c6e1a76a899aa12.tar.bz2 |
Merge "Move memcpy_to_i16_from_u8 to audio_utils"
-rw-r--r-- | media/libmedia/AudioTrack.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index 837fcc3..17e3d4b 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -43,6 +43,8 @@ #include <system/audio.h> #include <system/audio_policy.h> +#include <audio_utils/primitives.h> + namespace android { // --------------------------------------------------------------------------- @@ -1017,12 +1019,7 @@ ssize_t AudioTrack::write(const void* buffer, size_t userSize) if (mFormat == AUDIO_FORMAT_PCM_8_BIT && !(mFlags & AUDIO_POLICY_OUTPUT_FLAG_DIRECT)) { // Divide capacity by 2 to take expansion into account toWrite = audioBuffer.size>>1; - // 8 to 16 bit conversion - int count = toWrite; - int16_t *dst = (int16_t *)(audioBuffer.i8); - while(count--) { - *dst++ = (int16_t)(*src++^0x80) << 8; - } + memcpy_to_i16_from_u8(audioBuffer.i16, (const uint8_t *) src, toWrite); } else { toWrite = audioBuffer.size; memcpy(audioBuffer.i8, src, toWrite); @@ -1143,13 +1140,8 @@ bool AudioTrack::processAudioBuffer(const sp<AudioTrackThread>& thread) if (writtenSize > reqSize) writtenSize = reqSize; if (mFormat == AUDIO_FORMAT_PCM_8_BIT && !(mFlags & AUDIO_POLICY_OUTPUT_FLAG_DIRECT)) { - // 8 to 16 bit conversion - const int8_t *src = audioBuffer.i8 + writtenSize-1; - int count = writtenSize; - int16_t *dst = audioBuffer.i16 + writtenSize-1; - while(count--) { - *dst-- = (int16_t)(*src--^0x80) << 8; - } + // 8 to 16 bit conversion, note that source and destination are the same address + memcpy_to_i16_from_u8(audioBuffer.i16, (const uint8_t *) audioBuffer.i8, writtenSize); writtenSize <<= 1; } |