本文整理汇总了Java中com.google.android.exoplayer2.upstream.Allocation类的典型用法代码示例。如果您正苦于以下问题:Java Allocation类的具体用法?Java Allocation怎么用?Java Allocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Allocation类属于com.google.android.exoplayer2.upstream包,在下文中一共展示了Allocation类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readData
import com.google.android.exoplayer2.upstream.Allocation; //导入依赖的package包/类
/**
* Reads data from the front of the rolling buffer.
*
* @param absolutePosition The absolute position from which data should be read.
* @param target The array into which data should be written.
* @param length The number of bytes to read.
*/
private void readData(long absolutePosition, byte[] target, int length) {
advanceReadTo(absolutePosition);
int remaining = length;
while (remaining > 0) {
int toCopy = Math.min(remaining, (int) (readAllocationNode.endPosition - absolutePosition));
Allocation allocation = readAllocationNode.allocation;
System.arraycopy(allocation.data, readAllocationNode.translateOffset(absolutePosition),
target, length - remaining, toCopy);
remaining -= toCopy;
absolutePosition += toCopy;
if (absolutePosition == readAllocationNode.endPosition) {
readAllocationNode = readAllocationNode.next;
}
}
}
示例2: clearAllocationNodes
import com.google.android.exoplayer2.upstream.Allocation; //导入依赖的package包/类
/**
* Clears allocation nodes starting from {@code fromNode}.
*
* @param fromNode The node from which to clear.
*/
private void clearAllocationNodes(AllocationNode fromNode) {
if (!fromNode.wasInitialized) {
return;
}
// Bulk release allocations for performance (it's significantly faster when using
// DefaultAllocator because the allocator's lock only needs to be acquired and released once)
// [Internal: See b/29542039].
int allocationCount = (writeAllocationNode.wasInitialized ? 1 : 0)
+ ((int) (writeAllocationNode.startPosition - fromNode.startPosition) / allocationLength);
Allocation[] allocationsToRelease = new Allocation[allocationCount];
AllocationNode currentNode = fromNode;
for (int i = 0; i < allocationsToRelease.length; i++) {
allocationsToRelease[i] = currentNode.allocation;
currentNode = currentNode.clear();
}
allocator.release(allocationsToRelease);
}
示例3: readData
import com.google.android.exoplayer2.upstream.Allocation; //导入依赖的package包/类
/**
* Reads data from the front of the rolling buffer.
*
* @param absolutePosition The absolute position from which data should be read.
* @param target The buffer into which data should be written.
* @param length The number of bytes to read.
*/
private void readData(long absolutePosition, ByteBuffer target, int length) {
int remaining = length;
while (remaining > 0) {
dropDownstreamTo(absolutePosition);
int positionInAllocation = (int) (absolutePosition - totalBytesDropped);
int toCopy = Math.min(remaining, allocationLength - positionInAllocation);
Allocation allocation = dataQueue.peek();
target.put(allocation.data, allocation.translateOffset(positionInAllocation), toCopy);
absolutePosition += toCopy;
remaining -= toCopy;
}
}
示例4: clearSampleData
import com.google.android.exoplayer2.upstream.Allocation; //导入依赖的package包/类
private void clearSampleData() {
infoQueue.clearSampleData();
allocator.release(dataQueue.toArray(new Allocation[dataQueue.size()]));
dataQueue.clear();
allocator.trim();
totalBytesDropped = 0;
totalBytesWritten = 0;
lastAllocation = null;
lastAllocationOffset = allocationLength;
}
示例5: clearSampleData
import com.google.android.exoplayer2.upstream.Allocation; //导入依赖的package包/类
private void clearSampleData() {
infoQueue.clearSampleData();
allocator.release(dataQueue.toArray(new Allocation[dataQueue.size()]));
dataQueue.clear();
allocator.trim();
totalBytesDropped = 0;
totalBytesWritten = 0;
lastAllocation = null;
lastAllocationOffset = allocationLength;
needKeyframe = true;
}
示例6: initialize
import com.google.android.exoplayer2.upstream.Allocation; //导入依赖的package包/类
/**
* Initializes the node.
*
* @param allocation The node's {@link Allocation}.
* @param next The next {@link AllocationNode}.
*/
public void initialize(Allocation allocation, AllocationNode next) {
this.allocation = allocation;
this.next = next;
wasInitialized = true;
}