0

如何创建一个重写的方法,当该方法最初是多线程时,该方法被强制为单线程(而不是异步)?具体来说,我试图避免Grafika 的 ScreenRecordActivity中出现“dequeueOutputBuffer 不能在异步模式下使用”错误。“信息”变量需要是易变的而不是最终的。

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

更新 #1
Stacktrack 的错误: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)
4

0 回答 0