diff options
author | Chong Zhang <chz@google.com> | 2015-07-16 10:48:15 -0700 |
---|---|---|
committer | Chong Zhang <chz@google.com> | 2015-07-17 13:00:44 -0700 |
commit | 46d26dd29195450db15704e84d65740628a821fb (patch) | |
tree | 31627c4c60a4cae8a583701ccf3394351690b9d2 /media/libstagefright/AudioSource.cpp | |
parent | a8dc93efc9be8d5e37c7473601fb8654804188c1 (diff) | |
download | frameworks_av-46d26dd29195450db15704e84d65740628a821fb.zip frameworks_av-46d26dd29195450db15704e84d65740628a821fb.tar.gz frameworks_av-46d26dd29195450db15704e84d65740628a821fb.tar.bz2 |
MediaRecorder: enable audio for slow motion recording
bug:22460747
Change-Id: I23f773ecf7b86928a8eacd25a481636e645affbe
Diffstat (limited to 'media/libstagefright/AudioSource.cpp')
-rw-r--r-- | media/libstagefright/AudioSource.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/media/libstagefright/AudioSource.cpp b/media/libstagefright/AudioSource.cpp index 34f0148..3505844 100644 --- a/media/libstagefright/AudioSource.cpp +++ b/media/libstagefright/AudioSource.cpp @@ -50,15 +50,19 @@ static void AudioRecordCallbackFunction(int event, void *user, void *info) { } AudioSource::AudioSource( - audio_source_t inputSource, const String16 &opPackageName, uint32_t sampleRate, - uint32_t channelCount) + audio_source_t inputSource, const String16 &opPackageName, + uint32_t sampleRate, uint32_t channelCount, uint32_t outSampleRate) : mStarted(false), mSampleRate(sampleRate), + mOutSampleRate(outSampleRate > 0 ? outSampleRate : sampleRate), mPrevSampleTimeUs(0), + mFirstSampleTimeUs(-1ll), mNumFramesReceived(0), mNumClientOwnedBuffers(0) { - ALOGV("sampleRate: %d, channelCount: %d", sampleRate, channelCount); + ALOGV("sampleRate: %u, outSampleRate: %u, channelCount: %u", + sampleRate, outSampleRate, channelCount); CHECK(channelCount == 1 || channelCount == 2); + CHECK(sampleRate > 0); size_t minFrameCount; status_t status = AudioRecord::getMinFrameCount(&minFrameCount, @@ -261,6 +265,15 @@ status_t AudioSource::read( (int16_t *) buffer->data(), buffer->range_length() >> 1); } + if (mSampleRate != mOutSampleRate) { + if (mFirstSampleTimeUs < 0) { + mFirstSampleTimeUs = timeUs; + } + timeUs = mFirstSampleTimeUs + (timeUs - mFirstSampleTimeUs) + * (int64_t)mSampleRate / (int64_t)mOutSampleRate; + buffer->meta_data()->setInt64(kKeyTime, timeUs); + } + *out = buffer; return OK; } |