package defpackage;

import android.os.Handler;
import android.os.SystemClock;
import android.os.Trace;
import android.view.Surface;
import androidx.media3.decoder.DecoderException;
import androidx.media3.exoplayer.ExoPlaybackException;

/* renamed from: ᵝˁᵲ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C2881 extends AbstractC4483 {

    /* renamed from: ˀˁᵨ, reason: contains not printable characters */
    public boolean f11149;

    /* renamed from: ˀᵗᵩ, reason: contains not printable characters */
    public final C2441 f11150;

    /* renamed from: ˆᵼᵷˊ, reason: contains not printable characters */
    public C3446 f11151;

    /* renamed from: ˊʽˎ, reason: contains not printable characters */
    public InterfaceC1660 f11152;

    /* renamed from: ˊʾˊ, reason: contains not printable characters */
    public C3788 f11153;

    /* renamed from: ˊᵸˊ, reason: contains not printable characters */
    public final C3959 f11154;

    /* renamed from: ˌᵪ, reason: contains not printable characters */
    public Object f11155;

    /* renamed from: ˌᵹᵨˑ, reason: contains not printable characters */
    public int f11156;

    /* renamed from: ˎᵬˀ, reason: contains not printable characters */
    public InterfaceC1660 f11157;

    /* renamed from: ˑᵝﹳᵜ, reason: contains not printable characters */
    public final ᵶˉᵹʣ f11158;

    /* renamed from: ᵛˈᵤ, reason: contains not printable characters */
    public int f11159;

    /* renamed from: ᵠᵿː, reason: contains not printable characters */
    public C4779 f11160;

    /* renamed from: ᵡᵘˎʽ, reason: contains not printable characters */
    public final long f11161;

    /* renamed from: ᵡᵶᵡ, reason: contains not printable characters */
    public InterfaceC0146 f11162;

    /* renamed from: ᵫᵮʾ, reason: contains not printable characters */
    public int f11163;

    /* renamed from: ᵳᵹᵺˋ, reason: contains not printable characters */
    public Surface f11164;

    /* renamed from: ᵷᵱ, reason: contains not printable characters */
    public long f11165;

    /* renamed from: ᵽʛ, reason: contains not printable characters */
    public long f11166;

    public C2881(long j, Handler handler, InterfaceC3589 interfaceC3589, int i) {
        super(2);
        this.f11161 = j;
        this.f11166 = -9223372036854775807L;
        this.f11154 = new C3959();
        this.f11150 = new C2441(0, 0);
        this.f11158 = new ᵶˉᵹʣ(handler, interfaceC3589);
        this.f11159 = -1;
        this.f11163 = 0;
        this.f11160 = new C4779();
    }

    @Override // defpackage.AbstractC4483
    /* renamed from: ˀᵗᵝᵭ */
    public final int mo372(C3446 c3446) {
        return AbstractC2990.m7325(0, 0, 0, 0);
    }

    @Override // defpackage.AbstractC4483
    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final void mo7048() {
        if (this.f11163 == 0) {
            this.f11163 = 1;
        }
    }

    @Override // defpackage.AbstractC4483
    /* renamed from: ˌʾˀ */
    public final void mo374(long j, boolean z, boolean z2) {
        this.f11149 = false;
        this.f11163 = Math.min(this.f11163, 1);
        if (z) {
            long j2 = this.f11161;
            this.f11166 = j2 > 0 ? SystemClock.elapsedRealtime() + j2 : -9223372036854775807L;
        } else {
            this.f11166 = -9223372036854775807L;
        }
        C3959 c3959 = this.f11154;
        c3959.m8751();
        c3959.m8759();
    }

    @Override // defpackage.AbstractC4483
    /* renamed from: ˌᵜᵹᵩ */
    public final boolean mo375() {
        return this.f11149;
    }

    /* renamed from: ˎˑː, reason: contains not printable characters */
    public final void m7049() throws ExoPlaybackException {
        InterfaceC1660 interfaceC1660 = this.f11157;
        AbstractC4486.m9554(this.f11152, interfaceC1660);
        this.f11152 = interfaceC1660;
        if (interfaceC1660 != null && interfaceC1660.mo4745() == null && this.f11152.mo4740() == null) {
            return;
        }
        try {
            SystemClock.elapsedRealtime();
            this.f11151.getClass();
            Trace.beginSection("createFfmpegVideoDecoder");
            Trace.endSection();
            throw null;
        } catch (DecoderException e) {
            ᵳʿˉ.ᵸˑ("Video codec error", e);
            ᵶˉᵹʣ r3 = this.f11158;
            Handler handler = (Handler) r3.ᵢˇᵭ;
            if (handler != null) {
                handler.post(new RunnableC2013(r3, e, 1));
            }
            throw m9539(e, this.f11151, false, 4001);
        } catch (OutOfMemoryError e2) {
            throw m9539(e2, this.f11151, false, 4001);
        }
    }

    @Override // defpackage.AbstractC4483, defpackage.InterfaceC1822
    /* renamed from: ˏᵙ */
    public final void mo379(int i, Object obj) {
        Object obj2;
        Handler handler;
        if (i != 1) {
            if (i == 7) {
                return;
            }
            return;
        }
        if (obj instanceof Surface) {
            this.f11164 = (Surface) obj;
            this.f11162 = null;
            this.f11159 = 1;
        } else if (obj instanceof InterfaceC0146) {
            this.f11164 = null;
            this.f11162 = (InterfaceC0146) obj;
            this.f11159 = 0;
        } else {
            this.f11164 = null;
            this.f11162 = null;
            this.f11159 = -1;
            obj = null;
        }
        Object obj3 = this.f11155;
        ᵶˉᵹʣ r2 = this.f11158;
        if (obj3 == obj) {
            if (obj != null) {
                C3788 c3788 = this.f11153;
                if (c3788 != null) {
                    r2.ˁˑᵰ(c3788);
                }
                if (this.f11163 != 3 || (obj2 = this.f11155) == null || (handler = (Handler) r2.ᵢˇᵭ) == null) {
                    return;
                }
                handler.post(new RunnableC3741(r2, obj2, SystemClock.elapsedRealtime()));
                return;
            }
            return;
        }
        this.f11155 = obj;
        if (obj == null) {
            this.f11153 = null;
            this.f11163 = Math.min(this.f11163, 1);
            return;
        }
        C3788 c37882 = this.f11153;
        if (c37882 != null) {
            r2.ˁˑᵰ(c37882);
        }
        this.f11163 = Math.min(this.f11163, 1);
        if (this.f16722 == 2) {
            long j = this.f11161;
            this.f11166 = j > 0 ? SystemClock.elapsedRealtime() + j : -9223372036854775807L;
        }
    }

    @Override // defpackage.AbstractC4483
    /* renamed from: ˑᵱ */
    public final void mo380(C3446[] c3446Arr, long j, long j2, C2477 c2477) {
    }

    @Override // defpackage.AbstractC4483
    /* renamed from: ᵞʡ */
    public final void mo383() {
        this.f11156 = 0;
        this.f11165 = SystemClock.elapsedRealtime();
        SystemClock.elapsedRealtime();
        String str = AbstractC3558.f13329;
    }

    @Override // defpackage.AbstractC4483
    /* renamed from: ᵨᵳʝ */
    public final void mo387() {
        this.f11166 = -9223372036854775807L;
        if (this.f11156 > 0) {
            long jElapsedRealtime = SystemClock.elapsedRealtime();
            long j = jElapsedRealtime - this.f11165;
            int i = this.f11156;
            ᵶˉᵹʣ r5 = this.f11158;
            Handler handler = (Handler) r5.ᵢˇᵭ;
            if (handler != null) {
                handler.post(new RunnableC2013(r5, i, j));
            }
            this.f11156 = 0;
            this.f11165 = jElapsedRealtime;
        }
    }

    @Override // defpackage.AbstractC4483
    /* renamed from: ᵪʩ */
    public final void mo388() {
        ᵶˉᵹʣ r0 = this.f11158;
        this.f11151 = null;
        this.f11153 = null;
        this.f11163 = Math.min(this.f11163, 0);
        try {
            AbstractC4486.m9554(this.f11157, null);
            this.f11157 = null;
            AbstractC4486.m9554(this.f11152, null);
            this.f11152 = null;
        } finally {
            r0.ᵯٴᵦ(this.f11160);
        }
    }

    @Override // defpackage.AbstractC4483
    /* renamed from: ᵯٴᵦ */
    public final boolean mo390() {
        boolean zMo1128;
        if (this.f11151 != null) {
            if (m9538()) {
                zMo1128 = this.f16720;
            } else {
                InterfaceC0772 interfaceC0772 = this.f16719;
                interfaceC0772.getClass();
                zMo1128 = interfaceC0772.mo1128();
            }
            if (zMo1128 && (this.f11163 == 3 || this.f11159 == -1)) {
                this.f11166 = -9223372036854775807L;
                return true;
            }
        }
        if (this.f11166 == -9223372036854775807L) {
            return false;
        }
        if (SystemClock.elapsedRealtime() < this.f11166) {
            return true;
        }
        this.f11166 = -9223372036854775807L;
        return false;
    }

    @Override // defpackage.AbstractC4483
    /* renamed from: ᵳٴᵶ */
    public final void mo391(boolean z, boolean z2) {
        C4779 c4779 = new C4779();
        this.f11160 = c4779;
        ᵶˉᵹʣ r0 = this.f11158;
        Handler handler = (Handler) r0.ᵢˇᵭ;
        if (handler != null) {
            handler.post(new RunnableC2013(r0, c4779, 5));
        }
        this.f11163 = z2 ? 1 : 0;
    }

    @Override // defpackage.AbstractC4483
    /* renamed from: ᵶᵷᵕ */
    public final String mo394() {
        return "ExperimentalFfmpegVideoRenderer";
    }

    @Override // defpackage.AbstractC4483
    /* renamed from: ᵿʗᵝʽ */
    public final void mo397(long j, long j2) throws ExoPlaybackException {
        if (this.f11149) {
            return;
        }
        if (this.f11151 == null) {
            C2720 c2720 = this.f16732;
            c2720.m6736();
            C2441 c2441 = this.f11150;
            c2441.mo6221();
            int iM9535 = m9535(c2720, c2441, 2);
            if (iM9535 != -5) {
                if (iM9535 == -4) {
                    ᵛᵾˏ.ᵿʗᵝʽ(c2441.m9873(4));
                    this.f11149 = true;
                    return;
                }
                return;
            }
            C3446 c3446 = (C3446) c2720.f10550;
            c3446.getClass();
            InterfaceC1660 interfaceC1660 = (InterfaceC1660) c2720.f10548;
            AbstractC4486.m9554(this.f11157, interfaceC1660);
            this.f11157 = interfaceC1660;
            this.f11151 = c3446;
            m7049();
            C3446 c34462 = this.f11151;
            c34462.getClass();
            ᵶˉᵹʣ r4 = this.f11158;
            Handler handler = (Handler) r4.ᵢˇᵭ;
            if (handler != null) {
                handler.post(new RunnableC5417(r4, c34462, null, 24));
            }
        }
        m7049();
    }
}
