mirror of
https://github.com/androidx/media.git
synced 2025-05-03 21:29:49 +08:00
Clear supplementalData in DecoderInputBuffer.clear
PiperOrigin-RevId: 268894250
This commit is contained in:
parent
1d3d92ee4b
commit
d443be2a46
@ -95,14 +95,19 @@ public class DecoderInputBuffer extends Buffer {
|
||||
this.bufferReplacementMode = bufferReplacementMode;
|
||||
}
|
||||
|
||||
/** Resets {@link #supplementalData} in preparation for storing {@code length} bytes. */
|
||||
/**
|
||||
* Clears {@link #supplementalData} and ensures that it's large enough to accommodate {@code
|
||||
* length} bytes.
|
||||
*
|
||||
* @param length The length of the supplemental data that must be accommodated, in bytes.
|
||||
*/
|
||||
@EnsuresNonNull("supplementalData")
|
||||
public void resetSupplementalData(int length) {
|
||||
if (supplementalData == null || supplementalData.capacity() < length) {
|
||||
supplementalData = ByteBuffer.allocate(length);
|
||||
} else {
|
||||
supplementalData.clear();
|
||||
}
|
||||
supplementalData.position(0);
|
||||
supplementalData.limit(length);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,8 +139,7 @@ public class DecoderInputBuffer extends Buffer {
|
||||
ByteBuffer newData = createReplacementByteBuffer(requiredCapacity);
|
||||
// Copy data up to the current position from the old buffer to the new one.
|
||||
if (position > 0) {
|
||||
data.position(0);
|
||||
data.limit(position);
|
||||
data.flip();
|
||||
newData.put(data);
|
||||
}
|
||||
// Set the new buffer.
|
||||
@ -158,7 +162,7 @@ public class DecoderInputBuffer extends Buffer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Flips {@link #data} in preparation for being queued to a decoder.
|
||||
* Flips {@link #data} and {@link #supplementalData} in preparation for being queued to a decoder.
|
||||
*
|
||||
* @see java.nio.Buffer#flip()
|
||||
*/
|
||||
@ -175,6 +179,9 @@ public class DecoderInputBuffer extends Buffer {
|
||||
if (data != null) {
|
||||
data.clear();
|
||||
}
|
||||
if (supplementalData != null) {
|
||||
supplementalData.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private ByteBuffer createReplacementByteBuffer(int requiredCapacity) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user