diff options
author | junjiez <junjiez@codeaurora.org> | 2017-11-20 16:53:35 +0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2017-11-28 18:35:30 -0800 |
commit | 57edb53677cebeb2d5d554e7c3f975b6cb073007 (patch) | |
tree | 59429d86a4b393ac591044e31ec7bd2eaf411636 /src | |
parent | a3c4074bd2da5891347da727520b608eb26d40b9 (diff) | |
download | android_packages_apps_Snap-57edb53677cebeb2d5d554e7c3f975b6cb073007.tar.gz android_packages_apps_Snap-57edb53677cebeb2d5d554e7c3f975b6cb073007.tar.bz2 android_packages_apps_Snap-57edb53677cebeb2d5d554e7c3f975b6cb073007.zip |
SnapdragonCamera:Fix recording audio leg
start mediaRecorder after the capture session
is configured to avoid audio leg when it's
recording and restart sessions when mediaRecorder
has error
Change-Id: I7b76d9d359e44b54cb9c39ca222b2531a0502fb9
CRs-Fixed:2141607
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/android/camera/CaptureModule.java | 68 |
1 files changed, 44 insertions, 24 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 900154cd4..7aad7ddad 100755 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -3169,31 +3169,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 +3239,13 @@ public class CaptureModule implements CameraModule, PhotoController, + e.getMessage()); e.printStackTrace(); } + if (!startMediaRecorder()) { + mUI.showUIafterRecording(); + releaseMediaRecorder(); + mFrameProcessor.setVideoOutputSurface(null); + restartSession(true); + return; + } mUI.clearFocus(); mUI.resetPauseButton(); mRecordingTotalTime = 0L; @@ -3298,6 +3281,14 @@ public class CaptureModule implements CameraModule, PhotoController, } catch (IllegalStateException e) { e.printStackTrace(); } + if (!startMediaRecorder()) { + mUI.showUIafterRecording(); + releaseMediaRecorder(); + mFrameProcessor.setVideoOutputSurface(null); + restartSession(true); + return; + } + mUI.clearFocus(); mUI.resetPauseButton(); mRecordingTotalTime = 0L; @@ -3322,6 +3313,35 @@ public class CaptureModule implements CameraModule, PhotoController, 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); |