package o;

import android.media.AudioAttributes;
import android.media.AudioFormat;
import android.media.AudioMetadata;
import android.media.AudioMetadataReadMap;
import android.media.AudioTimestamp;
import android.media.AudioTrack;
import android.media.AudioTrack$OnCodecFormatChangedListener;
import android.media.MediaFormat;
import android.media.PlaybackParams;
import android.os.SystemClock;
import android.util.Log;
import androidx.media3.decoder.midi.MidiDecoder;
import b0.AbstractC0396a;
import b0.AbstractC0397b;
import b0.AbstractC0398c;
import b0.D;
import com.mstar.android.tv.TvLanguage;
import com.mstar.android.tv.TvPvrManager;
import com.seewo.sdk.model.SDKKeyboardCode;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.concurrent.Executor;
import n.AbstractC0637c;
import n.x;

/* JADX INFO: loaded from: classes.dex */
public final class j {

    /* JADX INFO: renamed from: s0, reason: collision with root package name */
    public static boolean f5879s0 = false;

    /* JADX INFO: renamed from: t0, reason: collision with root package name */
    public static boolean f5880t0 = false;

    /* JADX INFO: renamed from: u0, reason: collision with root package name */
    private static final int[] f5881u0 = {64, 64, 80, 80, 96, 96, 112, 112, 128, 128, 160, 160, TvLanguage.GORONTALO, TvLanguage.GORONTALO, TvLanguage.INTERLINGUA, TvLanguage.INTERLINGUA, 256, 256, TvLanguage.MOSSI, TvLanguage.MOSSI, TvLanguage.LULESAMI, TvLanguage.LULESAMI, TvLanguage.KLINGON, TvLanguage.KLINGON, 512, 512, 640, 640, 768, 768, 896, 896, 1024, 1024, 1152, 1152, 1280, 1280, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 69, 70, 87, 88, 104, 105, 121, 122, TvLanguage.CRIMEANTATAR, TvLanguage.CREOLESANDPIDGINSENGLISH, TvLanguage.FILIPINO, 175, TvLanguage.HERERO, TvLanguage.HILIGAYNON, TvLanguage.KAREN, TvLanguage.KASHMIRI, TvLanguage.LINGALA, TvLanguage.LITHUANIAN, TvLanguage.OJIBWA, TvLanguage.ORIYA, TvLanguage.WALLOON, TvLanguage.NKO, TvLanguage.YIDDISH, TvLanguage.YORUBA, 557, 558, 696, 697, 835, 836, 975, 976, 1114, 1115, 1253, 1254, 1393, 1394, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 96, 120, 120, 144, 144, TvLanguage.EWE, TvLanguage.EWE, TvLanguage.GORONTALO, TvLanguage.GORONTALO, 240, 240, 288, 288, TvLanguage.NORWEGIANBOKMAL, TvLanguage.NORWEGIANBOKMAL, TvLanguage.LULESAMI, TvLanguage.LULESAMI, TvLanguage.WASHO, TvLanguage.WASHO, 576, 576, 672, 672, 768, 768, 960, 960, 1152, 1152, 1344, 1344, 1536, 1536, 1728, 1728, 1920, 1920, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

    /* JADX INFO: renamed from: v0, reason: collision with root package name */
    private static final int[] f5882v0 = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, TvLanguage.GORONTALO, TvLanguage.INTERLINGUA, 256, TvLanguage.MOSSI, TvLanguage.LULESAMI, TvLanguage.KLINGON, 512, 576, 640};

    /* JADX INFO: renamed from: w0, reason: collision with root package name */
    private static final int[] f5883w0 = {48000, MidiDecoder.DEFAULT_SAMPLE_RATE, TvPvrManager.PVR_PLAYBACK_SPEED_FF_32X};

    /* JADX INFO: renamed from: x0, reason: collision with root package name */
    private static final int[] f5884x0 = {1, 2, 3, 6};

    /* JADX INFO: renamed from: y0, reason: collision with root package name */
    private static final byte[] f5885y0 = {0, SDKKeyboardCode.FUNCTION_KEY_BOARD_2, SDKKeyboardCode.FUNCTION_KEY_BOARD_F6, 95, SDKKeyboardCode.FUNCTION_KEY_BOARD_VOLUME_UP, -97, -65, -33, -1, -33, -65, -97, SDKKeyboardCode.FUNCTION_KEY_BOARD_VOLUME_UP, 95, SDKKeyboardCode.FUNCTION_KEY_BOARD_F6, SDKKeyboardCode.FUNCTION_KEY_BOARD_2};

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    private int f5886A;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    private long f5887B;

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    private long f5888C;

    /* JADX INFO: renamed from: D, reason: collision with root package name */
    private long f5889D;

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    private float f5890E;

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    private byte[] f5891F;

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    private int f5892G;

    /* JADX INFO: renamed from: H, reason: collision with root package name */
    private int f5893H;

    /* JADX INFO: renamed from: I, reason: collision with root package name */
    private ByteBuffer f5894I;

    /* JADX INFO: renamed from: J, reason: collision with root package name */
    private boolean f5895J;

    /* JADX INFO: renamed from: K, reason: collision with root package name */
    private ByteBuffer f5896K;

    /* JADX INFO: renamed from: L, reason: collision with root package name */
    private byte[] f5897L;

    /* JADX INFO: renamed from: N, reason: collision with root package name */
    private c f5899N;

    /* JADX INFO: renamed from: O, reason: collision with root package name */
    private int f5900O;

    /* JADX INFO: renamed from: P, reason: collision with root package name */
    private ByteBuffer f5901P;

    /* JADX INFO: renamed from: Q, reason: collision with root package name */
    private ByteBuffer f5902Q;

    /* JADX INFO: renamed from: R, reason: collision with root package name */
    private ByteBuffer f5903R;

    /* JADX INFO: renamed from: S, reason: collision with root package name */
    private boolean f5904S;

    /* JADX INFO: renamed from: T, reason: collision with root package name */
    private byte[] f5905T;

    /* JADX INFO: renamed from: U, reason: collision with root package name */
    private int f5906U;

    /* JADX INFO: renamed from: V, reason: collision with root package name */
    private int f5907V;

