summaryrefslogtreecommitdiffstats
path: root/media/libmediaplayerservice
diff options
context:
space:
mode:
authorKeith Mok <kmok@cyngn.com>2016-03-07 15:22:22 -0800
committerSteve Kondik <shade@chemlab.org>2016-03-07 22:41:22 -0800
commit51aee1e55bee9cf8e4fd30ecf19fccd7ab7bfc15 (patch)
tree6b27fcb3338f8660fb7cd10c95173c0de43a0161 /media/libmediaplayerservice
parentedd6ca3e244dda4687da86bc614a2bb709b3a963 (diff)
downloadframeworks_av-51aee1e55bee9cf8e4fd30ecf19fccd7ab7bfc15.zip
frameworks_av-51aee1e55bee9cf8e4fd30ecf19fccd7ab7bfc15.tar.gz
frameworks_av-51aee1e55bee9cf8e4fd30ecf19fccd7ab7bfc15.tar.bz2
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
Diffstat (limited to 'media/libmediaplayerservice')
-rw-r--r--media/libmediaplayerservice/StagefrightRecorder.cpp24
1 files changed, 24 insertions, 0 deletions
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<MediaSource> 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> audioSource = AVFactory::get()->createAudioSource(
mAudioSource,
mOpPackageName,