Skip to content

Commit

Permalink
BaseEncoder: prepare mediacodec on nonnull callback
Browse files Browse the repository at this point in the history
See #21
MediaCodec maybe crash on some devices due to null callback
  • Loading branch information
yrom committed May 24, 2018
1 parent 8dadf5b commit 3db3992
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/src/main/java/net/yrom/screenrecorder/BaseEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ public void prepare() throws IOException {
String mimeType = format.getString(MediaFormat.KEY_MIME);
final MediaCodec encoder = createEncoder(mimeType);
try {
encoder.setCallback(this.mCallback == null ? null : mCodecCallback);
if (this.mCallback != null) {
// NOTE: MediaCodec maybe crash on some devices due to null callback
encoder.setCallback(mCodecCallback);
}
encoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
onEncoderConfigured(encoder);
encoder.start();
Expand Down

0 comments on commit 3db3992

Please sign in to comment.