Skip to content

Commit 8b72930

Browse files
jmtriviAndroid (Google) Code Review
authored andcommitted
Merge "Define FLAG_BEACON in android.media.AudioAttributes" into lmp-dev
2 parents 97f5504 + 6894cd3 commit 8b72930

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

media/java/android/media/AudioAttributes.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package android.media;
1818

1919
import android.annotation.IntDef;
20+
import android.annotation.SystemApi;
2021
import android.os.Parcel;
2122
import android.os.Parcelable;
2223
import android.text.TextUtils;
@@ -143,22 +144,35 @@ public final class AudioAttributes implements Parcelable {
143144
* degradation only when going to a secure sink.
144145
*/
145146
// FIXME not guaranteed yet
146-
// TODO add OR to getFlags() when supported and in public API
147+
// TODO add in FLAG_ALL_PUBLIC when supported and in public API
147148
public final static int FLAG_SECURE = 0x1 << 1;
148149
/**
149150
* @hide
150151
* Flag to enable when the stream is associated with SCO usage.
151152
* Internal use only for dealing with legacy STREAM_BLUETOOTH_SCO
152153
*/
153154
public final static int FLAG_SCO = 0x1 << 2;
155+
/**
156+
* @hide
157+
* Flag defining a behavior where the system ensures that the playback of the sound will
158+
* be compatible with its use as a broadcast for surrounding people and/or devices.
159+
* Ensures audibility with no or minimal post-processing applied.
160+
*/
161+
@SystemApi
162+
public final static int FLAG_BEACON = 0x1 << 3;
154163

155164
/**
156165
* @hide
157166
* CANDIDATE FOR PUBLIC API
158167
* Flag requesting the use of an output stream supporting hardware A/V synchronization.
159168
*/
169+
// TODO add in FLAG_ALL_PUBLIC when in public API
160170
public final static int FLAG_HW_AV_SYNC = 0x1 << 4;
161171

172+
private final static int FLAG_ALL = FLAG_AUDIBILITY_ENFORCED | FLAG_SECURE | FLAG_SCO |
173+
FLAG_BEACON | FLAG_HW_AV_SYNC;
174+
private final static int FLAG_ALL_PUBLIC = FLAG_AUDIBILITY_ENFORCED;
175+
162176
private int mUsage = USAGE_UNKNOWN;
163177
private int mContentType = CONTENT_TYPE_UNKNOWN;
164178
private int mSource = MediaRecorder.AudioSource.AUDIO_SOURCE_INVALID;
@@ -202,7 +216,7 @@ public int getCapturePreset() {
202216
*/
203217
public int getFlags() {
204218
// only return the flags that are public
205-
return (mFlags & (FLAG_AUDIBILITY_ENFORCED | FLAG_HW_AV_SYNC));
219+
return (mFlags & (FLAG_ALL_PUBLIC));
206220
}
207221

208222
/**
@@ -212,7 +226,7 @@ public int getFlags() {
212226
* @return a combined mask of all flags
213227
*/
214228
public int getAllFlags() {
215-
return mFlags;
229+
return (mFlags & FLAG_ALL);
216230
}
217231

218232
/**
@@ -345,8 +359,7 @@ public Builder setContentType(@AttributeContentType int contentType) {
345359
* @return the same Builder instance.
346360
*/
347361
public Builder setFlags(int flags) {
348-
flags &= (AudioAttributes.FLAG_AUDIBILITY_ENFORCED | AudioAttributes.FLAG_SCO
349-
| AudioAttributes.FLAG_SECURE | AudioAttributes.FLAG_HW_AV_SYNC);
362+
flags &= AudioAttributes.FLAG_ALL;
350363
mFlags |= flags;
351364
return this;
352365
}

0 commit comments

Comments
 (0)