W / Looper:无法写入唤醒信号,errno = 89

时间:2018-03-02 03:12:24

标签: java android java-native-interface looper

当我通过“输入”方法使用从jni线程发送消息到此线程(ZWANJniThread)时,开始时它可以工作,但是当我创建一个新的ZWANJniThread线程时,有时,我得到“W / Looper:不能写入唤醒信号,errno = 89“在日志中。

是否有任何机构遇到此Looper错误或任何提示来检查此问题?感谢。

public class ZWANJniThread extends Thread
{   
    private static final String ZWANTAG = ZWANJniThread.class.getCanonicalName();   
    private Handler mMsgHandler  = null;

    VideoDeviceCallBack mVideoDeviceCallBack;

    public void setmVideoDeviceCallBack(VideoDeviceCallBack mVideoDeviceCallBack) {
        this.mVideoDeviceCallBack = mVideoDeviceCallBack;
    }

    public ZWANJniThread() {
        Log.e(ZWANTAG, ">>>>>ZWANJniThread Constructor");
    }



    public int Input(int msgWhat, Object msgObj){
        if(mMsgHandler == null)
        {   
            Log.e(ZWANTAG, "mMsgHandler is NULL===========");
            return 0;
        }
        Message msg = mMsgHandler.obtainMessage();
        msg.what = msgWhat;
        msg.obj = msgObj;
        mMsgHandler.sendMessage(msg);
        return 0;
    }


    @Override
    public void run(){

        Looper.prepare();

        mMsgHandler = new Handler(){
            @Override
            public void handleMessage(Message msg){
                Log.e("ZWANTAG", "handle Message---" + msg.what);


                switch (msg.what)
                {

                    case ZWANMessage.JniThreadMessage.VIDEODEVICE_Open:
                    {
                        T_ZWANCamerID tCamerId = (T_ZWANCamerID)msg.obj;
                        mVideoDeviceCallBack.Open(tCamerId.s32CamerID);
                        break;
                    }
                    case ZWANMessage.JniThreadMessage.VIDEODEVICE_Start:
                    {
                        T_ZWANVideoSwitchLevel tLevel= (T_ZWANVideoSwitchLevel) msg.obj;
                        mVideoDeviceCallBack.Start(null, tLevel.s32Width, tLevel.s32Height, tLevel.mLocalSurfaceHolder);
                        break;
                    }
                    case ZWANMessage.JniThreadMessage.VIDEODEVICE_Stop:
                    {
                        mVideoDeviceCallBack.Stop();
                        break;
                    }
                    case ZWANMessage.JniThreadMessage.VIDEODEVICE_Close:
                    {
                        mVideoDeviceCallBack.Close();
                        break;
                    }
                    default:
                        break;
                }

            }

        };


        Looper.loop();

    }
}

0 个答案:

没有答案