mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Ensure ParsableByteArray is large enough when appending in VorbisReader
PiperOrigin-RevId: 336643621
This commit is contained in:
parent
ca3b420cf6
commit
d2db0bb74a
@ -25,6 +25,7 @@ import com.google.android.exoplayer2.util.MimeTypes;
|
||||
import com.google.android.exoplayer2.util.ParsableByteArray;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* {@link StreamReader} to extract Vorbis data out of Ogg byte stream.
|
||||
@ -160,8 +161,11 @@ import java.util.ArrayList;
|
||||
@VisibleForTesting
|
||||
/* package */ static void appendNumberOfSamples(
|
||||
ParsableByteArray buffer, long packetSampleCount) {
|
||||
|
||||
buffer.setLimit(buffer.limit() + 4);
|
||||
if (buffer.capacity() < buffer.limit() + 4) {
|
||||
buffer.reset(Arrays.copyOf(buffer.getData(), buffer.limit() + 4));
|
||||
} else {
|
||||
buffer.setLimit(buffer.limit() + 4);
|
||||
}
|
||||
// The vorbis decoder expects the number of samples in the packet
|
||||
// to be appended to the audio data as an int32
|
||||
byte[] data = buffer.getData();
|
||||
|
Loading…
x
Reference in New Issue
Block a user