summaryrefslogtreecommitdiffstats
path: root/media/libmedia
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2009-08-04 10:42:26 -0700
committerEric Laurent <elaurent@google.com>2009-08-04 10:42:26 -0700
commit3302526f6276911b2dc40c731ea7fa0e7972d908 (patch)
treeac996692cf7f9204063c1ce585621d8963a54703 /media/libmedia
parent8b938cdab5bd3d074d9b41bc2915fcfc11e47f27 (diff)
downloadframeworks_av-3302526f6276911b2dc40c731ea7fa0e7972d908.zip
frameworks_av-3302526f6276911b2dc40c731ea7fa0e7972d908.tar.gz
frameworks_av-3302526f6276911b2dc40c731ea7fa0e7972d908.tar.bz2
Fix problem in AudioTrack with 8 bit PCM and direct output.
Do not perform 8 to 16 bit conversion in AudioTrack write() and processAudioBuffer() if direct output flag is set.
Diffstat (limited to 'media/libmedia')
-rw-r--r--media/libmedia/AudioTrack.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index b147d25..4b9d272 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -744,7 +744,7 @@ ssize_t AudioTrack::write(const void* buffer, size_t userSize)
size_t toWrite;
- if (mFormat == AudioSystem::PCM_8_BIT) {
+ if (mFormat == AudioSystem::PCM_8_BIT && !(mFlags & AudioSystem::OUTPUT_FLAG_DIRECT)) {
// Divide capacity by 2 to take expansion into account
toWrite = audioBuffer.size>>1;
// 8 to 16 bit conversion
@@ -753,7 +753,7 @@ ssize_t AudioTrack::write(const void* buffer, size_t userSize)
while(count--) {
*dst++ = (int16_t)(*src++^0x80) << 8;
}
- }else {
+ } else {
toWrite = audioBuffer.size;
memcpy(audioBuffer.i8, src, toWrite);
src += toWrite;
@@ -840,7 +840,7 @@ bool AudioTrack::processAudioBuffer(const sp<AudioTrackThread>& thread)
// Divide buffer size by 2 to take into account the expansion
// due to 8 to 16 bit conversion: the callback must fill only half
// of the destination buffer
- if (mFormat == AudioSystem::PCM_8_BIT) {
+ if (mFormat == AudioSystem::PCM_8_BIT && !(mFlags & AudioSystem::OUTPUT_FLAG_DIRECT)) {
audioBuffer.size >>= 1;
}
@@ -859,7 +859,7 @@ bool AudioTrack::processAudioBuffer(const sp<AudioTrackThread>& thread)
}
if (writtenSize > reqSize) writtenSize = reqSize;
- if (mFormat == AudioSystem::PCM_8_BIT) {
+ if (mFormat == AudioSystem::PCM_8_BIT && !(mFlags & AudioSystem::OUTPUT_FLAG_DIRECT)) {
// 8 to 16 bit conversion
const int8_t *src = audioBuffer.i8 + writtenSize-1;
int count = writtenSize;