summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2016-05-05 12:30:00 -0700
committerMichael Bestas <mikeioannina@cyanogenmod.org>2016-05-26 09:49:20 -0700
commit2bcea7e53062807cc700fc96a59135524c9d16d2 (patch)
tree7cd9f42415c1111154970f0d81407ef245e9fb37
parented07584abbb3aa9d01ab1cfc999db775b1d8000c (diff)
downloadandroid_packages_apps_Snap-2bcea7e53062807cc700fc96a59135524c9d16d2.tar.gz
android_packages_apps_Snap-2bcea7e53062807cc700fc96a59135524c9d16d2.tar.bz2
android_packages_apps_Snap-2bcea7e53062807cc700fc96a59135524c9d16d2.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
-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 f305c5f3d..896dc195b 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -1844,13 +1844,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;
@@ -1916,6 +1926,7 @@ public class VideoModule implements CameraModule,
} catch (RuntimeException e) {
Log.e(TAG, "Could not start media recorder. ", e);
releaseMediaRecorder();
+ releaseAudioFocus();
// If start fails, frameworks will not lock the camera for us.
mCameraDevice.lock();
mStartRecPending = false;
@@ -2068,6 +2079,7 @@ public class VideoModule implements CameraModule,
}
// release media recorder
releaseMediaRecorder();
+ releaseAudioFocus();
if (!mPaused) {
mCameraDevice.lock();
if (!ApiHelper.HAS_SURFACE_TEXTURE_RECORDING) {