package o;

import android.media.MediaDataSource;
import java.io.IOException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.dx, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1054dx extends MediaDataSource {
    public long l;
    public final /* synthetic */ C1532ix m;

    public C1054dx(C1532ix c1532ix) {
        this.m = c1532ix;
    }

    @Override // android.media.MediaDataSource
    public final long getSize() {
        return -1L;
    }

    @Override // android.media.MediaDataSource
    public final int readAt(long j, byte[] bArr, int i, int i2) throws IOException {
        if (i2 == 0) {
            return 0;
        }
        if (j < 0) {
            return -1;
        }
        try {
            long j2 = this.l;
            C1532ix c1532ix = this.m;
            if (j2 != j) {
                if (j2 >= 0 && j >= j2 + c1532ix.l.available()) {
                    return -1;
                }
                c1532ix.c(j);
                this.l = j;
            }
            if (i2 > c1532ix.l.available()) {
                i2 = c1532ix.l.available();
            }
            int i3 = c1532ix.read(bArr, i, i2);
            if (i3 >= 0) {
                this.l += i3;
                return i3;
            }
        } catch (IOException unused) {
        }
        this.l = -1L;
        return -1;
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() {
    }
}
