LINE.apk(点击下载) / s2.java


package y8;

import a9.d;
import ai.clova.cic.clientlib.builtins.audio.echocanceller.AcousticEchoCanceller;
import ai.clova.cic.clientlib.exoplayer2.C;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.media.AudioManager;
import android.media.AudioTrack;
import android.media.MediaFormat;
import android.os.Handler;
import android.os.Looper;
import android.util.SparseBooleanArray;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.TextureView;
import androidx.biometric.b0;
import c9.e;
import c9.i;
import com.google.android.exoplayer2.metadata.Metadata;
import da.m;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.TimeoutException;
import o32.a;
import ra.k;
import ra.k0;
import ra.p;
import ra.q;
import sa.j;
import sa.r;
import sa.s;
import ta.l;
import u3.y;
import y8.b;
import y8.d;
import y8.g2;
import y8.j2;
import y8.r;
import y8.s1;
import y8.v2;
import y9.x;
import z8.a1;
import z8.n0;
import z8.z0;

@Deprecated
public class s2 extends e implements r {
    public e A;
    public int B;
    public d C;
    public float D;
    public boolean E;
    public List<da.a> F;
    public boolean G;
    public boolean H;
    public boolean I;
    public o J;
    public s K;

    /* renamed from: b  reason: collision with root package name */
    public final n2[] f186940b;

    /* renamed from: c  reason: collision with root package name */
    public final ra.e f186941c = new ra.e();

    /* renamed from: d  reason: collision with root package name */
    public final a1 f186942d;

    /* renamed from: e  reason: collision with root package name */
    public final b f186943e;

    /* renamed from: f  reason: collision with root package name */
    public final c f186944f;

    /* renamed from: g  reason: collision with root package name */
    public final CopyOnWriteArraySet<g2.e> f186945g;

    /* renamed from: h  reason: collision with root package name */
    public final z0 f186946h;

    /* renamed from: i  reason: collision with root package name */
    public final b f186947i;

    /* renamed from: j  reason: collision with root package name */
    public final d f186948j;

    /* renamed from: k  reason: collision with root package name */
    public final v2 f186949k;

    /* renamed from: l  reason: collision with root package name */
    public final d3 f186950l;

    /* renamed from: m  reason: collision with root package name */
    public final e3 f186951m;

    /* renamed from: n  reason: collision with root package name */
    public final long f186952n;

    /* renamed from: o  reason: collision with root package name */
    public j1 f186953o;

    /* renamed from: p  reason: collision with root package name */
    public j1 f186954p;

    /* renamed from: q  reason: collision with root package name */
    public AudioTrack f186955q;

    /* renamed from: r  reason: collision with root package name */
    public Object f186956r;

    /* renamed from: s  reason: collision with root package name */
    public Surface f186957s;

    /* renamed from: t  reason: collision with root package name */
    public SurfaceHolder f186958t;

    /* renamed from: u  reason: collision with root package name */
    public l f186959u;

    /* renamed from: v  reason: collision with root package name */
    public boolean f186960v;

    /* renamed from: w  reason: collision with root package name */
    public TextureView f186961w;

    /* renamed from: x  reason: collision with root package name */
    public int f186962x;

    /* renamed from: y  reason: collision with root package name */
    public int f186963y;

    /* renamed from: z  reason: collision with root package name */
    public int f186964z;

    public final class b implements r, a9.r, m, r9.d, SurfaceHolder.Callback, TextureView.SurfaceTextureListener, l.b, d.b, b.AbstractC3430b, v2.b, g2.c, r.a {
        public b(a aVar) {
        }

        @Override // sa.r
        public void a(String str) {
            s2.this.f186946h.a(str);
        }

        @Override // a9.r
        public void b(String str) {
            s2.this.f186946h.b(str);
        }

        @Override // sa.r
        public void c(j1 j1Var, i iVar) {
            s2 s2Var = s2.this;
            s2Var.f186953o = j1Var;
            s2Var.f186946h.c(j1Var, iVar);
        }

        @Override // y8.r.a
        public void d(boolean z14) {
            s2.B(s2.this);
        }

