From 8d81bd58d8ecedb1cd640708fa5994624ecb88e9 Mon Sep 17 00:00:00 2001 From: aquilescanta Date: Thu, 13 Jan 2022 12:26:13 +0000 Subject: [PATCH] Remove Allocator.release(Allocation[]) and references PiperOrigin-RevId: 421530365 --- .../android/exoplayer2/upstream/Allocator.java | 7 ------- .../exoplayer2/upstream/DefaultAllocator.java | 14 ++------------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/Allocator.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/Allocator.java index 22d132dfed..aae5dc9715 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/Allocator.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/Allocator.java @@ -48,13 +48,6 @@ public interface Allocator { */ void release(Allocation allocation); - /** - * Releases an array of {@link Allocation Allocations} back to the allocator. - * - * @param allocations The array of {@link Allocation}s being released. - */ - void release(Allocation[] allocations); - /** * Releases all {@link Allocation Allocations} in the chain starting at the given {@link * AllocationNode}. diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultAllocator.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultAllocator.java index 7797883d20..7caaf4d3f8 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultAllocator.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultAllocator.java @@ -31,7 +31,6 @@ public final class DefaultAllocator implements Allocator { private final boolean trimOnReset; private final int individualAllocationSize; @Nullable private final byte[] initialAllocationBlock; - private final Allocation[] singleAllocationReleaseHolder; private int targetBufferSize; private int allocatedCount; @@ -76,7 +75,6 @@ public final class DefaultAllocator implements Allocator { } else { initialAllocationBlock = null; } - singleAllocationReleaseHolder = new Allocation[1]; } public synchronized void reset() { @@ -114,16 +112,8 @@ public final class DefaultAllocator implements Allocator { @Override public synchronized void release(Allocation allocation) { - singleAllocationReleaseHolder[0] = allocation; - release(singleAllocationReleaseHolder); - } - - @Override - public synchronized void release(Allocation[] allocations) { - for (Allocation allocation : allocations) { - availableAllocations[availableCount++] = allocation; - } - allocatedCount -= allocations.length; + availableAllocations[availableCount++] = allocation; + allocatedCount--; // Wake up threads waiting for the allocated size to drop. notifyAll(); }