Skip to content

Commit

Permalink
Use newer APIs for wave form generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
cody-signal authored and greyson-signal committed Feb 16, 2023
1 parent d714590 commit 23d0152
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ private AudioWaveFormGenerator() {}
codec.configure(format, null, null, 0);
codec.start();

ByteBuffer[] codecInputBuffers = codec.getInputBuffers();
ByteBuffer[] codecOutputBuffers = codec.getOutputBuffers();

extractor.selectTrack(0);

long kTimeOutUs = 5000;
Expand All @@ -82,7 +79,7 @@ private AudioWaveFormGenerator() {}
if (!sawInputEOS) {
int inputBufIndex = codec.dequeueInputBuffer(kTimeOutUs);
if (inputBufIndex >= 0) {
ByteBuffer dstBuf = codecInputBuffers[inputBufIndex];
ByteBuffer dstBuf = codec.getInputBuffer(inputBufIndex);
int sampleSize = extractor.readSampleData(dstBuf, 0);
long presentationTimeUs = 0;

Expand Down Expand Up @@ -122,7 +119,7 @@ private AudioWaveFormGenerator() {}
noOutputCounter = 0;
}

ByteBuffer buf = codecOutputBuffers[outputBufferIndex];
ByteBuffer buf = codec.getOutputBuffer(outputBufferIndex);
int barIndex = (int) ((wave.length * info.presentationTimeUs) / totalDurationUs);
long total = 0;
for (int i = 0; i < info.size; i += 2 * 4) {
Expand All @@ -137,8 +134,6 @@ private AudioWaveFormGenerator() {}
if ((info.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
sawOutputEOS = true;
}
} else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
codecOutputBuffers = codec.getOutputBuffers();
} else if (outputBufferIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
Log.d(TAG, "output format has changed to " + codec.getOutputFormat());
}
Expand Down

0 comments on commit 23d0152

Please sign in to comment.