diff options
author | Dave Sparks <davidsparks@android.com> | 2009-12-15 15:05:37 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-12-15 15:05:37 -0800 |
commit | c333133107fb492de481a96ed1277e71daf2dd8c (patch) | |
tree | b5b66e948c4c17e83d84c62356f88815b594637b /media/jni | |
parent | d3f237a53835f11d0fa07751d27f6bd06e745839 (diff) | |
parent | b5fc8ffcff6b8e1747af5c6ba1176a81986b55a8 (diff) | |
download | frameworks_base-c333133107fb492de481a96ed1277e71daf2dd8c.zip frameworks_base-c333133107fb492de481a96ed1277e71daf2dd8c.tar.gz frameworks_base-c333133107fb492de481a96ed1277e71daf2dd8c.tar.bz2 |
am b5fc8ffc: am 91487425: Merge change I0448ef20 into eclair
Merge commit 'b5fc8ffcff6b8e1747af5c6ba1176a81986b55a8'
* commit 'b5fc8ffcff6b8e1747af5c6ba1176a81986b55a8':
Fix SoundPool buffer size rounding error. Bug 2327620.
Diffstat (limited to 'media/jni')
-rw-r--r-- | media/jni/soundpool/SoundPool.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/media/jni/soundpool/SoundPool.cpp b/media/jni/soundpool/SoundPool.cpp index 4d2e048..70fba7e 100644 --- a/media/jni/soundpool/SoundPool.cpp +++ b/media/jni/soundpool/SoundPool.cpp @@ -500,7 +500,8 @@ void SoundChannel::play(const sp<Sample>& sample, int nextChannelID, float leftV } int numChannels = sample->numChannels(); uint32_t sampleRate = uint32_t(float(sample->sampleRate()) * rate + 0.5); - uint32_t bufferFrames = (afFrameCount * sampleRate) / afSampleRate; + uint32_t totalFrames = (kDefaultBufferCount * afFrameCount * sampleRate) / afSampleRate; + uint32_t bufferFrames = (totalFrames + (kDefaultBufferCount - 1)) / kDefaultBufferCount; uint32_t frameCount = 0; if (loop) { @@ -509,13 +510,13 @@ void SoundChannel::play(const sp<Sample>& sample, int nextChannelID, float leftV #ifndef USE_SHARED_MEM_BUFFER // Ensure minimum audio buffer size in case of short looped sample - if(frameCount < kDefaultBufferCount * bufferFrames) { - frameCount = kDefaultBufferCount * bufferFrames; + if(frameCount < totalFrames) { + frameCount = totalFrames; } #endif AudioTrack* newTrack; - + // mToggle toggles each time a track is started on a given channel. // The toggle is concatenated with the SoundChannel address and passed to AudioTrack // as callback user data. This enables the detection of callbacks received from the old @@ -524,7 +525,7 @@ void SoundChannel::play(const sp<Sample>& sample, int nextChannelID, float leftV unsigned long toggle = mToggle ^ 1; void *userData = (void *)((unsigned long)this | toggle); uint32_t channels = (numChannels == 2) ? AudioSystem::CHANNEL_OUT_STEREO : AudioSystem::CHANNEL_OUT_MONO; - + #ifdef USE_SHARED_MEM_BUFFER newTrack = new AudioTrack(streamType, sampleRate, sample->format(), channels, sample->getIMemory(), 0, callback, userData); |