    /* JADX INFO: renamed from: W, reason: collision with root package name */
    private int f5908W;

    /* JADX INFO: renamed from: X, reason: collision with root package name */
    private int f5909X;

    /* JADX INFO: renamed from: Y, reason: collision with root package name */
    private int f5910Y;

    /* JADX INFO: renamed from: Z, reason: collision with root package name */
    private int f5911Z;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final String f5912a;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    private int f5913a0;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final C0648b f5914b;

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    private int f5915b0;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private final long[] f5916c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private final d f5918d;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    private String f5919d0;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private AudioTrack f5920e;

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    private int f5921e0;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private volatile AudioTrack f5922f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private int f5924g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private int f5926h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private int f5928i;

    /* JADX INFO: renamed from: i0, reason: collision with root package name */
    private boolean f5929i0;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private int f5930j;

    /* JADX INFO: renamed from: j0, reason: collision with root package name */
    private ByteBuffer f5931j0;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private int f5932k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    private boolean f5934l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    private int f5936m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    private int f5938n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    private long f5940o;

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    private int f5941o0;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    private int f5942p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    private int f5944q;

    /* JADX INFO: renamed from: q0, reason: collision with root package name */
    private i f5945q0;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    private long f5946r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    private long f5948s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public boolean f5949t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    private long f5950u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    private Method f5951v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    private long f5952w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    private long f5953x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    private long f5954y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    private int f5955z = 0;

    /* JADX INFO: renamed from: M, reason: collision with root package name */
    private boolean f5898M = false;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    private long f5917c0 = -1;

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    private boolean f5923f0 = false;

    /* JADX INFO: renamed from: g0, reason: collision with root package name */
    private int f5925g0 = -1;

    /* JADX INFO: renamed from: h0, reason: collision with root package name */
    private ByteBuffer f5927h0 = null;

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    private long f5933k0 = -1;

    /* JADX INFO: renamed from: l0, reason: collision with root package name */
    private int f5935l0 = 0;

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    private int f5937m0 = 0;

    /* JADX INFO: renamed from: n0, reason: collision with root package name */
    private boolean f5939n0 = false;

    /* JADX INFO: renamed from: p0, reason: collision with root package name */
    public int f5943p0 = 0;

    /* JADX INFO: renamed from: r0, reason: collision with root package name */
    private boolean f5947r0 = false;

    class a implements Executor {
        a() {
        }

        @Override // java.util.concurrent.Executor
        public void execute(Runnable runnable) {
            runnable.run();
        }
    }

    class b implements Executor {
        b() {
        }

        @Override // java.util.concurrent.Executor
        public void execute(Runnable runnable) {
            runnable.run();
        }
    }

    public interface c {
        void a(AudioMetadataReadMap audioMetadataReadMap);
    }

    private static class d {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private final String f5958a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        protected AudioTrack f5959b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        private boolean f5960c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        protected int f5961d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        private long f5962e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        private long f5963f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        private long f5964g;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        private long f5965h;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        private long f5966i;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        private long f5967j;

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        protected int f5968k = -1;

        public d(String str) {
            this.f5958a = "AudioTrackUtil" + str;
        }

        public long a() {
            AudioTrack audioTrack = this.f5959b;
            if (audioTrack == null) {
                return 0L;
            }
            if (this.f5965h != -1) {
                return Math.min(this.f5967j, this.f5966i + ((((SystemClock.elapsedRealtime() * 1000) - this.f5965h) * ((long) this.f5961d)) / 1000000));
            }
            int playState = audioTrack.getPlayState();
            if (playState == 1) {
                return 0L;
            }
            long playbackHeadPosition = ((long) this.f5959b.getPlaybackHeadPosition()) & 4294967295L;
            if (this.f5960c) {
                if (playState == 2 && playbackHeadPosition == 0) {
                    this.f5964g = this.f5962e;
                }
                playbackHeadPosition += this.f5964g;
            }
            if (this.f5962e > playbackHeadPosition) {
                if (playbackHeadPosition == 0 && this.f5959b.getPlaybackHeadPosition() == 0 && this.f5962e + 3072000000000L < 4294967295L) {
                    Log.w(this.f5958a, "AudioTrack is very likely dead. Do not hanle this position over flow");
                } else {
                    this.f5963f++;
                }
            }
            this.f5962e = playbackHeadPosition;
            return playbackHeadPosition + (this.f5963f << 32);
        }

        public long b() {
            return (a() * 1000000) / ((long) this.f5961d);
        }

        public float c() {
            return 1.0f;
        }

        public long d() {
            throw new UnsupportedOperationException();
        }

        public long e() {
            throw new UnsupportedOperationException();
        }

        public void f(long j2) {
            if (this.f5959b == null) {
                return;
            }
            this.f5966i = a();
            this.f5965h = SystemClock.elapsedRealtime() * 1000;
            this.f5967j = j2;
            this.f5959b.stop();
        }

        public void g() {
            if (this.f5959b == null) {
                return;
            }
            long j2 = this.f5965h;
            if (j2 != -1) {
                return;
            }
            b0.o.c(this.f5958a, 2, "audioTrack.pause() @stopTimestamp", Long.valueOf(j2));
            this.f5959b.pause();
            Log.d(this.f5958a, "pause audioTrack.");
        }

        public void h() {
            if (this.f5959b == null) {
                return;
            }
            long j2 = this.f5965h;
            if (j2 != -1) {
                return;
            }
            b0.o.c(this.f5958a, 2, "audioTrack.play() @stopTimestamp", Long.valueOf(j2));
            this.f5959b.play();
            Log.d(this.f5958a, "play audioTrack success.");
        }

        public void i(AudioTrack audioTrack, boolean z2) {
            this.f5959b = audioTrack;
            this.f5960c = z2;
            this.f5965h = -1L;
            this.f5962e = 0L;
            this.f5963f = 0L;
            this.f5964g = 0L;
            if (audioTrack != null) {
                this.f5961d = audioTrack.getSampleRate();
            }
        }

        public void j(int i2) {
            this.f5968k = i2;
        }

        public void k(PlaybackParams playbackParams) {
            throw new UnsupportedOperationException();
        }

        public boolean l() {
            return false;
        }
    }

    private static class e extends d {

