package p138.p176.p177.p190.p192;

import com.google.android.exoplayer2.audio.AudioProcessor;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ShortBuffer;
import p000.p001.p002.p003.p004.C0567;

/* JADX INFO: renamed from: ދ.ހ.֏.ؠ.ࢪ.ޗ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C3503 implements AudioProcessor {

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public int f10421;

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public float f10422 = 1.0f;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public float f10423 = 1.0f;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public AudioProcessor.C0268 f10424;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public AudioProcessor.C0268 f10425;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public AudioProcessor.C0268 f10426;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public AudioProcessor.C0268 f10427;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public boolean f10428;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public C3502 f10429;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public ByteBuffer f10430;

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public ShortBuffer f10431;

    /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
    public ByteBuffer f10432;

    /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
    public long f10433;

    /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
    public long f10434;

    /* JADX INFO: renamed from: ލ, reason: contains not printable characters */
    public boolean f10435;

    public C3503() {
        AudioProcessor.C0268 c0268 = AudioProcessor.C0268.f1537;
        this.f10424 = c0268;
        this.f10425 = c0268;
        this.f10426 = c0268;
        this.f10427 = c0268;
        ByteBuffer byteBuffer = AudioProcessor.f1536;
        this.f10430 = byteBuffer;
        this.f10431 = byteBuffer.asShortBuffer();
        this.f10432 = AudioProcessor.f1536;
        this.f10421 = -1;
    }

    @Override // com.google.android.exoplayer2.audio.AudioProcessor
    public void flush() {
        if (mo1061()) {
            AudioProcessor.C0268 c0268 = this.f10424;
            this.f10426 = c0268;
            AudioProcessor.C0268 c02682 = this.f10425;
            this.f10427 = c02682;
            if (this.f10428) {
                this.f10429 = new C3502(c0268.f1538, c0268.f1539, this.f10422, this.f10423, c02682.f1538);
            } else {
                C3502 c3502 = this.f10429;
                if (c3502 != null) {
                    c3502.f10409 = 0;
                    c3502.f10411 = 0;
                    c3502.f10413 = 0;
                    c3502.f10414 = 0;
                    c3502.f10415 = 0;
                    c3502.f10416 = 0;
                    c3502.f10417 = 0;
                    c3502.f10418 = 0;
                    c3502.f10419 = 0;
                    c3502.f10420 = 0;
                }
            }
        }
        this.f10432 = AudioProcessor.f1536;
        this.f10433 = 0L;
        this.f10434 = 0L;
        this.f10435 = false;
    }

    @Override // com.google.android.exoplayer2.audio.AudioProcessor
    /* JADX INFO: renamed from: ֏ */
    public AudioProcessor.C0268 mo1057(AudioProcessor.C0268 c0268) throws AudioProcessor.UnhandledAudioFormatException {
        if (c0268.f1540 != 2) {
            throw new AudioProcessor.UnhandledAudioFormatException(c0268);
        }
        int i = this.f10421;
        if (i == -1) {
            i = c0268.f1538;
        }
        this.f10424 = c0268;
        AudioProcessor.C0268 c02682 = new AudioProcessor.C0268(i, c0268.f1539, 2);
        this.f10425 = c02682;
        this.f10428 = true;
        return c02682;
    }

    @Override // com.google.android.exoplayer2.audio.AudioProcessor
    /* JADX INFO: renamed from: ֏ */
    public void mo1058() {
        this.f10422 = 1.0f;
        this.f10423 = 1.0f;
        AudioProcessor.C0268 c0268 = AudioProcessor.C0268.f1537;
        this.f10424 = c0268;
        this.f10425 = c0268;
        this.f10426 = c0268;
        this.f10427 = c0268;
        ByteBuffer byteBuffer = AudioProcessor.f1536;
        this.f10430 = byteBuffer;
        this.f10431 = byteBuffer.asShortBuffer();
        this.f10432 = AudioProcessor.f1536;
        this.f10421 = -1;
        this.f10428 = false;
        this.f10429 = null;
        this.f10433 = 0L;
        this.f10434 = 0L;
        this.f10435 = false;
    }

    @Override // com.google.android.exoplayer2.audio.AudioProcessor
    /* JADX INFO: renamed from: ֏ */
    public void mo1059(ByteBuffer byteBuffer) {
        C3502 c3502 = this.f10429;
        C0567.m1856(c3502);
        if (byteBuffer.hasRemaining()) {
            ShortBuffer shortBufferAsShortBuffer = byteBuffer.asShortBuffer();
            int iRemaining = byteBuffer.remaining();
            this.f10433 += (long) iRemaining;
            int iRemaining2 = shortBufferAsShortBuffer.remaining();
            int i = c3502.f10400;
            int i2 = iRemaining2 / i;
            short[] sArrM5800 = c3502.m5800(c3502.f10408, c3502.f10409, i2);
            c3502.f10408 = sArrM5800;
            shortBufferAsShortBuffer.get(sArrM5800, c3502.f10409 * c3502.f10400, ((i * i2) * 2) / 2);
            c3502.f10409 += i2;
            c3502.m5797();
            byteBuffer.position(byteBuffer.position() + iRemaining);
        }
        int i3 = c3502.f10411 * c3502.f10400 * 2;
        if (i3 > 0) {
            if (this.f10430.capacity() < i3) {
                ByteBuffer byteBufferOrder = ByteBuffer.allocateDirect(i3).order(ByteOrder.nativeOrder());
                this.f10430 = byteBufferOrder;
                this.f10431 = byteBufferOrder.asShortBuffer();
            } else {
                this.f10430.clear();
                this.f10431.clear();
            }
            ShortBuffer shortBuffer = this.f10431;
            int iMin = Math.min(shortBuffer.remaining() / c3502.f10400, c3502.f10411);
            shortBuffer.put(c3502.f10410, 0, c3502.f10400 * iMin);
            int i4 = c3502.f10411 - iMin;
            c3502.f10411 = i4;
            short[] sArr = c3502.f10410;
            int i5 = c3502.f10400;
            System.arraycopy(sArr, iMin * i5, sArr, 0, i4 * i5);
            this.f10434 += (long) i3;
            this.f10430.limit(i3);
            this.f10432 = this.f10430;
        }
    }

    @Override // com.google.android.exoplayer2.audio.AudioProcessor
    /* JADX INFO: renamed from: ؠ */
    public boolean mo1060() {
        C3502 c3502;
        return this.f10435 && ((c3502 = this.f10429) == null || (c3502.f10411 * c3502.f10400) * 2 == 0);
    }

    @Override // com.google.android.exoplayer2.audio.AudioProcessor
    /* JADX INFO: renamed from: ހ */
    public boolean mo1061() {
        return this.f10425.f1538 != -1 && (Math.abs(this.f10422 - 1.0f) >= 0.01f || Math.abs(this.f10423 - 1.0f) >= 0.01f || this.f10425.f1538 != this.f10424.f1538);
    }

    @Override // com.google.android.exoplayer2.audio.AudioProcessor
    /* JADX INFO: renamed from: ށ */
    public ByteBuffer mo1062() {
        ByteBuffer byteBuffer = this.f10432;
        this.f10432 = AudioProcessor.f1536;
        return byteBuffer;
    }

    @Override // com.google.android.exoplayer2.audio.AudioProcessor
    /* JADX INFO: renamed from: ނ */
    public void mo1063() {
        int i;
        C3502 c3502 = this.f10429;
        if (c3502 != null) {
            int i2 = c3502.f10409;
            float f = c3502.f10401;
            float f2 = c3502.f10402;
            int i3 = c3502.f10411 + ((int) ((((i2 / (f / f2)) + c3502.f10413) / (c3502.f10403 * f2)) + 0.5f));
            c3502.f10408 = c3502.m5800(c3502.f10408, i2, (c3502.f10406 * 2) + i2);
            int i4 = 0;
            while (true) {
                i = c3502.f10406 * 2;
                int i5 = c3502.f10400;
                if (i4 >= i * i5) {
                    break;
                }
                c3502.f10408[(i5 * i2) + i4] = 0;
                i4++;
            }
            c3502.f10409 = i + c3502.f10409;
            c3502.m5797();
            if (c3502.f10411 > i3) {
                c3502.f10411 = i3;
            }
            c3502.f10409 = 0;
            c3502.f10416 = 0;
            c3502.f10413 = 0;
        }
        this.f10435 = true;
    }
}
