package com.strmr.ps.ui.player;

import android.os.Build;
import android.view.Display;
import android.widget.FrameLayout;
import androidx.media3.exoplayer.upstream.CmcdData;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.cr4;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.h32;
import defpackage.kq;
import defpackage.s38;
import java.util.concurrent.ExecutorService;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "com.strmr.ps.ui.player.VideoPlayerActivity$startDisplayModePoll$1", f = "VideoPlayerActivity.kt", i = {0, 0, 0, 0}, l = {3095}, m = "invokeSuspend", n = {"stablePolls", "pollIntervalMs", "maxPolls", CmcdData.OBJECT_TYPE_INIT_SEGMENT}, s = {"I$0", "J$0", "I$1", "I$2"})
final class an extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public int a;
    public int b;
    public int c;
    public long d;
    public int e;
    public final /* synthetic */ VideoPlayerActivity f;
    public final /* synthetic */ float i;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public an(VideoPlayerActivity videoPlayerActivity, float f, Continuation continuation) {
        super(2, continuation);
        this.f = videoPlayerActivity;
        this.i = f;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Object obj, Continuation continuation) {
        return new an(this.f, this.i, continuation);
    }

    @Override // defpackage.gr3
    public final Object invoke(Object obj, Object obj2) {
        return ((an) create((ak1) obj, (Continuation) obj2)).invokeSuspend(e6a.a);
    }

    /* JADX WARN: Removed duplicated region for block: B:10:0x0037  */
    /* JADX WARN: Removed duplicated region for block: B:15:0x0050  */
    /* JADX WARN: Removed duplicated region for block: B:16:0x0055  */
    /* JADX WARN: Removed duplicated region for block: B:18:0x005f  */
    /* JADX WARN: Removed duplicated region for block: B:19:0x0064  */
    /* JADX WARN: Removed duplicated region for block: B:21:0x0068  */
    /* JADX WARN: Removed duplicated region for block: B:33:0x00c5  */
    /* JADX WARN: Removed duplicated region for block: B:36:0x00ce  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:11:0x0045 -> B:13:0x0048). Please report as a decompilation issue!!! */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        long j;
        int i;
        int i2;
        int i3;
        ck1 ck1Var = ck1.a;
        int i4 = this.e;
        e6a e6aVar = e6a.a;
        float f = this.i;
        int i5 = 1;
        VideoPlayerActivity videoPlayerActivity = this.f;
        if (i4 == 0) {
            s38.b(obj);
            j = 60;
            i = 0;
            i2 = (int) 66;
            i3 = 0;
            if (i3 >= i2) {
            }
        } else {
            if (i4 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            i3 = this.c;
            i2 = this.b;
            j = this.d;
            i = this.a;
            s38.b(obj);
            Display display = Build.VERSION.SDK_INT < 30 ? videoPlayerActivity.getDisplay() : videoPlayerActivity.getWindowManager().getDefaultDisplay();
            Display.Mode mode = display == null ? display.getMode() : null;
            if (mode == null) {
                float refreshRate = mode.getRefreshRate();
                long[] jArr = VideoPlayerActivity.R0;
                int i6 = i5;
                if (Math.abs(refreshRate - f) <= Math.max(0.08f, f * 0.003f)) {
                    i++;
                    if (i >= 2) {
                        ExecutorService executorService = kq.a;
                        kq.h("FrameRate", "POLL CONFIRMED: display stable at " + mode.getRefreshRate() + "Hz after " + (((long) i3) * j) + "ms");
                        videoPlayerActivity.cz = false;
                        FrameLayout frameLayout = videoPlayerActivity.t;
                        if (frameLayout == null) {
                            cr4.n("loadingOverlay");
                            throw null;
                        }
                        if (frameLayout.getVisibility() == 0) {
                            VideoPlayerActivity.m(videoPlayerActivity);
                            return e6aVar;
                        }
                        return e6aVar;
                    }
                }
                i3++;
                i5 = i6;
                if (i3 >= i2) {
                    ExecutorService executorService2 = kq.a;
                    kq.h("FrameRate", "Display mode poll timed out after 4s (target: " + f + "Hz)");
                    videoPlayerActivity.cz = false;
                    FrameLayout frameLayout2 = videoPlayerActivity.t;
                    if (frameLayout2 == null) {
                        cr4.n("loadingOverlay");
                        throw null;
                    }
                    if (frameLayout2.getVisibility() == 0) {
                        VideoPlayerActivity.m(videoPlayerActivity);
                    }
                    return e6aVar;
                }
                this.a = i;
                this.d = j;
                this.b = i2;
                this.c = i3;
                this.e = i5;
                if (h32.a(j, this) == ck1Var) {
                    return ck1Var;
                }
                if (Build.VERSION.SDK_INT < 30) {
                }
                if (display == null) {
                }
                if (mode == null) {
                    i6 = i5;
                }
            }
            i = 0;
            i3++;
            i5 = i6;
            if (i3 >= i2) {
            }
        }
    }
}
