mirror of
https://github.com/androidx/media.git
synced 2025-05-04 06:00:37 +08:00
Move AudioTrack.SESSION_ID_NOT_SET to C
It's a nicer place for it to live once it starts being passed around more widely (e.g. through the video renderer, for tunneling) ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=142158460
This commit is contained in:
parent
588124da76
commit
04992fdaac
@ -96,6 +96,13 @@ public final class C {
|
|||||||
@SuppressWarnings("InlinedApi")
|
@SuppressWarnings("InlinedApi")
|
||||||
public static final int CRYPTO_MODE_AES_CBC = MediaCodec.CRYPTO_MODE_AES_CBC;
|
public static final int CRYPTO_MODE_AES_CBC = MediaCodec.CRYPTO_MODE_AES_CBC;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an unset {@link android.media.AudioTrack} session identifier. Equal to
|
||||||
|
* {@link AudioManager#AUDIO_SESSION_ID_GENERATE}.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("InlinedApi")
|
||||||
|
public static final int AUDIO_SESSION_ID_UNSET = AudioManager.AUDIO_SESSION_ID_GENERATE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an audio encoding, or an invalid or unset value.
|
* Represents an audio encoding, or an invalid or unset value.
|
||||||
*/
|
*/
|
||||||
|
@ -29,7 +29,6 @@ import android.view.SurfaceView;
|
|||||||
import android.view.TextureView;
|
import android.view.TextureView;
|
||||||
import com.google.android.exoplayer2.audio.AudioCapabilities;
|
import com.google.android.exoplayer2.audio.AudioCapabilities;
|
||||||
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
||||||
import com.google.android.exoplayer2.audio.AudioTrack;
|
|
||||||
import com.google.android.exoplayer2.audio.MediaCodecAudioRenderer;
|
import com.google.android.exoplayer2.audio.MediaCodecAudioRenderer;
|
||||||
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||||
@ -178,7 +177,7 @@ public class SimpleExoPlayer implements ExoPlayer {
|
|||||||
|
|
||||||
// Set initial values.
|
// Set initial values.
|
||||||
audioVolume = 1;
|
audioVolume = 1;
|
||||||
audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
|
audioSessionId = C.AUDIO_SESSION_ID_UNSET;
|
||||||
audioStreamType = C.STREAM_TYPE_DEFAULT;
|
audioStreamType = C.STREAM_TYPE_DEFAULT;
|
||||||
videoScalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
|
videoScalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
|
||||||
|
|
||||||
@ -393,7 +392,7 @@ public class SimpleExoPlayer implements ExoPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the audio session identifier, or {@code AudioTrack.SESSION_ID_NOT_SET} if not set.
|
* Returns the audio session identifier, or {@link C#AUDIO_SESSION_ID_UNSET} if not set.
|
||||||
*/
|
*/
|
||||||
public int getAudioSessionId() {
|
public int getAudioSessionId() {
|
||||||
return audioSessionId;
|
return audioSessionId;
|
||||||
@ -949,7 +948,7 @@ public class SimpleExoPlayer implements ExoPlayer {
|
|||||||
}
|
}
|
||||||
audioFormat = null;
|
audioFormat = null;
|
||||||
audioDecoderCounters = null;
|
audioDecoderCounters = null;
|
||||||
audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
|
audioSessionId = C.AUDIO_SESSION_ID_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextRenderer.Output implementation
|
// TextRenderer.Output implementation
|
||||||
|
@ -19,7 +19,6 @@ import android.annotation.SuppressLint;
|
|||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.media.AudioAttributes;
|
import android.media.AudioAttributes;
|
||||||
import android.media.AudioFormat;
|
import android.media.AudioFormat;
|
||||||
import android.media.AudioManager;
|
|
||||||
import android.media.AudioTimestamp;
|
import android.media.AudioTimestamp;
|
||||||
import android.media.PlaybackParams;
|
import android.media.PlaybackParams;
|
||||||
import android.os.ConditionVariable;
|
import android.os.ConditionVariable;
|
||||||
@ -147,13 +146,6 @@ public final class AudioTrack {
|
|||||||
*/
|
*/
|
||||||
public static final int RESULT_BUFFER_CONSUMED = 2;
|
public static final int RESULT_BUFFER_CONSUMED = 2;
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents an unset {@link android.media.AudioTrack} session identifier. Equal to
|
|
||||||
* {@link AudioManager#AUDIO_SESSION_ID_GENERATE}.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("InlinedApi")
|
|
||||||
public static final int SESSION_ID_NOT_SET = AudioManager.AUDIO_SESSION_ID_GENERATE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returned by {@link #getCurrentPositionUs} when the position is not set.
|
* Returned by {@link #getCurrentPositionUs} when the position is not set.
|
||||||
*/
|
*/
|
||||||
@ -508,7 +500,8 @@ public final class AudioTrack {
|
|||||||
/**
|
/**
|
||||||
* Initializes the audio track for writing new buffers using {@link #handleBuffer}.
|
* Initializes the audio track for writing new buffers using {@link #handleBuffer}.
|
||||||
*
|
*
|
||||||
* @param sessionId Audio track session identifier, or {@link #SESSION_ID_NOT_SET} to create one.
|
* @param sessionId Audio track session identifier, or {@link C#AUDIO_SESSION_ID_UNSET} to create
|
||||||
|
* one.
|
||||||
* @return The audio track session identifier.
|
* @return The audio track session identifier.
|
||||||
*/
|
*/
|
||||||
public int initialize(int sessionId) throws InitializationException {
|
public int initialize(int sessionId) throws InitializationException {
|
||||||
@ -518,7 +511,8 @@ public final class AudioTrack {
|
|||||||
/**
|
/**
|
||||||
* Initializes the audio track for writing new buffers using {@link #handleBuffer}.
|
* Initializes the audio track for writing new buffers using {@link #handleBuffer}.
|
||||||
*
|
*
|
||||||
* @param sessionId Audio track session identifier, or {@link #SESSION_ID_NOT_SET} to create one.
|
* @param sessionId Audio track session identifier, or {@link C#AUDIO_SESSION_ID_UNSET} to create
|
||||||
|
* one.
|
||||||
* @param tunneling Whether the audio track is to be used with tunneling video playback.
|
* @param tunneling Whether the audio track is to be used with tunneling video playback.
|
||||||
* @return The audio track session identifier.
|
* @return The audio track session identifier.
|
||||||
*/
|
*/
|
||||||
@ -539,7 +533,7 @@ public final class AudioTrack {
|
|||||||
if (useHwAvSync) {
|
if (useHwAvSync) {
|
||||||
audioTrack = createHwAvSyncAudioTrackV21(sampleRate, channelConfig, targetEncoding,
|
audioTrack = createHwAvSyncAudioTrackV21(sampleRate, channelConfig, targetEncoding,
|
||||||
bufferSize, sessionId);
|
bufferSize, sessionId);
|
||||||
} else if (sessionId == SESSION_ID_NOT_SET) {
|
} else if (sessionId == C.AUDIO_SESSION_ID_UNSET) {
|
||||||
audioTrack = new android.media.AudioTrack(streamType, sampleRate, channelConfig,
|
audioTrack = new android.media.AudioTrack(streamType, sampleRate, channelConfig,
|
||||||
targetEncoding, bufferSize, MODE_STREAM);
|
targetEncoding, bufferSize, MODE_STREAM);
|
||||||
} else {
|
} else {
|
||||||
|
@ -129,7 +129,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||||||
boolean playClearSamplesWithoutKeys, Handler eventHandler,
|
boolean playClearSamplesWithoutKeys, Handler eventHandler,
|
||||||
AudioRendererEventListener eventListener, AudioCapabilities audioCapabilities) {
|
AudioRendererEventListener eventListener, AudioCapabilities audioCapabilities) {
|
||||||
super(C.TRACK_TYPE_AUDIO, mediaCodecSelector, drmSessionManager, playClearSamplesWithoutKeys);
|
super(C.TRACK_TYPE_AUDIO, mediaCodecSelector, drmSessionManager, playClearSamplesWithoutKeys);
|
||||||
audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
|
audioSessionId = C.AUDIO_SESSION_ID_UNSET;
|
||||||
audioTrack = new AudioTrack(audioCapabilities, this);
|
audioTrack = new AudioTrack(audioCapabilities, this);
|
||||||
eventDispatcher = new EventDispatcher(eventHandler, eventListener);
|
eventDispatcher = new EventDispatcher(eventHandler, eventListener);
|
||||||
}
|
}
|
||||||
@ -274,7 +274,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDisabled() {
|
protected void onDisabled() {
|
||||||
audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
|
audioSessionId = C.AUDIO_SESSION_ID_UNSET;
|
||||||
try {
|
try {
|
||||||
audioTrack.release();
|
audioTrack.release();
|
||||||
} finally {
|
} finally {
|
||||||
@ -328,8 +328,8 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||||||
if (!audioTrack.isInitialized()) {
|
if (!audioTrack.isInitialized()) {
|
||||||
// Initialize the AudioTrack now.
|
// Initialize the AudioTrack now.
|
||||||
try {
|
try {
|
||||||
if (audioSessionId == AudioTrack.SESSION_ID_NOT_SET) {
|
if (audioSessionId == C.AUDIO_SESSION_ID_UNSET) {
|
||||||
audioSessionId = audioTrack.initialize(AudioTrack.SESSION_ID_NOT_SET);
|
audioSessionId = audioTrack.initialize(C.AUDIO_SESSION_ID_UNSET);
|
||||||
eventDispatcher.audioSessionId(audioSessionId);
|
eventDispatcher.audioSessionId(audioSessionId);
|
||||||
onAudioSessionId(audioSessionId);
|
onAudioSessionId(audioSessionId);
|
||||||
} else {
|
} else {
|
||||||
@ -387,7 +387,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||||||
case C.MSG_SET_STREAM_TYPE:
|
case C.MSG_SET_STREAM_TYPE:
|
||||||
@C.StreamType int streamType = (Integer) message;
|
@C.StreamType int streamType = (Integer) message;
|
||||||
if (audioTrack.setStreamType(streamType)) {
|
if (audioTrack.setStreamType(streamType)) {
|
||||||
audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
|
audioSessionId = C.AUDIO_SESSION_ID_UNSET;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -145,7 +145,7 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
|
|||||||
this.drmSessionManager = drmSessionManager;
|
this.drmSessionManager = drmSessionManager;
|
||||||
formatHolder = new FormatHolder();
|
formatHolder = new FormatHolder();
|
||||||
this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
|
this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
|
||||||
audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
|
audioSessionId = C.AUDIO_SESSION_ID_UNSET;
|
||||||
decoderReinitializationState = REINITIALIZATION_STATE_NONE;
|
decoderReinitializationState = REINITIALIZATION_STATE_NONE;
|
||||||
audioTrackNeedsConfigure = true;
|
audioTrackNeedsConfigure = true;
|
||||||
}
|
}
|
||||||
@ -245,8 +245,8 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!audioTrack.isInitialized()) {
|
if (!audioTrack.isInitialized()) {
|
||||||
if (audioSessionId == AudioTrack.SESSION_ID_NOT_SET) {
|
if (audioSessionId == C.AUDIO_SESSION_ID_UNSET) {
|
||||||
audioSessionId = audioTrack.initialize(AudioTrack.SESSION_ID_NOT_SET);
|
audioSessionId = audioTrack.initialize(C.AUDIO_SESSION_ID_UNSET);
|
||||||
eventDispatcher.audioSessionId(audioSessionId);
|
eventDispatcher.audioSessionId(audioSessionId);
|
||||||
onAudioSessionId(audioSessionId);
|
onAudioSessionId(audioSessionId);
|
||||||
} else {
|
} else {
|
||||||
@ -425,7 +425,7 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
|
|||||||
@Override
|
@Override
|
||||||
protected void onDisabled() {
|
protected void onDisabled() {
|
||||||
inputFormat = null;
|
inputFormat = null;
|
||||||
audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
|
audioSessionId = C.AUDIO_SESSION_ID_UNSET;
|
||||||
audioTrackNeedsConfigure = true;
|
audioTrackNeedsConfigure = true;
|
||||||
waitingForKeys = false;
|
waitingForKeys = false;
|
||||||
try {
|
try {
|
||||||
@ -554,7 +554,7 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
|
|||||||
case C.MSG_SET_STREAM_TYPE:
|
case C.MSG_SET_STREAM_TYPE:
|
||||||
@C.StreamType int streamType = (Integer) message;
|
@C.StreamType int streamType = (Integer) message;
|
||||||
if (audioTrack.setStreamType(streamType)) {
|
if (audioTrack.setStreamType(streamType)) {
|
||||||
audioSessionId = AudioTrack.SESSION_ID_NOT_SET;
|
audioSessionId = C.AUDIO_SESSION_ID_UNSET;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user