package o; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; /* renamed from: o.fXp, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C13342fXp extends fUX { private long a; private int b; private boolean d; private AbstractC13173fSu e; private TimeUnit i; public C13342fXp(InterfaceC13169fSq interfaceC13169fSq, long j, TimeUnit timeUnit, AbstractC13173fSu abstractC13173fSu, int i, boolean z) { super(interfaceC13169fSq); this.a = j; this.i = timeUnit; this.e = abstractC13173fSu; this.b = i; this.d = z; } @Override // o.AbstractC13163fSk public final void subscribeActual(InterfaceC13174fSv interfaceC13174fSv) { this.c.subscribe(new LWm(interfaceC13174fSv, this.a, this.i, this.e, this.b, this.d)); } /* renamed from: o.fXp$LWm */ /* loaded from: classes6.dex */ static final class LWm extends AtomicInteger implements InterfaceC13174fSv, fSJ { private InterfaceC13174fSv a; private Throwable b; private volatile boolean c; private volatile boolean d; private boolean e; private fSJ f; private C13416fZs g; private long h; private TimeUnit i; private AbstractC13173fSu j; LWm(InterfaceC13174fSv interfaceC13174fSv, long j, TimeUnit timeUnit, AbstractC13173fSu abstractC13173fSu, int i, boolean z) { this.a = interfaceC13174fSv; this.h = j; this.i = timeUnit; this.j = abstractC13173fSu; this.g = new C13416fZs<>(i); this.e = z; } @Override // o.InterfaceC13174fSv public final void onSubscribe(fSJ fsj) { if (EnumC13192fTf.d(this.f, fsj)) { this.f = fsj; this.a.onSubscribe(this); } } @Override // o.InterfaceC13174fSv public final void onNext(T t) { this.g.e(Long.valueOf(AbstractC13173fSu.b(this.i)), t); b(); } @Override // o.InterfaceC13174fSv public final void onError(Throwable th) { this.b = th; this.c = true; b(); } @Override // o.InterfaceC13174fSv public final void onComplete() { this.c = true; b(); } @Override // o.fSJ public final void dispose() { if (this.d) { return; } this.d = true; this.f.dispose(); if (getAndIncrement() == 0) { this.g.e(); } } private void b() { if (getAndIncrement() != 0) { return; } InterfaceC13174fSv interfaceC13174fSv = this.a; C13416fZs c13416fZs = this.g; boolean z = this.e; TimeUnit timeUnit = this.i; long j = this.h; int i = 1; while (!this.d) { boolean z2 = this.c; Long l = (Long) c13416fZs.a(); boolean z3 = l == null; long b = AbstractC13173fSu.b(timeUnit); if (!z3 && l.longValue() > b - j) { z3 = true; } if (z2) { if (!z) { Throwable th = this.b; if (th != null) { this.g.e(); interfaceC13174fSv.onError(th); return; } else if (z3) { interfaceC13174fSv.onComplete(); return; } } else if (z3) { Throwable th2 = this.b; if (th2 != null) { interfaceC13174fSv.onError(th2); return; } else { interfaceC13174fSv.onComplete(); return; } } } if (!z3) { c13416fZs.b(); interfaceC13174fSv.onNext(c13416fZs.b()); } else { i = addAndGet(-i); if (i == 0) { return; } } } this.g.e(); } @Override // o.fSJ public final boolean isDisposed() { return this.d; } } }