package defpackage;

import androidx.media3.extractor.ts.TsExtractor;
import defpackage.a21;
import java.util.concurrent.CancellationException;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
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 = "io.ktor.websocket.DefaultWebSocketSessionImpl$runOutgoingProcessor$1", f = "DefaultWebSocketSession.kt", i = {}, l = {246, TsExtractor.TS_STREAM_TYPE_AIT, TsExtractor.TS_STREAM_TYPE_AIT, TsExtractor.TS_STREAM_TYPE_AIT, 250, TsExtractor.TS_STREAM_TYPE_AIT, TsExtractor.TS_STREAM_TYPE_AIT, 254, TsExtractor.TS_STREAM_TYPE_AIT, TsExtractor.TS_STREAM_TYPE_AIT}, m = "invokeSuspend", n = {}, s = {})
final class l22 extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public Throwable a;
    public int b;
    public final /* synthetic */ g22 c;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public l22(g22 g22Var, Continuation continuation) {
        super(2, continuation);
        this.c = g22Var;
    }

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

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

    /* JADX WARN: Removed duplicated region for block: B:57:0x00f0 A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:58:0x00f1 A[RETURN] */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws Throwable {
        g22 g22Var = this.c;
        loa loaVar = g22Var.a;
        zg0 zg0Var = g22Var.d;
        ck1 ck1Var = ck1.a;
        int i = this.b;
        e6a e6aVar = e6a.a;
        try {
            try {
                try {
                } catch (n21 unused) {
                    zg0Var.h(null);
                    this.b = 4;
                    if (noa.a(loaVar, new a21(a21.a.d, ""), this) == ck1Var) {
                    }
                } catch (Throwable th) {
                    zg0Var.l(er2.a("Failed to send frame", th));
                    this.b = 8;
                    Object objA = noa.a(loaVar, th instanceof CancellationException ? new a21(a21.a.d, "") : new a21(a21.a.i, th.toString()), this);
                    if (objA != ck1.a) {
                        objA = e6aVar;
                    }
                    if (objA != ck1Var) {
                    }
                    return ck1Var;
                }
            } catch (CancellationException unused2) {
                a21 a21Var = new a21(a21.a.d, "");
                this.b = 5;
                AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = g22.k;
                if (g22Var.g(a21Var, null, this) != ck1Var) {
                    zg0Var.h(null);
                    this.b = 6;
                    if (noa.a(loaVar, new a21(a21.a.d, ""), this) != ck1Var) {
                    }
                }
            } catch (kv0 unused3) {
                zg0Var.h(null);
                this.b = 7;
                if (noa.a(loaVar, new a21(a21.a.d, ""), this) == ck1Var) {
                }
            } catch (o21 unused4) {
                zg0Var.h(null);
                this.b = 3;
                if (noa.a(loaVar, new a21(a21.a.d, ""), this) == ck1Var) {
                }
            }
        } catch (Throwable th2) {
            zg0Var.h(null);
            this.a = th2;
            this.b = 10;
            if (noa.a(loaVar, new a21(a21.a.d, ""), this) != ck1Var) {
                throw th2;
            }
        }
        switch (i) {
            case 0:
                s38.b(obj);
                this.b = 1;
                if (g22.d(g22Var, this) != ck1Var) {
                    zg0Var.h(null);
                    this.b = 2;
                    if (noa.a(loaVar, new a21(a21.a.d, ""), this) != ck1Var) {
                        return e6aVar;
                    }
                }
                return ck1Var;
            case 1:
                s38.b(obj);
                zg0Var.h(null);
                this.b = 2;
                if (noa.a(loaVar, new a21(a21.a.d, ""), this) != ck1Var) {
                    return ck1Var;
                }
                break;
            case 2:
                s38.b(obj);
                return e6aVar;
            case 3:
            case 4:
            case 6:
            case 7:
            case 9:
                s38.b(obj);
                return e6aVar;
            case 5:
                s38.b(obj);
                zg0Var.h(null);
                this.b = 6;
                if (noa.a(loaVar, new a21(a21.a.d, ""), this) != ck1Var) {
                }
                break;
            case 8:
                s38.b(obj);
                zg0Var.h(null);
                this.b = 9;
                if (noa.a(loaVar, new a21(a21.a.d, ""), this) == ck1Var) {
                }
                break;
            case 10:
                Throwable th3 = this.a;
                s38.b(obj);
                throw th3;
            default:
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
        }
    }
}
