package com.google.android.gms.internal.ads;

import java.io.IOException;
import java.nio.ByteBuffer;

/* JADX INFO: loaded from: classes2.dex */
public abstract class zf2 implements ed {

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public static final bg2 f19251h = rb.q(zf2.class);

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public ByteBuffer f19255d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public long f19256e;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public k40 f19258g;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public long f19257f = -1;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public boolean f19254c = true;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public boolean f19253b = true;

    public zf2(String str) {
        this.f19252a = str;
    }

    public final synchronized void a() {
        try {
            if (this.f19254c) {
                return;
            }
            try {
                bg2 bg2Var = f19251h;
                String str = this.f19252a;
                bg2Var.z(str.length() != 0 ? "mem mapping ".concat(str) : new String("mem mapping "));
                k40 k40Var = this.f19258g;
                long j10 = this.f19256e;
                long j11 = this.f19257f;
                ByteBuffer byteBuffer = k40Var.f13090a;
                int iPosition = byteBuffer.position();
                byteBuffer.position((int) j10);
                ByteBuffer byteBufferSlice = byteBuffer.slice();
                byteBufferSlice.limit((int) j11);
                byteBuffer.position(iPosition);
                this.f19255d = byteBufferSlice;
                this.f19254c = true;
            } catch (IOException e10) {
                throw new RuntimeException(e10);
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    public abstract void b(ByteBuffer byteBuffer);

    public final synchronized void c() {
        try {
            a();
            bg2 bg2Var = f19251h;
            String str = this.f19252a;
            bg2Var.z(str.length() != 0 ? "parsing details of ".concat(str) : new String("parsing details of "));
            ByteBuffer byteBuffer = this.f19255d;
            if (byteBuffer != null) {
                this.f19253b = true;
                byteBuffer.rewind();
                b(byteBuffer);
                if (byteBuffer.remaining() > 0) {
                    byteBuffer.slice();
                }
                this.f19255d = null;
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    @Override // com.google.android.gms.internal.ads.ed
    public final void e(k40 k40Var, ByteBuffer byteBuffer, long j10, cd cdVar) {
        this.f19256e = k40Var.g();
        byteBuffer.remaining();
        this.f19257f = j10;
        this.f19258g = k40Var;
        k40Var.f13090a.position((int) (k40Var.g() + j10));
        this.f19254c = false;
        this.f19253b = false;
        c();
    }

    @Override // com.google.android.gms.internal.ads.ed
    public final String zza() {
        return this.f19252a;
    }
}
