@TargetApi(21) private static String getDiagnosticInfoV21(Throwable cause) { if (cause instanceof CodecException) { return ((CodecException) cause).getDiagnosticInfo(); } return null; }
private void handleDecoderException(Exception e, ByteBuffer buf, int codecFlags, boolean throwOnTransient) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (e instanceof CodecException) { CodecException codecExc = (CodecException) e; if (codecExc.isTransient() && !throwOnTransient) { // We'll let transient exceptions go LimeLog.warning(codecExc.getDiagnosticInfo()); return; } LimeLog.severe(codecExc.getDiagnosticInfo()); } } // Only throw if we're not stopping if (!stopping) { // // There seems to be a race condition with decoder/surface teardown causing some // decoders to to throw IllegalStateExceptions even before 'stopping' is set. // To workaround this while allowing real exceptions to propagate, we will eat the // first exception. If we are still receiving exceptions 3 seconds later, we will // throw the original exception again. // if (initialException != null) { // This isn't the first time we've had an exception processing video if (System.currentTimeMillis() - initialExceptionTimestamp >= EXCEPTION_REPORT_DELAY_MS) { // It's been over 3 seconds and we're still getting exceptions. Throw the original now. if (!reportedCrash) { reportedCrash = true; crashListener.notifyCrash(initialException); } throw initialException; } } else { // This is the first exception we've hit if (buf != null || codecFlags != 0) { initialException = new RendererException(this, e, buf, codecFlags); } else { initialException = new RendererException(this, e); } initialExceptionTimestamp = System.currentTimeMillis(); } } }