Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper exception handling needed #7

Open
daschaa opened this issue Dec 14, 2021 · 0 comments
Open

Proper exception handling needed #7

daschaa opened this issue Dec 14, 2021 · 0 comments

Comments

@daschaa
Copy link

daschaa commented Dec 14, 2021

Hi there 👋

We are currently facing an issue with your library that we get an IllegalStateException when calling the VideoSlimmer.releaseCoder() method.

    android.media.MediaCodec.native_stop MediaCodec.java
    android.media.MediaCodec.stop MediaCodec.java:2251
    com.zolad.videoslimmer.VideoSlimEncoder.releaseCoder VideoSlimEncoder.java:613
    com.zolad.videoslimmer.VideoSlimEncoder.convertVideo VideoSlimEncoder.java:391
    com.zolad.videoslimmer.VideoSlimTask.doInBackground VideoSlimTask.java:30
    com.zolad.videoslimmer.VideoSlimTask.doInBackground VideoSlimTask.java:11
    android.os.AsyncTask$3.call AsyncTask.java:394
    java.util.concurrent.FutureTask.run FutureTask.java:266
    android.os.AsyncTask$SerialExecutor$1.run AsyncTask.java:305
    java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java:1167
    java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java:641
    java.lang.Thread.run Thread.java:923

We found out that this comes up when an encoder was already released when calling stop. See here https://developer.android.com/reference/android/media/MediaCodec?hl=en#stop()

We would suggest to wrap the releaseCoder() method in an exception handling block and catching RuntimeExceptions ( see #8).

private void releaseCoder() {
if (VERBOSE) Log.d(TAG, "releasing encoder objects");
if (mEncoder != null) {
mEncoder.stop();
mEncoder.release();
mEncoder = null;
}
if (mDecoder != null) {
mDecoder.stop();
mDecoder.release();
mDecoder = null;
}
if (mInputSurface != null) {
mInputSurface.release();
mInputSurface = null;
}
if (mMuxer != null) {
mMuxer.stop();
mMuxer.release();
mMuxer = null;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant