[BUG] audio: Misalignement of Native/Java AudioAttributes
Native audio attributes are initialized with a default source,
whereas JAVA AudioAttributes are initialized with an INVALID source.
It leads to equality failure, thus preventing to identify the
right strategy / volume group.
This CL fixes this misalignement by using the builder constructor
from AudioAttributes, thus cleaning the input source.
Test: AudioVolumeGroupTest
Bug: 238058094
Bug: 284010885
Bug: 284020937
Signed-off-by: Francois Gaffie <francois.gaffie@renault.com>
Change-Id: I1dca99cf60c8b3a6291743dc299324374e5752a6
Merged-In: I13d216814db66369ae72b496f4c9ae724cc40561
Change-Id: I13d216814db66369ae72b496f4c9ae724cc40561
Signed-off-by: François Gaffie <francois.gaffie@renault.com>
(cherry picked from commit 7a89e9fb3b)
This commit is contained in:
committed by
Mikhail Naganov
parent
0e2e9bb93c
commit
a4fa0a9114
@@ -1433,6 +1433,8 @@ public final class AudioAttributes implements Parcelable {
|
||||
return new String("AudioAttributes:"
|
||||
+ " usage=" + usageToString()
|
||||
+ " content=" + contentTypeToString()
|
||||
+ (mSource != MediaRecorder.AudioSource.AUDIO_SOURCE_INVALID
|
||||
? " source=" + MediaRecorder.toLogFriendlyAudioSource(mSource) : "")
|
||||
+ " flags=0x" + Integer.toHexString(mFlags).toUpperCase()
|
||||
+ " tags=" + mFormattedTags
|
||||
+ " bundle=" + (mBundle == null ? "null" : mBundle.toString()));
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.annotation.SystemApi;
|
||||
import android.annotation.TestApi;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.AudioSystem;
|
||||
import android.media.MediaRecorder;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
@@ -130,9 +129,7 @@ public final class AudioProductStrategy implements Parcelable {
|
||||
return aa;
|
||||
}
|
||||
}
|
||||
return new AudioAttributes.Builder()
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN)
|
||||
.setUsage(AudioAttributes.USAGE_UNKNOWN).build();
|
||||
return DEFAULT_ATTRIBUTES;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,7 +214,7 @@ public final class AudioProductStrategy implements Parcelable {
|
||||
@SystemApi
|
||||
public @NonNull AudioAttributes getAudioAttributes() {
|
||||
// We need a choice, so take the first one
|
||||
return mAudioAttributesGroups.length == 0 ? (new AudioAttributes.Builder().build())
|
||||
return mAudioAttributesGroups.length == 0 ? DEFAULT_ATTRIBUTES
|
||||
: mAudioAttributesGroups[0].getAudioAttributes();
|
||||
}
|
||||
|
||||
@@ -358,8 +355,7 @@ public final class AudioProductStrategy implements Parcelable {
|
||||
* Default attributes, with default source to be aligned with native.
|
||||
*/
|
||||
private static final @NonNull AudioAttributes DEFAULT_ATTRIBUTES =
|
||||
new AudioAttributes.Builder().setCapturePreset(MediaRecorder.AudioSource.DEFAULT)
|
||||
.build();
|
||||
new AudioAttributes.Builder().build();
|
||||
|
||||
/**
|
||||
* @hide
|
||||
@@ -429,8 +425,7 @@ public final class AudioProductStrategy implements Parcelable {
|
||||
|
||||
public @NonNull AudioAttributes getAudioAttributes() {
|
||||
// We need a choice, so take the first one
|
||||
return mAudioAttributes.length == 0 ? (new AudioAttributes.Builder().build())
|
||||
: mAudioAttributes[0];
|
||||
return mAudioAttributes.length == 0 ? DEFAULT_ATTRIBUTES : mAudioAttributes[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user