package B0;

import java.util.HashMap;
import java.util.Iterator;
import x0.AbstractC1709a;

/* JADX INFO: renamed from: B0.l, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C0025l {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final P0.e f836a;

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

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

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

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final long f842g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final HashMap f843h;
    public long i;

    public C0025l() {
        P0.e eVar = new P0.e();
        a("bufferForPlaybackMs", 1000, 0, "0");
        a("bufferForPlaybackAfterRebufferMs", 2000, 0, "0");
        a("minBufferMs", 50000, 1000, "bufferForPlaybackMs");
        a("minBufferMs", 50000, 2000, "bufferForPlaybackAfterRebufferMs");
        a("maxBufferMs", 50000, 50000, "minBufferMs");
        a("backBufferDurationMs", 0, 0, "0");
        this.f836a = eVar;
        long j8 = 50000;
        this.f837b = x0.v.L(j8);
        this.f838c = x0.v.L(j8);
        this.f839d = x0.v.L(1000);
        this.f840e = x0.v.L(2000);
        this.f841f = -1;
        this.f842g = x0.v.L(0);
        this.f843h = new HashMap();
        this.i = -1L;
    }

    public static void a(String str, int i, int i5, String str2) {
        AbstractC1709a.c(str + " cannot be less than " + str2, i >= i5);
    }

    public final int b() {
        Iterator it = this.f843h.values().iterator();
        int i = 0;
        while (it.hasNext()) {
            i += ((C0024k) it.next()).f835b;
        }
        return i;
    }

    public final boolean c(Q q8) {
        int i;
        C0024k c0024k = (C0024k) this.f843h.get(q8.f654a);
        c0024k.getClass();
        P0.e eVar = this.f836a;
        synchronized (eVar) {
            i = eVar.f5266d * eVar.f5264b;
        }
        boolean z8 = i >= b();
        float f3 = q8.f656c;
        long j8 = this.f838c;
        long jMin = this.f837b;
        if (f3 > 1.0f) {
            jMin = Math.min(x0.v.x(jMin, f3), j8);
        }
        long jMax = Math.max(jMin, 500000L);
        long j9 = q8.f655b;
        if (j9 < jMax) {
            c0024k.f834a = !z8;
            if (z8 && j9 < 500000) {
                AbstractC1709a.B("DefaultLoadControl", "Target buffer size reached with less than 500ms of buffered media data.");
            }
        } else if (j9 >= j8 || z8) {
            c0024k.f834a = false;
        }
        return c0024k.f834a;
    }

    public final void d() {
        if (!this.f843h.isEmpty()) {
            this.f836a.a(b());
            return;
        }
        P0.e eVar = this.f836a;
        synchronized (eVar) {
            if (eVar.f5263a) {
                eVar.a(0);
            }
        }
    }
}
