Propagate the possible exceptions during codec capability checks to the caller so a nice dialog can be displayed instead of crashing on buggy ROMs. Small change to evdev shutdown.

This commit is contained in:
Cameron Gutman 2014-09-03 20:00:00 -07:00
parent 2c23dbd2be
commit 178c53ee84
3 changed files with 16 additions and 4 deletions

View File

@ -198,7 +198,16 @@ public class Game extends Activity implements SurfaceHolder.Callback,
controllerHandler = new ControllerHandler(conn);
decoderRenderer = new ConfigurableDecoderRenderer();
decoderRenderer.initializeWithFlags(drFlags);
try {
decoderRenderer.initializeWithFlags(drFlags);
} catch (Exception e) {
Dialog.displayDialog(this, "Hardware Decoder Failure",
"The hardware decoder failed to initialize. First, try restarting your device."+
"If the issue persists, please send an email to the app developer. Forcing software decoding" +
"can circumvent this error if needed.", true);
return;
}
SurfaceHolder sh = sv.getHolder();
if (stretchToFit || !decoderRenderer.isHardwareAccelerated()) {
@ -301,7 +310,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
}
if (LimelightBuildProps.ROOT_BUILD) {
if (evdevWatcher != null) {
evdevWatcher.shutdown();
}

View File

@ -22,7 +22,7 @@ public class ConfigurableDecoderRenderer implements VideoDecoderRenderer {
return decoderRenderer.setup(width, height, redrawRate, renderTarget, drFlags);
}
public void initializeWithFlags(int drFlags) {
public void initializeWithFlags(int drFlags) throws Exception {
if ((drFlags & VideoDecoderRenderer.FLAG_FORCE_HARDWARE_DECODING) != 0 ||
((drFlags & VideoDecoderRenderer.FLAG_FORCE_SOFTWARE_DECODING) == 0 &&
MediaCodecDecoderRenderer.findSafeDecoder() != null)) {

View File

@ -91,7 +91,10 @@ public class MediaCodecDecoderRenderer implements VideoDecoderRenderer {
}
}
public static MediaCodecInfo findSafeDecoder() {
// We declare this method as explicitly throwing Exception
// since some bad decoders can throw IllegalArgumentExceptions unexpectedly
// and we want to be sure all callers are handling this possibility
public static MediaCodecInfo findSafeDecoder() throws Exception {
for (int i = 0; i < MediaCodecList.getCodecCount(); i++) {
MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);