0

For some reason I am using mediacodec API to decode mp4 audio track in JNI layer, I just reflect MediaCodec/MediaExtractor/AudioTrack into jni layer and try to decode audio and video tracks, but when I am decoding the audio track I can not get the whole audio track, the log info:

05-01 12:28:48.100 10030-10073/com.example.audiodecodernativedemo A/art: art/runtime/indirect_reference_table.cc:115] JNI ERROR (app bug): local reference table overflow (max=512)
05-01 12:28:48.100 10030-10073/com.example.audiodecodernativedemo A/art: art/runtime/indirect_reference_table.cc:115] local reference table dump:
05-01 12:28:48.100 10030-10073/com.example.audiodecodernativedemo A/art: art/runtime/indirect_reference_table.cc:115]   Last 10 entries (of 511):
05-01 12:28:48.100 10030-10073/com.example.audiodecodernativedemo A/art: art/runtime/indirect_reference_table.cc:115]       510: 0x12fa6140 java.nio.DirectByteBuffer
05-01 12:28:48.100 10030-10073/com.example.audiodecodernativedemo A/art: art/runtime/indirect_reference_table.cc:115]       509: 0x12fa6100 java.nio.DirectByteBuffer
05-01 12:28:48.100 10030-10073/com.example.audiodecodernativedemo A/art: art/runtime/indirect_reference_table.cc:115]       508: 0x12fa60c0 java.nio.DirectByteBuffer
05-01 12:28:48.100 10030-10073/com.example.audiodecodernativedemo A/art: art/runtime/indirect_reference_table.cc:115]       507: 0x12fa60c0 java.nio.DirectByteBuffer
05-01 12:28:48.100 10030-10073/com.example.audiodecodernativedemo A/art: art/runtime/indirect_reference_table.cc:115]       506: 0x12fa6040 java.nio.DirectByteBuffer
05-01 12:28:48.100 10030-10073/com.example.audiodecodernativedemo A/art: art/runtime/indirect_reference_table.cc:115]       505: 0x12f7bfc0 java.nio.DirectByteBuffer
05-01 12:28:48.100 10030-10073/com.example.audiodecodernativedemo A/art: art/runtime/indirect_reference_table.cc:115]       504: 0x12f7bfc0 java.nio.DirectByteBuffer
05-01 12:28:48.100 10030-10073/com.example.audiodecodernativedemo A/art: art/runtime/indirect_reference_table.cc:115]       503: 0x12f7bf40 java.nio.DirectByteBuffer
05-01 12:28:48.100 10030-10073/com.example.audiodecodernativedemo A/art: art/runtime/indirect_reference_table.cc:115]       502: 0x12f7bf00 

I have deleted all local reference I've created in my code. It seems that releaseOutputBuffer can not free ByteBuffer deliver to it for rendering. How can I decode audio in jni layer to avoid this problem?

fadden
  • 51,356
  • 5
  • 116
  • 166
Yupeng Zhu
  • 23
  • 4
  • Where is it failing? Can you show the backtrace? – fadden May 01 '16 at 18:19
  • @fadden,the bytebuffer can not free leads to local reference table overflow, here is the msg: Summary: 1 of android.media.MediaCodec$BufferInfo 1 ofcom.example.audiodecodernativedemo.MainActivity$AudioPlayerThread 2 of android.media.MediaFormat (2 unique instances)19 of java.lang.Class (9 unique instances)4 of java.lang.String (4 unique instances) 479 of java.nio.DirectByteBuffer (321 unique instances)1 of byte[] (9 elements)1 of byte[] (15 elements)1 of android.media.AudioTrack1 of android.media.MediaCodec1 of android.media.MediaExtractor – Yupeng Zhu May 02 '16 at 03:46
  • @fadden 479 of java.nio.DirectByteBuffer (321 unique instances),too many ByteBuffer instance, I've go through the java code successfully, but when I translate it into jni, this problem happen. can you give me some direct? – Yupeng Zhu May 02 '16 at 03:52
  • A local reference isn't getting deleted, in code that isn't returning to the VM. If the problem is in your code you can fix it, if it's a bug in the framework your options are more limited. The total / unique instance counts are a bit surprising -- in normal operation I'd expect it to be "leaking" multiple local references to a small set of objects. If all else fails, I believe there's an official MediaCodec native API in the Android NDK. – fadden May 02 '16 at 04:07
  • @fadden thank you very much for reply, I will check it more closely – Yupeng Zhu May 02 '16 at 15:18

0 Answers0