        @Override // sa.r
        public void e(e eVar) {
            s2.this.f186946h.e(eVar);
            s2 s2Var = s2.this;
            s2Var.f186953o = null;
            s2Var.A = null;
        }

        @Override // ta.l.b
        public void f(Surface surface) {
            s2.this.M(null);
        }

        @Override // ta.l.b
        public void g(Surface surface) {
            s2.this.M(surface);
        }

        @Override // a9.r
        public void h(Exception exc) {
            s2.this.f186946h.h(exc);
        }

        @Override // sa.r
        public void i(long j14, int i14) {
            s2.this.f186946h.i(j14, i14);
        }

        @Override // a9.r
        public void l(e eVar) {
            Objects.requireNonNull(s2.this);
            s2.this.f186946h.l(eVar);
        }

        @Override // a9.r
        public void m(Exception exc) {
            s2.this.f186946h.m(exc);
        }

        @Override // a9.r
        public void n(long j14) {
            s2.this.f186946h.n(j14);
        }

        @Override // sa.r
        public void o(Exception exc) {
            s2.this.f186946h.o(exc);
        }

        @Override // a9.r
        public void onAudioDecoderInitialized(String str, long j14, long j15) {
            s2.this.f186946h.onAudioDecoderInitialized(str, j14, j15);
        }

        @Override // da.m
        public void onCues(List<da.a> list) {
            s2 s2Var = s2.this;
            s2Var.F = list;
            Iterator<g2.e> it3 = s2Var.f186945g.iterator();
            while (it3.hasNext()) {
                it3.next().onCues(list);
            }
        }

        @Override // sa.r
        public void onDroppedFrames(int i14, long j14) {
            s2.this.f186946h.onDroppedFrames(i14, j14);
        }

        @Override // y8.g2.c
        public void onIsLoadingChanged(boolean z14) {
            Objects.requireNonNull(s2.this);
        }

        @Override // r9.d
        public void onMetadata(Metadata metadata) {
            s2.this.f186946h.onMetadata(metadata);
            a1 a1Var = s2.this.f186942d;
            s1.b b14 = a1Var.D.b();
            int i14 = 0;
            while (true) {
                Metadata.Entry[] entryArr = metadata.f27877b;
                if (i14 >= entryArr.length) {
                    break;
                }
                entryArr[i14].o0(b14);
                i14++;
            }
            a1Var.D = b14.a();
            s1 C = a1Var.C();
            if (!C.equals(a1Var.C)) {
                a1Var.C = C;
                p<g2.c> pVar = a1Var.f186372i;
                pVar.b(14, new g0(a1Var, 0));
                pVar.a();
            }
            Iterator<g2.e> it3 = s2.this.f186945g.iterator();
            while (it3.hasNext()) {
                it3.next().onMetadata(metadata);
            }
        }

        @Override // y8.g2.c
        public void onPlayWhenReadyChanged(boolean z14, int i14) {
            s2.B(s2.this);
        }

        @Override // y8.g2.c
        public void onPlaybackStateChanged(int i14) {
            s2.B(s2.this);
        }

        @Override // a9.r
        public void onSkipSilenceEnabledChanged(boolean z14) {
            s2 s2Var = s2.this;
            if (s2Var.E != z14) {
                s2Var.E = z14;
                s2Var.f186946h.onSkipSilenceEnabledChanged(z14);
                Iterator<g2.e> it3 = s2Var.f186945g.iterator();
                while (it3.hasNext()) {
                    it3.next().onSkipSilenceEnabledChanged(s2Var.E);
                }
            }
        }

        public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i14, int i15) {
            s2 s2Var = s2.this;
            Objects.requireNonNull(s2Var);
            Surface surface = new Surface(surfaceTexture);
            s2Var.M(surface);
            s2Var.f186957s = surface;
            s2.this.G(i14, i15);
        }

