diff options
author | Glenn Kasten <gkasten@google.com> | 2013-08-06 07:41:36 -0700 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2013-08-06 09:01:11 -0700 |
commit | c1fac191069774c7bfcb062edbb821ea56e7dbc0 (patch) | |
tree | d3b0d0065f3797041fedb4c1ae5122d29098a711 /services/audioflinger/Threads.cpp | |
parent | 77baebfe89c99415a0ee4c2ea87bfd8a0f9e51f1 (diff) | |
download | frameworks_av-c1fac191069774c7bfcb062edbb821ea56e7dbc0.zip frameworks_av-c1fac191069774c7bfcb062edbb821ea56e7dbc0.tar.gz frameworks_av-c1fac191069774c7bfcb062edbb821ea56e7dbc0.tar.bz2 |
Simplify the code that allocates mMixBuffer by removing mAllocMixBuffer
Change-Id: I5ac41210251789a034d760309c50fe018f2442ce
Diffstat (limited to 'services/audioflinger/Threads.cpp')
-rw-r--r-- | services/audioflinger/Threads.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index f0c27c3..6f46def 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -929,7 +929,7 @@ AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinge type_t type) : ThreadBase(audioFlinger, id, device, AUDIO_DEVICE_NONE, type), mNormalFrameCount(0), mMixBuffer(NULL), - mAllocMixBuffer(NULL), mSuspended(0), mBytesWritten(0), + mSuspended(0), mBytesWritten(0), // mStreamTypes[] initialized in constructor body mOutput(output), mLastWriteTime(0), mNumWrites(0), mNumDelayedWrites(0), mInWrite(false), @@ -983,7 +983,7 @@ AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinge AudioFlinger::PlaybackThread::~PlaybackThread() { mAudioFlinger->unregisterWriter(mNBLogWriter); - delete [] mAllocMixBuffer; + delete[] mMixBuffer; } void AudioFlinger::PlaybackThread::dump(int fd, const Vector<String16>& args) @@ -1615,11 +1615,11 @@ void AudioFlinger::PlaybackThread::readOutputParameters() ALOGI("HAL output buffer size %u frames, normal mix buffer size %u frames", mFrameCount, mNormalFrameCount); - delete[] mAllocMixBuffer; - size_t align = (mFrameSize < sizeof(int16_t)) ? sizeof(int16_t) : mFrameSize; - mAllocMixBuffer = new int8_t[mNormalFrameCount * mFrameSize + align - 1]; - mMixBuffer = (int16_t *) ((((size_t)mAllocMixBuffer + align - 1) / align) * align); - memset(mMixBuffer, 0, mNormalFrameCount * mFrameSize); + delete[] mMixBuffer; + size_t normalBufferSize = mNormalFrameCount * mFrameSize; + // For historical reasons mMixBuffer is int16_t[], but mFrameSize can be odd (such as 1) + mMixBuffer = new int16_t[(normalBufferSize + 1) >> 1]; + memset(mMixBuffer, 0, normalBufferSize); // force reconfiguration of effect chains and engines to take new buffer size and audio // parameters into account |