package androidx.media3.extractor;

import androidx.annotation.Nullable;
import androidx.media3.common.util.Assertions;

/* JADX INFO: loaded from: classes.dex */
public abstract class n {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final i f3416a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final m f3417b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final int f3418c;

    @Nullable
    protected j seekOperationParams;

    public n(k kVar, m mVar, long j10, long j11, long j12, long j13, long j14, int i10) {
        this.f3417b = mVar;
        this.f3418c = i10;
        this.f3416a = new i(kVar, j10, j11, j12, j13, j14);
    }

    public static int c(z zVar, long j10, r0 r0Var) {
        if (j10 == zVar.getPosition()) {
            return 0;
        }
        r0Var.f3463a = j10;
        return 1;
    }

    /* JADX WARN: Code restructure failed: missing block: B:32:0x00d6, code lost:
    
        return c(r28, r8, r29);
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final int a(z zVar, r0 r0Var) {
        while (true) {
            j jVar = (j) Assertions.checkStateNotNull(this.seekOperationParams);
            long j10 = jVar.f3394f;
            long j11 = jVar.f3395g;
            long j12 = jVar.f3396h;
            long j13 = j11 - j10;
            long j14 = this.f3418c;
            m mVar = this.f3417b;
            if (j13 <= j14) {
                this.seekOperationParams = null;
                mVar.b();
                return c(zVar, j10, r0Var);
            }
            long position = j12 - zVar.getPosition();
            if (position < 0 || position > 262144) {
                break;
            }
            zVar.k((int) position);
            zVar.j();
            l lVarA = mVar.a(zVar, jVar.f3390b);
            int i10 = lVarA.f3410a;
            if (i10 == -3) {
                this.seekOperationParams = null;
                mVar.b();
                return c(zVar, j12, r0Var);
            }
            long j15 = lVarA.f3411b;
            long j16 = lVarA.f3412c;
            if (i10 == -2) {
                jVar.f3392d = j15;
                jVar.f3394f = j16;
                jVar.f3396h = j.a(jVar.f3390b, j15, jVar.f3393e, j16, jVar.f3395g, jVar.f3391c);
            } else {
                if (i10 != -1) {
                    if (i10 != 0) {
                        throw new IllegalStateException("Invalid case");
                    }
                    long position2 = j16 - zVar.getPosition();
                    if (position2 >= 0 && position2 <= 262144) {
                        zVar.k((int) position2);
                    }
                    this.seekOperationParams = null;
                    mVar.b();
                    return c(zVar, j16, r0Var);
                }
                jVar.f3393e = j15;
                jVar.f3395g = j16;
                jVar.f3396h = j.a(jVar.f3390b, jVar.f3392d, j15, jVar.f3394f, j16, jVar.f3391c);
            }
        }
    }

    public final boolean b() {
        return this.seekOperationParams != null;
    }

    public final void d(long j10) {
        j jVar = this.seekOperationParams;
        if (jVar == null || jVar.f3389a != j10) {
            i iVar = this.f3416a;
            this.seekOperationParams = new j(j10, iVar.f3379a.a(j10), iVar.f3381c, iVar.f3382d, iVar.f3383e, iVar.f3384f, iVar.f3385g);
        }
    }
}
