Rabbit-R1/original r1/java/sources/androidx/media3/exoplayer/audio/MediaCodecAudioRenderer.java
2024-05-21 17:08:36 -04:00

597 lines
26 KiB
Java

package androidx.media3.exoplayer.audio;
import android.content.Context;
import android.media.AudioDeviceInfo;
import android.media.MediaCrypto;
import android.media.MediaFormat;
import android.os.Handler;
import androidx.media3.common.AudioAttributes;
import androidx.media3.common.AuxEffectInfo;
import androidx.media3.common.Format;
import androidx.media3.common.MimeTypes;
import androidx.media3.common.PlaybackParameters;
import androidx.media3.common.audio.AudioProcessor;
import androidx.media3.common.util.Assertions;
import androidx.media3.common.util.Log;
import androidx.media3.common.util.MediaFormatUtil;
import androidx.media3.common.util.Util;
import androidx.media3.decoder.DecoderInputBuffer;
import androidx.media3.exoplayer.DecoderReuseEvaluation;
import androidx.media3.exoplayer.ExoPlaybackException;
import androidx.media3.exoplayer.FormatHolder;
import androidx.media3.exoplayer.MediaClock;
import androidx.media3.exoplayer.Renderer;
import androidx.media3.exoplayer.RendererCapabilities;
import androidx.media3.exoplayer.audio.AudioRendererEventListener;
import androidx.media3.exoplayer.audio.AudioSink;
import androidx.media3.exoplayer.audio.DefaultAudioSink;
import androidx.media3.exoplayer.mediacodec.MediaCodecAdapter;
import androidx.media3.exoplayer.mediacodec.MediaCodecInfo;
import androidx.media3.exoplayer.mediacodec.MediaCodecRenderer;
import androidx.media3.exoplayer.mediacodec.MediaCodecSelector;
import androidx.media3.exoplayer.mediacodec.MediaCodecUtil;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import io.sentry.protocol.SentryThread;
import java.nio.ByteBuffer;
import java.util.List;
/* loaded from: classes2.dex */
public class MediaCodecAudioRenderer extends MediaCodecRenderer implements MediaClock {
private static final String TAG = "MediaCodecAudioRenderer";
private static final String VIVO_BITS_PER_SAMPLE_KEY = "v-bits-per-sample";
private boolean allowFirstBufferPositionDiscontinuity;
private boolean allowPositionDiscontinuity;
private final AudioSink audioSink;
private boolean audioSinkNeedsReset;
private int codecMaxInputSize;
private boolean codecNeedsDiscardChannelsWorkaround;
private final Context context;
private long currentPositionUs;
private Format decryptOnlyCodecFormat;
private final AudioRendererEventListener.EventDispatcher eventDispatcher;
private boolean experimentalKeepAudioTrackOnSeek;
private Format inputFormat;
private Renderer.WakeupListener wakeupListener;
public void experimentalSetEnableKeepAudioTrackOnSeek(boolean z) {
this.experimentalKeepAudioTrackOnSeek = z;
}
@Override // androidx.media3.exoplayer.BaseRenderer, androidx.media3.exoplayer.Renderer
public MediaClock getMediaClock() {
return this;
}
@Override // androidx.media3.exoplayer.Renderer, androidx.media3.exoplayer.RendererCapabilities
public String getName() {
return TAG;
}
protected void onPositionDiscontinuity() {
this.allowPositionDiscontinuity = true;
}
public MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector) {
this(context, mediaCodecSelector, null, null);
}
public MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector, Handler handler, AudioRendererEventListener audioRendererEventListener) {
this(context, mediaCodecSelector, handler, audioRendererEventListener, AudioCapabilities.DEFAULT_AUDIO_CAPABILITIES, new AudioProcessor[0]);
}
public MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector, Handler handler, AudioRendererEventListener audioRendererEventListener, AudioCapabilities audioCapabilities, AudioProcessor... audioProcessorArr) {
this(context, mediaCodecSelector, handler, audioRendererEventListener, new DefaultAudioSink.Builder().setAudioCapabilities((AudioCapabilities) MoreObjects.firstNonNull(audioCapabilities, AudioCapabilities.DEFAULT_AUDIO_CAPABILITIES)).setAudioProcessors(audioProcessorArr).build());
}
public MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector, Handler handler, AudioRendererEventListener audioRendererEventListener, AudioSink audioSink) {
this(context, MediaCodecAdapter.Factory.DEFAULT, mediaCodecSelector, false, handler, audioRendererEventListener, audioSink);
}
public MediaCodecAudioRenderer(Context context, MediaCodecSelector mediaCodecSelector, boolean z, Handler handler, AudioRendererEventListener audioRendererEventListener, AudioSink audioSink) {
this(context, MediaCodecAdapter.Factory.DEFAULT, mediaCodecSelector, z, handler, audioRendererEventListener, audioSink);
}
public MediaCodecAudioRenderer(Context context, MediaCodecAdapter.Factory factory, MediaCodecSelector mediaCodecSelector, boolean z, Handler handler, AudioRendererEventListener audioRendererEventListener, AudioSink audioSink) {
super(1, factory, mediaCodecSelector, z, 44100.0f);
this.context = context.getApplicationContext();
this.audioSink = audioSink;
this.eventDispatcher = new AudioRendererEventListener.EventDispatcher(handler, audioRendererEventListener);
audioSink.setListener(new AudioSinkListener());
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
protected int supportsFormat(MediaCodecSelector mediaCodecSelector, Format format) throws MediaCodecUtil.DecoderQueryException {
boolean z;
if (!MimeTypes.isAudio(format.sampleMimeType)) {
return RendererCapabilities.create(0);
}
int i = Util.SDK_INT >= 21 ? 32 : 0;
boolean z2 = true;
boolean z3 = format.cryptoType != 0;
boolean supportsFormatDrm = supportsFormatDrm(format);
int i2 = 8;
if (supportsFormatDrm && this.audioSink.supportsFormat(format) && (!z3 || MediaCodecUtil.getDecryptOnlyDecoderInfo() != null)) {
return RendererCapabilities.create(4, 8, i);
}
if ("audio/raw".equals(format.sampleMimeType) && !this.audioSink.supportsFormat(format)) {
return RendererCapabilities.create(1);
}
if (!this.audioSink.supportsFormat(Util.getPcmFormat(2, format.channelCount, format.sampleRate))) {
return RendererCapabilities.create(1);
}
List<MediaCodecInfo> decoderInfos = getDecoderInfos(mediaCodecSelector, format, false, this.audioSink);
if (decoderInfos.isEmpty()) {
return RendererCapabilities.create(1);
}
if (!supportsFormatDrm) {
return RendererCapabilities.create(2);
}
MediaCodecInfo mediaCodecInfo = decoderInfos.get(0);
boolean isFormatSupported = mediaCodecInfo.isFormatSupported(format);
if (!isFormatSupported) {
for (int i3 = 1; i3 < decoderInfos.size(); i3++) {
MediaCodecInfo mediaCodecInfo2 = decoderInfos.get(i3);
if (mediaCodecInfo2.isFormatSupported(format)) {
z = false;
mediaCodecInfo = mediaCodecInfo2;
break;
}
}
}
z = true;
z2 = isFormatSupported;
int i4 = z2 ? 4 : 3;
if (z2 && mediaCodecInfo.isSeamlessAdaptationSupported(format)) {
i2 = 16;
}
return RendererCapabilities.create(i4, i2, i, mediaCodecInfo.hardwareAccelerated ? 64 : 0, z ? 128 : 0);
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
protected List<MediaCodecInfo> getDecoderInfos(MediaCodecSelector mediaCodecSelector, Format format, boolean z) throws MediaCodecUtil.DecoderQueryException {
return MediaCodecUtil.getDecoderInfosSortedByFormatSupport(getDecoderInfos(mediaCodecSelector, format, z, this.audioSink), format);
}
private static List<MediaCodecInfo> getDecoderInfos(MediaCodecSelector mediaCodecSelector, Format format, boolean z, AudioSink audioSink) throws MediaCodecUtil.DecoderQueryException {
MediaCodecInfo decryptOnlyDecoderInfo;
if (format.sampleMimeType == null) {
return ImmutableList.of();
}
if (audioSink.supportsFormat(format) && (decryptOnlyDecoderInfo = MediaCodecUtil.getDecryptOnlyDecoderInfo()) != null) {
return ImmutableList.of(decryptOnlyDecoderInfo);
}
return MediaCodecUtil.getDecoderInfosSoftMatch(mediaCodecSelector, format, z, false);
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
protected boolean shouldUseBypass(Format format) {
return this.audioSink.supportsFormat(format);
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
protected MediaCodecAdapter.Configuration getMediaCodecConfiguration(MediaCodecInfo mediaCodecInfo, Format format, MediaCrypto mediaCrypto, float f) {
this.codecMaxInputSize = getCodecMaxInputSize(mediaCodecInfo, format, getStreamFormats());
this.codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(mediaCodecInfo.name);
MediaFormat mediaFormat = getMediaFormat(format, mediaCodecInfo.codecMimeType, this.codecMaxInputSize, f);
this.decryptOnlyCodecFormat = (!"audio/raw".equals(mediaCodecInfo.mimeType) || "audio/raw".equals(format.sampleMimeType)) ? null : format;
return MediaCodecAdapter.Configuration.createForAudioDecoding(mediaCodecInfo, mediaFormat, format, mediaCrypto);
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
protected DecoderReuseEvaluation canReuseCodec(MediaCodecInfo mediaCodecInfo, Format format, Format format2) {
DecoderReuseEvaluation canReuseCodec = mediaCodecInfo.canReuseCodec(format, format2);
int i = canReuseCodec.discardReasons;
if (isBypassPossible(format2)) {
i |= 32768;
}
if (getCodecMaxInputSize(mediaCodecInfo, format2) > this.codecMaxInputSize) {
i |= 64;
}
int i2 = i;
return new DecoderReuseEvaluation(mediaCodecInfo.name, format, format2, i2 != 0 ? 0 : canReuseCodec.result, i2);
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
protected float getCodecOperatingRateV23(float f, Format format, Format[] formatArr) {
int i = -1;
for (Format format2 : formatArr) {
int i2 = format2.sampleRate;
if (i2 != -1) {
i = Math.max(i, i2);
}
}
if (i == -1) {
return -1.0f;
}
return i * f;
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
protected void onCodecInitialized(String str, MediaCodecAdapter.Configuration configuration, long j, long j2) {
this.eventDispatcher.decoderInitialized(str, j, j2);
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
protected void onCodecReleased(String str) {
this.eventDispatcher.decoderReleased(str);
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
protected void onCodecError(Exception exc) {
Log.e(TAG, "Audio codec error", exc);
this.eventDispatcher.audioCodecError(exc);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
public DecoderReuseEvaluation onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException {
this.inputFormat = (Format) Assertions.checkNotNull(formatHolder.format);
DecoderReuseEvaluation onInputFormatChanged = super.onInputFormatChanged(formatHolder);
this.eventDispatcher.inputFormatChanged(this.inputFormat, onInputFormatChanged);
return onInputFormatChanged;
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
protected void onOutputFormatChanged(Format format, MediaFormat mediaFormat) throws ExoPlaybackException {
int pcmEncoding;
Format format2 = this.decryptOnlyCodecFormat;
int[] iArr = null;
if (format2 != null) {
format = format2;
} else if (getCodec() != null) {
if ("audio/raw".equals(format.sampleMimeType)) {
pcmEncoding = format.pcmEncoding;
} else if (Util.SDK_INT >= 24 && mediaFormat.containsKey("pcm-encoding")) {
pcmEncoding = mediaFormat.getInteger("pcm-encoding");
} else {
pcmEncoding = mediaFormat.containsKey(VIVO_BITS_PER_SAMPLE_KEY) ? Util.getPcmEncoding(mediaFormat.getInteger(VIVO_BITS_PER_SAMPLE_KEY)) : 2;
}
Format build = new Format.Builder().setSampleMimeType("audio/raw").setPcmEncoding(pcmEncoding).setEncoderDelay(format.encoderDelay).setEncoderPadding(format.encoderPadding).setChannelCount(mediaFormat.getInteger("channel-count")).setSampleRate(mediaFormat.getInteger("sample-rate")).build();
if (this.codecNeedsDiscardChannelsWorkaround && build.channelCount == 6 && format.channelCount < 6) {
iArr = new int[format.channelCount];
for (int i = 0; i < format.channelCount; i++) {
iArr[i] = i;
}
}
format = build;
}
try {
this.audioSink.configure(format, 0, iArr);
} catch (AudioSink.ConfigurationException e) {
throw createRendererException(e, e.format, 5001);
}
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer, androidx.media3.exoplayer.BaseRenderer
public void onEnabled(boolean z, boolean z2) throws ExoPlaybackException {
super.onEnabled(z, z2);
this.eventDispatcher.enabled(this.decoderCounters);
if (getConfiguration().tunneling) {
this.audioSink.enableTunnelingV21();
} else {
this.audioSink.disableTunneling();
}
this.audioSink.setPlayerId(getPlayerId());
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer, androidx.media3.exoplayer.BaseRenderer
public void onPositionReset(long j, boolean z) throws ExoPlaybackException {
super.onPositionReset(j, z);
if (this.experimentalKeepAudioTrackOnSeek) {
this.audioSink.experimentalFlushWithoutAudioTrackRelease();
} else {
this.audioSink.flush();
}
this.currentPositionUs = j;
this.allowFirstBufferPositionDiscontinuity = true;
this.allowPositionDiscontinuity = true;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer, androidx.media3.exoplayer.BaseRenderer
public void onStarted() {
super.onStarted();
this.audioSink.play();
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer, androidx.media3.exoplayer.BaseRenderer
public void onStopped() {
updateCurrentPosition();
this.audioSink.pause();
super.onStopped();
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer, androidx.media3.exoplayer.BaseRenderer
public void onDisabled() {
this.audioSinkNeedsReset = true;
this.inputFormat = null;
try {
this.audioSink.flush();
try {
super.onDisabled();
} finally {
}
} catch (Throwable th) {
try {
super.onDisabled();
throw th;
} finally {
}
}
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer, androidx.media3.exoplayer.BaseRenderer
public void onReset() {
try {
super.onReset();
} finally {
if (this.audioSinkNeedsReset) {
this.audioSinkNeedsReset = false;
this.audioSink.reset();
}
}
}
@Override // androidx.media3.exoplayer.BaseRenderer
protected void onRelease() {
this.audioSink.release();
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer, androidx.media3.exoplayer.Renderer
public boolean isEnded() {
return super.isEnded() && this.audioSink.isEnded();
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer, androidx.media3.exoplayer.Renderer
public boolean isReady() {
return this.audioSink.hasPendingData() || super.isReady();
}
@Override // androidx.media3.exoplayer.MediaClock
public long getPositionUs() {
if (getState() == 2) {
updateCurrentPosition();
}
return this.currentPositionUs;
}
@Override // androidx.media3.exoplayer.MediaClock
public void setPlaybackParameters(PlaybackParameters playbackParameters) {
this.audioSink.setPlaybackParameters(playbackParameters);
}
@Override // androidx.media3.exoplayer.MediaClock
public PlaybackParameters getPlaybackParameters() {
return this.audioSink.getPlaybackParameters();
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
protected 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;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
public void onProcessedStreamChange() {
super.onProcessedStreamChange();
this.audioSink.handleDiscontinuity();
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
protected boolean processOutputBuffer(long j, long j2, MediaCodecAdapter mediaCodecAdapter, ByteBuffer byteBuffer, int i, int i2, int i3, long j3, boolean z, boolean z2, Format format) throws ExoPlaybackException {
Assertions.checkNotNull(byteBuffer);
if (this.decryptOnlyCodecFormat != null && (i2 & 2) != 0) {
((MediaCodecAdapter) Assertions.checkNotNull(mediaCodecAdapter)).releaseOutputBuffer(i, false);
return true;
}
if (z) {
if (mediaCodecAdapter != null) {
mediaCodecAdapter.releaseOutputBuffer(i, false);
}
this.decoderCounters.skippedOutputBufferCount += i3;
this.audioSink.handleDiscontinuity();
return true;
}
try {
if (!this.audioSink.handleBuffer(byteBuffer, j3, i3)) {
return false;
}
if (mediaCodecAdapter != null) {
mediaCodecAdapter.releaseOutputBuffer(i, false);
}
this.decoderCounters.renderedOutputBufferCount += i3;
return true;
} catch (AudioSink.InitializationException e) {
throw createRendererException(e, this.inputFormat, e.isRecoverable, 5001);
} catch (AudioSink.WriteException e2) {
throw createRendererException(e2, format, e2.isRecoverable, 5002);
}
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
protected void renderToEndOfStream() throws ExoPlaybackException {
try {
this.audioSink.playToEndOfStream();
} catch (AudioSink.WriteException e) {
throw createRendererException(e, e.format, e.isRecoverable, 5002);
}
}
@Override // androidx.media3.exoplayer.mediacodec.MediaCodecRenderer
protected void onOutputStreamOffsetUsChanged(long j) {
this.audioSink.setOutputStreamOffsetUs(j);
}
@Override // androidx.media3.exoplayer.BaseRenderer, androidx.media3.exoplayer.PlayerMessage.Target
public void handleMessage(int i, Object obj) throws ExoPlaybackException {
if (i == 2) {
this.audioSink.setVolume(((Float) obj).floatValue());
return;
}
if (i == 3) {
this.audioSink.setAudioAttributes((AudioAttributes) obj);
return;
}
if (i == 6) {
this.audioSink.setAuxEffectInfo((AuxEffectInfo) obj);
return;
}
switch (i) {
case 9:
this.audioSink.setSkipSilenceEnabled(((Boolean) obj).booleanValue());
return;
case 10:
this.audioSink.setAudioSessionId(((Integer) obj).intValue());
return;
case 11:
this.wakeupListener = (Renderer.WakeupListener) obj;
return;
case 12:
if (Util.SDK_INT >= 23) {
Api23.setAudioSinkPreferredDevice(this.audioSink, obj);
return;
}
return;
default:
super.handleMessage(i, obj);
return;
}
}
protected int getCodecMaxInputSize(MediaCodecInfo mediaCodecInfo, Format format, Format[] formatArr) {
int codecMaxInputSize = getCodecMaxInputSize(mediaCodecInfo, format);
if (formatArr.length == 1) {
return codecMaxInputSize;
}
for (Format format2 : formatArr) {
if (mediaCodecInfo.canReuseCodec(format, format2).result != 0) {
codecMaxInputSize = Math.max(codecMaxInputSize, getCodecMaxInputSize(mediaCodecInfo, format2));
}
}
return codecMaxInputSize;
}
private int getCodecMaxInputSize(MediaCodecInfo mediaCodecInfo, Format format) {
if (!"OMX.google.raw.decoder".equals(mediaCodecInfo.name) || Util.SDK_INT >= 24 || (Util.SDK_INT == 23 && Util.isTv(this.context))) {
return format.maxInputSize;
}
return -1;
}
protected MediaFormat getMediaFormat(Format format, String str, int i, float f) {
MediaFormat mediaFormat = new MediaFormat();
mediaFormat.setString("mime", str);
mediaFormat.setInteger("channel-count", format.channelCount);
mediaFormat.setInteger("sample-rate", format.sampleRate);
MediaFormatUtil.setCsdBuffers(mediaFormat, format.initializationData);
MediaFormatUtil.maybeSetInteger(mediaFormat, "max-input-size", i);
if (Util.SDK_INT >= 23) {
mediaFormat.setInteger(SentryThread.JsonKeys.PRIORITY, 0);
if (f != -1.0f && !deviceDoesntSupportOperatingRate()) {
mediaFormat.setFloat("operating-rate", f);
}
}
if (Util.SDK_INT <= 28 && "audio/ac4".equals(format.sampleMimeType)) {
mediaFormat.setInteger("ac4-is-sync", 1);
}
if (Util.SDK_INT >= 24 && this.audioSink.getFormatSupport(Util.getPcmFormat(4, format.channelCount, format.sampleRate)) == 2) {
mediaFormat.setInteger("pcm-encoding", 4);
}
if (Util.SDK_INT >= 32) {
mediaFormat.setInteger("max-output-channel-count", 99);
}
return mediaFormat;
}
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;
}
}
private static boolean deviceDoesntSupportOperatingRate() {
return Util.SDK_INT == 23 && ("ZTE B2017G".equals(Util.MODEL) || "AXON 7 mini".equals(Util.MODEL));
}
private static boolean codecNeedsDiscardChannelsWorkaround(String str) {
return Util.SDK_INT < 24 && "OMX.SEC.aac.dec".equals(str) && "samsung".equals(Util.MANUFACTURER) && (Util.DEVICE.startsWith("zeroflte") || Util.DEVICE.startsWith("herolte") || Util.DEVICE.startsWith("heroqlte"));
}
/* loaded from: classes2.dex */
private final class AudioSinkListener implements AudioSink.Listener {
private AudioSinkListener() {
}
@Override // androidx.media3.exoplayer.audio.AudioSink.Listener
public void onPositionDiscontinuity() {
MediaCodecAudioRenderer.this.onPositionDiscontinuity();
}
@Override // androidx.media3.exoplayer.audio.AudioSink.Listener
public void onPositionAdvancing(long j) {
MediaCodecAudioRenderer.this.eventDispatcher.positionAdvancing(j);
}
@Override // androidx.media3.exoplayer.audio.AudioSink.Listener
public void onUnderrun(int i, long j, long j2) {
MediaCodecAudioRenderer.this.eventDispatcher.underrun(i, j, j2);
}
@Override // androidx.media3.exoplayer.audio.AudioSink.Listener
public void onSkipSilenceEnabledChanged(boolean z) {
MediaCodecAudioRenderer.this.eventDispatcher.skipSilenceEnabledChanged(z);
}
@Override // androidx.media3.exoplayer.audio.AudioSink.Listener
public void onOffloadBufferEmptying() {
if (MediaCodecAudioRenderer.this.wakeupListener != null) {
MediaCodecAudioRenderer.this.wakeupListener.onWakeup();
}
}
@Override // androidx.media3.exoplayer.audio.AudioSink.Listener
public void onOffloadBufferFull() {
if (MediaCodecAudioRenderer.this.wakeupListener != null) {
MediaCodecAudioRenderer.this.wakeupListener.onSleep();
}
}
@Override // androidx.media3.exoplayer.audio.AudioSink.Listener
public void onAudioSinkError(Exception exc) {
Log.e(MediaCodecAudioRenderer.TAG, "Audio sink error", exc);
MediaCodecAudioRenderer.this.eventDispatcher.audioSinkError(exc);
}
@Override // androidx.media3.exoplayer.audio.AudioSink.Listener
public void onAudioCapabilitiesChanged() {
MediaCodecAudioRenderer.this.onRendererCapabilitiesChanged();
}
}
/* loaded from: classes2.dex */
private static final class Api23 {
private Api23() {
}
public static void setAudioSinkPreferredDevice(AudioSink audioSink, Object obj) {
audioSink.setPreferredDevice((AudioDeviceInfo) obj);
}
}
}