diff options
author | Andy Hung <hunga@google.com> | 2014-05-29 18:52:38 -0700 |
---|---|---|
committer | Andy Hung <hunga@google.com> | 2014-05-30 14:50:20 -0700 |
commit | f8a106ae5c40735de6c75e7c12d5e0e2e22f12cf (patch) | |
tree | ae89a14bbedd04e58d6115ce550a7f462c3a53db | |
parent | 47aaf6da5d7ecc2ad28de004d1820b64b02dd344 (diff) | |
download | frameworks_av-f8a106ae5c40735de6c75e7c12d5e0e2e22f12cf.zip frameworks_av-f8a106ae5c40735de6c75e7c12d5e0e2e22f12cf.tar.gz frameworks_av-f8a106ae5c40735de6c75e7c12d5e0e2e22f12cf.tar.bz2 |
Fix floating point output from mixer
A buffer pointer was being erroneously reset to buffer start,
potentially causing an audio glitch. The floating point
output mode is not enabled at this time, but will be in
the future.
Change-Id: If8b6414d232f064f3a2e2c5a6da889a91b27fb24
-rw-r--r-- | services/audioflinger/AudioMixer.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index ace3bf1..a0f2b7d 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -1450,6 +1450,7 @@ void AudioMixer::process__OneTrack16BitsStereoNoResampling(state_t* state, AudioBufferProvider::Buffer& b(t.buffer); int32_t* out = t.mainBuffer; + float *fout = reinterpret_cast<float*>(out); size_t numFrames = state->frameCount; const int16_t vl = t.volume[0]; @@ -1463,9 +1464,10 @@ void AudioMixer::process__OneTrack16BitsStereoNoResampling(state_t* state, // in == NULL can happen if the track was flushed just after having // been enabled for mixing. - if (in == NULL || ((unsigned long)in & 3)) { - memset(out, 0, numFrames*MAX_NUM_CHANNELS*sizeof(int16_t)); - ALOGE_IF(((unsigned long)in & 3), "process stereo track: input buffer alignment pb: " + if (in == NULL || (((uintptr_t)in) & 3)) { + memset(out, 0, numFrames + * MAX_NUM_CHANNELS * audio_bytes_per_sample(t.mMixerFormat)); + ALOGE_IF((((uintptr_t)in) & 3), "process stereo track: input buffer alignment pb: " "buffer %p track %d, channels %d, needs %08x", in, i, t.channelCount, t.needs); return; @@ -1473,8 +1475,7 @@ void AudioMixer::process__OneTrack16BitsStereoNoResampling(state_t* state, size_t outFrames = b.frameCount; switch (t.mMixerFormat) { - case AUDIO_FORMAT_PCM_FLOAT: { - float *fout = reinterpret_cast<float*>(out); + case AUDIO_FORMAT_PCM_FLOAT: do { uint32_t rl = *reinterpret_cast<const uint32_t *>(in); in += 2; @@ -1485,7 +1486,7 @@ void AudioMixer::process__OneTrack16BitsStereoNoResampling(state_t* state, // Note: In case of later int16_t sink output, // conversion and clamping is done by memcpy_to_i16_from_float(). } while (--outFrames); - } break; + break; case AUDIO_FORMAT_PCM_16_BIT: if (CC_UNLIKELY(uint32_t(vl) > UNITY_GAIN || uint32_t(vr) > UNITY_GAIN)) { // volume is boosted, so we might need to clamp even though |