diff options
author | Andy Hung <hunga@google.com> | 2015-03-10 00:37:58 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-03-10 00:38:06 +0000 |
commit | 0e9a8f6a8e5d4d58fc358d47848fed52a94cae04 (patch) | |
tree | 0b133dd9d6367e40cf56ba4381aefa0f75a239a4 /media | |
parent | b5c4623b7fd82692e526ea52d97d9ca0ec6a37c8 (diff) | |
parent | a1c3516a243d00428ff2b470409d47cc9f5c9523 (diff) | |
download | frameworks_base-0e9a8f6a8e5d4d58fc358d47848fed52a94cae04.zip frameworks_base-0e9a8f6a8e5d4d58fc358d47848fed52a94cae04.tar.gz frameworks_base-0e9a8f6a8e5d4d58fc358d47848fed52a94cae04.tar.bz2 |
Merge "Fix SoundPool playback of multichannel files."
Diffstat (limited to 'media')
-rw-r--r-- | media/jni/soundpool/SoundPool.cpp | 8 | ||||
-rw-r--r-- | media/jni/soundpool/SoundPool.h | 4 |
2 files changed, 7 insertions, 5 deletions
diff --git a/media/jni/soundpool/SoundPool.cpp b/media/jni/soundpool/SoundPool.cpp index dfe2844..10233f3 100644 --- a/media/jni/soundpool/SoundPool.cpp +++ b/media/jni/soundpool/SoundPool.cpp @@ -638,7 +638,7 @@ status_t Sample::doLoad() goto error; } - if ((numChannels < 1) || (numChannels > 2)) { + if ((numChannels < 1) || (numChannels > 8)) { ALOGE("Sample channel count (%d) out of range", numChannels); status = BAD_VALUE; goto error; @@ -702,8 +702,10 @@ void SoundChannel::play(const sp<Sample>& sample, int nextChannelID, float leftV size_t frameCount = 0; if (loop) { - frameCount = sample->size()/numChannels/ - ((sample->format() == AUDIO_FORMAT_PCM_16_BIT) ? sizeof(int16_t) : sizeof(uint8_t)); + const audio_format_t format = sample->format(); + const size_t frameSize = audio_is_linear_pcm(format) + ? numChannels * audio_bytes_per_sample(format) : 1; + frameCount = sample->size() / frameSize; } #ifndef USE_SHARED_MEM_BUFFER diff --git a/media/jni/soundpool/SoundPool.h b/media/jni/soundpool/SoundPool.h index f520406..4aacf53 100644 --- a/media/jni/soundpool/SoundPool.h +++ b/media/jni/soundpool/SoundPool.h @@ -72,8 +72,8 @@ private: volatile int32_t mRefCount; uint16_t mSampleID; uint16_t mSampleRate; - uint8_t mState : 3; - uint8_t mNumChannels : 2; + uint8_t mState; + uint8_t mNumChannels; audio_format_t mFormat; int mFd; int64_t mOffset; |