Skip to content

Commit

Permalink
stagefright: Support audio in slow motion
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Keith Mok authored and PRJosh committed Mar 8, 2016
1 parent bbce60f commit be4590d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions media/libmediaplayerservice/StagefrightRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit be4590d

Please sign in to comment.