        /* JADX INFO: renamed from: l, reason: collision with root package name */
        private final AudioTimestamp f5969l;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        private long f5970m;

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        private long f5971n;

        /* JADX INFO: renamed from: o, reason: collision with root package name */
        private long f5972o;

        public e(String str) {
            super(str);
            this.f5969l = new AudioTimestamp();
        }

        @Override // o.j.d
        public long d() {
            return this.f5972o;
        }

        @Override // o.j.d
        public long e() {
            return this.f5969l.nanoTime;
        }

        @Override // o.j.d
        public void i(AudioTrack audioTrack, boolean z2) {
            super.i(audioTrack, z2);
            this.f5970m = 0L;
            this.f5971n = 0L;
            this.f5972o = 0L;
        }

        @Override // o.j.d
        public boolean l() {
            boolean timestamp = this.f5959b.getTimestamp(this.f5969l);
            if (timestamp) {
                long j2 = this.f5969l.framePosition;
                if (this.f5971n > j2) {
                    this.f5970m++;
                }
                this.f5971n = j2;
                this.f5972o = (this.f5970m << 32) + j2;
                b0.o.c("AudioTrackUtil", 2, "rawFramePosition: ", Long.valueOf(j2), "(", Long.valueOf((1000000 * j2) / ((long) this.f5961d)), "), lastTimestampFramePosition: ", Long.valueOf(this.f5972o), ", sampleRate: ", Integer.valueOf(this.f5961d));
            }
            return timestamp;
        }
    }

    private static class f extends e {

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        private PlaybackParams f5973p;

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        private float f5974q;

        public f(String str) {
            super(str);
            this.f5974q = 1.0f;
        }

        private void m() {
            PlaybackParams playbackParams;
            AudioTrack audioTrack = this.f5959b;
            if (audioTrack == null || (playbackParams = this.f5973p) == null) {
                return;
            }
            audioTrack.setPlaybackParams(playbackParams);
        }

        @Override // o.j.d
        public float c() {
            return this.f5974q;
        }

        @Override // o.j.e, o.j.d
        public void i(AudioTrack audioTrack, boolean z2) {
            super.i(audioTrack, z2);
            m();
        }

        @Override // o.j.d
        public void k(PlaybackParams playbackParams) {
            if (playbackParams == null) {
                playbackParams = new PlaybackParams();
            }
            PlaybackParams playbackParamsAllowDefaults = playbackParams.allowDefaults();
            this.f5973p = playbackParamsAllowDefaults;
            this.f5974q = playbackParamsAllowDefaults.getSpeed();
            m();
        }
    }

    public static final class g extends Exception {

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

        public g(int i2, int i3, int i4, int i5) {
            super("AudioTrack init failed: " + i2 + ", Config(" + i3 + ", " + i4 + ", " + i5 + ")");
            this.f5975b = i2;
        }
    }

    public static final class h extends RuntimeException {
        public h(String str) {
            super(str);
        }
    }

    private final class i implements AudioTrack$OnCodecFormatChangedListener {
        public void onCodecFormatChanged(AudioTrack audioTrack, AudioMetadataReadMap audioMetadataReadMap) {
            AudioMetadata.Key key = x.f5828r0;
            long jLongValue = audioMetadataReadMap.containsKey(key) ? ((Long) audioMetadataReadMap.get(key)).longValue() : -1L;
            String str = audioMetadataReadMap.containsKey(AudioMetadata.Format.KEY_MIME) ? (String) audioMetadataReadMap.get(AudioMetadata.Format.KEY_MIME) : null;
            int iIntValue = audioMetadataReadMap.containsKey(AudioMetadata.Format.KEY_SAMPLE_RATE) ? ((Integer) audioMetadataReadMap.get(AudioMetadata.Format.KEY_SAMPLE_RATE)).intValue() : 0;
            int iIntValue2 = audioMetadataReadMap.containsKey(AudioMetadata.Format.KEY_CHANNEL_MASK) ? ((Integer) audioMetadataReadMap.get(AudioMetadata.Format.KEY_CHANNEL_MASK)).intValue() : 0;
            if (audioMetadataReadMap.containsKey(AudioMetadata.Format.KEY_ATMOS_PRESENT)) {
                boolean zBooleanValue = ((Boolean) audioMetadataReadMap.get(AudioMetadata.Format.KEY_ATMOS_PRESENT)).booleanValue();
                Log.i(j.this.f5912a, "KEY_ATMOS_PRESENT isAtmos:" + zBooleanValue);
            }
            Log.i(j.this.f5912a, "seqNumber = " + jLongValue + ", mime = " + str + ", sampleRate = " + j.this.f5924g + ", newSampleRate = " + iIntValue + ", channelConfig = " + iIntValue2);
            if (j.this.f5899N != null) {
                j.this.f5899N.a(audioMetadataReadMap);
            }
        }

        private i() {
        }
    }

    /* JADX INFO: renamed from: o.j$j, reason: collision with other inner class name */
    public static final class C0084j extends Exception {

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

        public C0084j(int i2) {
            super("AudioTrack write failed: " + i2);
            this.f5977b = i2;
        }
    }

    public j(String str, C0648b c0648b, int i2) {
        this.f5912a = "AudioTrackMM" + str;
        this.f5914b = c0648b;
        if (D.f2965a >= 18) {
            try {
                this.f5951v = AudioTrack.class.getMethod("getLatency", null);
            } catch (NoSuchMethodException unused) {
            }
        }
        int i3 = D.f2965a;
        if (i3 >= 23) {
            this.f5918d = new f(str);
        } else if (i3 >= 19) {
            this.f5918d = new e(str);
        } else {
            this.f5918d = new d(str);
        }
        this.f5916c = new long[10];
        this.f5928i = i2;
        this.f5890E = 1.0f;
        this.f5886A = 0;
        this.f5900O = -1;
        if (i3 >= 30) {
            this.f5945q0 = new i();
        }
    }

    private boolean A() {
        return J() && this.f5886A != 0;
    }

    private void E() {
        if (this.f5904S) {
            return;
        }
        b0.o.d(this.f5912a, "initAc3", 2);
        this.f5905T = new byte[6];
        this.f5906U = 0;
        this.f5909X = 0;
        this.f5907V = 0;
        this.f5903R = ByteBuffer.allocate(0);
        this.f5904S = true;
        this.f5911Z = 0;
        this.f5913a0 = 0;
        this.f5915b0 = 0;
    }

