package x9; import java.nio.ByteBuffer; /* loaded from: classes2.dex */ final class p implements d { /* renamed from: a, reason: collision with root package name */ public final c f15502a = new c(); /* renamed from: b, reason: collision with root package name */ public final u f15503b; /* renamed from: c, reason: collision with root package name */ boolean f15504c; p(u uVar) { if (uVar == null) { throw new NullPointerException("sink == null"); } this.f15503b = uVar; } @Override // x9.d public d D() { if (this.f15504c) { throw new IllegalStateException("closed"); } long u02 = this.f15502a.u0(); if (u02 > 0) { this.f15503b.t0(this.f15502a, u02); } return this; } @Override // x9.d public d L(int i10) { if (this.f15504c) { throw new IllegalStateException("closed"); } this.f15502a.L(i10); return Q(); } @Override // x9.d public d Q() { if (this.f15504c) { throw new IllegalStateException("closed"); } long P = this.f15502a.P(); if (P > 0) { this.f15503b.t0(this.f15502a, P); } return this; } @Override // x9.d public c a() { return this.f15502a; } @Override // x9.u public w b() { return this.f15503b.b(); } @Override // x9.u, java.io.Closeable, java.lang.AutoCloseable public void close() { if (this.f15504c) { return; } try { c cVar = this.f15502a; long j10 = cVar.f15468b; if (j10 > 0) { this.f15503b.t0(cVar, j10); } th = null; } catch (Throwable th) { th = th; } try { this.f15503b.close(); } catch (Throwable th2) { if (th == null) { th = th2; } } this.f15504c = true; if (th != null) { x.e(th); } } @Override // x9.d public d e(int i10) { if (this.f15504c) { throw new IllegalStateException("closed"); } this.f15502a.e(i10); return Q(); } @Override // x9.d public d f(int i10) { if (this.f15504c) { throw new IllegalStateException("closed"); } this.f15502a.f(i10); return Q(); } @Override // x9.d, x9.u, java.io.Flushable public void flush() { if (this.f15504c) { throw new IllegalStateException("closed"); } c cVar = this.f15502a; long j10 = cVar.f15468b; if (j10 > 0) { this.f15503b.t0(cVar, j10); } this.f15503b.flush(); } @Override // x9.d public d h(int i10) { if (this.f15504c) { throw new IllegalStateException("closed"); } this.f15502a.h(i10); return Q(); } @Override // java.nio.channels.Channel public boolean isOpen() { return !this.f15504c; } @Override // x9.d public d j(String str) { if (this.f15504c) { throw new IllegalStateException("closed"); } this.f15502a.j(str); return Q(); } @Override // x9.d public d l(byte[] bArr, int i10, int i11) { if (this.f15504c) { throw new IllegalStateException("closed"); } this.f15502a.l(bArr, i10, i11); return Q(); } @Override // x9.d public d m(long j10) { if (this.f15504c) { throw new IllegalStateException("closed"); } this.f15502a.m(j10); return Q(); } @Override // x9.d public d q(byte[] bArr) { if (this.f15504c) { throw new IllegalStateException("closed"); } this.f15502a.q(bArr); return Q(); } @Override // x9.u public void t0(c cVar, long j10) { if (this.f15504c) { throw new IllegalStateException("closed"); } this.f15502a.t0(cVar, j10); Q(); } public String toString() { return "buffer(" + this.f15503b + ")"; } @Override // x9.d public d v0(f fVar) { if (this.f15504c) { throw new IllegalStateException("closed"); } this.f15502a.v0(fVar); return Q(); } @Override // java.nio.channels.WritableByteChannel public int write(ByteBuffer byteBuffer) { if (this.f15504c) { throw new IllegalStateException("closed"); } int write = this.f15502a.write(byteBuffer); Q(); return write; } }