        public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
            s2.this.M(null);
            s2.this.G(0, 0);
            return true;
        }

        public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int i14, int i15) {
            s2.this.G(i14, i15);
        }

        public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
        }

        @Override // sa.r
        public void onVideoDecoderInitialized(String str, long j14, long j15) {
            s2.this.f186946h.onVideoDecoderInitialized(str, j14, j15);
        }

        @Override // sa.r
        public void onVideoSizeChanged(s sVar) {
            s2 s2Var = s2.this;
            s2Var.K = sVar;
            s2Var.f186946h.onVideoSizeChanged(sVar);
            Iterator<g2.e> it3 = s2.this.f186945g.iterator();
            while (it3.hasNext()) {
                it3.next().onVideoSizeChanged(sVar);
            }
        }

        @Override // sa.r
        public void q(e eVar) {
            s2 s2Var = s2.this;
            s2Var.A = eVar;
            s2Var.f186946h.q(eVar);
        }

        @Override // a9.r
        public void r(e eVar) {
            s2.this.f186946h.r(eVar);
            s2.this.f186954p = null;
        }

        @Override // sa.r
        public void s(Object obj, long j14) {
            s2.this.f186946h.s(obj, j14);
            s2 s2Var = s2.this;
            if (s2Var.f186956r == obj) {
                Iterator<g2.e> it3 = s2Var.f186945g.iterator();
                while (it3.hasNext()) {
                    it3.next().onRenderedFirstFrame();
                }
            }
        }

        public void surfaceChanged(SurfaceHolder surfaceHolder, int i14, int i15, int i16) {
            s2.this.G(i15, i16);
        }

        public void surfaceCreated(SurfaceHolder surfaceHolder) {
            s2 s2Var = s2.this;
            if (s2Var.f186960v) {
                s2Var.M(surfaceHolder.getSurface());
            }
        }

        public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
            s2 s2Var = s2.this;
            if (s2Var.f186960v) {
                s2Var.M(null);
            }
            s2.this.G(0, 0);
        }

        @Override // a9.r
        public void t(j1 j1Var, i iVar) {
            s2 s2Var = s2.this;
            s2Var.f186954p = j1Var;
            s2Var.f186946h.t(j1Var, iVar);
        }

        @Override // a9.r
        public void u(int i14, long j14, long j15) {
            s2.this.f186946h.u(i14, j14, j15);
        }
    }

    public static final class c implements j, ta.a, j2.b {

        /* renamed from: b  reason: collision with root package name */
        public j f186966b;

        /* renamed from: c  reason: collision with root package name */
        public ta.a f186967c;

        /* renamed from: d  reason: collision with root package name */
        public j f186968d;

        /* renamed from: e  reason: collision with root package name */
        public ta.a f186969e;

        public c(a aVar) {
        }

        @Override // sa.j
        public void a(long j14, long j15, j1 j1Var, MediaFormat mediaFormat) {
            j jVar = this.f186968d;
            if (jVar != null) {
                jVar.a(j14, j15, j1Var, mediaFormat);
            }
            j jVar2 = this.f186966b;
            if (jVar2 != null) {
                jVar2.a(j14, j15, j1Var, mediaFormat);
            }
        }

        @Override // y8.j2.b
        public void handleMessage(int i14, Object obj) {
            if (i14 == 7) {
                this.f186966b = (j) obj;
            } else if (i14 == 8) {
                this.f186967c = (ta.a) obj;
            } else if (i14 == 10000) {
                l lVar = (l) obj;
                if (lVar == null) {
                    this.f186968d = null;
                    this.f186969e = null;
                    return;
                }
                this.f186968d = lVar.getVideoFrameMetadataListener();
                this.f186969e = lVar.getCameraMotionListener();
            }
        }

        @Override // ta.a
        public void onCameraMotion(long j14, float[] fArr) {
            ta.a aVar = this.f186969e;
            if (aVar != null) {
                aVar.onCameraMotion(j14, fArr);
            }
            ta.a aVar2 = this.f186967c;
            if (aVar2 != null) {
                aVar2.onCameraMotion(j14, fArr);
            }
        }

        @Override // ta.a
        public void onCameraMotionReset() {
            ta.a aVar = this.f186969e;
            if (aVar != null) {
                aVar.onCameraMotionReset();
            }
            ta.a aVar2 = this.f186967c;
            if (aVar2 != null) {
                aVar2.onCameraMotionReset();
            }
        }
    }

    public s2(r.b bVar) {
        s2 s2Var;
        Throwable th4;
        a1 a1Var;
        int i14;
        try {
            Context applicationContext = bVar.f186854a.getApplicationContext();
            this.f186946h = bVar.f186861h.get();
            this.C = bVar.f186863j;
            this.f186962x = bVar.f186864k;
            this.E = false;
            this.f186952n = bVar.f186871r;
            b bVar2 = new b(null);
            this.f186943e = bVar2;
            this.f186944f = new c(null);
            this.f186945g = new CopyOnWriteArraySet<>();
            Handler handler = new Handler(bVar.f186862i);
            this.f186940b = bVar.f186856c.get().a(handler, bVar2, bVar2, bVar2, bVar2);
            this.D = 1.0f;
            if (k0.f136472a < 21) {
                AudioTrack audioTrack = this.f186955q;
                if (!(audioTrack == null || audioTrack.getAudioSessionId() == 0)) {
                    this.f186955q.release();
                    this.f186955q = null;
                }
                if (this.f186955q == null) {
                    this.f186955q = new AudioTrack(3, AcousticEchoCanceller.SAMPLE_RATE_HZ_MIN, 4, 2, 2, 0, 0);
                }
                this.B = this.f186955q.getAudioSessionId();
            } else {
                AudioManager audioManager = (AudioManager) applicationContext.getSystemService("audio");
                if (audioManager == null) {
                    i14 = -1;
                } else {
                    i14 = audioManager.generateAudioSessionId();
                }
                this.B = i14;
            }
            this.F = Collections.emptyList();
            this.G = true;
            SparseBooleanArray sparseBooleanArray = new SparseBooleanArray();
            int[] iArr = {21, 22, 23, 24, 25, 26, 27, 28};
            for (int i15 = 0; i15 < 8; i15++) {
                int i16 = iArr[i15];
                b0.e(!false);
                sparseBooleanArray.append(i16, true);
            }
            b0.e(!false);
            try {
                a1Var = new a1(this.f186940b, bVar.f186858e.get(), bVar.f186857d.get(), bVar.f186859f.get(), bVar.f186860g.get(), this.f186946h, bVar.f186865l, bVar.f186866m, bVar.f186867n, bVar.f186868o, bVar.f186869p, bVar.f186870q, false, bVar.f186855b, bVar.f186862i, this, new g2.b(new k(sparseBooleanArray, null), null));
                s2Var = this;
            } catch (Throwable th5) {
                th4 = th5;
                s2Var = this;
                s2Var.f186941c.b();
                throw th4;
            }
            try {
                s2Var.f186942d = a1Var;
                a1Var.B(s2Var.f186943e);
                a1Var.f186373j.add(s2Var.f186943e);
                b bVar3 = new b(bVar.f186854a, handler, s2Var.f186943e);
                s2Var.f186947i = bVar3;
                bVar3.a(false);
                d dVar = new d(bVar.f186854a, handler, s2Var.f186943e);
                s2Var.f186948j = dVar;
                if (!k0.a(dVar.f186442d, null)) {
                    dVar.f186442d = null;
                    dVar.f186444f = 0;
                }
                v2 v2Var = new v2(bVar.f186854a, handler, s2Var.f186943e);
                s2Var.f186949k = v2Var;
                v2Var.c(k0.z(s2Var.C.f2901d));
                d3 d3Var = new d3(bVar.f186854a);
                s2Var.f186950l = d3Var;
                d3Var.f186455c = false;
                d3Var.a();
                e3 e3Var = new e3(bVar.f186854a);
                s2Var.f186951m = e3Var;
                e3Var.f186483c = false;
                e3Var.a();
                s2Var.J = E(v2Var);
                s2Var.K = s.f142260f;
                s2Var.J(1, 10, Integer.valueOf(s2Var.B));
                s2Var.J(2, 10, Integer.valueOf(s2Var.B));
                s2Var.J(1, 3, s2Var.C);
                s2Var.J(2, 4, Integer.valueOf(s2Var.f186962x));
                s2Var.J(2, 5, 0);
                s2Var.J(1, 9, Boolean.valueOf(s2Var.E));
                s2Var.J(2, 7, s2Var.f186944f);
                s2Var.J(6, 8, s2Var.f186944f);
                s2Var.f186941c.b();
            } catch (Throwable th6) {
                th4 = th6;
                s2Var.f186941c.b();
                throw th4;
            }
        } catch (Throwable th7) {
            th4 = th7;
            s2Var = this;
            s2Var.f186941c.b();
            throw th4;
        }
    }

    public static void B(s2 s2Var) {
        int playbackState = s2Var.getPlaybackState();
        boolean z14 = true;
        if (playbackState != 1) {
            if (playbackState == 2 || playbackState == 3) {
                s2Var.R();
                boolean z15 = s2Var.f186942d.E.f186477p;
                d3 d3Var = s2Var.f186950l;
                if (!s2Var.getPlayWhenReady() || z15) {
                    z14 = false;
                }
                d3Var.f186456d = z14;
                d3Var.a();
                e3 e3Var = s2Var.f186951m;
                e3Var.f186484d = s2Var.getPlayWhenReady();
                e3Var.a();
                return;
            } else if (playbackState != 4) {
                throw new IllegalStateException();
            }
        }
        d3 d3Var2 = s2Var.f186950l;
        d3Var2.f186456d = false;
        d3Var2.a();
        e3 e3Var2 = s2Var.f186951m;
        e3Var2.f186484d = false;
        e3Var2.a();
    }

    public static o E(v2 v2Var) {
        Objects.requireNonNull(v2Var);
        return new o(0, k0.f136472a >= 28 ? v2Var.f187017d.getStreamMinVolume(v2Var.f187019f) : 0, v2Var.f187017d.getStreamMaxVolume(v2Var.f187019f));
    }

    public static int F(boolean z14, int i14) {
        return (!z14 || i14 == 1) ? 1 : 2;
    }

    public void C(a1 a1Var) {
        z0 z0Var = this.f186946h;
        Objects.requireNonNull(z0Var);
        p<a1> pVar = z0Var.f198256g;
        if (!pVar.f136497g) {
            pVar.f136494d.add(new p.c<>(a1Var));
        }
    }

    public void D() {
        R();
        I();
        M(null);
        G(0, 0);
    }

    public final void G(int i14, int i15) {
        if (i14 != this.f186963y || i15 != this.f186964z) {
            this.f186963y = i14;
            this.f186964z = i15;
            this.f186946h.onSurfaceSizeChanged(i14, i15);
            Iterator<g2.e> it3 = this.f186945g.iterator();
            while (it3.hasNext()) {
                it3.next().onSurfaceSizeChanged(i14, i15);
            }
        }
    }

    public void H() {
        AudioTrack audioTrack;
        R();
        if (k0.f136472a < 21 && (audioTrack = this.f186955q) != null) {
            audioTrack.release();
            this.f186955q = null;
        }
        this.f186947i.a(false);
        v2 v2Var = this.f186949k;
        v2.c cVar = v2Var.f187018e;
        if (cVar != null) {
            try {
                v2Var.f187014a.unregisterReceiver(cVar);
            } catch (RuntimeException e14) {
                q.a("Error unregistering stream volume receiver", e14);
            }
            v2Var.f187018e = null;
        }
        d3 d3Var = this.f186950l;
        d3Var.f186456d = false;
        d3Var.a();
        e3 e3Var = this.f186951m;
        e3Var.f186484d = false;
        e3Var.a();
        d dVar = this.f186948j;
        dVar.f186441c = null;
        dVar.a();
        this.f186942d.M();
        z0 z0Var = this.f186946h;
        ra.m mVar = z0Var.f198258i;
        b0.g(mVar);
        mVar.post(new y(z0Var, 1));
        I();
        Surface surface = this.f186957s;
        if (surface != null) {
            surface.release();
            this.f186957s = null;
        }
        if (!this.I) {
            this.F = Collections.emptyList();
        } else {
            Objects.requireNonNull(null);
            throw null;
        }
    }

    public final void I() {
        if (this.f186959u != null) {
            j2 D2 = this.f186942d.D(this.f186944f);
            D2.f(10000);
            D2.e(null);
            D2.d();
            l lVar = this.f186959u;
            lVar.f148637b.remove(this.f186943e);
            this.f186959u = null;
        }
        TextureView textureView = this.f186961w;
        if (textureView != null) {
            if (textureView.getSurfaceTextureListener() == this.f186943e) {
                this.f186961w.setSurfaceTextureListener(null);
            }
            this.f186961w = null;
        }
        SurfaceHolder surfaceHolder = this.f186958t;
        if (surfaceHolder != null) {
            surfaceHolder.removeCallback(this.f186943e);
            this.f186958t = null;
        }
    }

    public final void J(int i14, int i15, Object obj) {
        n2[] n2VarArr = this.f186940b;
        for (n2 n2Var : n2VarArr) {
            if (n2Var.getTrackType() == i14) {
                j2 D2 = this.f186942d.D(n2Var);
                b0.e(!D2.f186679k);
                D2.f186673e = i15;
                b0.e(!D2.f186679k);
                D2.f186674f = obj;
                D2.d();
            }
        }
    }

    public void K(x xVar) {
        R();
        a1 a1Var = this.f186942d;
        Objects.requireNonNull(a1Var);
        a1Var.P(Collections.singletonList(xVar), -1, C.TIME_UNSET, true);
    }

    public final void L(SurfaceHolder surfaceHolder) {
        this.f186960v = false;
        this.f186958t = surfaceHolder;
        surfaceHolder.addCallback(this.f186943e);
        Surface surface = this.f186958t.getSurface();
        if (surface == null || !surface.isValid()) {
            G(0, 0);
            return;
        }
        Rect surfaceFrame = this.f186958t.getSurfaceFrame();
        G(surfaceFrame.width(), surfaceFrame.height());
    }

    public final void M(Object obj) {
        boolean z14;
        ArrayList arrayList = new ArrayList();
        n2[] n2VarArr = this.f186940b;
        int length = n2VarArr.length;
        int i14 = 0;
        while (true) {
            z14 = true;
            if (i14 >= length) {
                break;
            }
            n2 n2Var = n2VarArr[i14];
            if (n2Var.getTrackType() == 2) {
                j2 D2 = this.f186942d.D(n2Var);
                D2.f(1);
                b0.e(true ^ D2.f186679k);
                D2.f186674f = obj;
                D2.d();
                arrayList.add(D2);
            }
            i14++;
        }
        Object obj2 = this.f186956r;
        if (obj2 == null || obj2 == obj) {
            z14 = false;
        } else {
            try {
                Iterator it3 = arrayList.iterator();
                while (it3.hasNext()) {
                    ((j2) it3.next()).a(this.f186952n);
                }
            } catch (InterruptedException unused) {
                Thread.currentThread().interrupt();
            } catch (TimeoutException unused2) {
            }
            z14 = false;
            Object obj3 = this.f186956r;
            Surface surface = this.f186957s;
            if (obj3 == surface) {
                surface.release();
                this.f186957s = null;
            }
        }
        this.f186956r = obj;
        if (z14) {
            this.f186942d.R(false, q.d(new h1(3), a.d.TYPE));
        }
    }

    public void N(Surface surface) {
        R();
        I();
        M(surface);
        int i14 = surface == null ? 0 : -1;
        G(i14, i14);
    }

    public void O(float f14) {
        R();
        float h14 = k0.h(f14, 0.0f, 1.0f);
        if (this.D != h14) {
            this.D = h14;
            J(1, 2, Float.valueOf(this.f186948j.f186445g * h14));
            this.f186946h.onVolumeChanged(h14);
            Iterator<g2.e> it3 = this.f186945g.iterator();
            while (it3.hasNext()) {
                it3.next().onVolumeChanged(h14);
            }
        }
    }

    public void P() {
        R();
        this.f186948j.d(getPlayWhenReady(), 1);
        this.f186942d.R(false, null);
        this.F = Collections.emptyList();
    }

    public final void Q(boolean z14, int i14, int i15) {
        int i16 = 0;
        boolean z15 = z14 && i14 != -1;
        if (z15 && i14 != 1) {
            i16 = 1;
        }
        this.f186942d.Q(z15, i16, i15);
    }

    public final void R() {
        ra.e eVar = this.f186941c;
        synchronized (eVar) {
            boolean z14 = false;
            while (!eVar.f136447b) {
                try {
                    eVar.wait();
                } catch (InterruptedException unused) {
                    z14 = true;
                }
            }
            if (z14) {
                Thread.currentThread().interrupt();
            }
        }
        if (Thread.currentThread() != this.f186942d.f186379p.getThread()) {
            String m14 = k0.m("Player is accessed on the wrong thread.\nCurrent thread: '%s'\nExpected thread: '%s'\nSee https://exoplayer.dev/issues/player-accessed-on-wrong-thread", Thread.currentThread().getName(), this.f186942d.f186379p.getThread().getName());
            if (!this.G) {
                q.a(m14, this.H ? null : new IllegalStateException());
                this.H = true;
                return;
            }
            throw new IllegalStateException(m14);
        }
    }

    @Override // y8.g2
    public d2 a() {
        R();
        return this.f186942d.E.f186467f;
    }

    @Override // y8.g2
    public long c() {
        R();
        Objects.requireNonNull(this.f186942d);
        return 3000;
    }

    @Override // y8.g2
    public void clearVideoSurfaceView(SurfaceView surfaceView) {
        SurfaceHolder surfaceHolder;
        R();
        if (surfaceView == null) {
            surfaceHolder = null;
        } else {
            surfaceHolder = surfaceView.getHolder();
        }
        R();
        if (surfaceHolder != null && surfaceHolder == this.f186958t) {
            D();
        }
    }

    @Override // y8.g2
    public void clearVideoTextureView(TextureView textureView) {
        R();
        if (textureView != null && textureView == this.f186961w) {
            D();
        }
    }

    @Override // y8.g2
    public long d() {
        R();
        return this.f186942d.f186382s;
    }

    @Override // y8.g2
    public void e(g2.e eVar) {
        Objects.requireNonNull(eVar);
        this.f186945g.remove(eVar);
        this.f186942d.N(eVar);
    }

    @Override // y8.g2
    public void g(g2.e eVar) {
        Objects.requireNonNull(eVar);
        this.f186945g.add(eVar);
        this.f186942d.B(eVar);
    }

    @Override // y8.g2
    public Looper getApplicationLooper() {
        return this.f186942d.f186379p;
    }

    @Override // y8.g2
    public long getContentBufferedPosition() {
        R();
        return this.f186942d.getContentBufferedPosition();
    }

    @Override // y8.g2
    public long getContentPosition() {
        R();
        return this.f186942d.getContentPosition();
    }

    @Override // y8.g2
    public int getCurrentAdGroupIndex() {
        R();
        return this.f186942d.getCurrentAdGroupIndex();
    }

    @Override // y8.g2
    public int getCurrentAdIndexInAdGroup() {
        R();
        return this.f186942d.getCurrentAdIndexInAdGroup();
    }

    @Override // y8.g2
    public int getCurrentPeriodIndex() {
        R();
        return this.f186942d.getCurrentPeriodIndex();
    }

    @Override // y8.g2
    public long getCurrentPosition() {
        R();
        return this.f186942d.getCurrentPosition();
    }

    @Override // y8.g2
    public z2 getCurrentTimeline() {
        R();
        return this.f186942d.E.f186462a;
    }

    @Override // y8.g2
    public long getDuration() {
        R();
        return this.f186942d.getDuration();
    }

    @Override // y8.g2
    public boolean getPlayWhenReady() {
        R();
        return this.f186942d.E.f186473l;
    }

    @Override // y8.g2
    public f2 getPlaybackParameters() {
        R();
        return this.f186942d.E.f186475n;
    }

    @Override // y8.g2
    public int getPlaybackState() {
        R();
        return this.f186942d.E.f186466e;
    }

    @Override // y8.g2
    public int getPlaybackSuppressionReason() {
        R();
        return this.f186942d.E.f186474m;
    }

    @Override // y8.g2
    public int getRepeatMode() {
        R();
        return this.f186942d.f186384u;
    }

    @Override // y8.g2
    public boolean getShuffleModeEnabled() {
        R();
        return this.f186942d.f186385v;
    }

    @Override // y8.g2
    public long getTotalBufferedDuration() {
        R();
        return this.f186942d.getTotalBufferedDuration();
    }

    @Override // y8.g2
    public List<da.a> i() {
        R();
        return this.F;
    }

    @Override // y8.g2
    public boolean isPlayingAd() {
        R();
        return this.f186942d.isPlayingAd();
    }

    @Override // y8.g2
    public c3 j() {
        R();
        return this.f186942d.j();
    }

    @Override // y8.g2
    public g2.b l() {
        R();
        return this.f186942d.B;
    }

    @Override // y8.g2
    public s m() {
        return this.K;
    }

    @Override // y8.g2
    public int n() {
        R();
        return this.f186942d.n();
    }

    @Override // y8.g2
    public s1 p() {
        return this.f186942d.C;
    }

    @Override // y8.g2
    public void prepare() {
        R();
        boolean playWhenReady = getPlayWhenReady();
        int d14 = this.f186948j.d(playWhenReady, 2);
        Q(playWhenReady, d14, F(playWhenReady, d14));
        this.f186942d.prepare();
    }

    @Override // y8.g2
    public long q() {
        R();
        return this.f186942d.f186381r;
    }

    @Override // y8.g2
    public void seekTo(int i14, long j14) {
        R();
        z0 z0Var = this.f186946h;
        if (!z0Var.f198259j) {
            a1.a x14 = z0Var.x();
            z0Var.f198259j = true;
            n0 n0Var = new n0(x14, 0);
            z0Var.f198255f.put(-1, x14);
            p<a1> pVar = z0Var.f198256g;
            pVar.b(-1, n0Var);
            pVar.a();
        }
        this.f186942d.seekTo(i14, j14);
    }

    @Override // y8.g2
    public void setPlayWhenReady(boolean z14) {
        R();
        int d14 = this.f186948j.d(z14, getPlaybackState());
        Q(z14, d14, F(z14, d14));
    }

    @Override // y8.g2
    public void setRepeatMode(int i14) {
        R();
        this.f186942d.setRepeatMode(i14);
    }

    @Override // y8.g2
    public void setShuffleModeEnabled(boolean z14) {
        R();
        this.f186942d.setShuffleModeEnabled(z14);
    }

    @Override // y8.g2
    public void setVideoSurfaceView(SurfaceView surfaceView) {
        SurfaceHolder surfaceHolder;
        R();
        if (surfaceView instanceof sa.i) {
            I();
            M(surfaceView);
            L(surfaceView.getHolder());
        } else if (surfaceView instanceof l) {
            I();
            this.f186959u = (l) surfaceView;
            j2 D2 = this.f186942d.D(this.f186944f);
            D2.f(10000);
            D2.e(this.f186959u);
            D2.d();
            this.f186959u.f148637b.add(this.f186943e);
            M(this.f186959u.getVideoSurface());
            L(surfaceView.getHolder());
        } else {
            if (surfaceView == null) {
                surfaceHolder = null;
            } else {
                surfaceHolder = surfaceView.getHolder();
            }
            R();
            if (surfaceHolder == null) {
                D();
                return;
            }
            I();
            this.f186960v = true;
            this.f186958t = surfaceHolder;
            surfaceHolder.addCallback(this.f186943e);
            Surface surface = surfaceHolder.getSurface();
            if (surface == null || !surface.isValid()) {
                M(null);
                G(0, 0);
                return;
            }
            M(surface);
            Rect surfaceFrame = surfaceHolder.getSurfaceFrame();
            G(surfaceFrame.width(), surfaceFrame.height());
        }
    }

    @Override // y8.g2
    public void setVideoTextureView(TextureView textureView) {
        R();
        if (textureView == null) {
            D();
            return;
        }
        I();
        this.f186961w = textureView;
        textureView.getSurfaceTextureListener();
        textureView.setSurfaceTextureListener(this.f186943e);
        SurfaceTexture surfaceTexture = textureView.isAvailable() ? textureView.getSurfaceTexture() : null;
        if (surfaceTexture == null) {
            M(null);
            G(0, 0);
            return;
        }
        Surface surface = new Surface(surfaceTexture);
        M(surface);
        this.f186957s = surface;
        G(textureView.getWidth(), textureView.getHeight());
    }
}