void ximsWaitDone() { int ret; UserSelection *sel = &userSel; DPR(("ximsWaitDone():\tOpState=%s OpErrCode=%s[%d]\n", StateName(), error_name(OpErrCode), OpErrCode)); set_sig_chld(False); ret = sel->renv->status; switch (ret) { case ErrImsWaiting: sel->status = ErrImsTimeout; put_xims_log("'%s' timed-out.", sel->name, 0, 0); break; case ErrImsWaitDone: sel->status = NoError; # ifdef old_hpux if ((OpFlag & FLAG_CONNECT) || (sel->ent->ims->flags & F_TRY_CONNECT)) { sel->status = try_connection(sel); } # endif /* old_hpux */ break; case ErrImsConnecting: case ErrImsConnectDone: sel->status = NoError; break; case ErrImsAborted: /* put_xims_log("'%s' aborted.", sel->name, 0, 0); */ case ErrImsExecution: default: sel->status = ret; break; } if (sel->status != NoError) { OpErrCode = sel->status; DPR(("ximsWaitDone(): OpErrCode=%s[%d]\n", error_name(OpErrCode), OpErrCode)); } restore_resources(); settle_ims(sel); /* clear WM_COMMAND property */ OpState = OpErrCode == NoError ? State_Wait_Done : State_Wait_Err; ximsMain(); }
int minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { android::sp<android::IBinder> dpy = android::SurfaceComposerClient::getBuiltInDisplay(displayId); android::Vector<android::DisplayInfo> configs; android::status_t err = android::SurfaceComposerClient::getDisplayConfigs(dpy, &configs); if (err != android::NO_ERROR) { MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); return err; } int activeConfig = android::SurfaceComposerClient::getActiveConfig(dpy); if(static_cast<size_t>(activeConfig) >= configs.size()) { MCERROR("Active config %d not inside configs (size %zu)\n", activeConfig, configs.size()); return android::BAD_VALUE; } android::DisplayInfo dinfo = configs[activeConfig]; info->width = dinfo.w; info->height = dinfo.h; info->orientation = dinfo.orientation; info->fps = dinfo.fps; info->density = dinfo.density; info->xdpi = dinfo.xdpi; info->ydpi = dinfo.ydpi; info->secure = dinfo.secure; info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); return 0; }
virtual int consumePendingFrame(Minicap::Frame* frame) { android::status_t err; if ((err = mConsumer->lockNextBuffer(&mBuffer)) != android::NO_ERROR) { if (err == -EINTR) { return err; } else { MCERROR("Unable to lock next buffer %s (%d)", error_name(err), err); return err; } } frame->data = mBuffer.data; frame->format = convertFormat(mBuffer.format); frame->width = mBuffer.width; frame->height = mBuffer.height; frame->stride = mBuffer.stride; frame->bpp = android::bytesPerPixel(mBuffer.format); frame->size = mBuffer.stride * mBuffer.height * frame->bpp; mHaveBuffer = true; return 0; }
virtual int consumePendingFrame(Minicap::Frame* frame) { uint32_t width, height; android::PixelFormat format; android::status_t err; mHeap = NULL; err = mComposer->captureScreen(mDisplayId, &mHeap, &width, &height, &format, mDesiredWidth, mDesiredHeight, 0, -1UL); if (err != android::NO_ERROR) { MCERROR("ComposerService::captureScreen() failed %s", error_name(err)); return err; } frame->data = mHeap->getBase(); frame->width = width; frame->height = height; frame->format = convertFormat(format); frame->stride = width; frame->bpp = android::bytesPerPixel(format); frame->size = mHeap->getSize(); return 0; }
void ximsWait() { OpStateVal oldOpState = OpState; UserSelection *sel = &userSel; struct timeval interval; time_t start_tm = 0; int lapse; DPR(("ximsWait(): OpState=%s OpErrCode=%s[%d]\n", StateName(), error_name(OpErrCode), OpErrCode)); OpState = State_Wait; if (oldOpState == State_Start_Err) { /* don't change OpErrCode */ OpState = State_Wait_Err; return; } if (!is_waiting() || (OpFlag & FLAG_NOWAIT)) { ximsWaitDone(); } if (im_mod_available(sel->renv) != 1) { if (useWINDOW()) { xt_start_waiting(); /* never returns unless failed */ } /* waiting */ lapse = 0; interval.tv_sec = Opt.Interval / 1000; interval.tv_usec = (Opt.Interval % 1000) * 1000; start_tm = time((time_t) 0); while (is_waiting()) { select(0, 0, 0, 0, &interval); /* usleep */ lapse = (int) time((time_t) 0) - start_tm; if (im_mod_available(sel->renv) != 0 || lapse >= Opt.Timeout) { DPR(("ximsWait(tmout=%d): wait done (%d sec.)\n", Opt.Timeout, lapse)); break; } } } ximsWaitDone(); }
void PrintXErrorAndCoredump(Display *dpy, XErrorEvent *error, char *MyName) { char msg[256]; Bool suc = False; msg[255] = 0; #ifdef USE_GET_ERROR_TEXT /* can't call this from within an error handler! */ /* DV (21-Nov-2000): Well, actually we *can* call it in an error * handler since it does not trigger a protocol request. */ if (error->error_code >= FirstExtensionError) { suc = FRenderGetErrorText(error->error_code, msg); } if (!suc) XGetErrorText(dpy, error->error_code, msg, sizeof(msg)); fprintf(stderr,"%s: Cause of next X Error.\n", MyName); fprintf(stderr, " Error: %d (%s)\n", error->error_code, msg); #else fprintf(stderr,"%s: Cause of next X Error.\n", MyName); if (error->error_code >= FirstExtensionError) { suc = FRenderGetErrorText(error->error_code, msg); } if (suc) fprintf(stderr, " Error: %d (%s)\n", error->error_code, msg); else fprintf(stderr, " Error: %d (%s)\n", error->error_code, error_name(error->error_code)); #endif fprintf(stderr, " Major opcode of failed request: %d (%s)\n", error->request_code, request_name(error->request_code)); fprintf(stderr, " Minor opcode of failed request: %d \n", error->minor_code); /* error->resourceid may be uninitialised. This is no proble since we * are dumping core anyway. */ fprintf(stderr, " Resource id of failed request: 0x%lx \n", error->resourceid); /* leave a coredump */ do_coredump(); }
int minicap_try_get_display_info(int32_t displayId, Minicap::DisplayInfo* info) { android::DisplayInfo dinfo; android::status_t err = android::SurfaceComposerClient::getDisplayInfo(displayId, &dinfo); if (err != android::NO_ERROR) { MCERROR("SurfaceComposerClient::getDisplayInfo() failed: %s (%d)\n", error_name(err), err); return err; } info->width = dinfo.w; info->height = dinfo.h; info->orientation = dinfo.orientation; info->fps = dinfo.fps; info->density = dinfo.density; info->xdpi = dinfo.xdpi; info->ydpi = dinfo.ydpi; info->secure = false; info->size = sqrt(pow(dinfo.w / dinfo.xdpi, 2) + pow(dinfo.h / dinfo.ydpi, 2)); return 0; }
static void disassemble(Program * prog, Printer p, void *data) { Stream *s = new_stream(100); Stream *insn = new_stream(50); int i, l; unsigned pc; Bytecodes bc; const char *ptr; const char **names = prog->var_names; unsigned tmp, num_names = prog->num_var_names; # define NAMES(i) (tmp = i, \ tmp < num_names ? names[tmp] \ : "*** Unknown variable ***") Var *literals = prog->literals; initialize_tables(); print = p; print_data = data; stream_printf(s, "Language version number: %d", (int) prog->version); output(s); stream_printf(s, "First line number: %d", prog->first_lineno); output(s); for (i = -1; i < 0 || i < prog->fork_vectors_size; i++) { output(s); if (i == -1) { stream_printf(s, "Main code vector:"); output(s); stream_printf(s, "================="); output(s); bc = prog->main_vector; } else { stream_printf(s, "Forked code vector %d:", i); l = stream_length(s); output(s); while (l--) stream_add_char(s, '='); output(s); bc = prog->fork_vectors[i]; } stream_printf(s, "[Bytes for labels = %d, literals = %d, ", bc.numbytes_label, bc.numbytes_literal); stream_printf(s, "forks = %d, variables = %d, stack refs = %d]", bc.numbytes_fork, bc.numbytes_var_name, bc.numbytes_stack); output(s); stream_printf(s, "[Maximum stack size = %d]", bc.max_stack); output(s); max_bytes_width = 5; for (pc = 0; pc < bc.size;) { Byte b; unsigned arg; # define ADD_BYTES(n) (arg = add_bytes(s, bc.vector, pc, n), \ pc += n, \ arg) unsigned a1, a2; new_insn(s, pc); b = add_bytes(s, bc.vector, pc++, 1); if (b != OP_EXTENDED) stream_add_string(insn, COUNT_TICK(b) ? " * " : " "); if (IS_OPTIM_NUM_OPCODE(b)) stream_printf(insn, "NUM %d", OPCODE_TO_OPTIM_NUM(b)); #ifdef BYTECODE_REDUCE_REF else if (IS_PUSH_CLEAR_n(b)) stream_printf(insn, "PUSH_CLEAR %s", NAMES(PUSH_CLEAR_n_INDEX(b))); #endif /* BYTECODE_REDUCE_REF */ else if (IS_PUSH_n(b)) stream_printf(insn, "PUSH %s", NAMES(PUSH_n_INDEX(b))); else if (IS_PUT_n(b)) stream_printf(insn, "PUT %s", NAMES(PUT_n_INDEX(b))); else if (b == OP_EXTENDED) { b = ADD_BYTES(1); stream_add_string(insn, COUNT_EOP_TICK(b) ? " * " : " "); stream_add_string(insn, ext_mnemonics[b]); switch ((Extended_Opcode) b) { case EOP_WHILE_ID: a1 = ADD_BYTES(bc.numbytes_var_name); a2 = ADD_BYTES(bc.numbytes_label); stream_printf(insn, " %s %d", NAMES(a1), a2); break; case EOP_EXIT_ID: stream_printf(insn, " %s", NAMES(ADD_BYTES(bc.numbytes_var_name))); /* fall thru */ case EOP_EXIT: a1 = ADD_BYTES(bc.numbytes_stack); a2 = ADD_BYTES(bc.numbytes_label); stream_printf(insn, " %d %d", a1, a2); break; case EOP_PUSH_LABEL: case EOP_END_CATCH: case EOP_END_EXCEPT: case EOP_TRY_FINALLY: stream_printf(insn, " %d", ADD_BYTES(bc.numbytes_label)); break; case EOP_TRY_EXCEPT: stream_printf(insn, " %d", ADD_BYTES(1)); break; case EOP_LENGTH: stream_printf(insn, " %d", ADD_BYTES(bc.numbytes_stack)); break; case EOP_SCATTER: { int i, nargs = ADD_BYTES(1); a1 = ADD_BYTES(1); a2 = ADD_BYTES(1); stream_printf(insn, " %d/%d/%d:", nargs, a1, a2); for (i = 0; i < nargs; i++) { a1 = ADD_BYTES(bc.numbytes_var_name); a2 = ADD_BYTES(bc.numbytes_label); stream_printf(insn, " %s/%d", NAMES(a1), a2); } stream_printf(insn, " %d", ADD_BYTES(bc.numbytes_label)); } break; default: break; } } else { stream_add_string(insn, mnemonics[b]); switch ((Opcode) b) { case OP_IF: case OP_IF_QUES: case OP_EIF: case OP_AND: case OP_OR: case OP_JUMP: case OP_WHILE: stream_printf(insn, " %d", ADD_BYTES(bc.numbytes_label)); break; case OP_FORK: stream_printf(insn, " %d", ADD_BYTES(bc.numbytes_fork)); break; case OP_FORK_WITH_ID: a1 = ADD_BYTES(bc.numbytes_fork); a2 = ADD_BYTES(bc.numbytes_var_name); stream_printf(insn, " %d %s", a1, NAMES(a2)); break; case OP_FOR_LIST: case OP_FOR_RANGE: a1 = ADD_BYTES(bc.numbytes_var_name); a2 = ADD_BYTES(bc.numbytes_label); stream_printf(insn, " %s %d", NAMES(a1), a2); break; case OP_G_PUSH: #ifdef BYTECODE_REDUCE_REF case OP_G_PUSH_CLEAR: #endif /* BYTECODE_REDUCE_REF */ case OP_G_PUT: stream_printf(insn, " %s", NAMES(ADD_BYTES(bc.numbytes_var_name))); break; case OP_IMM: { Var v; v = literals[ADD_BYTES(bc.numbytes_literal)]; switch (v.type) { case TYPE_OBJ: stream_printf(insn, " #%d", v.v.obj); break; case TYPE_INT: stream_printf(insn, " %d", v.v.num); break; case TYPE_STR: stream_add_string(insn, " \""); for (ptr = v.v.str; *ptr; ptr++) { if (*ptr == '"' || *ptr == '\\') stream_add_char(insn, '\\'); stream_add_char(insn, *ptr); } stream_add_char(insn, '"'); break; case TYPE_ERR: stream_printf(insn, " %s", error_name(v.v.err)); break; default: stream_printf(insn, " <literal type = %d>", v.type); break; } } break; case OP_BI_FUNC_CALL: stream_printf(insn, " %s", name_func_by_num(ADD_BYTES(1))); default: break; } } finish_insn(s, insn); } } free_stream(s); free_stream(insn); }
void ximsStart() { int ret; UserSelection *sel = &userSel; OpStateVal oldOpState = OpState; DPR(("ximsStart(): OpState=%s OpErrCode=%s[%d]\n", StateName(), error_name(OpErrCode), OpErrCode)); OpState = State_Start; #ifdef DEBUG if (DebugLvl > 1) pr_UserSelection(sel); #endif ret = NoError; if (oldOpState == State_Select_Err) { /* don't change OpErrCode */ OpState = State_Start_Err; return; } if (oldOpState == State_Select_Canceled) { clear_UserSelection(sel); ret = ErrNoSelection; } else { /* save selection */ if (!(OpFlag & FLAG_NOSAVE) && (sel->flag & F_SELECT_CHANGED)) { if (save_user_selection(sel, NULL) != NoError) { DPR(("save_user_selection(): failed\n")); put_xims_warnmsg(ErrSaveSelection, 0, 0, 0); /* ret = ErrSaveSelection; */ } } } if (ret != NoError) { OpErrCode = ret; OpState = State_Start_Err; return; } if ((ret = check_selection(sel)) != NoError) { if (ret == ErrIsNone || ret == ErrNotRun) { build_run_env(sel); /* for make_new_environ() */ } OpErrCode = ret; OpState = State_Start_Done; return; } build_run_env(sel); if (useWINDOW()) /* initilaize Xt */ init_window_env(); ret = run_ims(sel); OpErrCode = ret; OpState = ret == NoError ? State_Start_Done : State_Start_Err; return; }