summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDongwon Kang <dwkang@google.com>2015-07-20 23:49:59 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-07-20 23:50:03 +0000
commit6444fe121449f1cacf4500d3098b590c74e3646d (patch)
tree22a18db4f2f715a44b27bffa57235324153e49b7
parent55786e1164d522d878d1f493c30330669b1fd868 (diff)
parent500747bf8fe4785b0e875b971b547723c35301f9 (diff)
downloadframeworks_base-6444fe121449f1cacf4500d3098b590c74e3646d.zip
frameworks_base-6444fe121449f1cacf4500d3098b590c74e3646d.tar.gz
frameworks_base-6444fe121449f1cacf4500d3098b590c74e3646d.tar.bz2
Merge "MediaSessionRecord: do not hold a lock when calling AudioSystem.isStreamActive" into mnc-dev
-rw-r--r--services/core/java/com/android/server/media/MediaSessionRecord.java46
1 files changed, 19 insertions, 27 deletions
diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java
index 7f5360b..f92f631 100644
--- a/services/core/java/com/android/server/media/MediaSessionRecord.java
+++ b/services/core/java/com/android/server/media/MediaSessionRecord.java
@@ -241,19 +241,10 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
flags &= ~AudioManager.FLAG_PLAY_SOUND;
}
if (mVolumeType == PlaybackInfo.PLAYBACK_TYPE_LOCAL) {
- int stream = AudioAttributes.toLegacyStreamType(mAudioAttrs);
// Adjust the volume with a handler not to be blocked by other system service.
- if (useSuggested) {
- if (AudioSystem.isStreamActive(stream, 0)) {
- postAdjustSuggestedStreamVolume(stream, direction, flags, packageName, uid);
- } else {
- flags |= previousFlagPlaySound;
- postAdjustSuggestedStreamVolume(AudioManager.USE_DEFAULT_STREAM_TYPE, direction,
- flags, packageName, uid);
- }
- } else {
- postAdjustStreamVolume(stream, direction, flags, packageName, uid);
- }
+ int stream = AudioAttributes.toLegacyStreamType(mAudioAttrs);
+ postAdjustLocalVolume(stream, direction, flags, packageName, uid, useSuggested,
+ previousFlagPlaySound);
} else {
if (mVolumeControlType == VolumeProvider.VOLUME_CONTROL_FIXED) {
// Nothing to do, the volume cannot be changed
@@ -459,24 +450,25 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
return mPackageName + "/" + mTag;
}
- private void postAdjustSuggestedStreamVolume(final int streamType, final int direction,
- final int flags, final String callingPackage, final int uid) {
+ private void postAdjustLocalVolume(final int stream, final int direction, final int flags,
+ final String packageName, final int uid, final boolean useSuggested,
+ final int previousFlagPlaySound) {
mHandler.post(new Runnable() {
@Override
public void run() {
- mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(streamType, direction,
- flags, callingPackage, uid);
- }
- });
- }
-
- private void postAdjustStreamVolume(final int streamType, final int direction, final int flags,
- final String callingPackage, final int uid) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mAudioManagerInternal.adjustStreamVolumeForUid(streamType, direction, flags,
- callingPackage, uid);
+ if (useSuggested) {
+ if (AudioSystem.isStreamActive(stream, 0)) {
+ mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream, direction,
+ flags, packageName, uid);
+ } else {
+ mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(
+ AudioManager.USE_DEFAULT_STREAM_TYPE, direction,
+ flags | previousFlagPlaySound, packageName, uid);
+ }
+ } else {
+ mAudioManagerInternal.adjustStreamVolumeForUid(stream, direction, flags,
+ packageName, uid);
+ }
}
});
}