diff options
| author | 2018-03-21 16:08:33 +0100 | |
|---|---|---|
| committer | 2019-03-18 13:28:34 -0700 | |
| commit | e6d280d660dcd5563a4f7ac1417c0de3fd9ef6be (patch) | |
| tree | 74ae631fa054561e359d44a62621803b9d1fe2f2 | |
| parent | b426499958ba75130151d8c54981d338b97a533b (diff) | |
Use AudioProductStrategies within AudioAttributes
AudioProductStrategies allows to avoid any hard coded operation in AOSP,
and the matching between the stream type and the attributes can also
be exposed by the XML audio policy engine configuration file.
This CL updates the AudioAttributes to make use of product strategies
to implement the legacy conversion between stream type and attributes.
It will continue fallbacking in hard coded mapping.
Bug: 124767636
Test: dumpsys media.audio_policy
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
Change-Id: I143403a81e363ed064cb8b422e5ca53cb4b6e18b
| -rw-r--r-- | media/java/android/media/AudioAttributes.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/media/java/android/media/AudioAttributes.java b/media/java/android/media/AudioAttributes.java index c2f29bc6e3bc..5249b10f9b2e 100644 --- a/media/java/android/media/AudioAttributes.java +++ b/media/java/android/media/AudioAttributes.java @@ -20,6 +20,7 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.SystemApi; import android.annotation.UnsupportedAppUsage; +import android.media.audiopolicy.AudioProductStrategies; import android.os.Build; import android.os.Bundle; import android.os.Parcel; @@ -725,6 +726,13 @@ public final class AudioAttributes implements Parcelable { */ @UnsupportedAppUsage public Builder setInternalLegacyStreamType(int streamType) { + final AudioProductStrategies ps = new AudioProductStrategies(); + if (ps.size() > 0) { + AudioAttributes attributes = ps.getAudioAttributesForLegacyStreamType(streamType); + if (attributes != null) { + return new Builder(attributes); + } + } switch(streamType) { case AudioSystem.STREAM_VOICE_CALL: mContentType = CONTENT_TYPE_SPEECH; @@ -1100,6 +1108,10 @@ public final class AudioAttributes implements Parcelable { AudioSystem.STREAM_MUSIC : AudioSystem.STREAM_TTS; } + final AudioProductStrategies ps = new AudioProductStrategies(); + if (ps.size() > 0) { + return ps.getLegacyStreamTypeForAudioAttributes(aa); + } // usage to stream type mapping switch (aa.getUsage()) { case USAGE_MEDIA: |