summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/VideoModule.java
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2016-05-05 12:30:00 -0700
committerJay Wang <jaywang@codeaurora.org>2016-05-06 12:17:55 -0700
commit5adcd0831d24c3fcf3c5916a7c6ff9d5201f7955 (patch)
tree8c98250187f23cd8b89cea1983620decc63e7ee9 /src/com/android/camera/VideoModule.java
parent6b741069fbe98a3b75ae8744f4a7790525199deb (diff)
downloadandroid_packages_apps_Snap-5adcd0831d24c3fcf3c5916a7c6ff9d5201f7955.tar.gz
android_packages_apps_Snap-5adcd0831d24c3fcf3c5916a7c6ff9d5201f7955.tar.bz2
android_packages_apps_Snap-5adcd0831d24c3fcf3c5916a7c6ff9d5201f7955.zip
SnapdragonCamera: Release audio focus when video recording is done
When video capturing is finished, release the audio focus so music application can resume the playback. Change-Id: I5c425b7717e9a31ec9c839ed2689d9b1da852428 CRs-Fixed: 1012070
Diffstat (limited to 'src/com/android/camera/VideoModule.java')
-rw-r--r--src/com/android/camera/VideoModule.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index c21a56ae8..f8d79ed00 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -1737,13 +1737,23 @@ public class VideoModule implements CameraModule,
// Send request to obtain audio focus. This will stop other
// music stream.
int result = am.requestAudioFocus(null, AudioManager.STREAM_MUSIC,
- AudioManager.AUDIOFOCUS_GAIN);
+ AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
if (result == AudioManager.AUDIOFOCUS_REQUEST_FAILED) {
Log.v(TAG, "Audio focus request failed");
}
}
+ private void releaseAudioFocus() {
+ AudioManager am = (AudioManager)mActivity.getSystemService(Context.AUDIO_SERVICE);
+
+ int result = am.abandonAudioFocus(null);
+
+ if (result == AudioManager.AUDIOFOCUS_REQUEST_FAILED) {
+ Log.v(TAG, "Audio focus release failed");
+ }
+ }
+
// For testing.
public boolean isRecording() {
return mMediaRecorderRecording;
@@ -1816,6 +1826,7 @@ public class VideoModule implements CameraModule,
} catch (RuntimeException e) {
Toast.makeText(mActivity,"Could not start media recorder.\n Can't start video recording.", Toast.LENGTH_LONG).show();
releaseMediaRecorder();
+ releaseAudioFocus();
// If start fails, frameworks will not lock the camera for us.
mCameraDevice.lock();
mStartRecPending = false;
@@ -1966,6 +1977,7 @@ public class VideoModule implements CameraModule,
}
// release media recorder
releaseMediaRecorder();
+ releaseAudioFocus();
if (!mPaused) {
mCameraDevice.lock();
if (!ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) {