149 lines
3.8 KiB
Java
149 lines
3.8 KiB
Java
package c.i.a.c.d2;
|
|
|
|
import androidx.annotation.Nullable;
|
|
import c.i.a.c.h2.c;
|
|
import c.i.a.c.h2.m;
|
|
import c.i.a.c.i2.w;
|
|
import java.nio.ByteBuffer;
|
|
import java.util.Objects;
|
|
/* compiled from: SampleDataQueue */
|
|
public class d0 {
|
|
public final m a;
|
|
public final int b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public final w f785c = new w(32);
|
|
public a d;
|
|
public a e;
|
|
public a f;
|
|
public long g;
|
|
|
|
/* compiled from: SampleDataQueue */
|
|
public static final class a {
|
|
public final long a;
|
|
public final long b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public boolean f786c;
|
|
@Nullable
|
|
public c d;
|
|
@Nullable
|
|
public a e;
|
|
|
|
public a(long j, int i) {
|
|
this.a = j;
|
|
this.b = j + ((long) i);
|
|
}
|
|
|
|
public int a(long j) {
|
|
return ((int) (j - this.a)) + this.d.b;
|
|
}
|
|
}
|
|
|
|
public d0(m mVar) {
|
|
this.a = mVar;
|
|
int i = mVar.b;
|
|
this.b = i;
|
|
a aVar = new a(0, i);
|
|
this.d = aVar;
|
|
this.e = aVar;
|
|
this.f = aVar;
|
|
}
|
|
|
|
public static a d(a aVar, long j, ByteBuffer byteBuffer, int i) {
|
|
while (j >= aVar.b) {
|
|
aVar = aVar.e;
|
|
}
|
|
while (i > 0) {
|
|
int min = Math.min(i, (int) (aVar.b - j));
|
|
byteBuffer.put(aVar.d.a, aVar.a(j), min);
|
|
i -= min;
|
|
j += (long) min;
|
|
if (j == aVar.b) {
|
|
aVar = aVar.e;
|
|
}
|
|
}
|
|
return aVar;
|
|
}
|
|
|
|
public static a e(a aVar, long j, byte[] bArr, int i) {
|
|
while (j >= aVar.b) {
|
|
aVar = aVar.e;
|
|
}
|
|
int i2 = i;
|
|
while (i2 > 0) {
|
|
int min = Math.min(i2, (int) (aVar.b - j));
|
|
System.arraycopy(aVar.d.a, aVar.a(j), bArr, i - i2, min);
|
|
i2 -= min;
|
|
j += (long) min;
|
|
if (j == aVar.b) {
|
|
aVar = aVar.e;
|
|
}
|
|
}
|
|
return aVar;
|
|
}
|
|
|
|
public void a(long j) {
|
|
if (j != -1) {
|
|
while (true) {
|
|
a aVar = this.d;
|
|
if (j >= aVar.b) {
|
|
m mVar = this.a;
|
|
c cVar = aVar.d;
|
|
synchronized (mVar) {
|
|
c[] cVarArr = mVar.f879c;
|
|
cVarArr[0] = cVar;
|
|
mVar.a(cVarArr);
|
|
}
|
|
a aVar2 = this.d;
|
|
aVar2.d = null;
|
|
a aVar3 = aVar2.e;
|
|
aVar2.e = null;
|
|
this.d = aVar3;
|
|
} else if (this.e.a < aVar.a) {
|
|
this.e = aVar;
|
|
return;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void b(int i) {
|
|
long j = this.g + ((long) i);
|
|
this.g = j;
|
|
a aVar = this.f;
|
|
if (j == aVar.b) {
|
|
this.f = aVar.e;
|
|
}
|
|
}
|
|
|
|
public final int c(int i) {
|
|
c cVar;
|
|
a aVar = this.f;
|
|
if (!aVar.f786c) {
|
|
m mVar = this.a;
|
|
synchronized (mVar) {
|
|
mVar.e++;
|
|
int i2 = mVar.f;
|
|
if (i2 > 0) {
|
|
c[] cVarArr = mVar.g;
|
|
int i3 = i2 - 1;
|
|
mVar.f = i3;
|
|
cVar = cVarArr[i3];
|
|
Objects.requireNonNull(cVar);
|
|
mVar.g[mVar.f] = null;
|
|
} else {
|
|
cVar = new c(new byte[mVar.b], 0);
|
|
}
|
|
}
|
|
a aVar2 = new a(this.f.b, this.b);
|
|
aVar.d = cVar;
|
|
aVar.e = aVar2;
|
|
aVar.f786c = true;
|
|
}
|
|
return Math.min(i, (int) (this.f.b - this.g));
|
|
}
|
|
}
|