Android – how to prevent java.lang.illegalstateexception generated by mediacodec.dequeueinputbuffer
The following code occasionally generates a java.lang.illegalstateexception:
Among them_ Mcdoder is an example of mediacodec. The decoded stream is H.264 video. The code works well in most cases. Is there any way to actively check the status of mediacodec to avoid this exception?
Stack trace:
resolvent:
This exception is thrown if the codec returns an internal error. This can be caused by an incorrect bitstream, for example (although the decoder should mostly handle what I think), or it may be the wrong delivery of a packet (attempting to decode interlaced H.264 video through mediacodec on modern Qualcomm chipsets can also cause objects to enter an error state, such as https://code.google.com/p/android/issues/detail?id=72336 – this is particularly annoying because it crashes the whole process when trying to turn off the codec.)
In addition to paying attention to exceptions, there is no way to know that this has happened (except reading the system log). (maybe this is a good supplement as a new API?) I'm not sure whether it can continue to try to provide the decoder. If it can recover, or it is a cause of failure and the whole decoder should be shut down