Class DefaultAllocator
- java.lang.Object
-
- com.google.android.exoplayer2.upstream.DefaultAllocator
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.upstream.Allocator
Allocator.AllocationNode
-
-
Constructor Summary
Constructors Constructor Description DefaultAllocator(boolean trimOnReset, int individualAllocationSize)Constructs an instance without creating anyAllocations up front.DefaultAllocator(boolean trimOnReset, int individualAllocationSize, int initialAllocationCount)Constructs an instance with someAllocations created up front.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Allocationallocate()Obtain anAllocation.intgetIndividualAllocationLength()Returns the length of each individualAllocation.intgetTotalBytesAllocated()Returns the total number of bytes currently allocated.voidrelease(Allocation allocation)Releases anAllocationback to the allocator.voidrelease(Allocator.AllocationNode allocationNode)Releases allAllocationsin the chain starting at the givenAllocator.AllocationNode.voidreset()voidsetTargetBufferSize(int targetBufferSize)voidtrim()Hints to the allocator that it should make a best effort to release any excessAllocations.
-
-
-
Constructor Detail
-
DefaultAllocator
public DefaultAllocator(boolean trimOnReset, int individualAllocationSize)Constructs an instance without creating anyAllocations up front.- Parameters:
trimOnReset- Whether memory is freed when the allocator is reset. Should be true unless the allocator will be re-used by multiple player instances.individualAllocationSize- The length of each individualAllocation.
-
DefaultAllocator
public DefaultAllocator(boolean trimOnReset, int individualAllocationSize, int initialAllocationCount)Constructs an instance with someAllocations created up front.Note:
Allocations created up front will never be discarded bytrim().- Parameters:
trimOnReset- Whether memory is freed when the allocator is reset. Should be true unless the allocator will be re-used by multiple player instances.individualAllocationSize- The length of each individualAllocation.initialAllocationCount- The number of allocations to create up front.
-
-
Method Detail
-
reset
public void reset()
-
setTargetBufferSize
public void setTargetBufferSize(int targetBufferSize)
-
allocate
public Allocation allocate()
Description copied from interface:AllocatorObtain anAllocation.When the caller has finished with the
Allocation, it should be returned by callingAllocator.release(Allocation).- Specified by:
allocatein interfaceAllocator- Returns:
- The
Allocation.
-
release
public void release(Allocation allocation)
Description copied from interface:AllocatorReleases anAllocationback to the allocator.- Specified by:
releasein interfaceAllocator- Parameters:
allocation- TheAllocationbeing released.
-
release
public void release(@Nullable Allocator.AllocationNode allocationNode)Description copied from interface:AllocatorReleases allAllocationsin the chain starting at the givenAllocator.AllocationNode.Implementations must not make memory allocations.
-
trim
public void trim()
Description copied from interface:AllocatorHints to the allocator that it should make a best effort to release any excessAllocations.
-
getTotalBytesAllocated
public int getTotalBytesAllocated()
Description copied from interface:AllocatorReturns the total number of bytes currently allocated.- Specified by:
getTotalBytesAllocatedin interfaceAllocator
-
getIndividualAllocationLength
public int getIndividualAllocationLength()
Description copied from interface:AllocatorReturns the length of each individualAllocation.- Specified by:
getIndividualAllocationLengthin interfaceAllocator
-
-