Change Overrided Method to Single-Threaded

224 views Asked by At

How can I create an overrided method where the method is forced to be single-threaded (not async) when originally it was multi-threaded? Specifically I am trying to avoid a "dequeueOutputBuffer can't be used in async mode" error in Grafika's ScreenRecordActivity. "info" variable needs to be volatile not final.

@Override
public void onOutputBufferAvailable(...) {
    ...
    int outputBufIndex = codec.dequeueOutputBuffer(info, kTimeOutUs);

Update #1
Stacktrack of error: pastebin.com/sgJpyTnP

E/MediaCodec: dequeueOutputBuffer can't be used in async mode
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
                 Process: com.google.grafika, PID: 4469
                 java.lang.IllegalStateException
                     at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
                     at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2632)
                     at com.android.grafika.ScreenRecordActivity$3$1.run(ScreenRecordActivity.java:283)
                     at java.lang.Thread.run(Thread.java:764)
                     at com.android.grafika.ScreenRecordActivity$3.onOutputBufferAvailable(ScreenRecordActivity.java:312)
                     at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1682)
                     at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1629)
                     at android.os.Handler.dispatchMessage(Handler.java:106)
                     at android.os.Looper.loop(Looper.java:164)
                     at android.app.ActivityThread.main(ActivityThread.java:6494)
                     at java.lang.reflect.Method.invoke(Native Method)
                     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
0

There are 0 answers