summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/FastCapture.cpp
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2015-03-03 11:48:45 -0800
committerGlenn Kasten <gkasten@google.com>2015-03-03 15:56:01 -0800
commit5115777127bb4d2d50833537e09054dcdffdfc76 (patch)
tree70e9d2aeb62926d0d9513fad6f607904a43de74f /services/audioflinger/FastCapture.cpp
parent8a0554c63dc40a2a7c066b03041079ec9eb220e5 (diff)
downloadframeworks_av-5115777127bb4d2d50833537e09054dcdffdfc76.zip
frameworks_av-5115777127bb4d2d50833537e09054dcdffdfc76.tar.gz
frameworks_av-5115777127bb4d2d50833537e09054dcdffdfc76.tar.bz2
Remove PCM16 assumption from FastCapture
Bug: 19586911 Change-Id: I74d4ddc09a9eb9c651f874482639d39a56f8ca1f
Diffstat (limited to 'services/audioflinger/FastCapture.cpp')
-rw-r--r--services/audioflinger/FastCapture.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/services/audioflinger/FastCapture.cpp b/services/audioflinger/FastCapture.cpp
index 2a10b4b..9e7e8a4 100644
--- a/services/audioflinger/FastCapture.cpp
+++ b/services/audioflinger/FastCapture.cpp
@@ -69,7 +69,7 @@ void FastCapture::onIdle()
void FastCapture::onExit()
{
- delete[] mReadBuffer;
+ free(mReadBuffer);
}
bool FastCapture::isSubClassCommand(FastThreadState::Command command)
@@ -124,16 +124,14 @@ void FastCapture::onStateChange()
}
if ((!Format_isEqual(mFormat, previousFormat)) || (frameCount != previous->mFrameCount)) {
- // FIXME to avoid priority inversion, don't delete here
- delete[] mReadBuffer;
+ // FIXME to avoid priority inversion, don't free here
+ free(mReadBuffer);
mReadBuffer = NULL;
if (frameCount > 0 && mSampleRate > 0) {
// FIXME new may block for unbounded time at internal mutex of the heap
// implementation; it would be better to have normal capture thread allocate for
// us to avoid blocking here and to prevent possible priority inversion
- unsigned channelCount = Format_channelCount(mFormat);
- // FIXME frameSize
- mReadBuffer = new short[frameCount * channelCount];
+ (void)posix_memalign(&mReadBuffer, 32, frameCount * Format_frameSize(mFormat));
mPeriodNs = (frameCount * 1000000000LL) / mSampleRate; // 1.00
mUnderrunNs = (frameCount * 1750000000LL) / mSampleRate; // 1.75
mOverrunNs = (frameCount * 500000000LL) / mSampleRate; // 0.50
@@ -188,8 +186,7 @@ void FastCapture::onWork()
ALOG_ASSERT(mReadBuffer != NULL);
if (mReadBufferState < 0) {
unsigned channelCount = Format_channelCount(mFormat);
- // FIXME frameSize
- memset(mReadBuffer, 0, frameCount * channelCount * sizeof(short));
+ memset(mReadBuffer, 0, frameCount * Format_frameSize(mFormat));
mReadBufferState = frameCount;
}
if (mReadBufferState > 0) {