Use newer APIs for wave form generation.
This commit is contained in:
parent
d714590d3f
commit
23d0152767
1 changed files with 2 additions and 7 deletions
|
@ -66,9 +66,6 @@ public final class AudioWaveFormGenerator {
|
||||||
codec.configure(format, null, null, 0);
|
codec.configure(format, null, null, 0);
|
||||||
codec.start();
|
codec.start();
|
||||||
|
|
||||||
ByteBuffer[] codecInputBuffers = codec.getInputBuffers();
|
|
||||||
ByteBuffer[] codecOutputBuffers = codec.getOutputBuffers();
|
|
||||||
|
|
||||||
extractor.selectTrack(0);
|
extractor.selectTrack(0);
|
||||||
|
|
||||||
long kTimeOutUs = 5000;
|
long kTimeOutUs = 5000;
|
||||||
|
@ -82,7 +79,7 @@ public final class AudioWaveFormGenerator {
|
||||||
if (!sawInputEOS) {
|
if (!sawInputEOS) {
|
||||||
int inputBufIndex = codec.dequeueInputBuffer(kTimeOutUs);
|
int inputBufIndex = codec.dequeueInputBuffer(kTimeOutUs);
|
||||||
if (inputBufIndex >= 0) {
|
if (inputBufIndex >= 0) {
|
||||||
ByteBuffer dstBuf = codecInputBuffers[inputBufIndex];
|
ByteBuffer dstBuf = codec.getInputBuffer(inputBufIndex);
|
||||||
int sampleSize = extractor.readSampleData(dstBuf, 0);
|
int sampleSize = extractor.readSampleData(dstBuf, 0);
|
||||||
long presentationTimeUs = 0;
|
long presentationTimeUs = 0;
|
||||||
|
|
||||||
|
@ -122,7 +119,7 @@ public final class AudioWaveFormGenerator {
|
||||||
noOutputCounter = 0;
|
noOutputCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteBuffer buf = codecOutputBuffers[outputBufferIndex];
|
ByteBuffer buf = codec.getOutputBuffer(outputBufferIndex);
|
||||||
int barIndex = (int) ((wave.length * info.presentationTimeUs) / totalDurationUs);
|
int barIndex = (int) ((wave.length * info.presentationTimeUs) / totalDurationUs);
|
||||||
long total = 0;
|
long total = 0;
|
||||||
for (int i = 0; i < info.size; i += 2 * 4) {
|
for (int i = 0; i < info.size; i += 2 * 4) {
|
||||||
|
@ -137,8 +134,6 @@ public final class AudioWaveFormGenerator {
|
||||||
if ((info.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
|
if ((info.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
|
||||||
sawOutputEOS = true;
|
sawOutputEOS = true;
|
||||||
}
|
}
|
||||||
} else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
|
|
||||||
codecOutputBuffers = codec.getOutputBuffers();
|
|
||||||
} else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
|
} else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
|
||||||
Log.d(TAG, "output format has changed to " + codec.getOutputFormat());
|
Log.d(TAG, "output format has changed to " + codec.getOutputFormat());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue