diff options
author | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-02-06 12:05:41 +0000 |
---|---|---|
committer | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-02-06 12:05:41 +0000 |
commit | 0db8a19fb3216a8a83d5d6cbd5f1ccbf997a20d8 (patch) | |
tree | 84c447f1105f8525a57aa4ce2f2f6d15ce316e29 /media | |
parent | 12170a107e7c96170a38dbe43e98447c87624bd7 (diff) | |
download | frameworks_av-0db8a19fb3216a8a83d5d6cbd5f1ccbf997a20d8.zip frameworks_av-0db8a19fb3216a8a83d5d6cbd5f1ccbf997a20d8.tar.gz frameworks_av-0db8a19fb3216a8a83d5d6cbd5f1ccbf997a20d8.tar.bz2 |
Revert "libstagefright: Convert mono to stereo for LPA clips"
Change-Id: Ib6cc3401c889a8ec52dc83e3bea367f94a582a40
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/LPAPlayerALSA.cpp | 68 |
1 files changed, 16 insertions, 52 deletions
diff --git a/media/libstagefright/LPAPlayerALSA.cpp b/media/libstagefright/LPAPlayerALSA.cpp index 18aae8f..38d6bac 100644 --- a/media/libstagefright/LPAPlayerALSA.cpp +++ b/media/libstagefright/LPAPlayerALSA.cpp @@ -87,8 +87,7 @@ mAudioSink(audioSink), mObserver(observer) { ALOGV("LPAPlayer::LPAPlayer() ctor"); objectsAlive++; - mNumOutputChannels =0; - mNumInputChannels = 0; + numChannels =0; mPaused = false; mIsA2DPEnabled = false; mAudioFlinger = NULL; @@ -257,24 +256,20 @@ status_t LPAPlayer::start(bool sourceAlreadyStarted) { success = format->findInt32(kKeySampleRate, &mSampleRate); CHECK(success); - success = format->findInt32(kKeyChannelCount, &mNumInputChannels); + success = format->findInt32(kKeyChannelCount, &numChannels); CHECK(success); - // Always produce stereo output - mNumOutputChannels = 2; - if(!format->findInt32(kKeyChannelMask, &mChannelMask)) { // log only when there's a risk of ambiguity of channel mask selection - ALOGI_IF(mNumInputChannels > 2, - "source format didn't specify channel mask, using (%d) channel order", mNumInputChannels); + ALOGI_IF(numChannels > 2, + "source format didn't specify channel mask, using (%d) channel order", numChannels); mChannelMask = CHANNEL_MASK_USE_CHANNEL_ORDER; } audio_output_flags_t flags = (audio_output_flags_t) (AUDIO_OUTPUT_FLAG_LPA | AUDIO_OUTPUT_FLAG_DIRECT); - ALOGV("mAudiosink->open() mSampleRate %d, numOutputChannels %d, mChannelMask %d, flags %d",mSampleRate, - mNumOutputChannels, mChannelMask, flags); + ALOGV("mAudiosink->open() mSampleRate %d, numChannels %d, mChannelMask %d, flags %d",mSampleRate, numChannels, mChannelMask, flags); err = mAudioSink->open( - mSampleRate, mNumOutputChannels, mChannelMask, AUDIO_FORMAT_PCM_16_BIT, + mSampleRate, numChannels, mChannelMask, AUDIO_FORMAT_PCM_16_BIT, DEFAULT_AUDIOSINK_BUFFERCOUNT, &LPAPlayer::AudioSinkCallback, this, @@ -377,7 +372,7 @@ void LPAPlayer::resume() { audio_output_flags_t flags = (audio_output_flags_t) (AUDIO_OUTPUT_FLAG_LPA | AUDIO_OUTPUT_FLAG_DIRECT); status_t err = mAudioSink->open( - mSampleRate, mNumOutputChannels, mChannelMask, AUDIO_FORMAT_PCM_16_BIT, + mSampleRate, numChannels, mChannelMask, AUDIO_FORMAT_PCM_16_BIT, DEFAULT_AUDIOSINK_BUFFERCOUNT, &LPAPlayer::AudioSinkCallback, this, @@ -496,12 +491,6 @@ void LPAPlayer::decoderThreadEntry() { } void* local_buf = malloc(MEM_BUFFER_SIZE); int bytesWritten = 0; - - if (!local_buf) { - ALOGE("Failed to allocate temporary buffer for decoderThread"); - return; - } - while (!killDecoderThread) { if (mReachedEOS || mPaused || !mIsAudioRouted) { @@ -511,27 +500,16 @@ void LPAPlayer::decoderThreadEntry() { continue; } - if (mIsA2DPEnabled) { - //nothing to do - continue; - } - - ALOGV("FillBuffer: MemBuffer size %d", MEM_BUFFER_SIZE); - ALOGV("Fillbuffer started"); - if (mNumInputChannels == 1) { - bytesWritten = fillBuffer(local_buf, MEM_BUFFER_SIZE/2); - CHECK(bytesWritten <= MEM_BUFFER_SIZE/2); - - convertMonoToStereo((int16_t*)local_buf, bytesWritten); - bytesWritten *= 2; - } else { + if (!mIsA2DPEnabled) { + ALOGV("FillBuffer: MemBuffer size %d", MEM_BUFFER_SIZE); + ALOGV("Fillbuffer started"); + //TODO: Add memset bytesWritten = fillBuffer(local_buf, MEM_BUFFER_SIZE); - CHECK(bytesWritten <= MEM_BUFFER_SIZE); - } + ALOGV("FillBuffer completed bytesToWrite %d", bytesWritten); - ALOGV("FillBuffer completed bytesToWrite %d", bytesWritten); - if(!killDecoderThread) { - mAudioSink->write(local_buf, bytesWritten); + if(!killDecoderThread) { + mAudioSink->write(local_buf, bytesWritten); + } } } @@ -684,7 +662,7 @@ size_t LPAPlayer::fillBuffer(void *data, size_t size) { size_t copy = size_remaining; if (copy > mInputBuffer->range_length()) { copy = mInputBuffer->range_length(); - } //is size_remaining < range_length impossible? + } memcpy((char *)data + size_done, (const char *)mInputBuffer->data() + mInputBuffer->range_offset(), @@ -812,18 +790,4 @@ void LPAPlayer::onPauseTimeOut() { } -//dup each mono frame -void LPAPlayer::convertMonoToStereo(int16_t *data, size_t size) -{ - int i =0; - int16_t *start_pointer = data; - int monoFrameCount = (size) / (sizeof(int16_t)); - - for (i = monoFrameCount; i > 0 ; i--) { - int16_t temp_sample = *(start_pointer + i - 1); - *(start_pointer + (i*2) - 1) = temp_sample; - *(start_pointer + (i*2) - 2) = temp_sample; - } -} - } //namespace android |