    private byte[] G(int i2) {
        return H(i2, false);
    }

    private byte[] H(int i2, boolean z2) {
        ByteBuffer byteBufferAllocate = ByteBuffer.allocate(4);
        if (z2) {
            byteBufferAllocate.order(ByteOrder.LITTLE_ENDIAN);
        } else {
            byteBufferAllocate.order(ByteOrder.BIG_ENDIAN);
        }
        byteBufferAllocate.putInt(i2);
        return byteBufferAllocate.array();
    }

    private boolean I() {
        return this.f5904S;
    }

    static int P(int i2, String str) {
        switch (i2) {
            case 1:
                return 4;
            case 2:
                return 12;
            case 3:
                return 28;
            case 4:
                return TvLanguage.HAIDA;
            case 5:
                return (str.equals("audio/ac3") || str.equals("audio/eac3")) ? TvLanguage.KIKUYU : TvLanguage.INDIC;
            case 6:
                return TvLanguage.KIKUYU;
            case 7:
                return 1276;
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
                return AbstractC0637c.f5500g;
            default:
                throw new IllegalArgumentException("Unsupported channel count: " + i2);
        }
    }

    private void R() {
        long jNanoTime = System.nanoTime() / 1000;
        if (jNanoTime - this.f5950u >= 500000) {
            boolean zL = this.f5918d.l();
            this.f5949t = zL;
            if (zL) {
                long jE = this.f5918d.e() / 1000;
                long jD = this.f5918d.d();
                if (jE < this.f5888C) {
                    this.f5949t = false;
                } else if (Math.abs(jE - jNanoTime) > 5000000) {
                    String str = "Spurious audio timestamp (system clock mismatch): " + jD + ", " + jE + ", " + jNanoTime;
                    if (f5880t0) {
                        throw new h(str);
                    }
                    Log.w(this.f5912a, str);
                    this.f5949t = false;
                }
            }
            Method method = this.f5951v;
            if (method != null && !this.f5934l) {
                try {
                    long jIntValue = (((long) ((Integer) method.invoke(this.f5922f, null)).intValue()) * 1000) - this.f5940o;
                    this.f5889D = jIntValue;
                    long jMax = Math.max(jIntValue, 0L);
                    this.f5889D = jMax;
                    if (jMax > 5000000) {
                        Log.w(this.f5912a, "Ignoring impossibly large audio latency: " + this.f5889D);
                        this.f5889D = 0L;
                    }
                } catch (Exception unused) {
                    this.f5951v = null;
                }
            }
            this.f5950u = jNanoTime;
        }
    }

    private boolean S() {
        int i2;
        return D.f2965a < 23 && ((i2 = this.f5932k) == 5 || i2 == 6 || i2 == 18);
    }

    private boolean T() {
        return S() && this.f5922f.getPlayState() == 2 && this.f5922f.getPlaybackHeadPosition() == 0;
    }

    private long V(long j2) {
        return j2 / ((long) this.f5936m);
    }

    private ByteBuffer X(ByteBuffer byteBuffer) {
        int iPosition = byteBuffer.position();
        int i2 = iPosition + 1;
        b0.o.c(this.f5912a, 2, "header=", Integer.toHexString(byteBuffer.get(iPosition) & 255), " ", Integer.valueOf(byteBuffer.get(i2) & 240));
        if ((byteBuffer.get(iPosition) & 255) != 255 || (byteBuffer.get(i2) & 240) != 240) {
            b0.o.c(this.f5912a, 2, "Not ADTS AAC, don't process.");
            return null;
        }
        int i3 = (byteBuffer.get(iPosition + 7) & 224) >> 5;
        b0.o.c(this.f5912a, 2, "elementId=", Integer.valueOf(i3));
        ByteBuffer byteBuffer2 = this.f5931j0;
        if (byteBuffer2 == null) {
            if (i3 != 5) {
                Log.e(this.f5912a, "No avaiable PCE");
                return null;
            }
            ByteBuffer byteBufferE = AbstractC0396a.e(byteBuffer);
            this.f5931j0 = byteBufferE;
            if (byteBufferE == null) {
                Log.w(this.f5912a, "no PCE in first frame");
            }
            return null;
        }
        if (i3 == 5) {
            Log.e(this.f5912a, "Already have PCE, do nothing");
            return null;
        }
        int iLimit = this.f5893H + byteBuffer2.limit();
        b0.o.c(this.f5912a, 2, "bufferBytesRemaining=", Integer.valueOf(this.f5893H), ", newBufferLength=", Integer.valueOf(iLimit));
        ByteBuffer byteBufferAllocate = ByteBuffer.allocate(iLimit);
        byteBufferAllocate.put(AbstractC0396a.a(this.f5924g, this.f5941o0, iLimit - 7));
        byteBufferAllocate.put(this.f5931j0);
        this.f5931j0.position(0);
        byteBuffer.position(7);
        byteBufferAllocate.put(byteBuffer);
        byteBufferAllocate.position(0);
        return byteBufferAllocate;
    }

    private void Z() {
        AudioTrack audioTrack = this.f5920e;
        if (audioTrack == null) {
            return;
        }
        this.f5920e = null;
        audioTrack.release();
    }

