mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08: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
fdd5bcdf5b
commit
1b2e9da0af
@ -44,9 +44,9 @@ import java.lang.reflect.Method;
|
|||||||
public final class AudioAttributes implements Bundleable {
|
public final class AudioAttributes implements Bundleable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default audio attributes, where the content type is {@link C#CONTENT_TYPE_UNKNOWN}, usage
|
* The default audio attributes, where the content type is {@link C#AUDIO_CONTENT_TYPE_UNKNOWN},
|
||||||
* is {@link C#USAGE_MEDIA}, capture policy is {@link C#ALLOW_CAPTURE_BY_ALL} and no flags are
|
* usage is {@link C#USAGE_MEDIA}, capture policy is {@link C#ALLOW_CAPTURE_BY_ALL} and no flags
|
||||||
* set.
|
* are set.
|
||||||
*/
|
*/
|
||||||
public static final AudioAttributes DEFAULT = new Builder().build();
|
public static final AudioAttributes DEFAULT = new Builder().build();
|
||||||
|
|
||||||
@ -62,11 +62,11 @@ public final class AudioAttributes implements Bundleable {
|
|||||||
/**
|
/**
|
||||||
* Creates a new builder for {@link AudioAttributes}.
|
* 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.
|
* C#USAGE_MEDIA}, capture policy is {@link C#ALLOW_CAPTURE_BY_ALL} and no flags are set.
|
||||||
*/
|
*/
|
||||||
public Builder() {
|
public Builder() {
|
||||||
contentType = C.CONTENT_TYPE_UNKNOWN;
|
contentType = C.AUDIO_CONTENT_TYPE_UNKNOWN;
|
||||||
flags = 0;
|
flags = 0;
|
||||||
usage = C.USAGE_MEDIA;
|
usage = C.USAGE_MEDIA;
|
||||||
allowedCapturePolicy = C.ALLOW_CAPTURE_BY_ALL;
|
allowedCapturePolicy = C.ALLOW_CAPTURE_BY_ALL;
|
||||||
|
@ -396,9 +396,15 @@ public final class C {
|
|||||||
@UnstableApi public static final int STREAM_TYPE_DEFAULT = STREAM_TYPE_MUSIC;
|
@UnstableApi public static final int STREAM_TYPE_DEFAULT = STREAM_TYPE_MUSIC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content types for audio attributes. One of {@link #CONTENT_TYPE_MOVIE}, {@link
|
* Content types for audio attributes. One of:
|
||||||
* #CONTENT_TYPE_MUSIC}, {@link #CONTENT_TYPE_SONIFICATION}, {@link #CONTENT_TYPE_SPEECH} or
|
*
|
||||||
* {@link #CONTENT_TYPE_UNKNOWN}.
|
* <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
|
// @Target list includes both 'default' targets and TYPE_USE, to ensure backwards compatibility
|
||||||
// with Kotlin usages from before TYPE_USE was added.
|
// with Kotlin usages from before TYPE_USE was added.
|
||||||
@ -406,34 +412,46 @@ public final class C {
|
|||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
|
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
|
||||||
@IntDef({
|
@IntDef({
|
||||||
CONTENT_TYPE_MOVIE,
|
AUDIO_CONTENT_TYPE_MOVIE,
|
||||||
CONTENT_TYPE_MUSIC,
|
AUDIO_CONTENT_TYPE_MUSIC,
|
||||||
CONTENT_TYPE_SONIFICATION,
|
AUDIO_CONTENT_TYPE_SONIFICATION,
|
||||||
CONTENT_TYPE_SPEECH,
|
AUDIO_CONTENT_TYPE_SPEECH,
|
||||||
CONTENT_TYPE_UNKNOWN
|
AUDIO_CONTENT_TYPE_UNKNOWN
|
||||||
})
|
})
|
||||||
public @interface AudioContentType {}
|
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;
|
@UnstableApi @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;
|
@UnstableApi @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 =
|
@UnstableApi @Deprecated
|
||||||
android.media.AudioAttributes.CONTENT_TYPE_SONIFICATION;
|
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;
|
@UnstableApi @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;
|
@UnstableApi @Deprecated
|
||||||
|
public static final int CONTENT_TYPE_UNKNOWN = AUDIO_CONTENT_TYPE_UNKNOWN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flags for audio attributes. Possible flag value is {@link #FLAG_AUDIBILITY_ENFORCED}.
|
* Flags for audio attributes. Possible flag value is {@link #FLAG_AUDIBILITY_ENFORCED}.
|
||||||
|
@ -1707,12 +1707,12 @@ public final class Util {
|
|||||||
case C.STREAM_TYPE_NOTIFICATION:
|
case C.STREAM_TYPE_NOTIFICATION:
|
||||||
case C.STREAM_TYPE_RING:
|
case C.STREAM_TYPE_RING:
|
||||||
case C.STREAM_TYPE_SYSTEM:
|
case C.STREAM_TYPE_SYSTEM:
|
||||||
return C.CONTENT_TYPE_SONIFICATION;
|
return C.AUDIO_CONTENT_TYPE_SONIFICATION;
|
||||||
case C.STREAM_TYPE_VOICE_CALL:
|
case C.STREAM_TYPE_VOICE_CALL:
|
||||||
return C.CONTENT_TYPE_SPEECH;
|
return C.AUDIO_CONTENT_TYPE_SPEECH;
|
||||||
case C.STREAM_TYPE_MUSIC:
|
case C.STREAM_TYPE_MUSIC:
|
||||||
default:
|
default:
|
||||||
return C.CONTENT_TYPE_MUSIC;
|
return C.AUDIO_CONTENT_TYPE_MUSIC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class AudioAttributesTest {
|
|||||||
public void roundTripViaBundle_yieldsEqualInstance() {
|
public void roundTripViaBundle_yieldsEqualInstance() {
|
||||||
AudioAttributes audioAttributes =
|
AudioAttributes audioAttributes =
|
||||||
new AudioAttributes.Builder()
|
new AudioAttributes.Builder()
|
||||||
.setContentType(C.CONTENT_TYPE_SONIFICATION)
|
.setContentType(C.AUDIO_CONTENT_TYPE_SONIFICATION)
|
||||||
.setFlags(C.FLAG_AUDIBILITY_ENFORCED)
|
.setFlags(C.FLAG_AUDIBILITY_ENFORCED)
|
||||||
.setUsage(C.USAGE_ALARM)
|
.setUsage(C.USAGE_ALARM)
|
||||||
.setAllowedCapturePolicy(C.ALLOW_CAPTURE_BY_SYSTEM)
|
.setAllowedCapturePolicy(C.ALLOW_CAPTURE_BY_SYSTEM)
|
||||||
|
@ -298,7 +298,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean willPauseWhenDucked() {
|
private boolean willPauseWhenDucked() {
|
||||||
return audioAttributes != null && audioAttributes.contentType == C.CONTENT_TYPE_SPEECH;
|
return audioAttributes != null && audioAttributes.contentType == C.AUDIO_CONTENT_TYPE_SPEECH;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -369,7 +369,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
|
|
||||||
// Special usages:
|
// Special usages:
|
||||||
case C.USAGE_ASSISTANCE_ACCESSIBILITY:
|
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.
|
// Voice shouldn't be interrupted by other playback.
|
||||||
return AUDIOFOCUS_GAIN_TRANSIENT;
|
return AUDIOFOCUS_GAIN_TRANSIENT;
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ public class AudioFocusManagerTest {
|
|||||||
AudioAttributes speechAudioAttributes =
|
AudioAttributes speechAudioAttributes =
|
||||||
new AudioAttributes.Builder()
|
new AudioAttributes.Builder()
|
||||||
.setUsage(C.USAGE_MEDIA)
|
.setUsage(C.USAGE_MEDIA)
|
||||||
.setContentType(C.CONTENT_TYPE_SPEECH)
|
.setContentType(C.AUDIO_CONTENT_TYPE_SPEECH)
|
||||||
.build();
|
.build();
|
||||||
audioFocusManager.setAudioAttributes(speechAudioAttributes);
|
audioFocusManager.setAudioAttributes(speechAudioAttributes);
|
||||||
|
|
||||||
|
@ -1811,7 +1811,7 @@ public class MediaControllerListenerTest {
|
|||||||
AudioAttributes testAttributes =
|
AudioAttributes testAttributes =
|
||||||
new AudioAttributes.Builder()
|
new AudioAttributes.Builder()
|
||||||
.setUsage(C.USAGE_MEDIA)
|
.setUsage(C.USAGE_MEDIA)
|
||||||
.setContentType(C.CONTENT_TYPE_MOVIE)
|
.setContentType(C.AUDIO_CONTENT_TYPE_MOVIE)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
MediaController controller = controllerTestRule.createController(remoteSession.getToken());
|
||||||
|
@ -520,7 +520,7 @@ public class MediaControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getAudioAttributes_returnsAudioAttributesOfPlayerInSession() throws Exception {
|
public void getAudioAttributes_returnsAudioAttributesOfPlayerInSession() throws Exception {
|
||||||
AudioAttributes testAttributes =
|
AudioAttributes testAttributes =
|
||||||
new AudioAttributes.Builder().setContentType(C.CONTENT_TYPE_MUSIC).build();
|
new AudioAttributes.Builder().setContentType(C.AUDIO_CONTENT_TYPE_MUSIC).build();
|
||||||
|
|
||||||
Bundle playerConfig =
|
Bundle playerConfig =
|
||||||
new RemoteMediaSession.MockPlayerConfigBuilder().setAudioAttributes(testAttributes).build();
|
new RemoteMediaSession.MockPlayerConfigBuilder().setAudioAttributes(testAttributes).build();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user