package defpackage;

import android.util.Log;
import j$.util.Objects;
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.NavigableMap;
import java.util.TreeMap;

/* JADX INFO: renamed from: ᵿᵹˁ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C5540 {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public int f20916;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final Object f20917;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final Object f20918;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final int f20919;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final Object f20920;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final Object f20921;

    public C5540(int i) {
        this.f20917 = new C0767(29);
        this.f20920 = new C0936(0);
        this.f20918 = new HashMap();
        this.f20921 = new HashMap();
        this.f20919 = i;
    }

    public C5540(C5286 c5286, C5286 c52862, int i, int i2, C2558 c2558, C1316 c1316) {
        this.f20917 = c5286;
        this.f20920 = c52862;
        this.f20919 = i;
        this.f20916 = i2;
        this.f20918 = c2558;
        this.f20921 = c1316;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static boolean m11162(C5540 c5540) {
        return Objects.equals(((C5286) c5540.f20917).f19987, "audio/raw");
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public synchronized void m11163() {
        m11169(0);
    }

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public NavigableMap m11164(Class cls) {
        HashMap map = (HashMap) this.f20918;
        NavigableMap navigableMap = (NavigableMap) map.get(cls);
        if (navigableMap != null) {
            return navigableMap;
        }
        TreeMap treeMap = new TreeMap();
        map.put(cls, treeMap);
        return treeMap;
    }

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public void m11165(int i, Class cls) {
        NavigableMap navigableMapM11164 = m11164(cls);
        Integer num = (Integer) navigableMapM11164.get(Integer.valueOf(i));
        if (num != null) {
            if (num.intValue() == 1) {
                navigableMapM11164.remove(Integer.valueOf(i));
                return;
            } else {
                navigableMapM11164.put(Integer.valueOf(i), Integer.valueOf(num.intValue() - 1));
                return;
            }
        }
        throw new NullPointerException("Tried to decrement empty size, size: " + i + ", this: " + this);
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public synchronized Object m11166(int i, Class cls) {
        C4928 c4928;
        int i2;
        try {
            Integer num = (Integer) m11164(cls).ceilingKey(Integer.valueOf(i));
            boolean z = num != null && ((i2 = this.f20916) == 0 || this.f20919 / i2 >= 2 || num.intValue() <= i * 8);
            C0936 c0936 = (C0936) this.f20920;
            if (z) {
                int iIntValue = num.intValue();
                InterfaceC0373 interfaceC0373M3180 = (InterfaceC0373) ((ArrayDeque) ((ᵜᵪʾ) c0936).ˌᴵ).poll();
                if (interfaceC0373M3180 == null) {
                    interfaceC0373M3180 = c0936.m3180();
                }
                c4928 = (C4928) interfaceC0373M3180;
                c4928.f18728 = iIntValue;
                c4928.f18729 = cls;
            } else {
                InterfaceC0373 interfaceC0373M31802 = (InterfaceC0373) ((ArrayDeque) ((ᵜᵪʾ) c0936).ˌᴵ).poll();
                if (interfaceC0373M31802 == null) {
                    interfaceC0373M31802 = c0936.m3180();
                }
                c4928 = (C4928) interfaceC0373M31802;
                c4928.f18728 = i;
                c4928.f18729 = cls;
            }
        } catch (Throwable th) {
            throw th;
        }
        return m11168(c4928, cls);
    }

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public synchronized void m11167(int i) {
        try {
            if (i >= 40) {
                m11163();
            } else if (i >= 20 || i == 15) {
                m11169(this.f20919 / 2);
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public Object m11168(C4928 c4928, Class cls) {
        C1417 c1417M11171 = m11171(cls);
        Object objM2782 = ((C0767) this.f20917).m2782(c4928);
        if (objM2782 != null) {
            this.f20916 -= c1417M11171.m4085() * c1417M11171.m4087(objM2782);
            m11165(c1417M11171.m4087(objM2782), cls);
        }
        if (objM2782 != null) {
            return objM2782;
        }
        Log.isLoggable(c1417M11171.m4086(), 2);
        int i = c4928.f18728;
        switch (c1417M11171.f5837) {
            case 0:
                return new byte[i];
            default:
                return new int[i];
        }
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public void m11169(int i) {
        while (this.f20916 > i) {
            Object objM2773 = ((C0767) this.f20917).m2773();
            ᵿᵽᵤ.ʽˈˋ(objM2773);
            C1417 c1417M11171 = m11171(objM2773.getClass());
            this.f20916 -= c1417M11171.m4085() * c1417M11171.m4087(objM2773);
            m11165(c1417M11171.m4087(objM2773), objM2773.getClass());
            if (Log.isLoggable(c1417M11171.m4086(), 2)) {
                c1417M11171.m4087(objM2773);
            }
        }
    }

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public synchronized void m11170(Object obj) {
        Class<?> cls = obj.getClass();
        C1417 c1417M11171 = m11171(cls);
        int iM4087 = c1417M11171.m4087(obj);
        int iM4085 = c1417M11171.m4085() * iM4087;
        if (iM4085 <= this.f20919 / 2) {
            C0936 c0936 = (C0936) this.f20920;
            InterfaceC0373 interfaceC0373M3180 = (InterfaceC0373) ((ArrayDeque) ((ᵜᵪʾ) c0936).ˌᴵ).poll();
            if (interfaceC0373M3180 == null) {
                interfaceC0373M3180 = c0936.m3180();
            }
            C4928 c4928 = (C4928) interfaceC0373M3180;
            c4928.f18728 = iM4087;
            c4928.f18729 = cls;
            ((C0767) this.f20917).m2769(c4928, obj);
            NavigableMap navigableMapM11164 = m11164(cls);
            Integer num = (Integer) navigableMapM11164.get(Integer.valueOf(c4928.f18728));
            Integer numValueOf = Integer.valueOf(c4928.f18728);
            int iIntValue = 1;
            if (num != null) {
                iIntValue = 1 + num.intValue();
            }
            navigableMapM11164.put(numValueOf, Integer.valueOf(iIntValue));
            this.f20916 += iM4085;
            m11169(this.f20919);
        }
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public C1417 m11171(Class cls) {
        C1417 c1417;
        HashMap map = (HashMap) this.f20921;
        C1417 c14172 = (C1417) map.get(cls);
        if (c14172 != null) {
            return c14172;
        }
        if (cls.equals(int[].class)) {
            c1417 = new C1417(1);
        } else {
            if (!cls.equals(byte[].class)) {
                ᵕᵩʽᵲ.ᵮᵣᵗˈ("No array pool found for: ".concat(cls.getSimpleName()));
                return null;
            }
            c1417 = new C1417(0);
        }
        map.put(cls, c1417);
        return c1417;
    }
}