    private ByteBuffer a0(ByteBuffer byteBuffer, int i2, int i3, int i4, ByteBuffer byteBuffer2) {
        int length;
        if (i4 == 3) {
            length = i3 * 2;
        } else if (i4 == AbstractC0637c.f5494a) {
            length = (i3 / 3) * 2;
        } else {
            if (i4 != AbstractC0637c.f5495b) {
                throw new IllegalStateException();
            }
            length = i3 / 2;
        }
        byte[] bArr = this.f5897L;
        if (bArr != null) {
            length += bArr.length;
        }
        if (byteBuffer2 == null || byteBuffer2.capacity() < length) {
            byteBuffer2 = ByteBuffer.allocateDirect(length);
        }
        byteBuffer2.position(0);
        byteBuffer2.limit(length);
        byte[] bArr2 = this.f5897L;
        if (bArr2 != null) {
            byteBuffer2.put(bArr2);
            this.f5897L = null;
        }
        int i5 = i3 + i2;
        if (i4 == 3) {
            while (i2 < i5) {
                byteBuffer2.put((byte) 0);
                byteBuffer2.put((byte) ((byteBuffer.get(i2) & 255) - 128));
                i2++;
            }
        } else if (i4 == AbstractC0637c.f5494a) {
            int i6 = (i5 - i2) / 3;
            for (int i7 = 0; i7 < i6; i7++) {
                int i8 = i7 * 3;
                byteBuffer2.put(byteBuffer.get(i8 + 1));
                byteBuffer2.put(byteBuffer.get(i8 + 2));
            }
        } else {
            if (i4 != AbstractC0637c.f5495b) {
                throw new IllegalStateException();
            }
            int i9 = (i5 - i2) / 4;
            for (int i10 = 0; i10 < i9; i10++) {
                int i11 = i10 * 4;
                byteBuffer2.put(byteBuffer.get(i11 + 2));
                byteBuffer2.put(byteBuffer.get(i11 + 3));
            }
        }
        byteBuffer2.position(0);
        return byteBuffer2;
    }

    private void c0() {
        this.f5904S = false;
        Log.d(this.f5912a, "resetAc3");
    }

