当前位置: 首页 > article >正文

OpenXR Monado创建跨进程通信通道 ipc_connect

 OpenXR Monado创建跨进程通信通道 ipc_connect

@monado/src/xrt/targets/openxr/target.c
xrt_instance_create
@monado/src/xrt/ipc/client/ipc_client_instance.c
    ipc_instance_create(ii, out_xinst);
        ipc_connect
            ipc_c->ica = ipc_client_android_create(android_globals_get_vm(), android_globals_get_activity());
        @monado/src/xrt/ipc/android/ipc_client_android.cpp
            int socket = ipc_client_android_blocking_connect(ipc_c->ica);
        @monado/src/xrt/ipc/android/org.freedesktop.monado.ipc.impl.hpp
                int fd = ica->client.blockingConnect(ica->activity, XRT_ANDROID_PACKAGE);  // blockingConnect(classRef().getMethod("blockingConnect", "(Landroid/content/Context;Ljava/lang/String;)I"))
        @monado/src/xrt/ipc/android/src/main/java/org/freedesktop/monado/ipc/Client.java
                    blockingConnect(Context context_, String packageName)  //packageName=org.freedesktop.monado.openxr_runtime.out_of_process
                        bind(context_, packageName)
                            Intent intent = new Intent(BuildConfig.SERVICE_ACTION).setPackage(packageName);  // String SERVICE_ACTION = "org.freedesktop.monado.ipc.CONNECT";
                            bindService(context, intent)
                                result = context.bindService(intent, this, flags);
        @monado/src/xrt/ipc/android/src/main/java/org/freedesktop/monado/ipc/MonadoService.kt
                                    MonadoService::onCreate
                                        val intent = Intent(this, javaClass)
                                        intent.action = BuildConfig.SERVICE_ACTION
                                        startService(intent)  //启动org.freedesktop.monado.ipc.MonadoService服务
                                            onServiceConnected
                                                monado = IMonado.Stub.asInterface(service);
                        ParcelFileDescriptor[] fds = ParcelFileDescriptor.createSocketPair();
                        ours = fds[0];   //75
                        theirs = fds[1];  //76
                        fd = ours;
        @monado/src/xrt/ipc/android/src/main/java/org/freedesktop/monado/ipc/MonadoImpl.java
                        monado.connect(theirs);  //跨进程,进入server进程
                            int fd = parcelFileDescriptor.getFd();  //78(从76复制过来)
        @monado/src/xrt/targets/service-lib/service_target.cpp
                            nativeAddClient(fd)  //Java_org_freedesktop_monado_ipc_MonadoImpl_nativeAddClient
                                return IpcServerHelper::instance().addClient(fd);
        @monado/src/xrt/ipc/server/ipc_server_mainloop_android.c
                                    return ipc_server_mainloop_add_fd(server, &server->ml, fd);
                                        int ret = write(ml->pipe_write, &newfd, sizeof(newfd));  //pipe_write=82, newfd=78
                                            int ret = epoll_wait(epoll_fd, events, NUM_POLL_EVENTS, NO_SLEEP);
                                            if (events[i].data.fd == ml->pipe_read) { handle_listen(vs, ml); }
                                                read(ml->pipe_read, &newfd, sizeof(newfd))   //pipe_read=81,newfd=78
                                                ml->last_accepted_fd = newfd; 
        @monado/src/xrt/ipc/server/ipc_server_process.c
                                                ipc_server_start_client_listener_thread(vs, newfd);
                                                    ics->imc.ipc_handle = ipc_handle;  //ipc_handle=78,openxr_runtime.out_of_process-25265
                                                    os_thread_start(&it->thread, ipc_server_client_thread, (void *)ics);
        @monado/src/xrt/ipc/server/ipc_server_per_client_thread.c
                                                        ipc_server_client_thread  //新线程,openxr_runtime.out_of_process-26722
                                                            volatile struct ipc_client_state *ics = (volatile struct ipc_client_state *)_ics;
                                                            client_loop(ics);
                                                                while (ics->server->running) {  //开启线程循环
                                                                    int ret = epoll_wait(epoll_fd, &event, 1, half_a_second_ms);
                                                                    ssize_t len = recv(ics->imc.ipc_handle, &buf, IPC_BUF_SIZE, 0);  //ipc_handle=78
        @monado/src/xrt/targets/openxr_android/.cxx/Debug/4h1i2215/arm64-v8a/src/xrt/ipc/ipc_server_generated.c
                                                                    xrt_result_t result = ipc_dispatch(ics, ipc_command);
@monado/src/xrt/ipc/server/ipc_server_handler.c
                                                                        case IPC_SWAPCHAIN_ACQUIRE_IMAGE: reply.result = ipc_handle_swapchain_acquire_image(ics, msg->id,&reply.index);
                                                                        xrt_result_t ret = ipc_send((struct ipc_message_channel *)&ics->imc, &reply, sizeof(reply));
                        return fd.getFd();
            socket = dup(socket);   //复制一份fd=77,openxr.hello_xr.opengles
            ipc_c->imc.ipc_handle = socket;  //77

@monado/src/xrt/targets/openxr/target.c xrt_instance_create @monado/src/xrt/ipc/client/ipc_client_instance.c ipc_instance_create(ii, out_xinst); ipc_connect ipc_c->ica = ipc_client_android_create(android_globals_get_vm(), android_globals_get_activity()); @monado/src/xrt/ipc/android/ipc_client_android.cpp int socket = ipc_client_android_blocking_connect(ipc_c->ica); @monado/src/xrt/ipc/android/org.freedesktop.monado.ipc.impl.hpp int fd = ica->client.blockingConnect(ica->activity, XRT_ANDROID_PACKAGE); // blockingConnect(classRef().getMethod("blockingConnect", "(Landroid/content/Context;Ljava/lang/String;)I")) @monado/src/xrt/ipc/android/src/main/java/org/freedesktop/monado/ipc/Client.java blockingConnect(Context context_, String packageName) //packageName=org.freedesktop.monado.openxr_runtime.out_of_process bind(context_, packageName) Intent intent = new Intent(BuildConfig.SERVICE_ACTION).setPackage(packageName); // String SERVICE_ACTION = "org.freedesktop.monado.ipc.CONNECT"; bindService(context, intent) result = context.bindService(intent, this, flags); @monado/src/xrt/ipc/android/src/main/java/org/freedesktop/monado/ipc/MonadoService.kt MonadoService::onCreate val intent = Intent(this, javaClass) intent.action = BuildConfig.SERVICE_ACTION startService(intent) //启动org.freedesktop.monado.ipc.MonadoService服务 onServiceConnected monado = IMonado.Stub.asInterface(service); ParcelFileDescriptor[] fds = ParcelFileDescriptor.createSocketPair(); ours = fds[0]; //75 theirs = fds[1]; //76 fd = ours; @monado/src/xrt/ipc/android/src/main/java/org/freedesktop/monado/ipc/MonadoImpl.java monado.connect(theirs); //跨进程,进入server进程 int fd = parcelFileDescriptor.getFd(); //78(从76复制过来) @monado/src/xrt/targets/service-lib/service_target.cpp nativeAddClient(fd) //Java_org_freedesktop_monado_ipc_MonadoImpl_nativeAddClient return IpcServerHelper::instance().addClient(fd); @monado/src/xrt/ipc/server/ipc_server_mainloop_android.c return ipc_server_mainloop_add_fd(server, &server->ml, fd); int ret = write(ml->pipe_write, &newfd, sizeof(newfd)); //pipe_write=82, newfd=78 int ret = epoll_wait(epoll_fd, events, NUM_POLL_EVENTS, NO_SLEEP); if (events[i].data.fd == ml->pipe_read) { handle_listen(vs, ml); } read(ml->pipe_read, &newfd, sizeof(newfd)) //pipe_read=81,newfd=78 ml->last_accepted_fd = newfd; @monado/src/xrt/ipc/server/ipc_server_process.c ipc_server_start_client_listener_thread(vs, newfd); ics->imc.ipc_handle = ipc_handle; //ipc_handle=78,openxr_runtime.out_of_process-25265 os_thread_start(&it->thread, ipc_server_client_thread, (void *)ics); @monado/src/xrt/ipc/server/ipc_server_per_client_thread.c ipc_server_client_thread //新线程,openxr_runtime.out_of_process-26722 volatile struct ipc_client_state *ics = (volatile struct ipc_client_state *)_ics; client_loop(ics); while (ics->server->running) { //开启线程循环 int ret = epoll_wait(epoll_fd, &event, 1, half_a_second_ms); ssize_t len = recv(ics->imc.ipc_handle, &buf, IPC_BUF_SIZE, 0); //ipc_handle=78 @monado/src/xrt/targets/openxr_android/.cxx/Debug/4h1i2215/arm64-v8a/src/xrt/ipc/ipc_server_generated.c xrt_result_t result = ipc_dispatch(ics, ipc_command); @monado/src/xrt/ipc/server/ipc_server_handler.c case IPC_SWAPCHAIN_ACQUIRE_IMAGE: reply.result = ipc_handle_swapchain_acquire_image(ics, msg->id,&reply.index); xrt_result_t ret = ipc_send((struct ipc_message_channel *)&ics->imc, &reply, sizeof(reply)); return fd.getFd(); socket = dup(socket); //复制一份fd=77,openxr.hello_xr.opengles ipc_c->imc.ipc_handle = socket; //77


http://www.kler.cn/a/304064.html

相关文章:

  • 什么是两化融合
  • 计算机网络分析题
  • LLM时代下Embedding模型如何重塑检索、增强生成
  • srs http-flv处理过程
  • 力扣--树题总结
  • 超详细:三大范式和反范式设计详解
  • SpringBoot常见面试题
  • 【前端】 flex布局详解
  • JavaScript StartsWith()方法
  • 从用户数据到区块链:Facebook如何利用去中心化技术
  • Postgresql 删除数组中的元素
  • Linux系统使用Docker安装DockerUI并实现远程管理本地容器无需公网IP
  • Prompt最佳实践|善用分隔符,让你的Prompt更清晰
  • 解决VScode中每次git push或者pull都需要重新输入账户名和密码问题
  • PL/SQL Developer工具的使用
  • 【数据结构初阶】队列接口实现及用队列实现栈超详解
  • 基于SpringBoot的高校电动车租赁服务管理系统
  • 智能化等保测评工具的兴起与应用实践
  • 房产销售系统:SpringBoot技术优化方案
  • 在已安装Python环境的基础上安装anaconda或者其他版本Python
  • 使用 RabbitMQ 实现秒杀订单系统的异步消息处理
  • 【C++】Linux平台C++实现Socket通信(Unix域、TCP/IP、UDP)
  • 基于Python的B站热门视频可视化分析与挖掘系统
  • 伊顿穆勒Moeller控制器电源维修easy 619-AC-RCX
  • CAESES许可证转移方法
  • Keras深度学习中文文本分类