summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjunjiez <junjiez@codeaurora.org>2017-11-20 16:53:35 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2017-11-21 17:18:08 -0800
commit0becd1cfcc341d0d96b1fb1ff436eeda8bd54cb9 (patch)
treebca8292df1b2b964e033ee96c62672be42f8cafe /src
parent091605696779974caa8c3ded0161eca82c9df302 (diff)
downloadandroid_packages_apps_Snap-0becd1cfcc341d0d96b1fb1ff436eeda8bd54cb9.tar.gz
android_packages_apps_Snap-0becd1cfcc341d0d96b1fb1ff436eeda8bd54cb9.tar.bz2
android_packages_apps_Snap-0becd1cfcc341d0d96b1fb1ff436eeda8bd54cb9.zip
SnapdragonCamera:Fix recording audio leg
start mediaRecorder after the capture session is configured to avoid audio leg when it's recording Change-Id: I30ac44fb21812dd4aec1c65138abae9d1dc4540f CRs-Fixed:2141607
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/android/camera/CaptureModule.java70
1 files changed, 46 insertions, 24 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 900154cd4..88d967e98 100755
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -393,6 +393,7 @@ public class CaptureModule implements CameraModule, PhotoController,
private boolean mHighSpeedRecordingMode = false; //HFR
private int mHighSpeedCaptureRate;
private CaptureRequest.Builder mVideoRequestBuilder;
+ private boolean mMediaRecorderReady = false;
private static final int STATS_DATA = 768;
public static int statsdata[] = new int[STATS_DATA];
@@ -3158,6 +3159,7 @@ public class CaptureModule implements CameraModule, PhotoController,
mStartRecPending = true;
mIsRecordingVideo = true;
mMediaRecorderPausing = false;
+ mMediaRecorderReady = false;
mActivity.updateStorageSpaceAndHint();
if (mActivity.getStorageSpaceBytes() <= Storage.LOW_STORAGE_THRESHOLD_BYTES) {
@@ -3169,31 +3171,7 @@ public class CaptureModule implements CameraModule, PhotoController,
try {
setUpMediaRecorder(cameraId);
- try {
- mMediaRecorder.start(); // Recording is now started
- } catch (RuntimeException e) {
- Toast.makeText(mActivity,"Could not start media recorder.\n " +
- "Can't start video recording.", Toast.LENGTH_LONG).show();
- releaseMediaRecorder();
- releaseAudioFocus();
- mStartRecPending = false;
- mIsRecordingVideo = false;
- return false;
- }
- if (mUnsupportedResolution == true ) {
- Log.v(TAG, "Unsupported Resolution according to target");
- mStartRecPending = false;
- mIsRecordingVideo = false;
- return false;
- }
- if (mMediaRecorder == null) {
- Log.e(TAG, "Fail to initialize media recorder");
- mStartRecPending = false;
- mIsRecordingVideo = false;
- return false;
- }
- requestAudioFocus();
mUI.clearFocus();
mUI.hideUIwhileRecording();
mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS, mCameraId[cameraId]);
@@ -3263,6 +3241,12 @@ public class CaptureModule implements CameraModule, PhotoController,
+ e.getMessage());
e.printStackTrace();
}
+ if (!startMediaRecorder()) {
+ mMediaRecorderReady = false;
+ return;
+ } else {
+ mMediaRecorderReady = true;
+ }
mUI.clearFocus();
mUI.resetPauseButton();
mRecordingTotalTime = 0L;
@@ -3298,6 +3282,13 @@ public class CaptureModule implements CameraModule, PhotoController,
} catch (IllegalStateException e) {
e.printStackTrace();
}
+ if (!startMediaRecorder()) {
+ mMediaRecorderReady = false;
+ return;
+ } else {
+ mMediaRecorderReady = true;
+ }
+
mUI.clearFocus();
mUI.resetPauseButton();
mRecordingTotalTime = 0L;
@@ -3318,10 +3309,41 @@ public class CaptureModule implements CameraModule, PhotoController,
} catch (IOException e) {
e.printStackTrace();
}
+ if (!mMediaRecorderReady)
+ return false;
mStartRecPending = false;
return true;
}
+ private boolean startMediaRecorder() {
+ try {
+ mMediaRecorder.start(); // Recording is now started
+ } catch (RuntimeException e) {
+ Toast.makeText(mActivity,"Could not start media recorder.\n " +
+ "Can't start video recording.", Toast.LENGTH_LONG).show();
+ releaseMediaRecorder();
+ releaseAudioFocus();
+ mStartRecPending = false;
+ mIsRecordingVideo = false;
+ return false;
+ }
+ if (mUnsupportedResolution == true ) {
+ Log.v(TAG, "Unsupported Resolution according to target");
+ mStartRecPending = false;
+ mIsRecordingVideo = false;
+ return false;
+ }
+ if (mMediaRecorder == null) {
+ Log.e(TAG, "Fail to initialize media recorder");
+ mStartRecPending = false;
+ mIsRecordingVideo = false;
+ return false;
+ }
+
+ requestAudioFocus();
+ return true;
+ }
+
private void updateTimeLapseSetting() {
String value = mSettingsManager.getValue(SettingsManager
.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL);