package defpackage;

import android.content.Context;
import android.media.MediaCodec;
import android.media.MediaCrypto;
import android.media.MediaCryptoException;
import android.media.MediaFormat;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.os.Trace;
import android.util.Pair;
import androidx.media3.decoder.DecoderInputBuffer$InsufficientCapacityException;
import androidx.media3.exoplayer.ExoPlaybackException;
import androidx.media3.exoplayer.drm.DrmSession$DrmSessionException;
import androidx.media3.exoplayer.mediacodec.MediaCodecDecoderException;
import androidx.media3.exoplayer.mediacodec.MediaCodecRenderer$DecoderInitializationException;
import androidx.media3.exoplayer.mediacodec.MediaCodecUtil$DecoderQueryException;
import j$.util.Objects;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;

/* JADX INFO: renamed from: ᵼˁˈʕ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public abstract class AbstractC5262 extends AbstractC0799 {

    /* JADX INFO: renamed from: ᵴˑʤᵷ, reason: contains not printable characters */
    public static final byte[] f19832 = {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 InterfaceC2978 f19833;

    /* JADX INFO: renamed from: ʿᵯᴵ, reason: contains not printable characters */
    public boolean f19834;

    /* JADX INFO: renamed from: ʿᵿʽᵞ, reason: contains not printable characters */
    public final C3673 f19835;

    /* JADX INFO: renamed from: ˀᵗ, reason: contains not printable characters */
    public final C3053 f19836;

    /* JADX INFO: renamed from: ˀᵛᵟ, reason: contains not printable characters */
    public ByteBuffer f19837;

    /* JADX INFO: renamed from: ˀᵝᵙᵛ, reason: contains not printable characters */
    public boolean f19838;

    /* JADX INFO: renamed from: ˁʢᵛ, reason: contains not printable characters */
    public final C3008 f19839;

    /* JADX INFO: renamed from: ˁᵺˈ, reason: contains not printable characters */
    public InterfaceC4417 f19840;

    /* JADX INFO: renamed from: ˆʤᵳ, reason: contains not printable characters */
    public float f19841;

    /* JADX INFO: renamed from: ˆˀᵯ, reason: contains not printable characters */
    public boolean f19842;

    /* JADX INFO: renamed from: ˆˌˁ, reason: contains not printable characters */
    public C2537 f19843;

    /* JADX INFO: renamed from: ˆᵱʣ, reason: contains not printable characters */
    public int f19844;

    /* JADX INFO: renamed from: ˈˊˑˑ, reason: contains not printable characters */
    public boolean f19845;

    /* JADX INFO: renamed from: ˈⁱᵡ, reason: contains not printable characters */
    public final boolean f19846;

    /* JADX INFO: renamed from: ˉˆᵗ, reason: contains not printable characters */
    public InterfaceC4417 f19847;

    /* JADX INFO: renamed from: ˊʧᵖ, reason: contains not printable characters */
    public boolean f19848;

    /* JADX INFO: renamed from: ˊˌˊ, reason: contains not printable characters */
    public final C3008 f19849;

    /* JADX INFO: renamed from: ˊᵨˌ, reason: contains not printable characters */
    public C0204 f19850;

    /* JADX INFO: renamed from: ˊᵶᵕᵛ, reason: contains not printable characters */
    public int f19851;

    /* JADX INFO: renamed from: ˋʿᐧ, reason: contains not printable characters */
    public C5286 f19852;

    /* JADX INFO: renamed from: ˋʿᵥᵔ, reason: contains not printable characters */
    public long f19853;

    /* JADX INFO: renamed from: ˋᵤᵦ, reason: contains not printable characters */
    public int f19854;

    /* JADX INFO: renamed from: ˋᵯᵩ, reason: contains not printable characters */
    public C4311 f19855;

    /* JADX INFO: renamed from: ˎʞ, reason: contains not printable characters */
    public long f19856;

    /* JADX INFO: renamed from: ˏʜᵪ, reason: contains not printable characters */
    public MediaFormat f19857;

    /* JADX INFO: renamed from: ˏʽˊᵰ, reason: contains not printable characters */
    public C1354 f19858;

    /* JADX INFO: renamed from: ˏᵩʨ, reason: contains not printable characters */
    public final MediaCodec.BufferInfo f19859;

    /* JADX INFO: renamed from: ːᵝٴᵶ, reason: contains not printable characters */
    public final long f19860;

    /* JADX INFO: renamed from: ˑʢ, reason: contains not printable characters */
    public final InterfaceC2865 f19861;

    /* JADX INFO: renamed from: ˑˀˉᵲ, reason: contains not printable characters */
    public C0204 f19862;

    /* JADX INFO: renamed from: ᵔﹳ, reason: contains not printable characters */
    public boolean f19863;

    /* JADX INFO: renamed from: ᵕʢ, reason: contains not printable characters */
    public boolean f19864;

    /* JADX INFO: renamed from: ᵕˁːᵚ, reason: contains not printable characters */
    public ExoPlaybackException f19865;

    /* JADX INFO: renamed from: ᵕᵜʽᵰ, reason: contains not printable characters */
    public long f19866;

    /* JADX INFO: renamed from: ᵗᵭ, reason: contains not printable characters */
    public float f19867;

    /* JADX INFO: renamed from: ᵘᵝ, reason: contains not printable characters */
    public boolean f19868;

    /* JADX INFO: renamed from: ᵘᵫᵡ, reason: contains not printable characters */
    public boolean f19869;

    /* JADX INFO: renamed from: ᵚᵹᵔᵜ, reason: contains not printable characters */
    public boolean f19870;

    /* JADX INFO: renamed from: ᵛˀˊ, reason: contains not printable characters */
    public final ArrayDeque f19871;

    /* JADX INFO: renamed from: ᵜᵤ, reason: contains not printable characters */
    public MediaCrypto f19872;

    /* JADX INFO: renamed from: ᵞᵛᵘ, reason: contains not printable characters */
    public final C3008 f19873;

    /* JADX INFO: renamed from: ᵟᵴᵥ, reason: contains not printable characters */
    public boolean f19874;

    /* JADX INFO: renamed from: ᵠᐧ, reason: contains not printable characters */
    public boolean f19875;

    /* JADX INFO: renamed from: ᵠᵚˀᵫ, reason: contains not printable characters */
    public int f19876;

    /* JADX INFO: renamed from: ᵠᵲˁ, reason: contains not printable characters */
    public int f19877;

    /* JADX INFO: renamed from: ᵡᵶ, reason: contains not printable characters */
    public final AtomicInteger f19878;

    /* JADX INFO: renamed from: ᵡᵶᵬʤ, reason: contains not printable characters */
    public C5286 f19879;

    /* JADX INFO: renamed from: ᵣʚʿ, reason: contains not printable characters */
    public boolean f19880;

    /* JADX INFO: renamed from: ᵥﹶ, reason: contains not printable characters */
    public boolean f19881;

    /* JADX INFO: renamed from: ᵧᵠᵾ, reason: contains not printable characters */
    public boolean f19882;

    /* JADX INFO: renamed from: ᵧᵢᵴᵸ, reason: contains not printable characters */
    public boolean f19883;

    /* JADX INFO: renamed from: ᵨˈʼﹶ, reason: contains not printable characters */
    public final float f19884;

    /* JADX INFO: renamed from: ᵨᵴᵚ, reason: contains not printable characters */
    public AbstractC5291 f19885;

    /* JADX INFO: renamed from: ᵪʚᵯʝ, reason: contains not printable characters */
    public boolean f19886;

    /* JADX INFO: renamed from: ᵪᵳˀ, reason: contains not printable characters */
    public boolean f19887;

    /* JADX INFO: renamed from: ᵫˈᵹ, reason: contains not printable characters */
    public float f19888;

    /* JADX INFO: renamed from: ᵬᵦˋ, reason: contains not printable characters */
    public C5286 f19889;

    /* JADX INFO: renamed from: ᵭᵬ, reason: contains not printable characters */
    public boolean f19890;

    /* JADX INFO: renamed from: ᵮᵟᵡ, reason: contains not printable characters */
    public MediaCodecRenderer$DecoderInitializationException f19891;

    /* JADX INFO: renamed from: ᵯˇ, reason: contains not printable characters */
    public int f19892;

    /* JADX INFO: renamed from: ᵰʜ, reason: contains not printable characters */
    public boolean f19893;

    /* JADX INFO: renamed from: ᵱʢᵢ, reason: contains not printable characters */
    public boolean f19894;

    /* JADX INFO: renamed from: ᵱᵭ, reason: contains not printable characters */
    public boolean f19895;

    /* JADX INFO: renamed from: ᵴˀᵰʒ, reason: contains not printable characters */
    public long f19896;

    /* JADX INFO: renamed from: ᵵᵬᵽ, reason: contains not printable characters */
    public final Context f19897;

    /* JADX INFO: renamed from: ᵵᵸᵕᵸ, reason: contains not printable characters */
    public InterfaceC1595 f19898;

    /* JADX INFO: renamed from: ᵹʾᵢᵯ, reason: contains not printable characters */
    public ArrayDeque f19899;

    /* JADX INFO: renamed from: ᵽˀᵥ, reason: contains not printable characters */
    public long f19900;

    /* JADX INFO: renamed from: ᵾᵻﹳᵮ, reason: contains not printable characters */
    public C5123 f19901;

    public AbstractC5262(Context context, int i, InterfaceC2865 interfaceC2865, InterfaceC2978 interfaceC2978, boolean z, float f) {
        super(i);
        this.f19897 = context.getApplicationContext();
        this.f19861 = interfaceC2865;
        interfaceC2978.getClass();
        this.f19833 = interfaceC2978;
        this.f19846 = z;
        this.f19884 = f;
        this.f19878 = new AtomicInteger();
        this.f19873 = new C3008(0, 0);
        this.f19849 = new C3008(0, 0);
        this.f19839 = new C3008(2, 0);
        C3053 c3053 = new C3053(2, 0);
        c3053.f11697 = 32;
        this.f19836 = c3053;
        this.f19859 = new MediaCodec.BufferInfo();
        this.f19867 = 1.0f;
        this.f19888 = 1.0f;
        this.f19860 = -9223372036854775807L;
        this.f19871 = new ArrayDeque();
        this.f19901 = C5123.f19274;
        c3053.m7093(0);
        c3053.f11582.order(ByteOrder.nativeOrder());
        C3673 c3673 = new C3673();
        c3673.f13946 = InterfaceC2497.f9685;
        c3673.f13947 = 0;
        c3673.f13945 = 2;
        this.f19835 = c3673;
        this.f19841 = -1.0f;
        this.f19892 = 0;
        this.f19851 = 0;
        this.f19877 = -1;
        this.f19876 = -1;
        this.f19900 = -9223372036854775807L;
        this.f19856 = -9223372036854775807L;
        this.f19896 = -9223372036854775807L;
        this.f19866 = -9223372036854775807L;
        this.f19844 = 0;
        this.f19854 = 0;
        this.f19843 = new C2537();
        this.f19875 = false;
        this.f19853 = 0L;
        int i2 = AbstractC5291.f20005;
        this.f19885 = C5196.f19563;
        C0204 c0204 = C0204.f1673;
        this.f19862 = c0204;
        this.f19850 = c0204;
    }

    /* JADX INFO: renamed from: ʽᵡᵢᵾ */
    public abstract ArrayList mo5587(InterfaceC2978 interfaceC2978, C5286 c5286, boolean z);

    /* JADX WARN: Removed duplicated region for block: B:107:0x02f3  */
    /* JADX WARN: Removed duplicated region for block: B:110:0x02fb  */
    /* JADX WARN: Removed duplicated region for block: B:111:0x02fe  */
    /* JADX INFO: renamed from: ʿٴˇ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean m10830(long j, long j2) throws ExoPlaybackException {
        C3053 c3053;
        C3053 c30532;
        int length;
        ByteBuffer byteBuffer;
        ᵻᵪ.ˌᴵ(!this.f19863);
        C3053 c30533 = this.f19836;
        if (c30533.m7151()) {
            ByteBuffer byteBuffer2 = c30533.f11582;
            int i = this.f19876;
            int i2 = c30533.f11698;
            long j3 = c30533.f11577;
            boolean zM10833 = m10833(this.f3593, c30533.f11696);
            boolean zM6278 = c30533.m6278(4);
            C5286 c5286 = this.f19852;
            c5286.getClass();
            c3053 = c30533;
            if (!mo5607(j, j2, null, byteBuffer2, i, 0, i2, j3, zM10833, zM6278, c5286)) {
                return false;
            }
            m10844(c3053.f11696);
            c3053.mo7091();
        } else {
            c3053 = c30533;
        }
        if (this.f19886) {
            this.f19863 = true;
            return false;
        }
        boolean z = this.f19848;
        C3008 c3008 = this.f19839;
        if (z) {
            ᵻᵪ.ˌᴵ(c3053.m7152(c3008));
            this.f19848 = false;
        }
        if (this.f19882) {
            if (c3053.m7151()) {
                return true;
            }
            this.f19880 = false;
            m10860();
            this.f19882 = false;
            m10843();
            if (!this.f19880) {
                return false;
            }
        }
        ᵻᵪ.ˌᴵ(!this.f19886);
        ˊˊᵞᵽ r1 = this.f3590;
        r1.ᵻˈᵦʼ();
        c3008.mo7091();
        do {
            c3008.mo7091();
            int iM2893 = m2893(r1, c3008, 0);
            if (iM2893 == -5) {
                mo5590(r1);
                break;
            }
            if (iM2893 != -4) {
                if (iM2893 != -3) {
                    ᵷᵝˎ.ᵱʡˏ();
                    return false;
                }
                if (m2899()) {
                    m10853().f19280 = this.f19856;
                }
            } else {
                if (c3008.m6278(4)) {
                    this.f19886 = true;
                    m10853().f19280 = this.f19856;
                    break;
                }
                this.f19856 = Math.max(this.f19856, c3008.f11577);
                if (m2899() || this.f19849.m6278(536870912)) {
                    m10853().f19280 = this.f19856;
                }
                byte[] bArr = null;
                if (this.f19887) {
                    C5286 c52862 = this.f19879;
                    c52862.getClass();
                    this.f19852 = c52862;
                    if (Objects.equals(c52862.f19987, "audio/opus") && !this.f19852.f19967.isEmpty()) {
                        byte[] bArr2 = (byte[]) this.f19852.f19967.get(0);
                        int i3 = (bArr2[10] & 255) | ((bArr2[11] & 255) << 8);
                        C4753 c4753M10878 = this.f19852.m10878();
                        c4753M10878.f18092 = i3;
                        this.f19852 = new C5286(c4753M10878);
                    }
                    mo5596(this.f19852, null);
                    this.f19887 = false;
                }
                c3008.m7092();
                C5286 c52863 = this.f19852;
                if (c52863 == null || !Objects.equals(c52863.f19987, "audio/opus")) {
                    c30532 = c3053;
                    if (!c30532.m7151()) {
                        long j4 = this.f3593;
                        c3053 = c30532;
                        if (m10833(j4, c3053.f11696) != m10833(j4, c3008.f11577)) {
                            break;
                        }
                    } else {
                        c3053 = c30532;
                    }
                } else {
                    if (c3008.m6278(268435456)) {
                        c3008.f11580 = this.f19852;
                        mo5594(c3008);
                    }
                    if (this.f3593 - c3008.f11577 <= 80000) {
                        List list = this.f19852.f19967;
                        C3673 c3673 = this.f19835;
                        c3673.getClass();
                        c3008.f11582.getClass();
                        if (c3008.f11582.limit() - c3008.f11582.position() != 0) {
                            if (c3673.f13945 == 2 && (list.size() == 1 || list.size() == 3)) {
                                bArr = (byte[]) list.get(0);
                            }
                            ByteBuffer byteBuffer3 = c3008.f11582;
                            int iPosition = byteBuffer3.position();
                            int iLimit = byteBuffer3.limit();
                            int i4 = iLimit - iPosition;
                            int i5 = (i4 + 255) / 255;
                            int i6 = i5 + 27 + i4;
                            if (c3673.f13945 == 2) {
                                length = bArr != null ? bArr.length + 28 : 47;
                                i6 = length + 44 + i6;
                            } else {
                                length = 0;
                            }
                            if (((ByteBuffer) c3673.f13946).capacity() < i6) {
                                c3673.f13946 = ByteBuffer.allocate(i6).order(ByteOrder.LITTLE_ENDIAN);
                            } else {
                                ((ByteBuffer) c3673.f13946).clear();
                            }
                            ByteBuffer byteBuffer4 = (ByteBuffer) c3673.f13946;
                            if (c3673.f13945 == 2) {
                                if (bArr != null) {
                                    C3673.m8286(byteBuffer4, 0L, 0, 1, true);
                                    byteBuffer = byteBuffer4;
                                    c30532 = c3053;
                                    byteBuffer.put(AbstractC3481.m7930(bArr.length));
                                    byteBuffer.put(bArr);
                                    byteBuffer.putInt(22, AbstractC0956.m3249(byteBuffer.arrayOffset(), bArr.length + 28, 0, byteBuffer.array()));
                                    byteBuffer.position(bArr.length + 28);
                                } else {
                                    c30532 = c3053;
                                    byteBuffer = byteBuffer4;
                                    byteBuffer.put(C3673.f13943);
                                }
                                byteBuffer.put(C3673.f13944);
                            } else {
                                c30532 = c3053;
                                byteBuffer = byteBuffer4;
                            }
                            int i7 = c3673.f13947 + ((int) ((ᵹˊᵫˋ.ᵪᵹᵥᵻ(byteBuffer3.get(0), byteBuffer3.limit() > 1 ? byteBuffer3.get(1) : (byte) 0) * 48000) / 1000000));
                            c3673.f13947 = i7;
                            C3673.m8286(byteBuffer, i7, c3673.f13945, i5, false);
                            for (int i8 = 0; i8 < i5; i8++) {
                                if (i4 >= 255) {
                                    byteBuffer.put((byte) -1);
                                    i4 -= 255;
                                } else {
                                    byteBuffer.put((byte) i4);
                                    i4 = 0;
                                }
                            }
                            while (iPosition < iLimit) {
                                byteBuffer.put(byteBuffer3.get(iPosition));
                                iPosition++;
                            }
                            byteBuffer3.position(byteBuffer3.limit());
                            byteBuffer.flip();
                            if (c3673.f13945 == 2) {
                                byteBuffer.putInt(length + 66, AbstractC0956.m3249(byteBuffer.arrayOffset() + length + 44, byteBuffer.limit() - byteBuffer.position(), 0, byteBuffer.array()));
                            } else {
                                byteBuffer.putInt(22, AbstractC0956.m3249(byteBuffer.arrayOffset(), byteBuffer.limit() - byteBuffer.position(), 0, byteBuffer.array()));
                            }
                            c3673.f13945++;
                            c3673.f13946 = byteBuffer;
                            c3008.mo7091();
                            c3008.m7093(((ByteBuffer) c3673.f13946).remaining());
                            c3008.f11582.put((ByteBuffer) c3673.f13946);
                            c3008.m7092();
                        }
                        if (!c30532.m7151()) {
                        }
                    }
                }
            }
        } while (c3053.m7152(c3008));
        this.f19848 = true;
        if (c3053.m7151()) {
            c3053.m7092();
        }
        return c3053.m7151() || this.f19886 || this.f19882;
    }

    /* JADX INFO: renamed from: ʿᵯᴵ, reason: contains not printable characters */
    public boolean m10831() {
        int i = this.f19854;
        if (i == 3 || ((this.f19883 && !this.f19894) || (this.f19842 && this.f19881))) {
            return true;
        }
        if (i != 2) {
            return false;
        }
        try {
            m10851();
            return false;
        } catch (ExoPlaybackException e) {
            ˋˀᵧ.ᵠˏˏ("Failed to update the DRM session, releasing the codec instead.", e);
            return true;
        }
    }

    /* JADX INFO: renamed from: ʿᵿʽᵞ, reason: contains not printable characters */
    public boolean m10832(C5286 c5286) {
        return true;
    }

    /* JADX INFO: renamed from: ˀᵗ, reason: contains not printable characters */
    public final boolean m10833(long j, long j2) {
        if (j2 >= j) {
            return false;
        }
        C5286 c5286 = this.f19852;
        return c5286 == null || !Objects.equals(c5286.f19987, "audio/opus") || j - j2 > 80000;
    }

    /* JADX INFO: renamed from: ˀᵭ, reason: contains not printable characters */
    public final boolean m10834(long j, long j2) throws ExoPlaybackException {
        InterfaceC1595 interfaceC1595 = this.f19898;
        interfaceC1595.getClass();
        int i = this.f19876;
        MediaCodec.BufferInfo bufferInfo = this.f19859;
        if (i < 0) {
            int iMo3037 = interfaceC1595.mo3037(bufferInfo);
            if (iMo3037 < 0) {
                if (iMo3037 != -2) {
                    if (this.f19834 && (this.f19886 || this.f19844 == 2)) {
                        m10859();
                    }
                    long j3 = this.f19866;
                    if (j3 != -9223372036854775807L) {
                        long j4 = j3 + 100;
                        this.f3583.getClass();
                        if (j4 < System.currentTimeMillis()) {
                            m10859();
                            return false;
                        }
                    }
                    return false;
                }
                this.f19894 = true;
                InterfaceC1595 interfaceC15952 = this.f19898;
                interfaceC15952.getClass();
                MediaFormat mediaFormatMo3041 = interfaceC15952.mo3041();
                if (this.f19892 != 0 && mediaFormatMo3041.getInteger("width") == 32 && mediaFormatMo3041.getInteger("height") == 32) {
                    this.f19895 = true;
                    return true;
                }
                if (Build.VERSION.SDK_INT >= 29 && !this.f19885.isEmpty()) {
                    C0204 c0204 = new C0204(C0204.m1364(mediaFormatMo3041, this.f19885).f15519);
                    if (!c0204.equals(this.f19850)) {
                        this.f19850 = c0204;
                        mo5595(c0204);
                    }
                }
                this.f19857 = mediaFormatMo3041;
                this.f19868 = true;
                return true;
            }
            bufferInfo.presentationTimeUs -= this.f19853;
            if (this.f19895) {
                this.f19895 = false;
                interfaceC1595.mo3045(iMo3037);
                return true;
            }
            if (bufferInfo.size == 0 && (bufferInfo.flags & 4) != 0) {
                m10859();
                return false;
            }
            this.f19876 = iMo3037;
            ByteBuffer byteBufferMo3038 = interfaceC1595.mo3038(iMo3037);
            this.f19837 = byteBufferMo3038;
            if (byteBufferMo3038 != null) {
                byteBufferMo3038.position(bufferInfo.offset);
                this.f19837.limit(bufferInfo.offset + bufferInfo.size);
            }
            m10850(bufferInfo.presentationTimeUs);
        }
        boolean z = this.f19875 || bufferInfo.presentationTimeUs < this.f3593;
        long j5 = this.f19901.f19280;
        boolean z2 = j5 != -9223372036854775807L && j5 <= bufferInfo.presentationTimeUs;
        this.f19838 = z2;
        ByteBuffer byteBuffer = this.f19837;
        int i2 = this.f19876;
        int i3 = bufferInfo.flags;
        long j6 = bufferInfo.presentationTimeUs;
        C5286 c5286 = this.f19852;
        c5286.getClass();
        if (!mo5607(j, j2, interfaceC1595, byteBuffer, i2, i3, 1, j6, z, z2, c5286)) {
            return false;
        }
        m10844(bufferInfo.presentationTimeUs);
        boolean z3 = (bufferInfo.flags & 4) != 0;
        if (!z3 && this.f19881 && this.f19838) {
            this.f3583.getClass();
            this.f19866 = System.currentTimeMillis();
        }
        this.f19876 = -1;
        this.f19837 = null;
        if (!z3) {
            return true;
        }
        m10859();
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:25:0x00cd  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x0105  */
    /* JADX INFO: renamed from: ˁʢᵛ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m10835(C1354 c1354, MediaCrypto mediaCrypto) {
        int i;
        this.f19858 = c1354;
        C5286 c5286 = this.f19879;
        c5286.getClass();
        String str = c1354.f5600;
        float f = this.f19888;
        C5286[] c5286Arr = this.f3589;
        c5286Arr.getClass();
        float fMo5597 = mo5597(f, c5286, c5286Arr);
        if (fMo5597 <= this.f19884) {
            fMo5597 = -1.0f;
        }
        this.f3583.getClass();
        long jElapsedRealtime = SystemClock.elapsedRealtime();
        C2781 c2781Mo5601 = mo5601(c1354, c5286, mediaCrypto, fMo5597);
        int i2 = Build.VERSION.SDK_INT;
        if (i2 >= 31) {
            C2136 c2136 = this.f3596;
            c2136.getClass();
            AbstractC5241.m10809(c2781Mo5601, c2136);
        }
        try {
            Trace.beginSection("createCodec:" + str);
            InterfaceC1595 interfaceC1595Mo4937 = this.f19861.mo4937(c2781Mo5601);
            this.f19898 = interfaceC1595Mo4937;
            this.f19874 = interfaceC1595Mo4937.mo3039(new ᵢʒʡᵟ(9, this));
            Trace.endSection();
            this.f3583.getClass();
            long jElapsedRealtime2 = SystemClock.elapsedRealtime();
            if (!c1354.m3879(this.f19897, c5286)) {
                String strM10876 = C5286.m10876(c5286);
                Locale locale = Locale.US;
                ˋˀᵧ.ʿٴˇ("Format exceeds selected codec's capabilities [" + strM10876 + ", " + str + "]");
            }
            this.f19841 = fMo5597;
            this.f19889 = c5286;
            boolean z = false;
            if (i2 <= 25 && "OMX.Exynos.avc.dec.secure".equals(str)) {
                String str2 = Build.MODEL;
                if (str2.startsWith("SM-T585") || str2.startsWith("SM-A510") || str2.startsWith("SM-A520") || str2.startsWith("SM-J700")) {
                    i = 2;
                }
            } else if (i2 >= 24 || !("OMX.Nvidia.h264.decode".equals(str) || "OMX.Nvidia.h264.decode.secure".equals(str))) {
                i = 0;
            } else {
                String str3 = Build.DEVICE;
                if ("flounder".equals(str3) || "flounder_lte".equals(str3) || "grouper".equals(str3) || "tilapia".equals(str3)) {
                    i = 1;
                }
            }
            this.f19892 = i;
            this.f19883 = i2 == 29 && "c2.android.aac.decoder".equals(str);
            this.f19842 = i2 == 23 && "OMX.google.vorbis.decoder".equals(str);
            String str4 = c1354.f5600;
            if ((i2 <= 25 && "OMX.rk.video_decoder.avc".equals(str4)) || ((i2 <= 29 && ("OMX.broadcom.video_decoder.tunnel".equals(str4) || "OMX.broadcom.video_decoder.tunnel.secure".equals(str4) || "OMX.bcm.vdec.avc.tunnel".equals(str4) || "OMX.bcm.vdec.avc.tunnel.secure".equals(str4) || "OMX.bcm.vdec.hevc.tunnel".equals(str4) || "OMX.bcm.vdec.hevc.tunnel.secure".equals(str4))) || ("Amazon".equals(Build.MANUFACTURER) && "AFTS".equals(Build.MODEL) && c1354.f5605))) {
                z = true;
            }
            this.f19834 = z;
            this.f19898.getClass();
            if (this.f3588 == 2) {
                this.f3583.getClass();
                this.f19900 = SystemClock.elapsedRealtime() + 1000;
            }
            this.f19843.f9825++;
            long j = jElapsedRealtime2 - jElapsedRealtime;
            if (i2 >= 31 && !this.f19885.isEmpty()) {
                InterfaceC1595 interfaceC1595 = this.f19898;
                interfaceC1595.getClass();
                interfaceC1595.mo3029(new ArrayList(this.f19885));
            }
            mo5605(jElapsedRealtime2, j, str);
        } catch (Throwable th) {
            Trace.endSection();
            throw th;
        }
    }

    /* JADX INFO: renamed from: ˁˌᵩ, reason: contains not printable characters */
    public final boolean m10836() throws ExoPlaybackException {
        if (!this.f19893) {
            m10851();
            return true;
        }
        this.f19844 = 1;
        if (this.f19842) {
            this.f19854 = 3;
            return false;
        }
        this.f19854 = 2;
        return true;
    }

    /* JADX WARN: Code restructure failed: missing block: B:75:0x0111, code lost:
    
        if (r4.mo4240(r2) != false) goto L140;
     */
    /* JADX WARN: Removed duplicated region for block: B:12:0x0032  */
    /* JADX WARN: Removed duplicated region for block: B:32:0x0063  */
    /* JADX WARN: Removed duplicated region for block: B:93:0x0145  */
    /* JADX INFO: renamed from: ˁᵺˈ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public C4394 mo5590(ˊˊᵞᵽ r15) throws ExoPlaybackException {
        C5286 c5286;
        int i;
        Pair pairM5109;
        boolean z = true;
        this.f19887 = true;
        C5286 c52862 = (C5286) r15.ᵔᵖᵹᵫ;
        c52862.getClass();
        String str = c52862.f19987;
        if (str == null) {
            throw m2900(new IllegalArgumentException("Sample MIME type is null."), c52862, false, 4005);
        }
        if (!str.equals("video/av01") && !str.equals("video/x-vnd.on2.vp9")) {
            if (str.equals("video/dolby-vision")) {
                byte[] bArr = AbstractC1879.f7440;
                if (str.equals("video/dolby-vision") && (pairM5109 = AbstractC1879.m5109(c52862)) != null) {
                    int iIntValue = ((Integer) pairM5109.first).intValue();
                    String str2 = (iIntValue == 16 || iIntValue == 32 || iIntValue == 256) ? "video/hevc" : iIntValue != 512 ? iIntValue != 1024 ? null : "video/av01" : "video/avc";
                    if (Objects.equals(str2, "video/av01")) {
                    }
                }
            }
            c5286 = c52862;
        } else if (c52862.f19967.isEmpty()) {
            c5286 = c52862;
        } else {
            C4753 c4753M10878 = c52862.m10878();
            c4753M10878.f18119 = null;
            c5286 = new C5286(c4753M10878);
        }
        InterfaceC4417 interfaceC4417 = (InterfaceC4417) r15.ᵜᵪʾ;
        AbstractC3589.m8104(this.f19840, interfaceC4417);
        this.f19840 = interfaceC4417;
        this.f19879 = c5286;
        if (this.f19880) {
            this.f19882 = true;
            return null;
        }
        InterfaceC1595 interfaceC1595 = this.f19898;
        if (interfaceC1595 == null) {
            this.f19899 = null;
            m10843();
            return null;
        }
        C1354 c1354 = this.f19858;
        c1354.getClass();
        C5286 c52863 = this.f19889;
        c52863.getClass();
        InterfaceC4417 interfaceC44172 = this.f19847;
        InterfaceC4417 interfaceC44173 = this.f19840;
        if (interfaceC44172 != interfaceC44173) {
            if (interfaceC44173 != null && interfaceC44172 != null && interfaceC44173.mo4234() != null && interfaceC44172.mo4234() != null && C2639.class.equals(C2639.class) && interfaceC44173.mo4237().equals(interfaceC44172.mo4237())) {
                UUID uuid = AbstractC3361.f12879;
                if (!uuid.equals(interfaceC44172.mo4237()) && !uuid.equals(interfaceC44173.mo4237())) {
                    if (!c1354.f5605) {
                        if (interfaceC44173.mo4236() != 2) {
                            if (interfaceC44173.mo4236() == 3 || interfaceC44173.mo4236() == 4) {
                                String str3 = c5286.f19987;
                                str3.getClass();
                            }
                        }
                    }
                }
            }
            if (this.f19893) {
                this.f19844 = 1;
                this.f19854 = 3;
            } else {
                m10846();
                m10843();
            }
            return new C4394(c1354.f5600, c52863, c5286, 0, 128);
        }
        boolean z2 = this.f19840 != this.f19847;
        C4394 c4394Mo5603 = mo5603(c1354, c52863, c5286, m10853().f19277);
        int i2 = c4394Mo5603.f16685;
        if (i2 != 0) {
            if (i2 == 1) {
                if (m10861(c5286)) {
                    this.f19889 = c5286;
                    if (z2) {
                        if (!m10836()) {
                        }
                    } else if (this.f19893) {
                        this.f19844 = 1;
                        if (this.f19842) {
                            this.f19854 = 3;
                            i = 2;
                        } else {
                            this.f19854 = 1;
                        }
                    }
                }
                i = 16;
            } else if (i2 == 2) {
                if (m10861(c5286)) {
                    this.f19869 = true;
                    this.f19851 = 1;
                    int i3 = this.f19892;
                    if (i3 != 2 && (i3 != 1 || c5286.f19973 != c52863.f19973 || c5286.f19981 != c52863.f19981)) {
                        z = false;
                    }
                    this.f19870 = z;
                    this.f19889 = c5286;
                    if (!z2 || m10836()) {
                    }
                }
                i = 16;
            } else {
                if (i2 != 3) {
                    ᵷᵝˎ.ᵱʡˏ();
                    return null;
                }
                if (m10861(c5286)) {
                    this.f19889 = c5286;
                    if (z2 && !m10836()) {
                        i = 2;
                    }
                }
                i = 16;
            }
            return (i2 != 0 || (this.f19898 == interfaceC1595 && this.f19854 != 3)) ? c4394Mo5603 : new C4394(c1354.f5600, c52863, c5286, 0, i);
        }
        if (this.f19893) {
            this.f19844 = 1;
            this.f19854 = 3;
        } else {
            m10846();
            m10843();
        }
        i = 0;
        if (i2 != 0) {
        }
    }

    /* JADX INFO: renamed from: ˆʤᵳ */
    public abstract void mo5591();

    /* JADX INFO: renamed from: ˆˀᵯ, reason: contains not printable characters */
    public boolean m10837(C3008 c3008) {
        return false;
    }

    @Override // defpackage.AbstractC0799
    /* JADX INFO: renamed from: ˈᵲᵢ */
    public final int mo376(C5286 c5286) throws ExoPlaybackException {
        try {
            return mo5602(this.f19833, c5286);
        } catch (MediaCodecUtil$DecoderQueryException e) {
            throw this.m2900(e, c5286, false, 4002);
        }
    }

    /* JADX INFO: renamed from: ˈⁱᵡ */
    public long mo5592(long j, long j2, boolean z) {
        return super.mo381(j, j2);
    }

    /* JADX INFO: renamed from: ˉˆᵗ */
    public abstract void mo5593(String str);

    /* JADX INFO: renamed from: ˉᵵᵜ, reason: contains not printable characters */
    public MediaCodecDecoderException m10838(IllegalStateException illegalStateException, C1354 c1354) {
        return new MediaCodecDecoderException(illegalStateException, c1354);
    }

    /* JADX INFO: renamed from: ˊˌˊ */
    public abstract void mo5594(C3008 c3008);

    /* JADX INFO: renamed from: ˊᵡᵗʨ, reason: contains not printable characters */
    public final void m10839() {
        try {
            InterfaceC1595 interfaceC1595 = this.f19898;
            interfaceC1595.getClass();
            interfaceC1595.flush();
        } finally {
            m10855();
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:15:0x003a, code lost:
    
        if (r4 >= r0) goto L16;
     */
    @Override // defpackage.AbstractC0799
    /* JADX INFO: renamed from: ˊᵨᵧ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void mo380(C5286[] c5286Arr, long j, long j2, C4100 c4100) {
        if (this.f19901.f19276 == -9223372036854775807L) {
            m10852(new C5123(-9223372036854775807L, j, j2));
            if (this.f19864) {
                mo5599();
                return;
            }
            return;
        }
        ArrayDeque arrayDeque = this.f19871;
        if (arrayDeque.isEmpty()) {
            long j3 = this.f19856;
            if (j3 != -9223372036854775807L) {
                long j4 = this.f19896;
                if (j4 != -9223372036854775807L) {
                }
            }
            m10852(new C5123(-9223372036854775807L, j, j2));
            if (this.f19901.f19276 != -9223372036854775807L) {
                mo5599();
                return;
            }
            return;
        }
        arrayDeque.add(new C5123(this.f19856, j, j2));
    }

    @Override // defpackage.AbstractC0799
    /* JADX INFO: renamed from: ˊᵫᵗ */
    public final long mo381(long j, long j2) {
        return mo5592(j, j2, this.f19874);
    }

    /* JADX WARN: Removed duplicated region for block: B:17:0x0032  */
    /* JADX WARN: Removed duplicated region for block: B:23:0x0049  */
    /* JADX INFO: renamed from: ˊᵾʽʼ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean m10840() throws ExoPlaybackException {
        InterfaceC1595 interfaceC1595 = this.f19898;
        if (interfaceC1595 != null && this.f19844 != 2 && !this.f19886) {
            int i = this.f19877;
            C3008 c3008 = this.f19849;
            if (i < 0) {
                int iMo3042 = interfaceC1595.mo3042();
                this.f19877 = iMo3042;
                if (iMo3042 >= 0) {
                    c3008.f11582 = interfaceC1595.mo3036(iMo3042);
                    c3008.mo7091();
                    if (this.f19844 != 1) {
                        if (!this.f19834) {
                            this.f19881 = true;
                            interfaceC1595.mo3035(this.f19877, 0, 0L, 4);
                            this.f19877 = -1;
                            c3008.f11582 = null;
                        }
                        this.f19844 = 2;
                        return false;
                    }
                    if (this.f19870) {
                        this.f19870 = false;
                        ByteBuffer byteBuffer = c3008.f11582;
                        byteBuffer.getClass();
                        byteBuffer.put(f19832);
                        interfaceC1595.mo3035(this.f19877, 38, 0L, 0);
                        this.f19877 = -1;
                        c3008.f11582 = null;
                        this.f19893 = true;
                        return true;
                    }
                    if (this.f19851 == 1) {
                        int i2 = 0;
                        while (true) {
                            C5286 c5286 = this.f19889;
                            c5286.getClass();
                            if (i2 >= c5286.f19967.size()) {
                                break;
                            }
                            byte[] bArr = (byte[]) this.f19889.f19967.get(i2);
                            ByteBuffer byteBuffer2 = c3008.f11582;
                            byteBuffer2.getClass();
                            byteBuffer2.put(bArr);
                            i2++;
                        }
                        this.f19851 = 2;
                    }
                    ByteBuffer byteBuffer3 = c3008.f11582;
                    byteBuffer3.getClass();
                    int iPosition = byteBuffer3.position();
                    ˊˊᵞᵽ r3 = this.f3590;
                    r3.ᵻˈᵦʼ();
                    try {
                        interfaceC1595.mo3044(new RunnableC4076(this, 29, r3));
                        int i3 = this.f19878.get();
                        if (i3 == -3) {
                            if (m2899()) {
                                m10853().f19280 = this.f19856;
                                return false;
                            }
                        } else {
                            if (i3 == -5) {
                                if (this.f19851 == 2) {
                                    c3008.mo7091();
                                    this.f19851 = 1;
                                }
                                mo5590(r3);
                                return true;
                            }
                            if (!c3008.m6278(4)) {
                                if (this.f19893 || c3008.m6278(1)) {
                                    long j = c3008.f11577;
                                    if (!m10837(c3008)) {
                                        boolean zM6278 = c3008.m6278(1073741824);
                                        if (zM6278) {
                                            C1243 c1243 = c3008.f11581;
                                            if (iPosition == 0) {
                                                c1243.getClass();
                                            } else {
                                                if (c1243.f5257 == null) {
                                                    int[] iArr = new int[1];
                                                    c1243.f5257 = iArr;
                                                    c1243.f5258.numBytesOfClearData = iArr;
                                                }
                                                int[] iArr2 = c1243.f5257;
                                                iArr2[0] = iArr2[0] + iPosition;
                                            }
                                        }
                                        if (this.f19887) {
                                            C5123 c5123M10853 = m10853();
                                            C0760 c0760 = c5123M10853.f19279;
                                            C5286 c52862 = this.f19879;
                                            c52862.getClass();
                                            c0760.m2710(j, c52862);
                                            c5123M10853.f19277 = true;
                                            this.f19887 = false;
                                        }
                                        this.f19856 = Math.max(this.f19856, j);
                                        if (m2899() || c3008.m6278(536870912)) {
                                            m10853().f19280 = this.f19856;
                                        }
                                        c3008.m7092();
                                        if (c3008.m6278(268435456)) {
                                            mo5594(c3008);
                                        }
                                        if (this.f19875) {
                                            long j2 = this.f19856;
                                            if (j <= j2) {
                                                this.f19853 = (j2 - j) + 1 + this.f19853;
                                            }
                                            this.f19856 = j;
                                            this.f19875 = false;
                                        }
                                        m10854(c3008);
                                        int iM10858 = m10858(c3008);
                                        long j3 = j + this.f19853;
                                        int i4 = this.f19877;
                                        if (zM6278) {
                                            interfaceC1595.mo3043(i4, c3008.f11581, j3, iM10858);
                                        } else {
                                            ByteBuffer byteBuffer4 = c3008.f11582;
                                            byteBuffer4.getClass();
                                            interfaceC1595.mo3035(i4, byteBuffer4.limit(), j3, iM10858);
                                        }
                                        this.f19877 = -1;
                                        c3008.f11582 = null;
                                        this.f19893 = true;
                                        this.f19851 = 0;
                                        this.f19843.f9821++;
                                        return true;
                                    }
                                } else {
                                    c3008.mo7091();
                                    if (this.f19851 == 2) {
                                        this.f19851 = 1;
                                        return true;
                                    }
                                }
                                return true;
                            }
                            m10853().f19280 = this.f19856;
                            if (this.f19851 == 2) {
                                c3008.mo7091();
                                this.f19851 = 1;
                            }
                            this.f19886 = true;
                            if (!this.f19893) {
                                m10859();
                                return false;
                            }
                            if (!this.f19834) {
                                this.f19881 = true;
                                interfaceC1595.mo3035(this.f19877, 0, 0L, 4);
                                this.f19877 = -1;
                                c3008.f11582 = null;
                                return false;
                            }
                        }
                    } catch (DecoderInputBuffer$InsufficientCapacityException e) {
                        mo5604(e);
                        m10841(0);
                        m10839();
                        return true;
                    }
                }
            } else if (this.f19844 != 1) {
            }
        }
        return false;
    }

    /* JADX INFO: renamed from: ˋʿᐧ */
    public abstract void mo5595(C0204 c0204);

    @Override // defpackage.AbstractC0799
    /* JADX INFO: renamed from: ˋˈ */
    public void mo383() {
        this.f19879 = null;
        m10852(C5123.f19274);
        this.f19871.clear();
        if (this.f19880) {
            this.f19880 = false;
            m10860();
        } else {
            if (this.f19898 == null) {
                return;
            }
            if (m10831()) {
                m10846();
            } else if (m10847()) {
                m10839();
            } else {
                this.f19875 = true;
            }
        }
    }

    /* JADX INFO: renamed from: ˋᵯᵩ */
    public abstract void mo5596(C5286 c5286, MediaFormat mediaFormat);

    @Override // defpackage.AbstractC0799
    /* JADX INFO: renamed from: ˌᵨʠᵫ */
    public final int mo384() {
        return 8;
    }

    /* JADX INFO: renamed from: ˏʜᵪ, reason: contains not printable characters */
    public final boolean m10841(int i) throws ExoPlaybackException {
        ˊˊᵞᵽ r0 = this.f3590;
        r0.ᵻˈᵦʼ();
        C3008 c3008 = this.f19873;
        c3008.mo7091();
        int iM2893 = m2893(r0, c3008, i | 4);
        if (iM2893 == -5) {
            mo5590(r0);
            return true;
        }
        if (iM2893 != -4 || !c3008.m6278(4)) {
            return false;
        }
        this.f19886 = true;
        m10859();
        return false;
    }

    /* JADX INFO: renamed from: ˏʽˊᵰ, reason: contains not printable characters */
    public final void m10842() {
        m10855();
        this.f19865 = null;
        this.f19899 = null;
        this.f19858 = null;
        this.f19889 = null;
        this.f19857 = null;
        this.f19868 = false;
        this.f19894 = false;
        this.f19841 = -1.0f;
        this.f19892 = 0;
        this.f19883 = false;
        this.f19842 = false;
        this.f19834 = false;
        this.f19874 = false;
        this.f19869 = false;
        this.f19851 = 0;
    }

    /* JADX WARN: Removed duplicated region for block: B:38:0x0084  */
    /* JADX WARN: Removed duplicated region for block: B:59:0x00c5  */
    /* JADX INFO: renamed from: ˏᵩʨ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m10843() throws ExoPlaybackException {
        C5286 c5286;
        InterfaceC4417 interfaceC4417;
        if (this.f19898 != null || this.f19880 || (c5286 = this.f19879) == null) {
            return;
        }
        String str = c5286.f19987;
        boolean z = true;
        if (this.f19840 == null && mo5598(c5286)) {
            this.f19880 = false;
            m10860();
            boolean zEquals = "audio/mp4a-latm".equals(str);
            C3053 c3053 = this.f19836;
            if (zEquals || "audio/mpeg".equals(str) || "audio/opus".equals(str)) {
                c3053.getClass();
                c3053.f11697 = 32;
            } else {
                c3053.getClass();
                c3053.f11697 = 1;
            }
            this.f19880 = true;
            return;
        }
        m10856(this.f19840);
        if (this.f19847 == null) {
            try {
                interfaceC4417 = this.f19847;
                if (interfaceC4417 == null && (interfaceC4417.mo4236() == 3 || this.f19847.mo4236() == 4)) {
                    InterfaceC4417 interfaceC44172 = this.f19847;
                    str.getClass();
                    if (interfaceC44172.mo4240(str)) {
                    }
                    m10848(this.f19872, z);
                } else {
                    z = false;
                    m10848(this.f19872, z);
                }
            } catch (MediaCodecRenderer$DecoderInitializationException e) {
                throw m2900(e, c5286, false, 4001);
            }
        } else {
            ᵻᵪ.ˌᴵ(this.f19872 == null);
            InterfaceC4417 interfaceC44173 = this.f19847;
            C2639 c2639Mo4234 = interfaceC44173.mo4234();
            if (!C2639.f10243 || c2639Mo4234 == null) {
                if (c2639Mo4234 != null) {
                    try {
                        this.f19872 = new MediaCrypto(c2639Mo4234.f10245, c2639Mo4234.f10244);
                    } catch (MediaCryptoException e2) {
                        throw m2900(e2, this.f19879, false, 6006);
                    }
                } else if (interfaceC44173.mo4238() != null) {
                }
                interfaceC4417 = this.f19847;
                if (interfaceC4417 == null) {
                    z = false;
                    m10848(this.f19872, z);
                }
            } else {
                int iMo4236 = interfaceC44173.mo4236();
                if (iMo4236 == 1) {
                    DrmSession$DrmSessionException drmSession$DrmSessionExceptionMo4238 = interfaceC44173.mo4238();
                    drmSession$DrmSessionExceptionMo4238.getClass();
                    throw m2900(drmSession$DrmSessionExceptionMo4238, this.f19879, false, drmSession$DrmSessionExceptionMo4238.f628);
                }
                if (iMo4236 == 4) {
                }
            }
        }
        MediaCrypto mediaCrypto = this.f19872;
        if (mediaCrypto == null || this.f19898 != null) {
            return;
        }
        mediaCrypto.release();
        this.f19872 = null;
    }

    @Override // defpackage.AbstractC0799, defpackage.InterfaceC1896
    /* JADX INFO: renamed from: ːˏᵟᵯ */
    public void mo386(int i, Object obj) {
        int i2;
        if (i == 11) {
            C4311 c4311 = (C4311) obj;
            c4311.getClass();
            this.f19855 = c4311;
            return;
        }
        if (i != 21) {
            if (i == 22 && (i2 = Build.VERSION.SDK_INT) >= 29) {
                obj.getClass();
                AbstractC5291 abstractC5291 = (AbstractC5291) obj;
                if (this.f19885.equals(abstractC5291)) {
                    return;
                }
                if (i2 >= 31) {
                    HashSet hashSet = new HashSet(abstractC5291);
                    HashSet hashSet2 = new HashSet();
                    AbstractC0228 it = this.f19885.iterator();
                    while (it.hasNext()) {
                        String str = (String) it.next();
                        if (!hashSet.remove(str)) {
                            hashSet2.add(str);
                        }
                    }
                    InterfaceC1595 interfaceC1595 = this.f19898;
                    if (interfaceC1595 != null) {
                        if (!hashSet2.isEmpty()) {
                            interfaceC1595.mo3032(new ArrayList(hashSet2));
                        }
                        if (!hashSet.isEmpty()) {
                            interfaceC1595.mo3029(new ArrayList(hashSet));
                        }
                    }
                }
                this.f19885 = abstractC5291;
                return;
            }
            return;
        }
        if (Build.VERSION.SDK_INT >= 29) {
            obj.getClass();
            C0204 c0204 = (C0204) obj;
            this.f19862 = c0204;
            InterfaceC1595 interfaceC15952 = this.f19898;
            if (interfaceC15952 != null) {
                Bundle bundle = new Bundle();
                for (Map.Entry entry : c0204.f1674.entrySet()) {
                    String str2 = (String) entry.getKey();
                    Object value = entry.getValue();
                    if (value != null) {
                        if (value instanceof Integer) {
                            bundle.putInt(str2, ((Integer) value).intValue());
                        } else if (value instanceof Long) {
                            bundle.putLong(str2, ((Long) value).longValue());
                        } else if (value instanceof Float) {
                            bundle.putFloat(str2, ((Float) value).floatValue());
                        } else if (value instanceof String) {
                            bundle.putString(str2, (String) value);
                        } else if (value instanceof ByteBuffer) {
                            ByteBuffer byteBuffer = (ByteBuffer) value;
                            byte[] bArr = new byte[byteBuffer.remaining()];
                            byteBuffer.duplicate().get(bArr);
                            bundle.putByteArray(str2, bArr);
                        }
                    }
                }
                interfaceC15952.mo3027(bundle);
            }
        }
    }

    /* JADX INFO: renamed from: ːᵝٴᵶ, reason: contains not printable characters */
    public void m10844(long j) {
        this.f19896 = j;
        while (true) {
            ArrayDeque arrayDeque = this.f19871;
            if (arrayDeque.isEmpty() || j < ((C5123) arrayDeque.peek()).f19278) {
                return;
            }
            C5123 c5123 = (C5123) arrayDeque.poll();
            c5123.getClass();
            m10852(c5123);
            mo5599();
        }
    }

    /* JADX INFO: renamed from: ˑʢ */
    public abstract float mo5597(float f, C5286 c5286, C5286[] c5286Arr);

    /* JADX INFO: renamed from: ˑˊᵲ, reason: contains not printable characters */
    public final void m10845(MediaFormat mediaFormat) {
        if (Build.VERSION.SDK_INT >= 29) {
            for (Map.Entry entry : this.f19862.f1674.entrySet()) {
                String str = (String) entry.getKey();
                Object value = entry.getValue();
                if (value == null) {
                    mediaFormat.setString(str, null);
                } else if (value instanceof Integer) {
                    mediaFormat.setInteger(str, ((Integer) value).intValue());
                } else if (value instanceof Long) {
                    mediaFormat.setLong(str, ((Long) value).longValue());
                } else if (value instanceof Float) {
                    mediaFormat.setFloat(str, ((Float) value).floatValue());
                } else if (value instanceof String) {
                    mediaFormat.setString(str, (String) value);
                } else if (value instanceof ByteBuffer) {
                    mediaFormat.setByteBuffer(str, (ByteBuffer) value);
                }
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:41:0x0078 A[LOOP:1: B:31:0x0053->B:41:0x0078, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:52:0x0099 A[LOOP:2: B:42:0x0079->B:52:0x0099, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:87:0x0079 A[EDGE_INSN: B:87:0x0079->B:90:? BREAK  A[LOOP:1: B:31:0x0053->B:41:0x0078], SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:88:0x009a A[EDGE_INSN: B:88:0x009a->B:53:0x009a BREAK  A[LOOP:2: B:42:0x0079->B:52:0x0099], SYNTHETIC] */
    @Override // defpackage.AbstractC0799
    /* JADX INFO: renamed from: ᵔᵖᵹᵫ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void mo388(long j, long j2) throws ExoPlaybackException {
        boolean z;
        boolean z2;
        boolean z3 = false;
        if (this.f19890) {
            this.f19890 = false;
            m10859();
        }
        ExoPlaybackException exoPlaybackException = this.f19865;
        if (exoPlaybackException != null) {
            this.f19865 = null;
            throw exoPlaybackException;
        }
        try {
            if (this.f19863) {
                mo5591();
                return;
            }
            if (this.f19879 != null || m10841(2)) {
                m10843();
                if (this.f19880) {
                    Trace.beginSection("bypassRender");
                    while (m10830(j, j2)) {
                    }
                    Trace.endSection();
                } else if (this.f19898 != null) {
                    this.f3583.getClass();
                    long jElapsedRealtime = SystemClock.elapsedRealtime();
                    Trace.beginSection("drainAndFeed");
                    while (m10834(j, j2)) {
                        long j3 = this.f19860;
                        if (j3 != -9223372036854775807L) {
                            this.f3583.getClass();
                            if (SystemClock.elapsedRealtime() - jElapsedRealtime < j3) {
                                z2 = true;
                                if (!z2) {
                                    break;
                                }
                            } else {
                                z2 = false;
                                if (!z2) {
                                }
                            }
                        } else {
                            z2 = true;
                            if (!z2) {
                            }
                        }
                    }
                    while (m10840()) {
                        long j4 = this.f19860;
                        if (j4 != -9223372036854775807L) {
                            this.f3583.getClass();
                            if (SystemClock.elapsedRealtime() - jElapsedRealtime < j4) {
                                z = true;
                                if (!z) {
                                    break;
                                }
                            } else {
                                z = false;
                                if (!z) {
                                }
                            }
                        } else {
                            z = true;
                            if (!z) {
                            }
                        }
                    }
                    Trace.endSection();
                } else {
                    C2537 c2537 = this.f19843;
                    int i = c2537.f9828;
                    InterfaceC4833 interfaceC4833 = this.f3597;
                    interfaceC4833.getClass();
                    c2537.f9828 = i + interfaceC4833.mo1986(j - this.f3580);
                    m10841(1);
                }
                synchronized (this.f19843) {
                }
            }
        } catch (MediaCodec.CryptoException e) {
            throw m2900(e, this.f19879, false, AbstractC0956.m3219(e.getErrorCode()));
        } catch (IllegalStateException e2) {
            boolean z4 = e2 instanceof MediaCodec.CodecException;
            if (!z4) {
                StackTraceElement[] stackTrace = e2.getStackTrace();
                if (stackTrace.length <= 0 || !stackTrace[0].getClassName().equals("android.media.MediaCodec")) {
                    throw e2;
                }
            }
            mo5604(e2);
            if (z4 && ((MediaCodec.CodecException) e2).isRecoverable()) {
                z3 = true;
            }
            if (z3) {
                m10846();
            }
            MediaCodecDecoderException mediaCodecDecoderExceptionM10838 = m10838(e2, this.f19858);
            throw m2900(mediaCodecDecoderExceptionM10838, this.f19879, z3, mediaCodecDecoderExceptionM10838.f647 == 1101 ? 4006 : 4003);
        }
    }

    /* JADX INFO: renamed from: ᵕᵜʽᵰ */
    public boolean mo5598(C5286 c5286) {
        return false;
    }

    /* JADX INFO: renamed from: ᵗᵭ */
    public abstract void mo5599();

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX INFO: renamed from: ᵘᵝ, reason: contains not printable characters */
    public final void m10846() {
        try {
            InterfaceC1595 interfaceC1595 = this.f19898;
            if (interfaceC1595 != null) {
                interfaceC1595.mo3040();
                this.f19843.f9819++;
                C1354 c1354 = this.f19858;
                c1354.getClass();
                mo5593(c1354.f5600);
            }
            this.f19898 = null;
            try {
                MediaCrypto mediaCrypto = this.f19872;
                if (mediaCrypto != null) {
                    mediaCrypto.release();
                }
            } finally {
            }
        } catch (Throwable th) {
            this.f19898 = null;
            try {
                MediaCrypto mediaCrypto2 = this.f19872;
                if (mediaCrypto2 != null) {
                    mediaCrypto2.release();
                }
                throw th;
            } finally {
            }
        }
    }

    /* JADX INFO: renamed from: ᵚᵹᵔᵜ, reason: contains not printable characters */
    public boolean m10847() {
        return true;
    }

    /* JADX INFO: renamed from: ᵛˀˊ, reason: contains not printable characters */
    public final void m10848(MediaCrypto mediaCrypto, boolean z) throws MediaCodecRenderer$DecoderInitializationException {
        C5286 c5286 = this.f19879;
        c5286.getClass();
        if (this.f19899 == null) {
            try {
                List listM10849 = m10849(z);
                ArrayDeque arrayDeque = new ArrayDeque();
                this.f19899 = arrayDeque;
                if (this.f19846) {
                    arrayDeque.addAll(listM10849);
                } else {
                    ArrayList arrayList = (ArrayList) listM10849;
                    if (!arrayList.isEmpty()) {
                        this.f19899.add((C1354) arrayList.get(0));
                    }
                }
                this.f19891 = null;
            } catch (MediaCodecUtil$DecoderQueryException e) {
                throw new MediaCodecRenderer$DecoderInitializationException(c5286, e, z, -49998);
            }
        }
        if (this.f19899.isEmpty()) {
            throw new MediaCodecRenderer$DecoderInitializationException(c5286, null, z, -49999);
        }
        ArrayDeque arrayDeque2 = this.f19899;
        arrayDeque2.getClass();
        while (this.f19898 == null) {
            C1354 c1354 = (C1354) arrayDeque2.peekFirst();
            c1354.getClass();
            if (!m10832(c5286) || !m10857(c1354)) {
                return;
            }
            try {
                m10835(c1354, mediaCrypto);
            } catch (Exception e2) {
                ˋˀᵧ.ᵠˏˏ("Failed to initialize decoder: " + c1354, e2);
                arrayDeque2.removeFirst();
                MediaCodecRenderer$DecoderInitializationException mediaCodecRenderer$DecoderInitializationException = new MediaCodecRenderer$DecoderInitializationException("Decoder init failed: " + c1354.f5600 + ", " + c5286, e2, c5286.f19987, z, c1354, e2 instanceof MediaCodec.CodecException ? ((MediaCodec.CodecException) e2).getDiagnosticInfo() : null);
                mo5604(mediaCodecRenderer$DecoderInitializationException);
                MediaCodecRenderer$DecoderInitializationException mediaCodecRenderer$DecoderInitializationException2 = this.f19891;
                if (mediaCodecRenderer$DecoderInitializationException2 == null) {
                    this.f19891 = mediaCodecRenderer$DecoderInitializationException;
                } else {
                    this.f19891 = new MediaCodecRenderer$DecoderInitializationException(mediaCodecRenderer$DecoderInitializationException2.getMessage(), mediaCodecRenderer$DecoderInitializationException2.getCause(), mediaCodecRenderer$DecoderInitializationException2.f648, mediaCodecRenderer$DecoderInitializationException2.f650, mediaCodecRenderer$DecoderInitializationException2.f649, mediaCodecRenderer$DecoderInitializationException2.f651);
                }
                if (arrayDeque2.isEmpty()) {
                    throw this.f19891;
                }
            }
        }
        this.f19899 = null;
    }

    /* JADX INFO: renamed from: ᵛˑﹳ, reason: contains not printable characters */
    public final List m10849(boolean z) {
        C5286 c5286 = this.f19879;
        c5286.getClass();
        InterfaceC2978 interfaceC2978 = this.f19833;
        ArrayList arrayListMo5587 = mo5587(interfaceC2978, c5286, z);
        if (!arrayListMo5587.isEmpty() || !z) {
            return arrayListMo5587;
        }
        ArrayList arrayListMo55872 = mo5587(interfaceC2978, c5286, false);
        if (!arrayListMo55872.isEmpty()) {
            ˋˀᵧ.ʿٴˇ("Drm session requires secure decoder for " + c5286.f19987 + ", but no secure decoder available. Trying to proceed with " + arrayListMo55872 + ".");
        }
        return arrayListMo55872;
    }

    /* JADX INFO: renamed from: ᵜᵤ */
    public void mo5600(long j) {
    }

    /* JADX INFO: renamed from: ᵞᵛᵘ */
    public abstract C2781 mo5601(C1354 c1354, C5286 c5286, MediaCrypto mediaCrypto, float f);

    /* JADX INFO: renamed from: ᵟᵴᵥ */
    public abstract int mo5602(InterfaceC2978 interfaceC2978, C5286 c5286);

    @Override // defpackage.AbstractC0799
    /* JADX INFO: renamed from: ᵟᵹᵙ */
    public void mo390(long j, boolean z, boolean z2) throws ExoPlaybackException {
        ArrayDeque arrayDeque = this.f19871;
        if (!arrayDeque.isEmpty()) {
            this.f19901 = (C5123) arrayDeque.getLast();
        }
        arrayDeque.clear();
        if (z2) {
            this.f19886 = false;
            this.f19863 = false;
            this.f19890 = false;
            if (this.f19880) {
                m10860();
            } else if (this.f19898 != null) {
                if (m10831()) {
                    m10846();
                    m10843();
                } else if (m10847()) {
                    m10839();
                } else {
                    this.f19875 = true;
                }
            }
            if (this.f19901.f19279.m2726() > 0) {
                this.f19887 = true;
            }
            this.f19901.f19279.m2723();
            this.f19901.f19277 = false;
        }
    }

    /* JADX INFO: renamed from: ᵠˏˏ */
    public abstract C4394 mo5603(C1354 c1354, C5286 c5286, C5286 c52862, boolean z);

    /* JADX INFO: renamed from: ᵠᵚˀᵫ, reason: contains not printable characters */
    public final void m10850(long j) {
        C5286 c5286 = (C5286) this.f19901.f19279.m2728(j);
        if (c5286 == null && this.f19845 && this.f19857 != null) {
            c5286 = (C5286) this.f19901.f19279.m2733();
        }
        if (c5286 != null) {
            this.f19852 = c5286;
        } else if (!this.f19868 || this.f19852 == null) {
            return;
        }
        C5286 c52862 = this.f19852;
        c52862.getClass();
        mo5596(c52862, this.f19857);
        this.f19868 = false;
        this.f19845 = false;
    }

    /* JADX INFO: renamed from: ᵠᵲˁ, reason: contains not printable characters */
    public final void m10851() throws ExoPlaybackException {
        InterfaceC4417 interfaceC4417 = this.f19840;
        interfaceC4417.getClass();
        C2639 c2639Mo4234 = interfaceC4417.mo4234();
        if (c2639Mo4234 != null) {
            try {
                MediaCrypto mediaCrypto = this.f19872;
                mediaCrypto.getClass();
                mediaCrypto.setMediaDrmSession(c2639Mo4234.f10244);
            } catch (MediaCryptoException e) {
                throw m2900(e, this.f19879, false, 6006);
            }
        }
        m10856(this.f19840);
        this.f19844 = 0;
        this.f19854 = 0;
    }

    /* JADX INFO: renamed from: ᵡᵶ */
    public abstract void mo5604(Exception exc);

    /* JADX INFO: renamed from: ᵡᵶᵬʤ */
    public abstract void mo5605(long j, long j2, String str);

    /* JADX INFO: renamed from: ᵧᵢᵴᵸ, reason: contains not printable characters */
    public final void m10852(C5123 c5123) {
        this.f19901 = c5123;
        long j = c5123.f19276;
        if (j != -9223372036854775807L) {
            this.f19845 = true;
            mo5600(j);
        }
    }

    /* JADX INFO: renamed from: ᵨˈʼﹶ, reason: contains not printable characters */
    public final C5123 m10853() {
        ArrayDeque arrayDeque = this.f19871;
        return !arrayDeque.isEmpty() ? (C5123) arrayDeque.getLast() : this.f19901;
    }

    /* JADX INFO: renamed from: ᵫˈᵹ, reason: contains not printable characters */
    public void m10854(C3008 c3008) {
    }

    /* JADX INFO: renamed from: ᵬᵦˋ */
    public abstract boolean mo5607(long j, long j2, InterfaceC1595 interfaceC1595, ByteBuffer byteBuffer, int i, int i2, int i3, long j3, boolean z, boolean z2, C5286 c5286);

    /* JADX INFO: renamed from: ᵮᵟᵡ, reason: contains not printable characters */
    public void m10855() {
        this.f19877 = -1;
        this.f19849.f11582 = null;
        this.f19876 = -1;
        this.f19837 = null;
        this.f19856 = -9223372036854775807L;
        m10853().f19280 = -9223372036854775807L;
        this.f19896 = -9223372036854775807L;
        this.f19900 = -9223372036854775807L;
        this.f19881 = false;
        this.f19866 = -9223372036854775807L;
        this.f19893 = false;
        this.f19870 = false;
        this.f19895 = false;
        this.f19838 = false;
        this.f19844 = 0;
        this.f19854 = 0;
        this.f19851 = this.f19869 ? 1 : 0;
        this.f19875 = false;
        this.f19853 = 0L;
    }

    /* JADX INFO: renamed from: ᵯˇ, reason: contains not printable characters */
    public final void m10856(InterfaceC4417 interfaceC4417) {
        AbstractC3589.m8104(this.f19847, interfaceC4417);
        this.f19847 = interfaceC4417;
    }

    /* JADX INFO: renamed from: ᵱᵭ, reason: contains not printable characters */
    public boolean m10857(C1354 c1354) {
        return true;
    }

    /* JADX INFO: renamed from: ᵵᵬᵽ, reason: contains not printable characters */
    public int m10858(C3008 c3008) {
        return 0;
    }

    /* JADX INFO: renamed from: ᵵᵸᵕᵸ, reason: contains not printable characters */
    public final void m10859() throws ExoPlaybackException {
        int i = this.f19854;
        if (i == 1) {
            m10839();
            return;
        }
        if (i == 2) {
            m10839();
            m10851();
        } else if (i != 3) {
            this.f19863 = true;
            mo5591();
        } else {
            m10846();
            m10843();
        }
    }

    @Override // defpackage.AbstractC0799
    /* JADX INFO: renamed from: ᵶˇᵱ */
    public void mo2898(float f, float f2) throws ExoPlaybackException {
        this.f19867 = f;
        this.f19888 = f2;
        m10861(this.f19889);
    }

    /* JADX INFO: renamed from: ᵹʾᵢᵯ, reason: contains not printable characters */
    public final void m10860() {
        this.f19856 = -9223372036854775807L;
        m10853().f19280 = -9223372036854775807L;
        this.f19896 = -9223372036854775807L;
        this.f19882 = false;
        this.f19836.mo7091();
        this.f19839.mo7091();
        this.f19848 = false;
        C3673 c3673 = this.f19835;
        c3673.getClass();
        c3673.f13946 = InterfaceC2497.f9685;
        c3673.f13947 = 0;
        c3673.f13945 = 2;
    }

    /* JADX INFO: renamed from: ᵽˀᵥ, reason: contains not printable characters */
    public final boolean m10861(C5286 c5286) throws ExoPlaybackException {
        if (this.f19898 != null && this.f19854 != 3 && this.f3588 != 0) {
            float f = this.f19888;
            c5286.getClass();
            C5286[] c5286Arr = this.f3589;
            c5286Arr.getClass();
            float fMo5597 = mo5597(f, c5286, c5286Arr);
            float f2 = this.f19841;
            if (f2 != fMo5597) {
                if (fMo5597 == -1.0f) {
                    if (this.f19893) {
                        this.f19844 = 1;
                        this.f19854 = 3;
                        return false;
                    }
                    m10846();
                    m10843();
                    return false;
                }
                if (f2 != -1.0f || fMo5597 > this.f19884) {
                    Bundle bundle = new Bundle();
                    bundle.putFloat("operating-rate", fMo5597);
                    InterfaceC1595 interfaceC1595 = this.f19898;
                    interfaceC1595.getClass();
                    interfaceC1595.mo3027(bundle);
                    this.f19841 = fMo5597;
                }
            }
        }
        return true;
    }
}
