An app decodes H.264/H.265 video streams smoothly and flawlessly with the above scanning turned off. When the scanning is turned on, the decoding has long pauses (up to 3 seconds) periodically. It varies with devices. On some devices, the Wi-Fi scanning causes this and it is the Bluetooth scanning on other devices.
This app uses the following code to get a decoded video frame:
MediaCodec.BufferInfo bi = new MediaCodec.BufferInfo();
int iOutputBufferIndex = myMediaCodec.dequeueOutputBuffer(bi, TIMEOUT_USEC);
When the scanning is on, it occasionally takes up to 3 seconds to have a valid iOutputBufferIndex (>= 0). It is MediaCodec.INFO_TRY_AGAIN_LATER (-1) during the period.
Could anyone shed some light on this and offer a tip on the remedy?

