package com.bumptech.glide.load.engine;

/* JADX INFO: loaded from: classes.dex */
public final class y implements e0 {

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final x f5805d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final a5.h f5806e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f5807f;

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

    public y(e0 e0Var, boolean z10, boolean z11, a5.h hVar, x xVar) {
        this.f5804c = (e0) t5.n.checkNotNull(e0Var);
        this.f5802a = z10;
        this.f5803b = z11;
        this.f5806e = hVar;
        this.f5805d = (x) t5.n.checkNotNull(xVar);
    }

    @Override // com.bumptech.glide.load.engine.e0
    public final synchronized void a() {
        if (this.f5807f > 0) {
            throw new IllegalStateException("Cannot recycle a resource while it is still acquired");
        }
        if (this.f5808g) {
            throw new IllegalStateException("Cannot recycle a resource that has already been recycled");
        }
        this.f5808g = true;
        if (this.f5803b) {
            this.f5804c.a();
        }
    }

    @Override // com.bumptech.glide.load.engine.e0
    public final Class b() {
        return this.f5804c.b();
    }

    public final synchronized void c() {
        if (this.f5808g) {
            throw new IllegalStateException("Cannot acquire a recycled resource");
        }
        this.f5807f++;
    }

    public final void d() {
        boolean z10;
        synchronized (this) {
            int i10 = this.f5807f;
            if (i10 <= 0) {
                throw new IllegalStateException("Cannot release a recycled or not yet acquired resource");
            }
            z10 = true;
            int i11 = i10 - 1;
            this.f5807f = i11;
            if (i11 != 0) {
                z10 = false;
            }
        }
        if (z10) {
            ((q) this.f5805d).c(this.f5806e, this);
        }
    }

    @Override // com.bumptech.glide.load.engine.e0
    public final Object get() {
        return this.f5804c.get();
    }

    @Override // com.bumptech.glide.load.engine.e0
    public final int getSize() {
        return this.f5804c.getSize();
    }

    public final synchronized String toString() {
        return "EngineResource{isMemoryCacheable=" + this.f5802a + ", listener=" + this.f5805d + ", key=" + this.f5806e + ", acquired=" + this.f5807f + ", isRecycled=" + this.f5808g + ", resource=" + this.f5804c + '}';
    }
}
