- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
538 lines
23 KiB
Java
538 lines
23 KiB
Java
package com.mbridge.msdk.playercommon.exoplayer2.audio;
|
|
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import android.os.SystemClock;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.ExoPlaybackException;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.Format;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.FormatHolder;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.PlaybackParameters;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.audio.AudioRendererEventListener;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.audio.AudioSink;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.decoder.DecoderCounters;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.decoder.DecoderInputBuffer;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.decoder.SimpleDecoder;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.decoder.SimpleOutputBuffer;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.drm.DrmSession;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.drm.DrmSessionManager;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.drm.ExoMediaCrypto;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.util.Assertions;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.util.MediaClock;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.util.MimeTypes;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.util.TraceUtil;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.util.Util;
|
|
import java.lang.annotation.Retention;
|
|
import java.lang.annotation.RetentionPolicy;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements MediaClock {
|
|
private static final int REINITIALIZATION_STATE_NONE = 0;
|
|
private static final int REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM = 1;
|
|
private static final int REINITIALIZATION_STATE_WAIT_END_OF_STREAM = 2;
|
|
private boolean allowFirstBufferPositionDiscontinuity;
|
|
private boolean allowPositionDiscontinuity;
|
|
private final AudioSink audioSink;
|
|
private boolean audioTrackNeedsConfigure;
|
|
private long currentPositionUs;
|
|
private SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends AudioDecoderException> decoder;
|
|
private DecoderCounters decoderCounters;
|
|
private boolean decoderReceivedBuffers;
|
|
private int decoderReinitializationState;
|
|
private DrmSession<ExoMediaCrypto> drmSession;
|
|
private final DrmSessionManager<ExoMediaCrypto> drmSessionManager;
|
|
private int encoderDelay;
|
|
private int encoderPadding;
|
|
private final AudioRendererEventListener.EventDispatcher eventDispatcher;
|
|
private final DecoderInputBuffer flagsOnlyBuffer;
|
|
private final FormatHolder formatHolder;
|
|
private DecoderInputBuffer inputBuffer;
|
|
private Format inputFormat;
|
|
private boolean inputStreamEnded;
|
|
private SimpleOutputBuffer outputBuffer;
|
|
private boolean outputStreamEnded;
|
|
private DrmSession<ExoMediaCrypto> pendingDrmSession;
|
|
private final boolean playClearSamplesWithoutKeys;
|
|
private boolean waitingForKeys;
|
|
|
|
@Retention(RetentionPolicy.SOURCE)
|
|
public @interface ReinitializationState {
|
|
}
|
|
|
|
public abstract SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends AudioDecoderException> createDecoder(Format format, ExoMediaCrypto exoMediaCrypto) throws AudioDecoderException;
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer, com.mbridge.msdk.playercommon.exoplayer2.Renderer
|
|
public MediaClock getMediaClock() {
|
|
return this;
|
|
}
|
|
|
|
public void onAudioSessionId(int i) {
|
|
}
|
|
|
|
public void onAudioTrackPositionDiscontinuity() {
|
|
}
|
|
|
|
public void onAudioTrackUnderrun(int i, long j, long j2) {
|
|
}
|
|
|
|
public abstract int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format);
|
|
|
|
public SimpleDecoderAudioRenderer() {
|
|
this((Handler) null, (AudioRendererEventListener) null, new AudioProcessor[0]);
|
|
}
|
|
|
|
public SimpleDecoderAudioRenderer(Handler handler, AudioRendererEventListener audioRendererEventListener, AudioProcessor... audioProcessorArr) {
|
|
this(handler, audioRendererEventListener, null, null, false, audioProcessorArr);
|
|
}
|
|
|
|
public SimpleDecoderAudioRenderer(Handler handler, AudioRendererEventListener audioRendererEventListener, AudioCapabilities audioCapabilities) {
|
|
this(handler, audioRendererEventListener, audioCapabilities, null, false, new AudioProcessor[0]);
|
|
}
|
|
|
|
public SimpleDecoderAudioRenderer(Handler handler, AudioRendererEventListener audioRendererEventListener, AudioCapabilities audioCapabilities, DrmSessionManager<ExoMediaCrypto> drmSessionManager, boolean z, AudioProcessor... audioProcessorArr) {
|
|
this(handler, audioRendererEventListener, drmSessionManager, z, new DefaultAudioSink(audioCapabilities, audioProcessorArr));
|
|
}
|
|
|
|
public SimpleDecoderAudioRenderer(Handler handler, AudioRendererEventListener audioRendererEventListener, DrmSessionManager<ExoMediaCrypto> drmSessionManager, boolean z, AudioSink audioSink) {
|
|
super(1);
|
|
this.drmSessionManager = drmSessionManager;
|
|
this.playClearSamplesWithoutKeys = z;
|
|
this.eventDispatcher = new AudioRendererEventListener.EventDispatcher(handler, audioRendererEventListener);
|
|
this.audioSink = audioSink;
|
|
audioSink.setListener(new AudioSinkListener());
|
|
this.formatHolder = new FormatHolder();
|
|
this.flagsOnlyBuffer = DecoderInputBuffer.newFlagsOnlyInstance();
|
|
this.decoderReinitializationState = 0;
|
|
this.audioTrackNeedsConfigure = true;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.RendererCapabilities
|
|
public final int supportsFormat(Format format) {
|
|
int supportsFormatInternal = supportsFormatInternal(this.drmSessionManager, format);
|
|
if (supportsFormatInternal <= 2) {
|
|
return supportsFormatInternal;
|
|
}
|
|
return supportsFormatInternal | (Util.SDK_INT >= 21 ? 32 : 0) | 8;
|
|
}
|
|
|
|
public final boolean supportsOutputEncoding(int i) {
|
|
return this.audioSink.isEncodingSupported(i);
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.Renderer
|
|
public void render(long j, long j2) throws ExoPlaybackException {
|
|
if (this.outputStreamEnded) {
|
|
try {
|
|
this.audioSink.playToEndOfStream();
|
|
return;
|
|
} catch (AudioSink.WriteException e) {
|
|
throw ExoPlaybackException.createForRenderer(e, getIndex());
|
|
}
|
|
}
|
|
if (this.inputFormat == null) {
|
|
this.flagsOnlyBuffer.clear();
|
|
int readSource = readSource(this.formatHolder, this.flagsOnlyBuffer, true);
|
|
if (readSource != -5) {
|
|
if (readSource == -4) {
|
|
Assertions.checkState(this.flagsOnlyBuffer.isEndOfStream());
|
|
this.inputStreamEnded = true;
|
|
processEndOfStream();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
onInputFormatChanged(this.formatHolder.format);
|
|
}
|
|
maybeInitDecoder();
|
|
if (this.decoder != null) {
|
|
try {
|
|
TraceUtil.beginSection("drainAndFeed");
|
|
while (drainOutputBuffer()) {
|
|
}
|
|
while (feedInputBuffer()) {
|
|
}
|
|
TraceUtil.endSection();
|
|
this.decoderCounters.ensureUpdated();
|
|
} catch (AudioDecoderException | AudioSink.ConfigurationException | AudioSink.InitializationException | AudioSink.WriteException e2) {
|
|
throw ExoPlaybackException.createForRenderer(e2, getIndex());
|
|
}
|
|
}
|
|
}
|
|
|
|
public Format getOutputFormat() {
|
|
Format format = this.inputFormat;
|
|
return Format.createAudioSampleFormat(null, MimeTypes.AUDIO_RAW, null, -1, -1, format.channelCount, format.sampleRate, 2, null, null, 0, null);
|
|
}
|
|
|
|
private boolean drainOutputBuffer() throws ExoPlaybackException, AudioDecoderException, AudioSink.ConfigurationException, AudioSink.InitializationException, AudioSink.WriteException {
|
|
if (this.outputBuffer == null) {
|
|
SimpleOutputBuffer dequeueOutputBuffer = this.decoder.dequeueOutputBuffer();
|
|
this.outputBuffer = dequeueOutputBuffer;
|
|
if (dequeueOutputBuffer == null) {
|
|
return false;
|
|
}
|
|
this.decoderCounters.skippedOutputBufferCount += dequeueOutputBuffer.skippedOutputBufferCount;
|
|
}
|
|
if (this.outputBuffer.isEndOfStream()) {
|
|
if (this.decoderReinitializationState == 2) {
|
|
releaseDecoder();
|
|
maybeInitDecoder();
|
|
this.audioTrackNeedsConfigure = true;
|
|
} else {
|
|
this.outputBuffer.release();
|
|
this.outputBuffer = null;
|
|
processEndOfStream();
|
|
}
|
|
return false;
|
|
}
|
|
if (this.audioTrackNeedsConfigure) {
|
|
Format outputFormat = getOutputFormat();
|
|
this.audioSink.configure(outputFormat.pcmEncoding, outputFormat.channelCount, outputFormat.sampleRate, 0, null, this.encoderDelay, this.encoderPadding);
|
|
this.audioTrackNeedsConfigure = false;
|
|
}
|
|
AudioSink audioSink = this.audioSink;
|
|
SimpleOutputBuffer simpleOutputBuffer = this.outputBuffer;
|
|
if (!audioSink.handleBuffer(simpleOutputBuffer.data, simpleOutputBuffer.timeUs)) {
|
|
return false;
|
|
}
|
|
this.decoderCounters.renderedOutputBufferCount++;
|
|
this.outputBuffer.release();
|
|
this.outputBuffer = null;
|
|
return true;
|
|
}
|
|
|
|
private boolean feedInputBuffer() throws AudioDecoderException, ExoPlaybackException {
|
|
SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends AudioDecoderException> simpleDecoder = this.decoder;
|
|
if (simpleDecoder == null || this.decoderReinitializationState == 2 || this.inputStreamEnded) {
|
|
return false;
|
|
}
|
|
if (this.inputBuffer == null) {
|
|
DecoderInputBuffer dequeueInputBuffer = simpleDecoder.dequeueInputBuffer();
|
|
this.inputBuffer = dequeueInputBuffer;
|
|
if (dequeueInputBuffer == null) {
|
|
return false;
|
|
}
|
|
}
|
|
if (this.decoderReinitializationState == 1) {
|
|
this.inputBuffer.setFlags(4);
|
|
this.decoder.queueInputBuffer((SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends AudioDecoderException>) this.inputBuffer);
|
|
this.inputBuffer = null;
|
|
this.decoderReinitializationState = 2;
|
|
return false;
|
|
}
|
|
int readSource = this.waitingForKeys ? -4 : readSource(this.formatHolder, this.inputBuffer, false);
|
|
if (readSource == -3) {
|
|
return false;
|
|
}
|
|
if (readSource == -5) {
|
|
onInputFormatChanged(this.formatHolder.format);
|
|
return true;
|
|
}
|
|
if (this.inputBuffer.isEndOfStream()) {
|
|
this.inputStreamEnded = true;
|
|
this.decoder.queueInputBuffer((SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends AudioDecoderException>) this.inputBuffer);
|
|
this.inputBuffer = null;
|
|
return false;
|
|
}
|
|
boolean shouldWaitForKeys = shouldWaitForKeys(this.inputBuffer.isEncrypted());
|
|
this.waitingForKeys = shouldWaitForKeys;
|
|
if (shouldWaitForKeys) {
|
|
return false;
|
|
}
|
|
this.inputBuffer.flip();
|
|
onQueueInputBuffer(this.inputBuffer);
|
|
this.decoder.queueInputBuffer((SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends AudioDecoderException>) this.inputBuffer);
|
|
this.decoderReceivedBuffers = true;
|
|
this.decoderCounters.inputBufferCount++;
|
|
this.inputBuffer = null;
|
|
return true;
|
|
}
|
|
|
|
private boolean shouldWaitForKeys(boolean z) throws ExoPlaybackException {
|
|
DrmSession<ExoMediaCrypto> drmSession = this.drmSession;
|
|
if (drmSession == null || (!z && this.playClearSamplesWithoutKeys)) {
|
|
return false;
|
|
}
|
|
int state = drmSession.getState();
|
|
if (state != 1) {
|
|
return state != 4;
|
|
}
|
|
throw ExoPlaybackException.createForRenderer(this.drmSession.getError(), getIndex());
|
|
}
|
|
|
|
private void processEndOfStream() throws ExoPlaybackException {
|
|
this.outputStreamEnded = true;
|
|
try {
|
|
this.audioSink.playToEndOfStream();
|
|
} catch (AudioSink.WriteException e) {
|
|
throw ExoPlaybackException.createForRenderer(e, getIndex());
|
|
}
|
|
}
|
|
|
|
private void flushDecoder() throws ExoPlaybackException {
|
|
this.waitingForKeys = false;
|
|
if (this.decoderReinitializationState != 0) {
|
|
releaseDecoder();
|
|
maybeInitDecoder();
|
|
return;
|
|
}
|
|
this.inputBuffer = null;
|
|
SimpleOutputBuffer simpleOutputBuffer = this.outputBuffer;
|
|
if (simpleOutputBuffer != null) {
|
|
simpleOutputBuffer.release();
|
|
this.outputBuffer = null;
|
|
}
|
|
this.decoder.flush();
|
|
this.decoderReceivedBuffers = false;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.Renderer
|
|
public boolean isEnded() {
|
|
return this.outputStreamEnded && this.audioSink.isEnded();
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.Renderer
|
|
public boolean isReady() {
|
|
return this.audioSink.hasPendingData() || !(this.inputFormat == null || this.waitingForKeys || (!isSourceReady() && this.outputBuffer == null));
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.util.MediaClock
|
|
public long getPositionUs() {
|
|
if (getState() == 2) {
|
|
updateCurrentPosition();
|
|
}
|
|
return this.currentPositionUs;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.util.MediaClock
|
|
public PlaybackParameters setPlaybackParameters(PlaybackParameters playbackParameters) {
|
|
return this.audioSink.setPlaybackParameters(playbackParameters);
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.util.MediaClock
|
|
public PlaybackParameters getPlaybackParameters() {
|
|
return this.audioSink.getPlaybackParameters();
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer
|
|
public void onEnabled(boolean z) throws ExoPlaybackException {
|
|
DecoderCounters decoderCounters = new DecoderCounters();
|
|
this.decoderCounters = decoderCounters;
|
|
this.eventDispatcher.enabled(decoderCounters);
|
|
int i = getConfiguration().tunnelingAudioSessionId;
|
|
if (i != 0) {
|
|
this.audioSink.enableTunnelingV21(i);
|
|
} else {
|
|
this.audioSink.disableTunneling();
|
|
}
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer
|
|
public void onPositionReset(long j, boolean z) throws ExoPlaybackException {
|
|
this.audioSink.reset();
|
|
this.currentPositionUs = j;
|
|
this.allowFirstBufferPositionDiscontinuity = true;
|
|
this.allowPositionDiscontinuity = true;
|
|
this.inputStreamEnded = false;
|
|
this.outputStreamEnded = false;
|
|
if (this.decoder != null) {
|
|
flushDecoder();
|
|
}
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer
|
|
public void onStarted() {
|
|
this.audioSink.play();
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer
|
|
public void onStopped() {
|
|
updateCurrentPosition();
|
|
this.audioSink.pause();
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer
|
|
public void onDisabled() {
|
|
this.inputFormat = null;
|
|
this.audioTrackNeedsConfigure = true;
|
|
this.waitingForKeys = false;
|
|
try {
|
|
releaseDecoder();
|
|
this.audioSink.release();
|
|
try {
|
|
DrmSession<ExoMediaCrypto> drmSession = this.drmSession;
|
|
if (drmSession != null) {
|
|
this.drmSessionManager.releaseSession(drmSession);
|
|
}
|
|
try {
|
|
DrmSession<ExoMediaCrypto> drmSession2 = this.pendingDrmSession;
|
|
if (drmSession2 != null && drmSession2 != this.drmSession) {
|
|
this.drmSessionManager.releaseSession(drmSession2);
|
|
}
|
|
} finally {
|
|
}
|
|
} catch (Throwable th) {
|
|
try {
|
|
DrmSession<ExoMediaCrypto> drmSession3 = this.pendingDrmSession;
|
|
if (drmSession3 != null && drmSession3 != this.drmSession) {
|
|
this.drmSessionManager.releaseSession(drmSession3);
|
|
}
|
|
throw th;
|
|
} finally {
|
|
}
|
|
}
|
|
} catch (Throwable th2) {
|
|
try {
|
|
DrmSession<ExoMediaCrypto> drmSession4 = this.drmSession;
|
|
if (drmSession4 != null) {
|
|
this.drmSessionManager.releaseSession(drmSession4);
|
|
}
|
|
try {
|
|
DrmSession<ExoMediaCrypto> drmSession5 = this.pendingDrmSession;
|
|
if (drmSession5 != null && drmSession5 != this.drmSession) {
|
|
this.drmSessionManager.releaseSession(drmSession5);
|
|
}
|
|
throw th2;
|
|
} finally {
|
|
}
|
|
} catch (Throwable th3) {
|
|
try {
|
|
DrmSession<ExoMediaCrypto> drmSession6 = this.pendingDrmSession;
|
|
if (drmSession6 != null && drmSession6 != this.drmSession) {
|
|
this.drmSessionManager.releaseSession(drmSession6);
|
|
}
|
|
throw th3;
|
|
} finally {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.BaseRenderer, com.mbridge.msdk.playercommon.exoplayer2.PlayerMessage.Target
|
|
public void handleMessage(int i, Object obj) throws ExoPlaybackException {
|
|
if (i == 2) {
|
|
this.audioSink.setVolume(((Float) obj).floatValue());
|
|
} else if (i == 3) {
|
|
this.audioSink.setAudioAttributes((AudioAttributes) obj);
|
|
} else {
|
|
super.handleMessage(i, obj);
|
|
}
|
|
}
|
|
|
|
private void maybeInitDecoder() throws ExoPlaybackException {
|
|
ExoMediaCrypto exoMediaCrypto;
|
|
if (this.decoder != null) {
|
|
return;
|
|
}
|
|
DrmSession<ExoMediaCrypto> drmSession = this.pendingDrmSession;
|
|
this.drmSession = drmSession;
|
|
if (drmSession != null) {
|
|
exoMediaCrypto = drmSession.getMediaCrypto();
|
|
if (exoMediaCrypto == null && this.drmSession.getError() == null) {
|
|
return;
|
|
}
|
|
} else {
|
|
exoMediaCrypto = null;
|
|
}
|
|
try {
|
|
long elapsedRealtime = SystemClock.elapsedRealtime();
|
|
TraceUtil.beginSection("createAudioDecoder");
|
|
this.decoder = createDecoder(this.inputFormat, exoMediaCrypto);
|
|
TraceUtil.endSection();
|
|
long elapsedRealtime2 = SystemClock.elapsedRealtime();
|
|
this.eventDispatcher.decoderInitialized(this.decoder.getName(), elapsedRealtime2, elapsedRealtime2 - elapsedRealtime);
|
|
this.decoderCounters.decoderInitCount++;
|
|
} catch (AudioDecoderException e) {
|
|
throw ExoPlaybackException.createForRenderer(e, getIndex());
|
|
}
|
|
}
|
|
|
|
private void releaseDecoder() {
|
|
SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer, ? extends AudioDecoderException> simpleDecoder = this.decoder;
|
|
if (simpleDecoder == null) {
|
|
return;
|
|
}
|
|
this.inputBuffer = null;
|
|
this.outputBuffer = null;
|
|
simpleDecoder.release();
|
|
this.decoder = null;
|
|
this.decoderCounters.decoderReleaseCount++;
|
|
this.decoderReinitializationState = 0;
|
|
this.decoderReceivedBuffers = false;
|
|
}
|
|
|
|
private void onInputFormatChanged(Format format) throws ExoPlaybackException {
|
|
Format format2 = this.inputFormat;
|
|
this.inputFormat = format;
|
|
if (!Util.areEqual(format.drmInitData, format2 == null ? null : format2.drmInitData)) {
|
|
if (this.inputFormat.drmInitData != null) {
|
|
DrmSessionManager<ExoMediaCrypto> drmSessionManager = this.drmSessionManager;
|
|
if (drmSessionManager == null) {
|
|
throw ExoPlaybackException.createForRenderer(new IllegalStateException("Media requires a DrmSessionManager"), getIndex());
|
|
}
|
|
DrmSession<ExoMediaCrypto> acquireSession = drmSessionManager.acquireSession(Looper.myLooper(), this.inputFormat.drmInitData);
|
|
this.pendingDrmSession = acquireSession;
|
|
if (acquireSession == this.drmSession) {
|
|
this.drmSessionManager.releaseSession(acquireSession);
|
|
}
|
|
} else {
|
|
this.pendingDrmSession = null;
|
|
}
|
|
}
|
|
if (this.decoderReceivedBuffers) {
|
|
this.decoderReinitializationState = 1;
|
|
} else {
|
|
releaseDecoder();
|
|
maybeInitDecoder();
|
|
this.audioTrackNeedsConfigure = true;
|
|
}
|
|
this.encoderDelay = format.encoderDelay;
|
|
this.encoderPadding = format.encoderPadding;
|
|
this.eventDispatcher.inputFormatChanged(format);
|
|
}
|
|
|
|
private void onQueueInputBuffer(DecoderInputBuffer decoderInputBuffer) {
|
|
if (!this.allowFirstBufferPositionDiscontinuity || decoderInputBuffer.isDecodeOnly()) {
|
|
return;
|
|
}
|
|
if (Math.abs(decoderInputBuffer.timeUs - this.currentPositionUs) > 500000) {
|
|
this.currentPositionUs = decoderInputBuffer.timeUs;
|
|
}
|
|
this.allowFirstBufferPositionDiscontinuity = false;
|
|
}
|
|
|
|
private void updateCurrentPosition() {
|
|
long currentPositionUs = this.audioSink.getCurrentPositionUs(isEnded());
|
|
if (currentPositionUs != Long.MIN_VALUE) {
|
|
if (!this.allowPositionDiscontinuity) {
|
|
currentPositionUs = Math.max(this.currentPositionUs, currentPositionUs);
|
|
}
|
|
this.currentPositionUs = currentPositionUs;
|
|
this.allowPositionDiscontinuity = false;
|
|
}
|
|
}
|
|
|
|
public final class AudioSinkListener implements AudioSink.Listener {
|
|
private AudioSinkListener() {
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.audio.AudioSink.Listener
|
|
public final void onAudioSessionId(int i) {
|
|
SimpleDecoderAudioRenderer.this.eventDispatcher.audioSessionId(i);
|
|
SimpleDecoderAudioRenderer.this.onAudioSessionId(i);
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.audio.AudioSink.Listener
|
|
public final void onPositionDiscontinuity() {
|
|
SimpleDecoderAudioRenderer.this.onAudioTrackPositionDiscontinuity();
|
|
SimpleDecoderAudioRenderer.this.allowPositionDiscontinuity = true;
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.playercommon.exoplayer2.audio.AudioSink.Listener
|
|
public final void onUnderrun(int i, long j, long j2) {
|
|
SimpleDecoderAudioRenderer.this.eventDispatcher.audioTrackUnderrun(i, j, j2);
|
|
SimpleDecoderAudioRenderer.this.onAudioTrackUnderrun(i, j, j2);
|
|
}
|
|
}
|
|
}
|