package com.applovin.impl; import com.mbridge.msdk.playercommon.exoplayer2.C; /* loaded from: classes.dex */ public class f6 implements lc { private final r5 a; private final long b; private final long c; private final long d; private final long e; private final int f; private final boolean g; private final long h; private final boolean i; private int j; private boolean k; @Override // com.applovin.impl.lc public boolean a() { return this.i; } @Override // com.applovin.impl.lc public n0 b() { return this.a; } @Override // com.applovin.impl.lc public long d() { return this.h; } public f6() { this(new r5(true, 65536), 50000, 50000, 2500, 5000, -1, false, 0, false); } @Override // com.applovin.impl.lc public void f() { a(false); } @Override // com.applovin.impl.lc public void c() { a(true); } @Override // com.applovin.impl.lc public void e() { a(true); } private static void a(int i, int i2, String str, String str2) { b1.a(i >= i2, str + " cannot be less than " + str2); } public f6(r5 r5Var, int i, int i2, int i3, int i4, int i5, boolean z, int i6, boolean z2) { a(i3, 0, "bufferForPlaybackMs", "0"); a(i4, 0, "bufferForPlaybackAfterRebufferMs", "0"); a(i, i3, "minBufferMs", "bufferForPlaybackMs"); a(i, i4, "minBufferMs", "bufferForPlaybackAfterRebufferMs"); a(i2, i, "maxBufferMs", "minBufferMs"); a(i6, 0, "backBufferDurationMs", "0"); this.a = r5Var; this.b = t2.a(i); this.c = t2.a(i2); this.d = t2.a(i3); this.e = t2.a(i4); this.f = i5; this.j = i5 == -1 ? C.DEFAULT_VIDEO_BUFFER_SIZE : i5; this.g = z; this.h = t2.a(i6); this.i = z2; } public int a(qi[] qiVarArr, h8[] h8VarArr) { int i = 0; for (int i2 = 0; i2 < qiVarArr.length; i2++) { if (h8VarArr[i2] != null) { i += a(qiVarArr[i2].e()); } } return Math.max(C.DEFAULT_VIDEO_BUFFER_SIZE, i); } private static int a(int i) { switch (i) { case -2: return 0; case -1: default: throw new IllegalArgumentException(); case 0: return 144310272; case 1: return C.DEFAULT_VIDEO_BUFFER_SIZE; case 2: return 131072000; case 3: case 4: case 5: case 6: return 131072; } } @Override // com.applovin.impl.lc public void a(qi[] qiVarArr, po poVar, h8[] h8VarArr) { int i = this.f; if (i == -1) { i = a(qiVarArr, h8VarArr); } this.j = i; this.a.a(i); } private void a(boolean z) { int i = this.f; if (i == -1) { i = C.DEFAULT_VIDEO_BUFFER_SIZE; } this.j = i; this.k = false; if (z) { this.a.e(); } } @Override // com.applovin.impl.lc public boolean a(long j, long j2, float f) { boolean z = true; boolean z2 = this.a.d() >= this.j; long j3 = this.b; if (f > 1.0f) { j3 = Math.min(xp.a(j3, f), this.c); } if (j2 < Math.max(j3, 500000L)) { if (!this.g && z2) { z = false; } this.k = z; if (!z && j2 < 500000) { pc.d("DefaultLoadControl", "Target buffer size reached with less than 500ms of buffered media data."); } } else if (j2 >= this.c || z2) { this.k = false; } return this.k; } @Override // com.applovin.impl.lc public boolean a(long j, float f, boolean z, long j2) { long b = xp.b(j, f); long j3 = z ? this.e : this.d; if (j2 != C.TIME_UNSET) { j3 = Math.min(j2 / 2, j3); } return j3 <= 0 || b >= j3 || (!this.g && this.a.d() >= this.j); } }