package com.google.android.gms.internal.ads;

import androidx.annotation.Nullable;

/* JADX INFO: loaded from: classes2.dex */
public final class bh2 implements ii2 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final lj2 f9539a;

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

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

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

    @Nullable
    private ej2 zzc;

    @Nullable
    private ii2 zzd;

    public bh2(ah2 ah2Var) {
        this.f9540b = ah2Var;
        lj2 lj2Var = new lj2();
        lj2Var.f13743d = wd.f18030d;
        this.f9539a = lj2Var;
        this.f9541c = true;
    }

    public final void a(ej2 ej2Var) throws zziw {
        ii2 ii2Var;
        ii2 ii2VarZzd = ej2Var.zzd();
        if (ii2VarZzd == null || ii2VarZzd == (ii2Var = this.zzd)) {
            return;
        }
        if (ii2Var != null) {
            throw new zziw(2, new IllegalStateException("Multiple renderer media clocks enabled."), 1000);
        }
        this.zzd = ii2VarZzd;
        this.zzc = ej2Var;
        ii2VarZzd.c(this.f9539a.f13743d);
    }

    public final void b(ej2 ej2Var) {
        if (ej2Var == this.zzc) {
            this.zzd = null;
            this.zzc = null;
            this.f9541c = true;
        }
    }

    @Override // com.google.android.gms.internal.ads.ii2
    public final void c(wd wdVar) {
        ii2 ii2Var = this.zzd;
        if (ii2Var != null) {
            ii2Var.c(wdVar);
            wdVar = this.zzd.zzj();
        }
        this.f9539a.c(wdVar);
    }

    /* JADX WARN: Removed duplicated region for block: B:25:0x005e  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final long d(boolean z10) {
        wd wdVarZzj;
        ej2 ej2Var = this.zzc;
        lj2 lj2Var = this.f9539a;
        if (ej2Var == null || ej2Var.d() || ((z10 && ((pf2) this.zzc).f15399g != 2) || (!this.zzc.B() && (z10 || ((pf2) this.zzc).x())))) {
            this.f9541c = true;
            if (this.f9542d) {
                lj2Var.a();
            }
        } else {
            ii2 ii2Var = this.zzd;
            ii2Var.getClass();
            long jZzg = ii2Var.zzg();
            if (!this.f9541c) {
                lj2Var.d(jZzg);
                wdVarZzj = ii2Var.zzj();
                if (!wdVarZzj.equals(lj2Var.f13743d)) {
                    lj2Var.c(wdVarZzj);
                    ((u71) ((h81) ((ci2) this.f9540b).f9923h).zzd(16, wdVarZzj)).a();
                }
            } else if (jZzg < lj2Var.zzg()) {
                lj2Var.b();
            } else {
                this.f9541c = false;
                if (this.f9542d) {
                    lj2Var.a();
                }
                lj2Var.d(jZzg);
                wdVarZzj = ii2Var.zzj();
                if (!wdVarZzj.equals(lj2Var.f13743d)) {
                }
            }
        }
        return zzg();
    }

    @Override // com.google.android.gms.internal.ads.ii2
    public final long zzg() {
        if (this.f9541c) {
            return this.f9539a.zzg();
        }
        ii2 ii2Var = this.zzd;
        ii2Var.getClass();
        return ii2Var.zzg();
    }

    @Override // com.google.android.gms.internal.ads.ii2
    public final boolean zzh() {
        if (this.f9541c) {
            return false;
        }
        ii2 ii2Var = this.zzd;
        ii2Var.getClass();
        return ii2Var.zzh();
    }

    @Override // com.google.android.gms.internal.ads.ii2
    public final wd zzj() {
        ii2 ii2Var = this.zzd;
        return ii2Var != null ? ii2Var.zzj() : this.f9539a.f13743d;
    }
}
