在android 侧和 qnx 侧都指定mmid 使用habmm_socket_open 创建通讯channel
使用user_os_utils_send_recv完成消息的发送和接收
apps/qnx_ap/AMSS/multimedia/display/Hoya/wfd_be_qnx/src
/* -----------------------------------------------------------------------------
932 * Main
933 * ---------------------------------------------------------------------------*/
934 int main(int argc, char **argv)
935 {
936 uint32_t uI = 0x00;
937 uint32_t uJ = 0x00;
938 int iStatus = 0x00;
939 int iHabRet = 0x00;
940 uint32_t uDispID = 0x00;
941 uint32_t uClientIdx = 6; /* WFD_CLIENT_ID_LV_GVM is default */
942 int iArgFoundIndex = -1;
943 int rc = 0x00;
944 client_app_ctx *psCtx = &gCtx;
945 u32 uPacketSize = 0x00;
946 struct openwfd_req *psWFDReq = NULL;
947 struct openwfd_resp *psWFDResp = NULL;
948 struct openwfd_cmd *psWFDcmd = NULL;
949 struct openwfd_cmd *psWFDcmd_resp = NULL;
950 struct wire_header *psHDR = NULL;
951 struct wire_packet sReq;
952 struct wire_packet sResp;
953 char thread_name[HOST_OS_UTILS_THREAD_NAME_LEN_IN_BYTES];
954 struct sched_param params;
955 client_buf_channel_ctx sBufCtx;
956
957 params.sched_priority = THREAD_PRIORITY;
958 if (sched_setparam(0, ¶ms))
959 {
960 fprintf(stderr, "sched_setparam() failed %d \n", errno);
961 }
962
963 // Register signal and signal handler
964 signal(SIGINT, signal_handler);
965 signal(SIGTERM, signal_handler);
966
967 /* Arguments processing */
968 if (1 != argc)
969 {
970 /* print help info */
971 iArgFoundIndex = searchArgv(argc, argv, ARGV_PRINT_HELP);
972 if (-1 != iArgFoundIndex)
973 {
974 printHelp();
975 return 0;
976 }
977
978 uClientIdx = atoi(argv[1]);
979 fprintf(stderr, "passed in uClientIdx=%d\n", uClientIdx);
980
981 if (WFD_CLIENT_TYPE_MAX <= uClientIdx)
982 {
983 fprintf(stderr, "uClientIdx=%d is invalid, exiting...\n", uClientIdx);
984 return -1;
985 }
986 } //END: if 1 != argc
987
988 /* [TODO] Currently, we index all the entries at position 0 since we do not know the type for the client.
989 * Following initialization will be terminated once we pass-in the type as a parameter to the wfd_be app.
990 * The change will allows us to index at the right position for channel_map array for hab channel connection.
991 */
992 uClientIdx = WFD_CLIENT_TYPE_NONE;
993
994 /* init slog buffer */
995 if (-1 == host_os_utils_log_open())
996 {
997 fprintf(stderr, "%s host_os_utils_log_open Failed\n", __FUNCTION__);
998 return -1;
999 }
1000
1001 /* init Wire Host */
1002 if (0 != wire_host_init())
1003 {
1004 WFD_BE_LOG_ERROR("wire_host_init() failed");
1005 return -1;
1006 }
1007
1008 memset((char *)psCtx, 0x00, sizeof(client_app_ctx));
1009
1010 for (uI = 0; uI < WFD_APP_NUM_THREADS; uI++)
1011 {
1012 if (0 == MM_SignalQ_Create(&psCtx->sThreadInfo[uI].uThreadSigQueue))
1013 {
1014 if (0 != MM_Signal_Create(psCtx->sThreadInfo[uI].uThreadSigQueue,
1015 NULL, NULL,
1016 &psCtx->sThreadInfo[uI].uThreadSigHdl))
1017 {
1018 WFD_BE_LOG_ERROR("Failed to create a signal handle");
1019 iStatus = -1;
1020 MM_SignalQ_Release(psCtx->sThreadInfo[uI].uThreadSigQueue);
1021 goto MAIN_END;
1022 }
1023 }
1024 else
1025 {
1026 WFD_BE_LOG_ERROR("failed to create signal queue");
1027 iStatus = -1;
1028 goto MAIN_END;
1029 }
1030
1031 WFD_BE_LOG_INFO("uThreadSigQueue=%p uThreadSigHdl=%p",
1032 psCtx->sThreadInfo[uI].uThreadSigQueue,
1033 psCtx->sThreadInfo[uI].uThreadSigHdl);
1034 }
1035
1036 /* create worker thread for commit */
1037 for (uI = 0; uI < WFD_NUM_DISPLAY; uI++)
1038 {
1039 if (uI >= WFD_APP_NUM_THREADS)
1040 {
1041 WFD_BE_LOG_ERROR("Err: pthread create exceed max thread");
1042 break;
1043 }
1044 if (0 != MM_CriticalSection_Create(&psCtx->sThreadInfo[uI].uThreadLock))
1045 {
1046 WFD_BE_LOG_ERROR("CS creation failed, exiting");
1047 goto MAIN_END;
1048 }
1049 snprintf(thread_name,
1050 HOST_OS_UTILS_THREAD_NAME_LEN_IN_BYTES,
1051 "%s_%s_%u",
1052 HOST_OS_UTILS_LOG_MODULE_NAME,
1053 HOST_OS_UTILS_COMMIT_WORKER_NAME,
1054 uI);
1055 psCtx->sThreadInfo[uI].eThreadCtrl = THREAD_RUNNING;
1056 psCtx->sThreadInfo[uI].uArg = uI;
1057 if (0 != MM_Thread_CreateEx(THREAD_PRIORITY,
1058 0,
1059 &commit_worker,
1060 &psCtx->sThreadInfo[uI].uArg,
1061 THREAD_STACK_SIZE,
1062 thread_name,
1063 &psCtx->sThreadInfo[uI].uThreadHdl))
1064 {
1065 WFD_BE_LOG_ERROR("Err pthread_create failed on commit_worker");
1066 goto MAIN_END;
1067 }
1068 }
1069
1070 /* create worker threads for vsync */
1071 for (uI = WFD_NUM_DISPLAY; uI < (WFD_NUM_DISPLAY * 2); uI++)
1072 {
1073 if (uI > WFD_APP_NUM_THREADS)
1074 {
1075 WFD_BE_LOG_ERROR("Err: pthread create exceed max thread");
1076 break;
1077 }
1078 if (0 != MM_CriticalSection_Create(&psCtx->sThreadInfo[uI].uThreadLock))
1079 {
1080 WFD_BE_LOG_ERROR("CS creation failed, exiting");
1081 goto MAIN_END;
1082 }
1083 snprintf(thread_name,
1084 HOST_OS_UTILS_THREAD_NAME_LEN_IN_BYTES,
1085 "%s_%s_%u",
1086 HOST_OS_UTILS_LOG_MODULE_NAME,
1087 HOST_OS_UTILS_VSYNC_LISTENER_NAME,
1088 uI - WFD_NUM_DISPLAY);
1089 psCtx->sThreadInfo[uI].eThreadCtrl = THREAD_RUNNING;
1090 psCtx->sThreadInfo[uI].uArg = uI;
1091 if (0 != MM_Thread_CreateEx(THREAD_PRIORITY,
1092 0,
1093 &vsync_listener,
1094 &psCtx->sThreadInfo[uI].uArg,
1095 THREAD_STACK_SIZE,
1096 thread_name,
1097 &psCtx->sThreadInfo[uI].uThreadHdl))
1098 {
1099 WFD_BE_LOG_ERROR("Err pthread_create failed on event_listener");
1100 goto MAIN_END;
1101 }
1102 }
1103
1104 if (0 != MM_CriticalSection_Create(&psCtx->uCBChlLock))
1105 {
1106 WFD_BE_LOG_ERROR("CS creation failed, exiting");
1107 goto MAIN_END;
1108 }
1109 drop_abilities_wfd_be();
1110 while(!psCtx->iExitApp)
1111 {
1112 WFD_BE_LOG_CRITICAL_INFO("creating channels for uClientIdx=%d, batch_support=%d",
1113 uClientIdx, ENABLE_BATCH_COMMIT);
1114
1115 if (0x00 != channel_map[uClientIdx][HYP_CMD_CHANNEL_IDX])
1116 {
1117 /* create hypervisor channel with HAB */
1118 iHabRet = habmm_socket_open(&psCtx->iCmdChlHdl,
1119 channel_map[uClientIdx][HYP_CMD_CHANNEL_IDX],
1120 (uint32_t)HYPERVISOR_NO_TIMEOUT_VAL,
1121 0x00);
1122 if (0x00 != iHabRet)
1123 {
1124 WFD_BE_LOG_ERROR("habmm_socket_open() failed, iHabRet=%d", iHabRet);
1125 goto MAIN_END;
1126 }
1127 WFD_BE_LOG_CRITICAL_INFO("habmm_socket_open successful w iHabHandle=%d MM_ID=%d",
1128 psCtx->iCmdChlHdl, channel_map[uClientIdx][HYP_CMD_CHANNEL_IDX]);
1129 }
1130
1131 if (0x00 != channel_map[uClientIdx][HYP_EVENT_CHANNEL_IDX])
1132 {
1133

最低0.47元/天 解锁文章
761

被折叠的 条评论
为什么被折叠?



