summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/Tracks.cpp
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2015-03-29 01:03:07 -0700
committerAndy Hung <hunga@google.com>2015-04-08 15:23:30 -0700
commit97a893eb34f8687485c88eaf15917974a203f20b (patch)
tree6a103ab6f76dcabb0416677055dab4a8454f9fd7 /services/audioflinger/Tracks.cpp
parent6b3b7e304e0f8f167241b2c75f1eb04a9ef192ec (diff)
downloadframeworks_av-97a893eb34f8687485c88eaf15917974a203f20b.zip
frameworks_av-97a893eb34f8687485c88eaf15917974a203f20b.tar.gz
frameworks_av-97a893eb34f8687485c88eaf15917974a203f20b.tar.bz2
Add RecordBufferConverter for RecordThread data processing
Change-Id: Ia3aab8590cd41e8a7cba0a7345d70d2866d92045
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 dc9f249..b2f44f2 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -1989,7 +1989,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)
{
@@ -1997,21 +1997,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);
@@ -2022,11 +2024,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)