android-decodeencodetest icon indicating copy to clipboard operation
android-decodeencodetest copied to clipboard

some problems in onInputBufferAvailable callback

Open kaitian521 opened this issue 3 years ago • 1 comments

while (!mAudioExtractorDone) {
                    int size = mAudioExtractor.readSampleData(decoderInputBuffer, 0);
                    long presentationTime = mAudioExtractor.getSampleTime();
                    if (VERBOSE) {
                        Log.d(TAG, "audio extractor: returned buffer of size " + size);
                        Log.d(TAG, "audio extractor: returned buffer for time " + presentationTime);
                    }
                    if (size >= 0) {
                        codec.queueInputBuffer(
                                index,
                                0,
                                size,
                                presentationTime,
                                mAudioExtractor.getSampleFlags());

                        mAudioExtractor.advance();
                        mAudioExtractedFrameCount++;
                        logState();
                    } else {
                        mAudioExtractorDone = true;
                        if (VERBOSE) {
                            Log.d(TAG, "audio extractor: EOS");
                        }
                        codec.queueInputBuffer(
                                index,
                                0,
                                0,
                                0,
                                MediaCodec.BUFFER_FLAG_END_OF_STREAM);
                    }

should change to this codes int onInputBufferAvailable callback, otherwise there will be an IllegalStateException for MadiaCodec encoder or decoder

kaitian521 avatar Jan 19 '22 07:01 kaitian521