package com.google.android.exoplayer2.mediacodec;

import android.annotation.TargetApi;
import android.media.MediaCodec;
import android.media.MediaCrypto;
import android.media.MediaCryptoException;
import android.media.MediaFormat;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.drm.DrmSession;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
import java.nio.ByteBuffer;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import p000.p001.p002.p003.p004.C0567;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p190.AbstractC3413;
import p138.p176.p177.p190.C3414;
import p138.p176.p177.p190.C3431;
import p138.p176.p177.p190.C3433;
import p138.p176.p177.p190.p193.C3510;
import p138.p176.p177.p190.p193.C3511;
import p138.p176.p177.p190.p194.C3530;
import p138.p176.p177.p190.p194.C3542;
import p138.p176.p177.p190.p194.InterfaceC3532;
import p138.p176.p177.p190.p209.C3707;
import p138.p176.p177.p190.p209.InterfaceC3708;
import p138.p176.p177.p190.p239.C4131;
import p138.p176.p177.p190.p239.C4136;
import p138.p176.p177.p190.p239.C4148;
import p138.p176.p177.p190.p239.C4150;

/* JADX INFO: loaded from: classes.dex */
public abstract class MediaCodecRenderer extends AbstractC3413 {

    /* JADX INFO: renamed from: ၶ, reason: contains not printable characters */
    public static final byte[] f1667 = {0, 0, 1, 103, 66, -64, 11, -38, 37, -112, 0, 0, 1, 104, -50, 15, 19, 32, 0, 0, 1, 101, -120, -124, 13, -50, 113, 24, -96, 0, 47, -65, 28, 49, -61, 39, 93, 120};

    /* JADX INFO: renamed from: ގ, reason: contains not printable characters */
    public final InterfaceC3708 f1668;

    /* JADX INFO: renamed from: ޏ, reason: contains not printable characters */
    public final InterfaceC3532<C3542> f1669;

    /* JADX INFO: renamed from: ސ, reason: contains not printable characters */
    public final boolean f1670;

    /* JADX INFO: renamed from: ޑ, reason: contains not printable characters */
    public final boolean f1671;

    /* JADX INFO: renamed from: ޒ, reason: contains not printable characters */
    public final float f1672;

    /* JADX INFO: renamed from: ޓ, reason: contains not printable characters */
    public final C3511 f1673;

    /* JADX INFO: renamed from: ޔ, reason: contains not printable characters */
    public final C3511 f1674;

    /* JADX INFO: renamed from: ޕ, reason: contains not printable characters */
    public final C4148<C3431> f1675;

    /* JADX INFO: renamed from: ޖ, reason: contains not printable characters */
    public final ArrayList<Long> f1676;

    /* JADX INFO: renamed from: ޗ, reason: contains not printable characters */
    public final MediaCodec.BufferInfo f1677;

    /* JADX INFO: renamed from: ޘ, reason: contains not printable characters */
    public boolean f1678;

    /* JADX INFO: renamed from: ޙ, reason: contains not printable characters */
    public C3431 f1679;

    /* JADX INFO: renamed from: ޚ, reason: contains not printable characters */
    public C3431 f1680;

    /* JADX INFO: renamed from: ޛ, reason: contains not printable characters */
    public DrmSession<C3542> f1681;

    /* JADX INFO: renamed from: ޜ, reason: contains not printable characters */
    public DrmSession<C3542> f1682;

    /* JADX INFO: renamed from: ޝ, reason: contains not printable characters */
    public MediaCrypto f1683;

    /* JADX INFO: renamed from: ޞ, reason: contains not printable characters */
    public boolean f1684;

    /* JADX INFO: renamed from: ޟ, reason: contains not printable characters */
    public long f1685;

    /* JADX INFO: renamed from: ޠ, reason: contains not printable characters */
    public float f1686;

    /* JADX INFO: renamed from: ޡ, reason: contains not printable characters */
    public MediaCodec f1687;

    /* JADX INFO: renamed from: ޢ, reason: contains not printable characters */
    public C3431 f1688;

    /* JADX INFO: renamed from: ޣ, reason: contains not printable characters */
    public float f1689;

    /* JADX INFO: renamed from: ޤ, reason: contains not printable characters */
    public ArrayDeque<C3707> f1690;

    /* JADX INFO: renamed from: ޥ, reason: contains not printable characters */
    public DecoderInitializationException f1691;

    /* JADX INFO: renamed from: ޱ, reason: contains not printable characters */
    public C3707 f1692;

    /* JADX INFO: renamed from: ࢠ, reason: contains not printable characters */
    public int f1693;

    /* JADX INFO: renamed from: ࢢ, reason: contains not printable characters */
    public boolean f1694;

    /* JADX INFO: renamed from: ࢣ, reason: contains not printable characters */
    public boolean f1695;

    /* JADX INFO: renamed from: ࢤ, reason: contains not printable characters */
    public boolean f1696;

    /* JADX INFO: renamed from: ࢥ, reason: contains not printable characters */
    public boolean f1697;

    /* JADX INFO: renamed from: ࢦ, reason: contains not printable characters */
    public boolean f1698;

    /* JADX INFO: renamed from: ࢧ, reason: contains not printable characters */
    public boolean f1699;

    /* JADX INFO: renamed from: ࢨ, reason: contains not printable characters */
    public boolean f1700;

    /* JADX INFO: renamed from: ࢩ, reason: contains not printable characters */
    public boolean f1701;

