summaryrefslogtreecommitdiffstats
path: root/media/libmediaplayerservice
diff options
context:
space:
mode:
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,