summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/Tracks.cpp
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2015-04-08 22:54:38 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-08 22:54:39 +0000
commit77a44e8d1f902a100500ea69a450e22889dcff31 (patch)
tree0e1ca5b8a21f3d99141542b0d866e382db140591 /services/audioflinger/Tracks.cpp
parent0c0acdadc9ca961acd1f3b4b85c2befef2dc7161 (diff)
parent97a893eb34f8687485c88eaf15917974a203f20b (diff)
downloadframeworks_av-77a44e8d1f902a100500ea69a450e22889dcff31.zip
frameworks_av-77a44e8d1f902a100500ea69a450e22889dcff31.tar.gz
frameworks_av-77a44e8d1f902a100500ea69a450e22889dcff31.tar.bz2
Merge "Add RecordBufferConverter for RecordThread data processing"
Diffstat (limited to 'services/audioflinger/Tracks.cpp')
-rw-r--r--services/audioflinger/Tracks.cpp42
1 files changed, 26 insertions, 16 deletions
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 5625661..6e78b32 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -1990,7 +1990,7 @@ AudioFlinger::RecordThread::RecordTrack::RecordTrack(
((flags & IAudioFlinger::TRACK_FAST) ? ALLOC_PIPE : ALLOC_CBLK) :
((buffer == NULL) ? ALLOC_LOCAL : ALLOC_NONE),
type),
- mOverflow(false), mResampler(NULL), mRsmpOutBuffer(NULL), mRsmpOutFrameCount(0),
+ mOverflow(false),
// See real initialization of mRsmpInFront at RecordThread::start()
mRsmpInUnrel(0), mRsmpInFront(0), mFramesToDrop(0), mResamplerBufferProvider(NULL)
{
@@ -1998,21 +1998,23 @@ AudioFlinger::RecordThread::RecordTrack::RecordTrack(
return;
}
+ mRecordBufferConverter = new RecordBufferConverter(
+ thread->mChannelMask, thread->mFormat, thread->mSampleRate,
+ channelMask, format, sampleRate);
+ // Check if the RecordBufferConverter construction was successful.
+ // If not, don't continue with construction.
+ //
+ // NOTE: It would be extremely rare that the record track cannot be created
+ // for the current device, but a pending or future device change would make
+ // the record track configuration valid.
+ if (mRecordBufferConverter->initCheck() != NO_ERROR) {
+ ALOGE("RecordTrack unable to create record buffer converter");
+ return;
+ }
+
mServerProxy = new AudioRecordServerProxy(mCblk, mBuffer, frameCount,
mFrameSize, !isExternalTrack());
-
- uint32_t channelCount = audio_channel_count_from_in_mask(channelMask);
- // FIXME I don't understand either of the channel count checks
- if (thread->mSampleRate != sampleRate && thread->mChannelCount <= FCC_2 &&
- channelCount <= FCC_2) {
- // sink SR
- mResampler = AudioResampler::create(AUDIO_FORMAT_PCM_16_BIT,
- thread->mChannelCount, sampleRate);
- // source SR
- mResampler->setSampleRate(thread->mSampleRate);
- mResampler->setVolume(AudioMixer::UNITY_GAIN_FLOAT, AudioMixer::UNITY_GAIN_FLOAT);
- mResamplerBufferProvider = new ResamplerBufferProvider(this);
- }
+ mResamplerBufferProvider = new ResamplerBufferProvider(this);
if (flags & IAudioFlinger::TRACK_FAST) {
ALOG_ASSERT(thread->mFastTrackAvail);
@@ -2023,11 +2025,19 @@ AudioFlinger::RecordThread::RecordTrack::RecordTrack(
AudioFlinger::RecordThread::RecordTrack::~RecordTrack()
{
ALOGV("%s", __func__);
- delete mResampler;
- delete[] mRsmpOutBuffer;
+ delete mRecordBufferConverter;
delete mResamplerBufferProvider;
}
+status_t AudioFlinger::RecordThread::RecordTrack::initCheck() const
+{
+ status_t status = TrackBase::initCheck();
+ if (status == NO_ERROR && mServerProxy == 0) {
+ status = BAD_VALUE;
+ }
+ return status;
+}
+
// AudioBufferProvider interface
status_t AudioFlinger::RecordThread::RecordTrack::getNextBuffer(AudioBufferProvider::Buffer* buffer,
int64_t pts __unused)