    /* JADX INFO: renamed from: ࢪ, reason: contains not printable characters */
    public boolean f1702;

    /* JADX INFO: renamed from: ࢫ, reason: contains not printable characters */
    public boolean f1703;

    /* JADX INFO: renamed from: ࢬ, reason: contains not printable characters */
    public ByteBuffer[] f1704;

    /* JADX INFO: renamed from: ೱ, reason: contains not printable characters */
    public ByteBuffer[] f1705;

    /* JADX INFO: renamed from: ೲ, reason: contains not printable characters */
    public long f1706;

    /* JADX INFO: renamed from: ഩ, reason: contains not printable characters */
    public int f1707;

    /* JADX INFO: renamed from: ഺ, reason: contains not printable characters */
    public int f1708;

    /* JADX INFO: renamed from: ൎ, reason: contains not printable characters */
    public ByteBuffer f1709;

    /* JADX INFO: renamed from: ໞ, reason: contains not printable characters */
    public boolean f1710;

    /* JADX INFO: renamed from: ໟ, reason: contains not printable characters */
    public boolean f1711;

    /* JADX INFO: renamed from: ྈ, reason: contains not printable characters */
    public boolean f1712;

    /* JADX INFO: renamed from: ྉ, reason: contains not printable characters */
    public int f1713;

    /* JADX INFO: renamed from: ྌ, reason: contains not printable characters */
    public int f1714;

    /* JADX INFO: renamed from: ဢ, reason: contains not printable characters */
    public int f1715;

    /* JADX INFO: renamed from: ဨ, reason: contains not printable characters */
    public boolean f1716;

    /* JADX INFO: renamed from: ၚ, reason: contains not printable characters */
    public boolean f1717;

    /* JADX INFO: renamed from: ၛ, reason: contains not printable characters */
    public boolean f1718;

    /* JADX INFO: renamed from: ၜ, reason: contains not printable characters */
    public long f1719;

    /* JADX INFO: renamed from: ၝ, reason: contains not printable characters */
    public long f1720;

    /* JADX INFO: renamed from: ၡ, reason: contains not printable characters */
    public boolean f1721;

    /* JADX INFO: renamed from: ၥ, reason: contains not printable characters */
    public boolean f1722;

    /* JADX INFO: renamed from: ၦ, reason: contains not printable characters */
    public boolean f1723;

    /* JADX INFO: renamed from: ၮ, reason: contains not printable characters */
    public boolean f1724;

    /* JADX INFO: renamed from: ၯ, reason: contains not printable characters */
    public boolean f1725;

    /* JADX INFO: renamed from: ၰ, reason: contains not printable characters */
    public boolean f1726;

    /* JADX INFO: renamed from: ၵ, reason: contains not printable characters */
    public C3510 f1727;

    public static class DecoderException extends Exception {
    }

    public static class DecoderInitializationException extends Exception {

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public final String f1728;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public final boolean f1729;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public final C3707 f1730;

        /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
        public final String f1731;

        public DecoderInitializationException(String str, Throwable th, String str2, boolean z, C3707 c3707, String str3, DecoderInitializationException decoderInitializationException) {
            super(str, th);
            this.f1728 = str2;
            this.f1729 = z;
            this.f1730 = c3707;
            this.f1731 = str3;
        }

        /* JADX WARN: Illegal instructions before constructor call */
        public DecoderInitializationException(C3431 c3431, Throwable th, boolean z, int i) {
            String str = "Decoder init failed: [" + i + "], " + c3431;
            String str2 = c3431.f10090;
            StringBuilder sbM4897 = C2803.m4897("com.google.android.exoplayer2.mediacodec.MediaCodecRenderer_", i < 0 ? "neg_" : "");
            sbM4897.append(Math.abs(i));
            this(str, th, str2, z, null, sbM4897.toString(), null);
        }
    }

