mirror of
https://github.com/samsonjs/media.git
synced 2026-03-30 10:15:48 +00:00
Rename CONTENT_TYPE_ @AudioContentType values to AUDIO_CONTENT_TYPE_*
This is consistent with the IntDef name, and frees up the CONTENT_TYPE_ prefix for the @ContentType values (which are currently just TYPE_*, and therefore ambiguous with lots of other 'type' values in C). PiperOrigin-RevId: 445356476
This commit is contained in:
parent
c5ad28a96c
commit
07d08ba85b
6 changed files with 47 additions and 31 deletions
|
|
@ -391,9 +391,15 @@ public final class C {
|
|||
public static final int STREAM_TYPE_DEFAULT = STREAM_TYPE_MUSIC;
|
||||
|
||||
/**
|
||||
* Content types for audio attributes. One of {@link #CONTENT_TYPE_MOVIE}, {@link
|
||||
* #CONTENT_TYPE_MUSIC}, {@link #CONTENT_TYPE_SONIFICATION}, {@link #CONTENT_TYPE_SPEECH} or
|
||||
* {@link #CONTENT_TYPE_UNKNOWN}.
|
||||
* Content types for audio attributes. One of:
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@link #AUDIO_CONTENT_TYPE_MOVIE}
|
||||
* <li>{@link #AUDIO_CONTENT_TYPE_MUSIC}
|
||||
* <li>{@link #AUDIO_CONTENT_TYPE_SONIFICATION}
|
||||
* <li>{@link #AUDIO_CONTENT_TYPE_SPEECH}
|
||||
* <li>{@link #AUDIO_CONTENT_TYPE_UNKNOWN}
|
||||
* </ul>
|
||||
*/
|
||||
// @Target list includes both 'default' targets and TYPE_USE, to ensure backwards compatibility
|
||||
// with Kotlin usages from before TYPE_USE was added.
|
||||
|
|
@ -401,34 +407,44 @@ public final class C {
|
|||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
|
||||
@IntDef({
|
||||
CONTENT_TYPE_MOVIE,
|
||||
CONTENT_TYPE_MUSIC,
|
||||
CONTENT_TYPE_SONIFICATION,
|
||||
CONTENT_TYPE_SPEECH,
|
||||
CONTENT_TYPE_UNKNOWN
|
||||
AUDIO_CONTENT_TYPE_MOVIE,
|
||||
AUDIO_CONTENT_TYPE_MUSIC,
|
||||
AUDIO_CONTENT_TYPE_SONIFICATION,
|
||||
AUDIO_CONTENT_TYPE_SPEECH,
|
||||
AUDIO_CONTENT_TYPE_UNKNOWN
|
||||
})
|
||||
public @interface AudioContentType {}
|
||||
/** See {@link AudioAttributes#CONTENT_TYPE_MOVIE}. */
|
||||
public static final int AUDIO_CONTENT_TYPE_MOVIE = AudioAttributes.CONTENT_TYPE_MOVIE;
|
||||
/**
|
||||
* @see android.media.AudioAttributes#CONTENT_TYPE_MOVIE
|
||||
* @deprecated Use {@link #AUDIO_CONTENT_TYPE_MOVIE} instead.
|
||||
*/
|
||||
public static final int CONTENT_TYPE_MOVIE = android.media.AudioAttributes.CONTENT_TYPE_MOVIE;
|
||||
@Deprecated public static final int CONTENT_TYPE_MOVIE = AUDIO_CONTENT_TYPE_MOVIE;
|
||||
/** See {@link AudioAttributes#CONTENT_TYPE_MUSIC}. */
|
||||
public static final int AUDIO_CONTENT_TYPE_MUSIC = AudioAttributes.CONTENT_TYPE_MUSIC;
|
||||
/**
|
||||
* @see android.media.AudioAttributes#CONTENT_TYPE_MUSIC
|
||||
* @deprecated Use {@link #AUDIO_CONTENT_TYPE_MUSIC} instead.
|
||||
*/
|
||||
public static final int CONTENT_TYPE_MUSIC = android.media.AudioAttributes.CONTENT_TYPE_MUSIC;
|
||||
@Deprecated public static final int CONTENT_TYPE_MUSIC = AUDIO_CONTENT_TYPE_MUSIC;
|
||||
/** See {@link AudioAttributes#CONTENT_TYPE_SONIFICATION}. */
|
||||
public static final int AUDIO_CONTENT_TYPE_SONIFICATION =
|
||||
AudioAttributes.CONTENT_TYPE_SONIFICATION;
|
||||
/**
|
||||
* @see android.media.AudioAttributes#CONTENT_TYPE_SONIFICATION
|
||||
* @deprecated Use {@link #AUDIO_CONTENT_TYPE_SONIFICATION} instead.
|
||||
*/
|
||||
public static final int CONTENT_TYPE_SONIFICATION =
|
||||
android.media.AudioAttributes.CONTENT_TYPE_SONIFICATION;
|
||||
@Deprecated public static final int CONTENT_TYPE_SONIFICATION = AUDIO_CONTENT_TYPE_SONIFICATION;
|
||||
/** See {@link AudioAttributes#CONTENT_TYPE_SPEECH}. */
|
||||
public static final int AUDIO_CONTENT_TYPE_SPEECH = AudioAttributes.CONTENT_TYPE_SPEECH;
|
||||
/**
|
||||
* @see android.media.AudioAttributes#CONTENT_TYPE_SPEECH
|
||||
* @deprecated Use {@link #AUDIO_CONTENT_TYPE_SPEECH} instead.
|
||||
*/
|
||||
public static final int CONTENT_TYPE_SPEECH = android.media.AudioAttributes.CONTENT_TYPE_SPEECH;
|
||||
@Deprecated public static final int CONTENT_TYPE_SPEECH = AUDIO_CONTENT_TYPE_SPEECH;
|
||||
/** See {@link AudioAttributes#CONTENT_TYPE_UNKNOWN}. */
|
||||
public static final int AUDIO_CONTENT_TYPE_UNKNOWN = AudioAttributes.CONTENT_TYPE_UNKNOWN;
|
||||
/**
|
||||
* @see android.media.AudioAttributes#CONTENT_TYPE_UNKNOWN
|
||||
* @deprecated Use {@link #AUDIO_CONTENT_TYPE_UNKNOWN} instead.
|
||||
*/
|
||||
public static final int CONTENT_TYPE_UNKNOWN = android.media.AudioAttributes.CONTENT_TYPE_UNKNOWN;
|
||||
@Deprecated public static final int CONTENT_TYPE_UNKNOWN = AUDIO_CONTENT_TYPE_UNKNOWN;
|
||||
|
||||
/**
|
||||
* Flags for audio attributes. Possible flag value is {@link #FLAG_AUDIBILITY_ENFORCED}.
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ import java.lang.reflect.Method;
|
|||
public final class AudioAttributes implements Bundleable {
|
||||
|
||||
/**
|
||||
* The default audio attributes, where the content type is {@link C#CONTENT_TYPE_UNKNOWN}, usage
|
||||
* is {@link C#USAGE_MEDIA}, capture policy is {@link C#ALLOW_CAPTURE_BY_ALL} and no flags are
|
||||
* set.
|
||||
* The default audio attributes, where the content type is {@link C#AUDIO_CONTENT_TYPE_UNKNOWN},
|
||||
* usage is {@link C#USAGE_MEDIA}, capture policy is {@link C#ALLOW_CAPTURE_BY_ALL} and no flags
|
||||
* are set.
|
||||
*/
|
||||
public static final AudioAttributes DEFAULT = new Builder().build();
|
||||
|
||||
|
|
@ -63,11 +63,11 @@ public final class AudioAttributes implements Bundleable {
|
|||
/**
|
||||
* Creates a new builder for {@link AudioAttributes}.
|
||||
*
|
||||
* <p>By default the content type is {@link C#CONTENT_TYPE_UNKNOWN}, usage is {@link
|
||||
* <p>By default the content type is {@link C#AUDIO_CONTENT_TYPE_UNKNOWN}, usage is {@link
|
||||
* C#USAGE_MEDIA}, capture policy is {@link C#ALLOW_CAPTURE_BY_ALL} and no flags are set.
|
||||
*/
|
||||
public Builder() {
|
||||
contentType = C.CONTENT_TYPE_UNKNOWN;
|
||||
contentType = C.AUDIO_CONTENT_TYPE_UNKNOWN;
|
||||
flags = 0;
|
||||
usage = C.USAGE_MEDIA;
|
||||
allowedCapturePolicy = C.ALLOW_CAPTURE_BY_ALL;
|
||||
|
|
|
|||
|
|
@ -1705,12 +1705,12 @@ public final class Util {
|
|||
case C.STREAM_TYPE_NOTIFICATION:
|
||||
case C.STREAM_TYPE_RING:
|
||||
case C.STREAM_TYPE_SYSTEM:
|
||||
return C.CONTENT_TYPE_SONIFICATION;
|
||||
return C.AUDIO_CONTENT_TYPE_SONIFICATION;
|
||||
case C.STREAM_TYPE_VOICE_CALL:
|
||||
return C.CONTENT_TYPE_SPEECH;
|
||||
return C.AUDIO_CONTENT_TYPE_SPEECH;
|
||||
case C.STREAM_TYPE_MUSIC:
|
||||
default:
|
||||
return C.CONTENT_TYPE_MUSIC;
|
||||
return C.AUDIO_CONTENT_TYPE_MUSIC;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class AudioAttributesTest {
|
|||
public void roundTripViaBundle_yieldsEqualInstance() {
|
||||
AudioAttributes audioAttributes =
|
||||
new AudioAttributes.Builder()
|
||||
.setContentType(C.CONTENT_TYPE_SONIFICATION)
|
||||
.setContentType(C.AUDIO_CONTENT_TYPE_SONIFICATION)
|
||||
.setFlags(C.FLAG_AUDIBILITY_ENFORCED)
|
||||
.setUsage(C.USAGE_ALARM)
|
||||
.setAllowedCapturePolicy(C.ALLOW_CAPTURE_BY_SYSTEM)
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
}
|
||||
|
||||
private boolean willPauseWhenDucked() {
|
||||
return audioAttributes != null && audioAttributes.contentType == C.CONTENT_TYPE_SPEECH;
|
||||
return audioAttributes != null && audioAttributes.contentType == C.AUDIO_CONTENT_TYPE_SPEECH;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -367,7 +367,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
|
||||
// Special usages:
|
||||
case C.USAGE_ASSISTANCE_ACCESSIBILITY:
|
||||
if (audioAttributes.contentType == C.CONTENT_TYPE_SPEECH) {
|
||||
if (audioAttributes.contentType == C.AUDIO_CONTENT_TYPE_SPEECH) {
|
||||
// Voice shouldn't be interrupted by other playback.
|
||||
return AUDIOFOCUS_GAIN_TRANSIENT;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ public class AudioFocusManagerTest {
|
|||
AudioAttributes speechAudioAttributes =
|
||||
new AudioAttributes.Builder()
|
||||
.setUsage(C.USAGE_MEDIA)
|
||||
.setContentType(C.CONTENT_TYPE_SPEECH)
|
||||
.setContentType(C.AUDIO_CONTENT_TYPE_SPEECH)
|
||||
.build();
|
||||
audioFocusManager.setAudioAttributes(speechAudioAttributes);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue