package okio; import android.support.v4.media.session.PlaybackStateCompat; /* loaded from: classes5.dex */ public abstract class SegmentPool { public static long byteCount; public static Segment next; public static Segment take() { synchronized (SegmentPool.class) { try { Segment segment = next; if (segment != null) { next = segment.next; segment.next = null; byteCount -= PlaybackStateCompat.ACTION_PLAY_FROM_URI; return segment; } return new Segment(); } catch (Throwable th) { throw th; } } } public static void recycle(Segment segment) { if (segment.next != null || segment.prev != null) { throw new IllegalArgumentException(); } if (segment.shared) { return; } synchronized (SegmentPool.class) { try { long j = byteCount; if (j + PlaybackStateCompat.ACTION_PLAY_FROM_URI > PlaybackStateCompat.ACTION_PREPARE_FROM_SEARCH) { return; } byteCount = j + PlaybackStateCompat.ACTION_PLAY_FROM_URI; segment.next = next; segment.limit = 0; segment.pos = 0; next = segment; } catch (Throwable th) { throw th; } } } }