summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2016-04-22 16:01:50 -0700
committerJay Wang <jaywang@codeaurora.org>2016-04-22 16:08:50 -0700
commit74eb673ebd4372164bd0591070e7e1f37f01fdd6 (patch)
treeee28910f93ce42cba84cc7c591b7ee6b2d1f334c
parentc677af58364c893bbee13b7f33451d8af6e2256c (diff)
downloadandroid_packages_apps_Snap-74eb673ebd4372164bd0591070e7e1f37f01fdd6.tar.gz
android_packages_apps_Snap-74eb673ebd4372164bd0591070e7e1f37f01fdd6.tar.bz2
android_packages_apps_Snap-74eb673ebd4372164bd0591070e7e1f37f01fdd6.zip
SnapdragonCamera: request audio focus before starting video recording
Use audio focus API to stop other music streams when starting video recording. Change-Id: I0097d0c2bd7157bc1936b9120bbe7c917b9707ee CRs-Fixed: 1005855
-rw-r--r--src/com/android/camera/VideoModule.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 31dd1e92c..a7a7f0d3a 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -1731,13 +1731,17 @@ public class VideoModule implements CameraModule,
* Make sure we're not recording music playing in the background, ask the
* MediaPlaybackService to pause playback.
*/
- private void pauseAudioPlayback() {
- // Shamelessly copied from MediaPlaybackService.java, which
- // should be public, but isn't.
- Intent i = new Intent("com.android.music.musicservicecommand");
- i.putExtra("command", "pause");
+ private void requestAudioFocus() {
+ AudioManager am = (AudioManager)mActivity.getSystemService(Context.AUDIO_SERVICE);
+
+ // Send request to obtain audio focus. This will stop other
+ // music stream.
+ int result = am.requestAudioFocus(null, AudioManager.STREAM_MUSIC,
+ AudioManager.AUDIOFOCUS_GAIN);
- mActivity.sendBroadcast(i);
+ if (result == AudioManager.AUDIOFOCUS_REQUEST_FAILED) {
+ Log.v(TAG, "Audio focus request failed");
+ }
}
// For testing.
@@ -1805,7 +1809,7 @@ public class VideoModule implements CameraModule,
return false;
}
- pauseAudioPlayback();
+ requestAudioFocus();
try {
mMediaRecorder.start(); // Recording is now started