    public MediaCodecRenderer(int i, InterfaceC3708 interfaceC3708, InterfaceC3532<C3542> interfaceC3532, boolean z, boolean z2, float f) {
        super(i);
        if (interfaceC3708 == null) {
            throw null;
        }
        this.f1668 = interfaceC3708;
        this.f1669 = interfaceC3532;
        this.f1670 = z;
        this.f1671 = z2;
        this.f1672 = f;
        this.f1673 = new C3511(0);
        this.f1674 = new C3511(0);
        this.f1675 = new C4148<>();
        this.f1676 = new ArrayList<>();
        this.f1677 = new MediaCodec.BufferInfo();
        this.f1713 = 0;
        this.f1714 = 0;
        this.f1715 = 0;
        this.f1689 = -1.0f;
        this.f1686 = 1.0f;
        this.f1685 = -9223372036854775807L;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public abstract float mo1143(float f, C3431 c3431, C3431[] c3431Arr);

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public abstract int mo1144(MediaCodec mediaCodec, C3707 c3707, C3431 c3431, C3431 c34312);

    @Override // p138.p176.p177.p190.AbstractC3413
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final int mo1145(C3431 c3431) throws ExoPlaybackException {
        try {
            return mo1146(this.f1668, this.f1669, c3431);
        } catch (MediaCodecUtil.DecoderQueryException e) {
            throw m5439(e, c3431);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public abstract int mo1146(InterfaceC3708 interfaceC3708, InterfaceC3532<C3542> interfaceC3532, C3431 c3431);

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public abstract List<C3707> mo1147(InterfaceC3708 interfaceC3708, C3431 c3431, boolean z);

    @Override // p138.p176.p177.p190.AbstractC3413, p138.p176.p177.p190.InterfaceC3450
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void mo1148(float f) throws ExoPlaybackException {
        this.f1686 = f;
        if (this.f1687 == null || this.f1715 == 3 || this.f9965 == 0) {
            return;
        }
        m1185();
    }

    @Override // p138.p176.p177.p190.InterfaceC3450
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo1149(long j, long j2) throws ExoPlaybackException {
        boolean z = false;
        if (this.f1726) {
            this.f1726 = false;
            m1180();
        }
        boolean z2 = true;
        try {
            if (this.f1722) {
                mo1182();
                return;
            }
            if (this.f1679 != null || m1168(true)) {
                m1179();
                if (this.f1687 != null) {
                    long jElapsedRealtime = SystemClock.elapsedRealtime();
                    C0567.m1892("drainAndFeed");
                    while (m1167(j, j2)) {
                    }
                    while (m1175()) {
                        if (!(this.f1685 == -9223372036854775807L || SystemClock.elapsedRealtime() - jElapsedRealtime < this.f1685)) {
                            break;
                        }
                    }
                    C0567.m1913();
                } else {
                    this.f1727.f10454 += this.f9966.mo6118(j - this.f9968);
                    m1168(false);
                }
                this.f1727.m5809();
            }
        } catch (IllegalStateException e) {
            if (C4150.f13259 < 21 || !(e instanceof MediaCodec.CodecException)) {
                StackTraceElement[] stackTrace = e.getStackTrace();
                if (stackTrace.length > 0 && stackTrace[0].getClassName().equals("android.media.MediaCodec")) {
                    z = true;
                }
                z2 = z;
            }
            if (!z2) {
                throw e;
            }
            throw m5439(e, this.f1679);
        }
    }

    @Override // p138.p176.p177.p190.AbstractC3413
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo1150(long j, boolean z) throws ExoPlaybackException {
        this.f1721 = false;
        this.f1722 = false;
        this.f1726 = false;
        m1176();
        this.f1675.m6731();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public abstract void mo1151(MediaCodec mediaCodec, MediaFormat mediaFormat);

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m1152(MediaCrypto mediaCrypto, boolean z) throws DecoderInitializationException {
        if (this.f1690 == null) {
            try {
                List<C3707> listM1162 = m1162(z);
                ArrayDeque<C3707> arrayDeque = new ArrayDeque<>();
                this.f1690 = arrayDeque;
                if (this.f1671) {
                    arrayDeque.addAll(listM1162);
                } else if (!listM1162.isEmpty()) {
                    this.f1690.add(listM1162.get(0));
                }
                this.f1691 = null;
            } catch (MediaCodecUtil.DecoderQueryException e) {
                throw new DecoderInitializationException(this.f1679, e, z, -49998);
            }
        }
        if (this.f1690.isEmpty()) {
            throw new DecoderInitializationException(this.f1679, null, z, -49999);
        }
        while (this.f1687 == null) {
            C3707 c3707PeekFirst = this.f1690.peekFirst();
            if (!mo1161(c3707PeekFirst)) {
                return;
            }
            try {
                m1158(c3707PeekFirst, mediaCrypto);
            } catch (Exception e2) {
                C4131.m6646("MediaCodecRenderer", "Failed to initialize decoder: " + c3707PeekFirst, e2);
                this.f1690.removeFirst();
                C3431 c3431 = this.f1679;
                StringBuilder sbM4889 = C2803.m4889("Decoder init failed: ");
                sbM4889.append(c3707PeekFirst.f11431);
                sbM4889.append(", ");
                sbM4889.append(c3431);
                DecoderInitializationException decoderInitializationException = new DecoderInitializationException(sbM4889.toString(), e2, c3431.f10090, z, c3707PeekFirst, (C4150.f13259 < 21 || !(e2 instanceof MediaCodec.CodecException)) ? null : ((MediaCodec.CodecException) e2).getDiagnosticInfo(), null);
                DecoderInitializationException decoderInitializationException2 = this.f1691;
                if (decoderInitializationException2 == null) {
                    this.f1691 = decoderInitializationException;
                } else {
                    this.f1691 = new DecoderInitializationException(decoderInitializationException2.getMessage(), decoderInitializationException2.getCause(), decoderInitializationException2.f1728, decoderInitializationException2.f1729, decoderInitializationException2.f1730, decoderInitializationException2.f1731, decoderInitializationException);
                }
                if (this.f1690.isEmpty()) {
                    throw this.f1691;
                }
            }
        }
        this.f1690 = null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m1153(DrmSession<C3542> drmSession) {
        C3530.m5828(this.f1681, drmSession);
        this.f1681 = drmSession;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public abstract void mo1154(String str, long j, long j2);

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:35:0x0071  */
    /* JADX WARN: Removed duplicated region for block: B:64:0x00cb  */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void mo1155(C3433 c3433) throws ExoPlaybackException {
        boolean zRequiresSecureDecoderComponent;
        boolean z = true;
        this.f1725 = true;
        C3431 c3431 = c3433.f10114;
        C0567.m1856(c3431);
        C3431 c34312 = c3431;
        if (c3433.f10112) {
            m1164((DrmSession<C3542>) c3433.f10113);
        } else {
            this.f1682 = m5440(this.f1679, c34312, this.f1669, this.f1682);
        }
        this.f1679 = c34312;
        if (this.f1687 == null) {
            m1179();
            return;
        }
        if ((this.f1682 != null || this.f1681 == null) && (this.f1682 == null || this.f1681 != null)) {
            DrmSession<C3542> drmSession = this.f1682;
            if (drmSession != this.f1681 && !this.f1692.f11436) {
                C3542 c3542 = (C3542) drmSession.mo1112();
                if (c3542 == null) {
                    zRequiresSecureDecoderComponent = true;
                    if (!zRequiresSecureDecoderComponent) {
                    }
                } else {
                    if (c3542.f10512) {
                        zRequiresSecureDecoderComponent = false;
                    } else {
                        try {
                            MediaCrypto mediaCrypto = new MediaCrypto(c3542.f10510, c3542.f10511);
                            try {
                                zRequiresSecureDecoderComponent = mediaCrypto.requiresSecureDecoderComponent(c34312.f10090);
                            } finally {
                                mediaCrypto.release();
                            }
                        } catch (MediaCryptoException unused) {
                            zRequiresSecureDecoderComponent = true;
                        }
                    }
                    if (!zRequiresSecureDecoderComponent) {
                    }
                }
            } else if (C4150.f13259 >= 23 || this.f1682 == this.f1681) {
                int iMo1144 = mo1144(this.f1687, this.f1692, this.f1688, c34312);
                if (iMo1144 == 0) {
                    m1173();
                    return;
                }
                if (iMo1144 == 1) {
                    this.f1688 = c34312;
                    m1185();
                    if (this.f1682 != this.f1681) {
                        m1174();
                        return;
                    } else {
                        if (this.f1716) {
                            this.f1714 = 1;
                            this.f1715 = 1;
                            return;
                        }
                        return;
                    }
                }
                if (iMo1144 != 2) {
                    if (iMo1144 != 3) {
                        throw new IllegalStateException();
                    }
                    this.f1688 = c34312;
                    m1185();
                    if (this.f1682 != this.f1681) {
                        m1174();
                        return;
                    }
                    return;
                }
                if (this.f1694) {
                    m1173();
                    return;
                }
                this.f1712 = true;
                this.f1713 = 1;
                int i = this.f1693;
                if (i != 2) {
                    if (i == 1) {
                        int i2 = c34312.f10095;
                        C3431 c34313 = this.f1688;
                        if (i2 != c34313.f10095 || c34312.f10096 != c34313.f10096) {
                            z = false;
                        }
                    }
                }
                this.f1701 = z;
                this.f1688 = c34312;
                m1185();
                if (this.f1682 != this.f1681) {
                    m1174();
                    return;
                }
                return;
            }
        }
        m1173();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo1156(C3511 c3511) {
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public abstract void mo1157(C3707 c3707, MediaCodec mediaCodec, C3431 c3431, MediaCrypto mediaCrypto, float f);

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m1158(C3707 c3707, MediaCrypto mediaCrypto) throws Exception {
        MediaCodec mediaCodecCreateByCodecName;
        long jElapsedRealtime;
        String str = c3707.f11431;
        float fMo1143 = C4150.f13259 < 23 ? -1.0f : mo1143(this.f1686, this.f1679, this.f9967);
        float f = fMo1143 <= this.f1672 ? -1.0f : fMo1143;
        try {
            jElapsedRealtime = SystemClock.elapsedRealtime();
            C0567.m1892("createCodec:" + str);
            mediaCodecCreateByCodecName = MediaCodec.createByCodecName(str);
        } catch (Exception e) {
            e = e;
            mediaCodecCreateByCodecName = null;
        }
        try {
            C0567.m1913();
            C0567.m1892("configureCodec");
            mo1157(c3707, mediaCodecCreateByCodecName, this.f1679, mediaCrypto, f);
            C0567.m1913();
            C0567.m1892("startCodec");
            mediaCodecCreateByCodecName.start();
            C0567.m1913();
            long jElapsedRealtime2 = SystemClock.elapsedRealtime();
            if (C4150.f13259 < 21) {
                this.f1704 = mediaCodecCreateByCodecName.getInputBuffers();
                this.f1705 = mediaCodecCreateByCodecName.getOutputBuffers();
            }
            this.f1687 = mediaCodecCreateByCodecName;
            this.f1692 = c3707;
            this.f1689 = f;
            this.f1688 = this.f1679;
            this.f1693 = (C4150.f13259 <= 25 && "OMX.Exynos.avc.dec.secure".equals(str) && (C4150.f13262.startsWith("SM-T585") || C4150.f13262.startsWith("SM-A510") || C4150.f13262.startsWith("SM-A520") || C4150.f13262.startsWith("SM-J700"))) ? 2 : (C4150.f13259 >= 24 || !(("OMX.Nvidia.h264.decode".equals(str) || "OMX.Nvidia.h264.decode.secure".equals(str)) && ("flounder".equals(C4150.f13260) || "flounder_lte".equals(C4150.f13260) || "grouper".equals(C4150.f13260) || "tilapia".equals(C4150.f13260)))) ? 0 : 1;
            this.f1694 = C4150.f13262.startsWith("SM-T230") && "OMX.MARVELL.VIDEO.HW.CODA7542DECODER".equals(str);
            this.f1695 = C4150.f13259 < 21 && this.f1688.f10092.isEmpty() && "OMX.MTK.VIDEO.DECODER.AVC".equals(str);
            int i = C4150.f13259;
            this.f1696 = i < 18 || (i == 18 && ("OMX.SEC.avc.dec".equals(str) || "OMX.SEC.avc.dec.secure".equals(str))) || (C4150.f13259 == 19 && C4150.f13262.startsWith("SM-G800") && ("OMX.Exynos.avc.dec".equals(str) || "OMX.Exynos.avc.dec.secure".equals(str)));
            this.f1697 = C4150.f13259 == 29 && "c2.android.aac.decoder".equals(str);
            this.f1698 = (C4150.f13259 <= 23 && "OMX.google.vorbis.decoder".equals(str)) || (C4150.f13259 <= 19 && (("hb2000".equals(C4150.f13260) || "stvm8".equals(C4150.f13260)) && ("OMX.amlogic.avc.decoder.awesome".equals(str) || "OMX.amlogic.avc.decoder.awesome.secure".equals(str))));
            this.f1699 = C4150.f13259 == 21 && "OMX.google.aac.decoder".equals(str);
            this.f1700 = C4150.f13259 <= 18 && this.f1688.f10103 == 1 && "OMX.MTK.AUDIO.DECODER.MP3".equals(str);
            String str2 = c3707.f11431;
            this.f1703 = ((C4150.f13259 <= 25 && "OMX.rk.video_decoder.avc".equals(str2)) || ((C4150.f13259 <= 17 && "OMX.allwinner.video.decoder.avc".equals(str2)) || ("Amazon".equals(C4150.f13261) && "AFTS".equals(C4150.f13262) && c3707.f11436))) || mo1178();
            m1183();
            m1184();
            this.f1706 = this.f9965 == 2 ? SystemClock.elapsedRealtime() + 1000 : -9223372036854775807L;
            this.f1712 = false;
            this.f1713 = 0;
            this.f1717 = false;
            this.f1716 = false;
            this.f1719 = -9223372036854775807L;
            this.f1720 = -9223372036854775807L;
            this.f1714 = 0;
            this.f1715 = 0;
            this.f1701 = false;
            this.f1702 = false;
            this.f1710 = false;
            this.f1711 = false;
            this.f1724 = true;
            this.f1727.f10451++;
            mo1154(str, jElapsedRealtime2, jElapsedRealtime2 - jElapsedRealtime);
        } catch (Exception e2) {
            e = e2;
            if (mediaCodecCreateByCodecName != null) {
                if (C4150.f13259 < 21) {
                    this.f1704 = null;
                    this.f1705 = null;
                }
                mediaCodecCreateByCodecName.release();
            }
            throw e;
        }
    }

    @Override // p138.p176.p177.p190.AbstractC3413
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo1159(boolean z) {
        InterfaceC3532<C3542> interfaceC3532 = this.f1669;
        if (interfaceC3532 != null && !this.f1678) {
            this.f1678 = true;
            interfaceC3532.mo1129();
        }
        this.f1727 = new C3510();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public abstract boolean mo1160(long j, long j2, MediaCodec mediaCodec, ByteBuffer byteBuffer, int i, int i2, long j3, boolean z, boolean z2, C3431 c3431);

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public boolean mo1161(C3707 c3707) {
        return true;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final List<C3707> m1162(boolean z) {
        List<C3707> listMo1147 = mo1147(this.f1668, this.f1679, z);
        if (listMo1147.isEmpty() && z) {
            listMo1147 = mo1147(this.f1668, this.f1679, false);
            if (!listMo1147.isEmpty()) {
                StringBuilder sbM4889 = C2803.m4889("Drm session requires secure decoder for ");
                sbM4889.append(this.f1679.f10090);
                sbM4889.append(", but no secure decoder available. Trying to proceed with ");
                sbM4889.append(listMo1147);
                sbM4889.append(".");
                Log.w("MediaCodecRenderer", sbM4889.toString());
            }
        }
        return listMo1147;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public abstract void mo1163(long j);

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final void m1164(DrmSession<C3542> drmSession) {
        C3530.m5828(this.f1682, drmSession);
        this.f1682 = drmSession;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public abstract void mo1165(C3511 c3511);

    @Override // p138.p176.p177.p190.InterfaceC3450
    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public boolean mo1166() {
        return this.f1722;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final boolean m1167(long j, long j2) throws ExoPlaybackException {
        boolean z;
        boolean zMo1160;
        int iDequeueOutputBuffer;
        boolean z2;
        if (!(this.f1708 >= 0)) {
            if (this.f1699 && this.f1717) {
                try {
                    iDequeueOutputBuffer = this.f1687.dequeueOutputBuffer(this.f1677, 0L);
                } catch (IllegalStateException unused) {
                    m1180();
                    if (this.f1722) {
                        mo1181();
                    }
                    return false;
                }
            } else {
                iDequeueOutputBuffer = this.f1687.dequeueOutputBuffer(this.f1677, 0L);
            }
            if (iDequeueOutputBuffer < 0) {
                if (iDequeueOutputBuffer != -2) {
                    if (iDequeueOutputBuffer == -3) {
                        if (C4150.f13259 < 21) {
                            this.f1705 = this.f1687.getOutputBuffers();
                        }
                        return true;
                    }
                    if (this.f1703 && (this.f1721 || this.f1714 == 2)) {
                        m1180();
                    }
                    return false;
                }
                this.f1718 = true;
                MediaFormat outputFormat = this.f1687.getOutputFormat();
                if (this.f1693 != 0 && outputFormat.getInteger("width") == 32 && outputFormat.getInteger("height") == 32) {
                    this.f1702 = true;
                } else {
                    if (this.f1700) {
                        outputFormat.setInteger("channel-count", 1);
                    }
                    mo1151(this.f1687, outputFormat);
                }
                return true;
            }
            if (this.f1702) {
                this.f1702 = false;
                this.f1687.releaseOutputBuffer(iDequeueOutputBuffer, false);
                return true;
            }
            MediaCodec.BufferInfo bufferInfo = this.f1677;
            if (bufferInfo.size == 0 && (bufferInfo.flags & 4) != 0) {
                m1180();
                return false;
            }
            this.f1708 = iDequeueOutputBuffer;
            ByteBuffer outputBuffer = C4150.f13259 >= 21 ? this.f1687.getOutputBuffer(iDequeueOutputBuffer) : this.f1705[iDequeueOutputBuffer];
            this.f1709 = outputBuffer;
            if (outputBuffer != null) {
                outputBuffer.position(this.f1677.offset);
                ByteBuffer byteBuffer = this.f1709;
                MediaCodec.BufferInfo bufferInfo2 = this.f1677;
                byteBuffer.limit(bufferInfo2.offset + bufferInfo2.size);
            }
            long j3 = this.f1677.presentationTimeUs;
            int size = this.f1676.size();
            int i = 0;
            while (true) {
                if (i >= size) {
                    z2 = false;
                    break;
                }
                if (this.f1676.get(i).longValue() == j3) {
                    this.f1676.remove(i);
                    z2 = true;
                    break;
                }
                i++;
            }
            this.f1710 = z2;
            this.f1711 = this.f1720 == this.f1677.presentationTimeUs;
            C3431 c3431M6733 = this.f1675.m6733(this.f1677.presentationTimeUs);
            if (c3431M6733 != null) {
                this.f1680 = c3431M6733;
            }
        }
        if (this.f1699 && this.f1717) {
            try {
                z = false;
                try {
                    zMo1160 = mo1160(j, j2, this.f1687, this.f1709, this.f1708, this.f1677.flags, this.f1677.presentationTimeUs, this.f1710, this.f1711, this.f1680);
                } catch (IllegalStateException unused2) {
                    m1180();
                    if (this.f1722) {
                        mo1181();
                    }
                    return z;
                }
            } catch (IllegalStateException unused3) {
                z = false;
            }
        } else {
            z = false;
            MediaCodec mediaCodec = this.f1687;
            ByteBuffer byteBuffer2 = this.f1709;
            int i2 = this.f1708;
            MediaCodec.BufferInfo bufferInfo3 = this.f1677;
            zMo1160 = mo1160(j, j2, mediaCodec, byteBuffer2, i2, bufferInfo3.flags, bufferInfo3.presentationTimeUs, this.f1710, this.f1711, this.f1680);
        }
        if (zMo1160) {
            mo1163(this.f1677.presentationTimeUs);
            boolean z3 = (this.f1677.flags & 4) != 0;
            m1184();
            if (!z3) {
                return true;
            }
            m1180();
        }
        return z;
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final boolean m1168(boolean z) throws ExoPlaybackException {
        C3433 c3433M5457 = m5457();
        this.f1674.mo5803();
        int iM5438 = m5438(c3433M5457, this.f1674, z);
        if (iM5438 == -5) {
            mo1155(c3433M5457);
            return true;
        }
        if (iM5438 != -4 || !this.f1674.m5805()) {
            return false;
        }
        this.f1721 = true;
        m1180();
        return false;
    }

    @Override // p138.p176.p177.p190.InterfaceC3450
    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public boolean mo1169() {
        if (this.f1679 == null || this.f1723) {
            return false;
        }
        if (!(mo5448() ? this.f9970 : this.f9966.mo6119())) {
            if (!(this.f1708 >= 0) && (this.f1706 == -9223372036854775807L || SystemClock.elapsedRealtime() >= this.f1706)) {
                return false;
            }
        }
        return true;
    }

    @Override // p138.p176.p177.p190.AbstractC3413
    /* JADX INFO: renamed from: ޏ, reason: contains not printable characters */
    public void mo1170() {
        this.f1679 = null;
        if (this.f1682 == null && this.f1681 == null) {
            mo1177();
        } else {
            mo1171();
        }
    }

    @Override // p138.p176.p177.p190.AbstractC3413
    /* JADX INFO: renamed from: ސ, reason: contains not printable characters */
    public void mo1171() {
        try {
            mo1181();
            m1164((DrmSession<C3542>) null);
            InterfaceC3532<C3542> interfaceC3532 = this.f1669;
            if (interfaceC3532 == null || !this.f1678) {
                return;
            }
            this.f1678 = false;
            interfaceC3532.mo1126();
        } catch (Throwable th) {
            m1164((DrmSession<C3542>) null);
            throw th;
        }
    }

    @Override // p138.p176.p177.p190.AbstractC3413
    /* JADX INFO: renamed from: ޓ, reason: contains not printable characters */
    public final int mo1172() {
        return 8;
    }

    /* JADX INFO: renamed from: ޔ, reason: contains not printable characters */
    public final void m1173() throws ExoPlaybackException {
        if (this.f1716) {
            this.f1714 = 1;
            this.f1715 = 3;
        } else {
            mo1181();
            m1179();
        }
    }

    /* JADX INFO: renamed from: ޕ, reason: contains not printable characters */
    public final void m1174() throws ExoPlaybackException {
        if (C4150.f13259 < 23) {
            m1173();
        } else if (!this.f1716) {
            m1186();
        } else {
            this.f1714 = 1;
            this.f1715 = 2;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:95:0x0162  */
    /* JADX INFO: renamed from: ޖ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean m1175() throws ExoPlaybackException {
        int iPosition;
        int iM5438;
        boolean z;
        MediaCodec mediaCodec = this.f1687;
        if (mediaCodec == null || this.f1714 == 2 || this.f1721) {
            return false;
        }
        if (this.f1707 < 0) {
            int iDequeueInputBuffer = mediaCodec.dequeueInputBuffer(0L);
            this.f1707 = iDequeueInputBuffer;
            if (iDequeueInputBuffer < 0) {
                return false;
            }
            this.f1673.f10461 = C4150.f13259 >= 21 ? this.f1687.getInputBuffer(iDequeueInputBuffer) : this.f1704[iDequeueInputBuffer];
            this.f1673.mo5803();
        }
        if (this.f1714 == 1) {
            if (!this.f1703) {
                this.f1717 = true;
                this.f1687.queueInputBuffer(this.f1707, 0, 0, 0L, 4);
                m1183();
            }
            this.f1714 = 2;
            return false;
        }
        if (this.f1701) {
            this.f1701 = false;
            this.f1673.f10461.put(f1667);
            this.f1687.queueInputBuffer(this.f1707, 0, f1667.length, 0L, 0);
            m1183();
            this.f1716 = true;
            return true;
        }
        C3433 c3433M5457 = m5457();
        if (this.f1723) {
            iM5438 = -4;
            iPosition = 0;
        } else {
            if (this.f1713 == 1) {
                for (int i = 0; i < this.f1688.f10092.size(); i++) {
                    this.f1673.f10461.put(this.f1688.f10092.get(i));
                }
                this.f1713 = 2;
            }
            iPosition = this.f1673.f10461.position();
            iM5438 = m5438(c3433M5457, this.f1673, false);
        }
        if (mo5448()) {
            this.f1720 = this.f1719;
        }
        if (iM5438 == -3) {
            return false;
        }
        if (iM5438 == -5) {
            if (this.f1713 == 2) {
                this.f1673.mo5803();
                this.f1713 = 1;
            }
            mo1155(c3433M5457);
            return true;
        }
        if (this.f1673.m5805()) {
            if (this.f1713 == 2) {
                this.f1673.mo5803();
                this.f1713 = 1;
            }
            this.f1721 = true;
            if (!this.f1716) {
                m1180();
                return false;
            }
            try {
                if (!this.f1703) {
                    this.f1717 = true;
                    this.f1687.queueInputBuffer(this.f1707, 0, 0, 0L, 4);
                    m1183();
                }
                return false;
            } catch (MediaCodec.CryptoException e) {
                throw m5439(e, this.f1679);
            }
        }
        if (this.f1724 && !this.f1673.m5802(1)) {
            this.f1673.mo5803();
            if (this.f1713 == 2) {
                this.f1713 = 1;
            }
            return true;
        }
        this.f1724 = false;
        boolean zM5813 = this.f1673.m5813();
        DrmSession<C3542> drmSession = this.f1681;
        if (drmSession == null || (!zM5813 && (this.f1670 || drmSession.mo1111()))) {
            z = false;
        } else {
            int iMo1113 = this.f1681.mo1113();
            if (iMo1113 == 1) {
                throw m5439(this.f1681.mo1114(), this.f1679);
            }
            if (iMo1113 != 4) {
                z = true;
            }
        }
        this.f1723 = z;
        if (z) {
            return false;
        }
        if (this.f1695 && !zM5813) {
            C4136.m6663(this.f1673.f10461);
            if (this.f1673.f10461.position() == 0) {
                return true;
            }
            this.f1695 = false;
        }
        try {
            long j = this.f1673.f10463;
            if (this.f1673.m5804()) {
                this.f1676.add(Long.valueOf(j));
            }
            if (this.f1725) {
                this.f1675.m6732(j, this.f1679);
                this.f1725 = false;
            }
            this.f1719 = Math.max(this.f1719, j);
            this.f1673.m5812();
            if (this.f1673.m5802(268435456)) {
                mo1156(this.f1673);
            }
            mo1165(this.f1673);
            if (zM5813) {
                MediaCodec.CryptoInfo cryptoInfo = this.f1673.f10460.f10447;
                if (iPosition != 0) {
                    if (cryptoInfo.numBytesOfClearData == null) {
                        cryptoInfo.numBytesOfClearData = new int[1];
                    }
                    int[] iArr = cryptoInfo.numBytesOfClearData;
                    iArr[0] = iArr[0] + iPosition;
                }
                this.f1687.queueSecureInputBuffer(this.f1707, 0, cryptoInfo, j, 0);
            } else {
                this.f1687.queueInputBuffer(this.f1707, 0, this.f1673.f10461.limit(), j, 0);
            }
            m1183();
            this.f1716 = true;
            this.f1713 = 0;
            this.f1727.f10453++;
            return true;
        } catch (MediaCodec.CryptoException e2) {
            throw m5439(e2, this.f1679);
        }
    }

    /* JADX INFO: renamed from: ޗ, reason: contains not printable characters */
    public final boolean m1176() throws ExoPlaybackException {
        boolean zMo1177 = mo1177();
        if (zMo1177) {
            m1179();
        }
        return zMo1177;
    }

    /* JADX INFO: renamed from: ޘ, reason: contains not printable characters */
    public boolean mo1177() {
        if (this.f1687 == null) {
            return false;
        }
        if (this.f1715 == 3 || this.f1696 || ((this.f1697 && !this.f1718) || (this.f1698 && this.f1717))) {
            mo1181();
            return true;
        }
        this.f1687.flush();
        m1183();
        m1184();
        this.f1706 = -9223372036854775807L;
        this.f1717 = false;
        this.f1716 = false;
        this.f1724 = true;
        this.f1701 = false;
        this.f1702 = false;
        this.f1710 = false;
        this.f1711 = false;
        this.f1723 = false;
        this.f1676.clear();
        this.f1719 = -9223372036854775807L;
        this.f1720 = -9223372036854775807L;
        this.f1714 = 0;
        this.f1715 = 0;
        this.f1713 = this.f1712 ? 1 : 0;
        return false;
    }

    /* JADX INFO: renamed from: ޙ, reason: contains not printable characters */
    public boolean mo1178() {
        return false;
    }

    /* JADX INFO: renamed from: ޚ, reason: contains not printable characters */
    public final void m1179() throws ExoPlaybackException {
        if (this.f1687 != null || this.f1679 == null) {
            return;
        }
        m1153(this.f1682);
        String str = this.f1679.f10090;
        DrmSession<C3542> drmSession = this.f1681;
        if (drmSession != null) {
            if (this.f1683 == null) {
                C3542 c3542 = (C3542) drmSession.mo1112();
                if (c3542 != null) {
                    try {
                        MediaCrypto mediaCrypto = new MediaCrypto(c3542.f10510, c3542.f10511);
                        this.f1683 = mediaCrypto;
                        this.f1684 = !c3542.f10512 && mediaCrypto.requiresSecureDecoderComponent(str);
                    } catch (MediaCryptoException e) {
                        throw m5439(e, this.f1679);
                    }
                } else if (this.f1681.mo1114() == null) {
                    return;
                }
            }
            if (C3542.f10509) {
                int iMo1113 = this.f1681.mo1113();
                if (iMo1113 == 1) {
                    throw m5439(this.f1681.mo1114(), this.f1679);
                }
                if (iMo1113 != 4) {
                    return;
                }
            }
        }
        try {
            m1152(this.f1683, this.f1684);
        } catch (DecoderInitializationException e2) {
            throw m5439(e2, this.f1679);
        }
    }

    /* JADX INFO: renamed from: ޛ, reason: contains not printable characters */
    public final void m1180() throws ExoPlaybackException {
        int i = this.f1715;
        if (i == 1) {
            m1176();
            return;
        }
        if (i == 2) {
            m1186();
        } else if (i != 3) {
            this.f1722 = true;
            mo1182();
        } else {
            mo1181();
            m1179();
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX INFO: renamed from: ޜ, reason: contains not printable characters */
    public void mo1181() {
        this.f1690 = null;
        this.f1692 = null;
        this.f1688 = null;
        this.f1718 = false;
        m1183();
        m1184();
        if (C4150.f13259 < 21) {
            this.f1704 = null;
            this.f1705 = null;
        }
        this.f1723 = false;
        this.f1706 = -9223372036854775807L;
        this.f1676.clear();
        this.f1719 = -9223372036854775807L;
        this.f1720 = -9223372036854775807L;
        try {
            if (this.f1687 != null) {
                this.f1727.f10452++;
                try {
                    this.f1687.stop();
                    this.f1687.release();
                } catch (Throwable th) {
                    this.f1687.release();
                    throw th;
                }
            }
            this.f1687 = null;
            try {
                if (this.f1683 != null) {
                    this.f1683.release();
                }
            } finally {
            }
        } catch (Throwable th2) {
            this.f1687 = null;
            try {
                if (this.f1683 != null) {
                    this.f1683.release();
                }
                throw th2;
            } finally {
            }
        }
    }

    /* JADX INFO: renamed from: ޝ, reason: contains not printable characters */
    public void mo1182() {
    }

    /* JADX INFO: renamed from: ޞ, reason: contains not printable characters */
    public final void m1183() {
        this.f1707 = -1;
        this.f1673.f10461 = null;
    }

    /* JADX INFO: renamed from: ޟ, reason: contains not printable characters */
    public final void m1184() {
        this.f1708 = -1;
        this.f1709 = null;
    }

    /* JADX INFO: renamed from: ޠ, reason: contains not printable characters */
    public final void m1185() throws ExoPlaybackException {
        if (C4150.f13259 < 23) {
            return;
        }
        float fMo1143 = mo1143(this.f1686, this.f1688, this.f9967);
        float f = this.f1689;
        if (f == fMo1143) {
            return;
        }
        if (fMo1143 == -1.0f) {
            m1173();
            return;
        }
        if (f != -1.0f || fMo1143 > this.f1672) {
            Bundle bundle = new Bundle();
            bundle.putFloat("operating-rate", fMo1143);
            this.f1687.setParameters(bundle);
            this.f1689 = fMo1143;
        }
    }

    @TargetApi(23)
    /* JADX INFO: renamed from: ޡ, reason: contains not printable characters */
    public final void m1186() throws ExoPlaybackException {
        C3542 c3542 = (C3542) this.f1682.mo1112();
        if (c3542 == null) {
            mo1181();
            m1179();
            return;
        }
        if (C3414.f9976.equals(c3542.f10510)) {
            mo1181();
            m1179();
        } else {
            if (m1176()) {
                return;
            }
            try {
                this.f1683.setMediaDrmSession(c3542.f10511);
                m1153(this.f1682);
                this.f1714 = 0;
                this.f1715 = 0;
            } catch (MediaCryptoException e) {
                throw m5439(e, this.f1679);
            }
        }
    }
}
