I finally find out the solution. I answer here so people who found the same problem can fix it.
When my mediacodec plays near the end of file, it doesn't queue more input buffer into the inputQueue, therefore when it needs to dequeue the buffers, it cannot find any buffer to play