diff options
author | Andy Hung <hunga@google.com> | 2015-04-22 19:16:25 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-04-22 19:16:26 +0000 |
commit | 04f07fd61022dac46ddda9c815d65bc3d3278b84 (patch) | |
tree | d7d4a83f5190b4f917a608de504814e824862569 | |
parent | 20bd9bfc3ae429412c8eb98619b40fb8e3671bbc (diff) | |
parent | 5744661e85981f8a9456bf470e2761235fc026da (diff) | |
download | frameworks_av-04f07fd61022dac46ddda9c815d65bc3d3278b84.zip frameworks_av-04f07fd61022dac46ddda9c815d65bc3d3278b84.tar.gz frameworks_av-04f07fd61022dac46ddda9c815d65bc3d3278b84.tar.bz2 |
Merge "Make record buffer in RecordThread variable format"
-rw-r--r-- | services/audioflinger/Threads.cpp | 16 | ||||
-rw-r--r-- | services/audioflinger/Threads.h | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 4eaeda3..d3d77cd 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -5324,7 +5324,7 @@ AudioFlinger::RecordThread::~RecordThread() } mAudioFlinger->unregisterWriter(mFastCaptureNBLogWriter); mAudioFlinger->unregisterWriter(mNBLogWriter); - delete[] mRsmpInBuffer; + free(mRsmpInBuffer); } void AudioFlinger::RecordThread::onFirstRef() @@ -5557,7 +5557,7 @@ reacquire_wakelock: // If an NBAIO source is present, use it to read the normal capture's data if (mPipeSource != 0) { size_t framesToRead = mBufferSize / mFrameSize; - framesRead = mPipeSource->read(&mRsmpInBuffer[rear * mChannelCount], + framesRead = mPipeSource->read((uint8_t*)mRsmpInBuffer + rear * mFrameSize, framesToRead, AudioBufferProvider::kInvalidPTS); if (framesRead == 0) { // since pipe is non-blocking, simulate blocking input @@ -5566,7 +5566,7 @@ reacquire_wakelock: // otherwise use the HAL / AudioStreamIn directly } else { ssize_t bytesRead = mInput->stream->read(mInput->stream, - &mRsmpInBuffer[rear * mChannelCount], mBufferSize); + (uint8_t*)mRsmpInBuffer + rear * mFrameSize, mBufferSize); if (bytesRead < 0) { framesRead = bytesRead; } else { @@ -5586,13 +5586,13 @@ reacquire_wakelock: ALOG_ASSERT(framesRead > 0); if (mTeeSink != 0) { - (void) mTeeSink->write(&mRsmpInBuffer[rear * mChannelCount], framesRead); + (void) mTeeSink->write((uint8_t*)mRsmpInBuffer + rear * mFrameSize, framesRead); } // If destination is non-contiguous, we now correct for reading past end of buffer. { size_t part1 = mRsmpInFramesP2 - rear; if ((size_t) framesRead > part1) { - memcpy(mRsmpInBuffer, &mRsmpInBuffer[mRsmpInFramesP2 * mChannelCount], + memcpy(mRsmpInBuffer, (uint8_t*)mRsmpInBuffer + mRsmpInFramesP2 * mFrameSize, (framesRead - part1) * mFrameSize); } } @@ -6210,7 +6210,7 @@ status_t AudioFlinger::RecordThread::ResamplerBufferProvider::getNextBuffer( return NOT_ENOUGH_DATA; } - buffer->raw = recordThread->mRsmpInBuffer + front * recordThread->mChannelCount; + buffer->raw = (uint8_t*)recordThread->mRsmpInBuffer + front * recordThread->mFrameSize; buffer->frameCount = part1; mRsmpInUnrel = part1; return NO_ERROR; @@ -6584,7 +6584,7 @@ void AudioFlinger::RecordThread::readInputParameters_l() // Note this is independent of the maximum downsampling ratio permitted for capture. mRsmpInFrames = mFrameCount * 7; mRsmpInFramesP2 = roundup(mRsmpInFrames); - delete[] mRsmpInBuffer; + free(mRsmpInBuffer); // TODO optimize audio capture buffer sizes ... // Here we calculate the size of the sliding buffer used as a source @@ -6594,7 +6594,7 @@ void AudioFlinger::RecordThread::readInputParameters_l() // The current value is higher than necessary. However it should not add to latency. // Over-allocate beyond mRsmpInFramesP2 to permit a HAL read past end of buffer - mRsmpInBuffer = new int16_t[(mRsmpInFramesP2 + mFrameCount - 1) * mChannelCount]; + (void)posix_memalign(&mRsmpInBuffer, 32, (mRsmpInFramesP2 + mFrameCount - 1) * mFrameSize); // AudioRecord mSampleRate and mChannelCount are constant due to AudioRecord API constraints. // But if thread's mSampleRate or mChannelCount changes, how will that affect active tracks? diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h index 27bc56b..ed2e4a1 100644 --- a/services/audioflinger/Threads.h +++ b/services/audioflinger/Threads.h @@ -1267,7 +1267,7 @@ private: Condition mStartStopCond; // resampler converts input at HAL Hz to output at AudioRecord client Hz - int16_t *mRsmpInBuffer; // see new[] for details on the size + void *mRsmpInBuffer; // size_t mRsmpInFrames; // size of resampler input in frames size_t mRsmpInFramesP2;// size rounded up to a power-of-2 |