From 51aee1e55bee9cf8e4fd30ecf19fccd7ab7bfc15 Mon Sep 17 00:00:00 2001 From: Keith Mok Date: Mon, 7 Mar 2016 15:22:22 -0800 Subject: stagefright: Support audio in slow motion We need to query AVUtil for slow motion recording to support audio in slow motion recording instead of using mCaptureFps and mCaptureFpsEnable, since qcom camera1 HAL don't call setCaptureRate for slow motion recording. CYNGNOS-2196 Change-Id: I7b75ab44499ed13cb1e4e6f527103ec0f09ffcc8 --- .../libmediaplayerservice/StagefrightRecorder.cpp | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'media/libmediaplayerservice') diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index 709e653..d182a68 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -963,6 +963,30 @@ sp StagefrightRecorder::createAudioSource() { } } + // If using QCOM extension (Camera 1 HAL) for slow motion recording + // mCaptureFpsEnable and mCaptureFps will not be set via setCaptureRate + // We need to query from AVUtil, in order to support slow motion audio recording + if (mVideoSourceNode != NULL) { + int hfrRatio = AVUtils::get()->HFRUtils().getHFRRatio(mVideoSourceNode->getFormat()); + if (hfrRatio != 1) { + // Upscale the sample rate for slow motion recording. + // Fail audio source creation if source sample rate is too high, as it could + // cause out-of-memory due to large input buffer size. And audio recording + // probably doesn't make sense in the scenario, since the slow-down factor + // is probably huge (eg. mSampleRate=48K, hfrRatio=240, mFrameRate=1). + const static int32_t SAMPLE_RATE_HZ_MAX = 192000; + sourceSampleRate = + (mSampleRate * hfrRatio + mFrameRate / 2) / mFrameRate; + if (sourceSampleRate < mSampleRate || sourceSampleRate > SAMPLE_RATE_HZ_MAX) { + ALOGE("source sample rate out of range! " + "(mSampleRate %d, hfrRatio %d, mFrameRate %d", + mSampleRate, hfrRatio, mFrameRate); + return NULL; + } + } + } + + sp audioSource = AVFactory::get()->createAudioSource( mAudioSource, mOpPackageName, -- cgit v1.1