    /* JADX WARN: Code restructure failed: missing block: B:81:0x02ac, code lost:
    
        android.util.Log.e(r35.f5912a, "wrong bsid=" + r6);
     */
    /* JADX WARN: Removed duplicated region for block: B:111:0x0334  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    private int d(java.nio.ByteBuffer r36, int r37) throws o.j.C0084j {
        /*
            Method dump skipped, instruction units count: 828
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.j.d(java.nio.ByteBuffer, int):int");
    }

    private void d0() {
        this.f5946r = 0L;
        this.f5944q = 0;
        this.f5942p = 0;
        this.f5948s = 0L;
        this.f5949t = false;
        this.f5950u = 0L;
        this.f5933k0 = -1L;
        this.f5935l0 = 0;
    }

    private void e(ByteBuffer byteBuffer, long j2) {
        int i2 = this.f5893H;
        byte[] bArrL = l(false, j2);
        byte[] bArrP = p(i2);
        boolean z2 = j2 != 0;
        int length = (z2 ? 18 : 10) + bArrL.length + bArrP.length;
        int i3 = this.f5893H + length;
        this.f5893H = i3;
        if (this.f5901P == null) {
            this.f5901P = ByteBuffer.allocate(i3);
        }
        int iLimit = this.f5901P.limit();
        int i4 = this.f5893H;
        if (iLimit < i4) {
            this.f5901P = ByteBuffer.allocate(i4);
        }
        this.f5901P.clear();
        this.f5901P.put((byte) 85);
        this.f5901P.put((byte) 85);
        this.f5901P.put((byte) 0);
        this.f5901P.put((byte) 3);
        this.f5901P.putInt(4, i2 + length);
        this.f5901P.put(8, (byte) 0);
        this.f5901P.put(9, z2 ? SDKKeyboardCode.FUNCTION_KEY_BOARD_Y : SDKKeyboardCode.FUNCTION_KEY_BOARD_I);
        if (z2) {
            this.f5901P.putLong(10, 1000 * j2);
            this.f5901P.position(18);
        } else {
            this.f5901P.position(10);
        }
        this.f5901P.put(bArrL);
        this.f5901P.put(bArrP);
        this.f5901P.put(byteBuffer);
        this.f5901P.position(0);
        Log.d(this.f5912a, "append ms dtv audio v3 header, size=" + this.f5893H + ",pts=" + j2);
    }

    private void f() throws g {
        int state = this.f5922f.getState();
        if (state != 1) {
            try {
                this.f5922f.release();
            } catch (Exception unused) {
            } catch (Throwable th) {
                this.f5922f = null;
                throw th;
            }
            this.f5922f = null;
            throw new g(state, this.f5924g, this.f5926h, this.f5938n);
        }
        Log.d(this.f5912a, "[Performance]AudioTrack init success: , Config(" + this.f5924g + ", " + this.f5926h + ", " + this.f5938n + ")");
    }

    private void f0() {
        if (J()) {
            if (D.f2965a < 21) {
                h0(this.f5922f, this.f5890E);
                return;
            }
            Log.d(this.f5912a, "audioTrack.setVolume:" + this.f5890E);
            g0(this.f5922f, this.f5890E);
        }
    }

    private static byte[] g(byte[]... bArr) {
        int length = 0;
        for (byte[] bArr2 : bArr) {
            length += bArr2.length;
        }
        byte[] bArr3 = new byte[length];
        int length2 = 0;
        for (byte[] bArr4 : bArr) {
            System.arraycopy(bArr4, 0, bArr3, length2, bArr4.length);
            length2 += bArr4.length;
        }
        return bArr3;
    }

    private static void g0(AudioTrack audioTrack, float f2) {
        audioTrack.setVolume(f2);
    }

    private static void h0(AudioTrack audioTrack, float f2) {
        audioTrack.setStereoVolume(f2, f2);
    }

    private long j(long j2) {
        return (j2 * ((long) this.f5924g)) / 1000000;
    }

    private long k(long j2) {
        return (j2 * 1000000) / ((long) this.f5924g);
    }

    private byte[] l(boolean z2, long j2) {
        return z2 ? g(m(z2), o(z2), n(j2)) : g(m(z2), o(z2));
    }

    private void l0() {
        if (D.f2965a < 31) {
            return;
        }
        try {
            Method declaredMethod = Class.forName("android.media.AudioTrack").getDeclaredMethod("setStartThresholdInFrames", Integer.TYPE);
            if (declaredMethod != null) {
                declaredMethod.invoke(this.f5922f, 1);
                Log.i(this.f5912a, "setStartThresholdInFrames success");
            }
        } catch (Exception unused) {
            Log.e(this.f5912a, "Android sdk version dose not support setStartThresholdInFrames().");
        }
    }

    private byte[] m(boolean z2) {
        byte[] bArr = new byte[6];
        bArr[3] = z2 ? SDKKeyboardCode.FUNCTION_KEY_BOARD_V : SDKKeyboardCode.FUNCTION_KEY_BOARD_L;
        bArr[5] = z2 ? (byte) 2 : (byte) 1;
        return bArr;
    }

    private byte[] n(long j2) {
        byte[] bArr = new byte[10];
        bArr[1] = 2;
        bArr[3] = 10;
        byte b2 = f5885y0[(int) (((j2 / 100000) / 1000) % 16)];
        bArr[4] = b2;
        bArr[5] = b2;
        return bArr;
    }

    private byte[] o(boolean z2) {
        byte[] bArr = new byte[9];
        bArr[1] = 1;
        bArr[3] = 9;
        bArr[8] = z2 ? (byte) 1 : (byte) 0;
        return bArr;
    }

    private byte[] p(int i2) {
        byte[] bArr = new byte[6];
        System.arraycopy(G(i2 + 6), 0, bArr, 0, 4);
        bArr[5] = 1;
        return bArr;
    }

    private void p0() {
        Log.d(this.f5912a, "setup media tunneling, tunnelingAudioSessionId = " + this.f5900O);
        AudioAttributes.Builder builder = new AudioAttributes.Builder();
        builder.setFlags(16);
        builder.setUsage(1);
        builder.setContentType(3);
        AudioFormat.Builder builder2 = new AudioFormat.Builder();
        builder2.setChannelMask(this.f5926h);
        builder2.setEncoding(this.f5932k);
        builder2.setSampleRate(this.f5924g);
        this.f5922f = new AudioTrack(builder.build(), builder2.build(), this.f5938n, 1, this.f5900O);
    }

    private static int q(ByteBuffer byteBuffer) {
        byte[] bArr = new byte[byteBuffer.limit()];
        byteBuffer.duplicate().get(bArr);
        return AbstractC0398c.a(bArr);
    }

    private void q0(int i2) {
        int i3;
        Log.d(this.f5912a, "setup tunneling ms audiotrack, hwSyncId = " + i2);
        if (((-65536) & i2) != 0) {
            i3 = (((i2 >> 16) & 65535) << 12) | 1610612736;
            i2 &= 65535;
            Log.d(this.f5912a, "setup merak1 mediasync audio contentid = " + i3);
        } else {
            i3 = Integer.MAX_VALUE;
        }
        AudioAttributes.Builder builder = new AudioAttributes.Builder();
        builder.setFlags(16);
        builder.setUsage(1);
        builder.setContentType(3);
        AudioFormat.Builder builder2 = new AudioFormat.Builder();
        builder2.setChannelMask(this.f5926h);
        builder2.setEncoding(this.f5932k);
        builder2.setSampleRate(this.f5924g);
        AudioAttributes audioAttributesBuild = builder.build();
        this.f5922f = new AudioTrack.Builder().setAudioAttributes(audioAttributesBuild).setAudioFormat(builder2.build()).setTransferMode(1).setBufferSizeInBytes(this.f5938n).setTunerConfiguration(new AudioTrack.TunerConfiguration(i3, i2)).setOffloadedPlayback(false).setEncapsulationMode(1).build();
        if (D.f2965a >= 31) {
            l0();
        }
    }

    private boolean r0() {
        int i2 = this.f5932k;
        return i2 == 5 || i2 == 6 || i2 == 18 || i2 == 3 || i2 == 2 || i2 == AbstractC0637c.f5494a || i2 == AbstractC0637c.f5495b;
    }

    private static int s0(AudioTrack audioTrack, ByteBuffer byteBuffer, int i2) {
        return audioTrack.write(byteBuffer, i2, 1);
    }

    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    static int t(String str, int i2) {
        str.hashCode();
        byte b2 = -1;
        switch (str.hashCode()) {
            case -2123537834:
                if (str.equals("audio/eac3-joc")) {
                    b2 = 0;
                }
                break;
            case -2122938134:
                if (str.equals("audio/mp4a-latm-hw")) {
                    b2 = 1;
                }
                break;
            case -1365340241:
                if (str.equals("audio/vnd.dts.hd;profile=lbr")) {
                    b2 = 2;
                }
                break;
            case -1095064472:
                if (str.equals("audio/vnd.dts")) {
                    b2 = 3;
                }
                break;
            case -432837260:
                if (str.equals("audio/mpeg-L1")) {
                    b2 = 4;
                }
                break;
            case -432837259:
                if (str.equals("audio/mpeg-L2")) {
                    b2 = 5;
                }
                break;
            case -53558318:
                if (str.equals("audio/mp4a-latm")) {
                    b2 = 6;
                }
                break;
            case 187078296:
                if (str.equals("audio/ac3")) {
                    b2 = 7;
                }
                break;
            case 187078297:
                if (str.equals("audio/ac4")) {
                    b2 = 8;
                }
                break;
            case 187081690:
                if (str.equals("audio/dra")) {
                    b2 = 9;
                }
                break;
            case 1382920842:
                if (str.equals("audio/ac4-joc")) {
                    b2 = 10;
                }
                break;
            case 1504578661:
                if (str.equals("audio/eac3")) {
                    b2 = 11;
                }
                break;
            case 1504823652:
                if (str.equals("audio/mha1")) {
                    b2 = 12;
                }
                break;
            case 1504824024:
                if (str.equals("audio/mhm1")) {
                    b2 = SDKKeyboardCode.FUNCTION_KEY_BOARD_J;
                }
                break;
            case 1504831518:
                if (str.equals("audio/mpeg")) {
                    b2 = 14;
                }
                break;
            case 1505942594:
                if (str.equals("audio/vnd.dts.hd")) {
                    b2 = SDKKeyboardCode.FUNCTION_KEY_BOARD_L;
                }
                break;
            case 1556697186:
                if (str.equals("audio/true-hd")) {
                    b2 = SDKKeyboardCode.FUNCTION_KEY_BOARD_M;
                }
                break;
        }
        switch (b2) {
            case 0:
                return 6;
            case 1:
            case 6:
                if (i2 == 5) {
                    return 11;
                }
                return i2 == 29 ? 12 : 10;
            case 2:
            case 15:
                return 8;
            case 3:
                return 7;
            case 4:
            case 5:
            case 14:
                return 9;
            case 7:
                return 5;
            case 8:
            case 10:
                return AbstractC0637c.f5496c;
            case 9:
                return AbstractC0637c.f5499f;
            case 11:
                return 6;
            case 12:
            case 13:
                return AbstractC0637c.f5497d;
            case 16:
                return 14;
            default:
                return 0;
        }
    }

    private int t0(AudioTrack audioTrack, ByteBuffer byteBuffer, int i2, long j2) {
        return audioTrack.write(byteBuffer, i2, 1, j2 * 1000);
    }

    private static int u(int i2, ByteBuffer byteBuffer) {
        if (i2 == 5) {
            return AbstractC0397b.a();
        }
        if (i2 == 6 || i2 == 18) {
            return AbstractC0397b.g(byteBuffer);
        }
        if (i2 == AbstractC0637c.f5496c) {
            byte[] bArr = new byte[byteBuffer.limit()];
            byteBuffer.duplicate().get(bArr);
            return AbstractC0398c.b(bArr);
        }
        if (i2 == 14) {
            return TvLanguage.WASHO;
        }
        if (i2 != 9) {
            throw new IllegalStateException("Unexpected audio encoding: " + i2);
        }
        if (byteBuffer.limit() - byteBuffer.position() < 4) {
            return 0;
        }
        for (int i3 = 0; i3 < (byteBuffer.limit() - byteBuffer.position()) - 4; i3++) {
            int iC = r.c(D.m(byteBuffer, byteBuffer.position() + i3));
            if (iC == -1) {
                throw new IllegalArgumentException("Mpeg audio frameCount unset");
            }
            if (iC != 0) {
                return iC;
            }
        }
        return 0;
    }

    private long w() {
        return this.f5934l ? this.f5954y : V(this.f5952w);
    }

    public boolean B() {
        return J() && (w() > this.f5918d.a() || T());
    }

    public int C() {
        return D(0);
    }

    public int D(int i2) {
        Log.d(this.f5912a, "audiotrack initialize sessionId:" + i2);
        if (this.f5900O != -1) {
            p0();
        } else {
            this.f5922f = new AudioTrack(this.f5928i, this.f5924g, this.f5926h, this.f5932k, this.f5938n, 1);
        }
        int i3 = D.f2965a;
        if (i3 >= 31) {
            l0();
        }
        f();
        if (i3 >= 30) {
            this.f5922f.addOnCodecFormatChangedListener(new a(), this.f5945q0);
        }
        int audioSessionId = this.f5922f.getAudioSessionId();
        if (f5879s0 && i3 < 21) {
            AudioTrack audioTrack = this.f5920e;
            if (audioTrack != null && audioSessionId != audioTrack.getAudioSessionId()) {
                Z();
            }
            if (this.f5920e == null) {
                this.f5920e = new AudioTrack(this.f5928i, 4000, 4, 2, 2, 0, audioSessionId);
            }
        }
        this.f5918d.i(this.f5922f, S());
        f0();
        if ("1".equals(D.y("mtk.exoplayer.dump.audio.output", "0"))) {
            this.f5923f0 = true;
        } else {
            this.f5923f0 = false;
        }
        if (this.f5932k == 10 && this.f5941o0 > 2) {
            Log.i(this.f5912a, "AAC mNeedProcessFirstBuffer");
            this.f5929i0 = true;
        }
        return audioSessionId;
    }

    public int F(int i2) {
        this.f5947r0 = true;
        Log.d(this.f5912a, "audiotrack initialize with hwSyncId=" + i2);
        q0(i2);
        f();
        int i3 = D.f2965a;
        if (i3 >= 30) {
            this.f5922f.addOnCodecFormatChangedListener(new b(), this.f5945q0);
        }
        int audioSessionId = this.f5922f.getAudioSessionId();
        if (f5879s0 && i3 < 21) {
            AudioTrack audioTrack = this.f5920e;
            if (audioTrack != null && audioSessionId != audioTrack.getAudioSessionId()) {
                Z();
            }
            if (this.f5920e == null) {
                this.f5920e = new AudioTrack(this.f5928i, 4000, 4, 2, 2, 0, audioSessionId);
            }
        }
        this.f5918d.i(this.f5922f, S());
        f0();
        if ("1".equals(D.y("mtk.exoplayer.dump.audio.output", "0"))) {
            this.f5923f0 = true;
        } else {
            this.f5923f0 = false;
        }
        Log.d(this.f5912a, "audiotrack initialize done, hwSyncId " + i2 + ", sessionId=" + audioSessionId);
        return audioSessionId;
    }

    public boolean J() {
        return this.f5922f != null;
    }

    public boolean K(String str) {
        String[] strArrSplit;
        String str2;
        if (this.f5922f == null || str == null || (str2 = (strArrSplit = str.split("="))[0]) == null || !str2.equals("AC4_MainPresGroupIdx")) {
            return false;
        }
        int i2 = Integer.parseInt(strArrSplit[1]);
        e0(i2);
        Log.d(this.f5912a, "set ac4 preselect main index:" + i2);
        return true;
    }

    public boolean L(String str) {
        C0648b c0648b = this.f5914b;
        return c0648b != null && c0648b.f(t(str, -1));
    }

    public boolean M() {
        boolean z2 = this.f5922f != null && this.f5922f.getPlayState() == 3;
        b0.o.c(this.f5912a, 2, "audiotrack isPlaying:", Boolean.valueOf(z2));
        return z2;
    }

    public boolean N() {
        return ("audio/mp4a-latm-hw".equals(this.f5919d0) || "audio/true-hd".equals(this.f5919d0) || this.f5925g0 == 42) ? false : true;
    }

    public boolean O() {
        return (this.f5922f == null || this.f5922f.getPlayState() != 3 || this.f5918d.b() == 0) ? false : true;
    }

    int Q(int i2) {
        if (i2 == 3) {
            return 1;
        }
        if (i2 != 2) {
            if (i2 == AbstractC0637c.f5494a) {
                return 3;
            }
            if (i2 == AbstractC0637c.f5495b) {
                return 4;
            }
        }
        return 2;
    }

    public void U() {
        if (J()) {
            d0();
            this.f5918d.g();
        }
    }

    public void W() {
        Log.d(this.f5912a, "Try play audioTrack");
        if (J()) {
            long jNanoTime = System.nanoTime() / 1000;
            this.f5888C = jNanoTime;
            b0.o.c(this.f5912a, 2, "audioTrack.play() @sysTime ", Long.valueOf(jNanoTime));
            this.f5918d.h();
        }
    }

    public void Y() {
        b0();
        Z();
    }

    public void b0() {
        if (J()) {
            Log.d(this.f5912a, "audiotrack reset");
            AudioTrack audioTrack = this.f5922f;
            this.f5922f = null;
            this.f5952w = 0L;
            this.f5954y = 0L;
            this.f5953x = 0L;
            this.f5937m0 = 0;
            int i2 = this.f5932k;
            if (i2 != 7 && i2 != 8) {
                this.f5955z = 0;
            }
            this.f5893H = 0;
            this.f5886A = 0;
            this.f5889D = 0L;
            this.f5943p0 = 0;
            d0();
            c0();
            if (audioTrack.getPlayState() == 3) {
                audioTrack.pause();
            }
            this.f5918d.i(null, false);
            Log.d(this.f5912a, "+++audiotrack flush");
            audioTrack.flush();
            Log.d(this.f5912a, "---audiotrack flush");
            Log.d(this.f5912a, "+++audiotrack release");
            if (D.f2965a >= 30) {
                audioTrack.removeOnCodecFormatChangedListener(this.f5945q0);
            }
            audioTrack.release();
            Log.d(this.f5912a, "---audiotrack release");
        }
    }

    public void e0(int i2) {
        if (this.f5922f == null) {
            return;
        }
        this.f5922f.setPresentation(o.i.a(i2).build());
    }

    /* JADX WARN: Removed duplicated region for block: B:113:0x01e1  */
    /* JADX WARN: Removed duplicated region for block: B:114:0x01e4  */
    /* JADX WARN: Removed duplicated region for block: B:60:0x00f0  */
    /* JADX WARN: Removed duplicated region for block: B:61:0x00f3  */
    /* JADX WARN: Removed duplicated region for block: B:67:0x0106  */
    /* JADX WARN: Removed duplicated region for block: B:68:0x010a  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void h(java.lang.String r33, int r34, int r35, int r36, int r37) {
        /*
            Method dump skipped, instruction units count: 498
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.j.h(java.lang.String, int, int, int, int):void");
    }

    public void i(String str, MediaFormat mediaFormat, int i2, int i3) {
        int i4;
        if ("audio/mp4a-latm".equals(str)) {
            if (mediaFormat.containsKey("aac-profile")) {
                this.f5925g0 = mediaFormat.getInteger("aac-profile");
            }
            if (mediaFormat.containsKey("csd-0")) {
                this.f5927h0 = mediaFormat.getByteBuffer("csd-0");
                Log.i(this.f5912a, "got AAC ASC buffer");
            }
        }
        int integer = mediaFormat.getInteger("channel-count");
        int integer2 = mediaFormat.getInteger("sample-rate");
        this.f5900O = i3;
        if ("audio/mha1".equals(str) || "audio/mhm1".equals(str)) {
            integer = 2;
        }
        int i5 = integer;
        if ("audio/raw".equals(str) || !mediaFormat.containsKey("bitrate")) {
            i4 = 0;
        } else {
            int integer3 = mediaFormat.getInteger("bitrate");
            int i6 = (int) (((((long) integer3) * 250000) / 8) / 1000000);
            if (("audio/mp4a-latm-hw".equals(str) || "audio/mp4a-latm".equals(str)) && i6 < 3072) {
                Log.i(this.f5912a, "Set the bufferSize[3072] for AAC to prevent underrun.");
                i6 = 3072;
            }
            Log.i(this.f5912a, "Configure mimeType: " + str + ", bitrate: " + integer3);
            i4 = i6;
        }
        Log.i(this.f5912a, "configure mimeType:" + str + ", channelCount:" + i5 + ", sampleRate:" + integer2 + ", pcmEncoding:" + i2 + ", specifiedBufferSize:" + i4 + ", tunnelingAudioSessionId:" + i3);
        h(str, i5, integer2, i2, i4);
    }

    public void i0(c cVar) {
        this.f5899N = cVar;
    }

    public void j0(int i2) {
        this.f5943p0 = i2;
    }

    public void k0(PlaybackParams playbackParams) {
        this.f5918d.k(playbackParams);
    }

    public boolean m0(int i2) {
        if (this.f5928i == i2) {
            return false;
        }
        this.f5928i = i2;
        b0();
        return true;
    }

    public void n0(int i2) {
        this.f5900O = i2;
    }

    public void o0(float f2) {
        if (this.f5890E != f2) {
            this.f5890E = f2;
            f0();
        }
    }

    public int r() {
        return this.f5938n;
    }

    /* JADX WARN: Removed duplicated region for block: B:33:0x0088  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public long s(boolean r26) {
        /*
            Method dump skipped, instruction units count: 221
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.j.s(boolean):long");
    }

    public long v() {
        return this.f5934l ? this.f5953x : this.f5952w;
    }

    /* JADX WARN: Removed duplicated region for block: B:123:0x02a5  */
    /* JADX WARN: Removed duplicated region for block: B:137:0x02c9  */
    /* JADX WARN: Removed duplicated region for block: B:149:0x02fd  */
    /* JADX WARN: Removed duplicated region for block: B:159:0x031b  */
    /* JADX WARN: Removed duplicated region for block: B:162:0x0326  */
    /* JADX WARN: Removed duplicated region for block: B:175:0x036d  */
    /* JADX WARN: Type inference failed for: r12v1 */
    /* JADX WARN: Type inference failed for: r12v13 */
    /* JADX WARN: Type inference failed for: r12v2, types: [boolean] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public int x(java.nio.ByteBuffer r34, int r35, int r36, long r37) throws o.j.C0084j {
        /*
            Method dump skipped, instruction units count: 1394
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.j.x(java.nio.ByteBuffer, int, int, long):int");
    }

    public void y() {
        if (this.f5886A == 1) {
            this.f5886A = 2;
        }
    }

    public void z() {
        if (J()) {
            Log.i(this.f5912a, "audio track handle end of stream.");
            this.f5918d.f(w());
        }
    }
}
