ScanAsyncFile::ScanAsyncFile(MSec timeout_,ulen max_packets) : pset("ScanAsyncFile.pset",max_packets), timeout(timeout_), final_timeout(3*timeout_), mutex("ScanAsyncFile"), sem("ScanAsyncFile") { init_slots(); }
static struct taginfo * init_struct_info(TNF *tnf, tnf_ref32_t *tag, struct taginfo *info) { if ((!INFO_STRUCT(info)) || (INFO_DERIVED(info) || INFO_ARRAY(info) || INFO_SCALAR(info))) _tnf_error(tnf, TNF_ERR_INTERNAL); if (info->size == (size_t)-1) _tnf_error(tnf, TNF_ERR_BADTNF); /* Get slot information */ init_slots(tnf, tag, info); return (info); }
int main(int argc, char* argv[]) { struct connection conn; iopoll_fd fds[2]; int selfpipe; int i; msg_debug_init(); testmode = getenv("TESTMODE") != 0; if ((shell_argv = malloc((argc + 3) * sizeof *argv)) == 0) die_oom(111); for (i = 1; i < argc; ++i) shell_argv[i-1] = argv[i]; for (; i < argc + 4; ++i) shell_argv[i-1] = 0; shell_argc = argc - 1; if ((path = getenv("PATH")) == 0) die1(111, "No PATH is set"); if ((devnull = open("/dev/null", O_RDWR)) == -1) die1sys(111, "Could not open \"/dev/null\""); if (!nonblock_on(0)) die1sys(111, "Could not set non-blocking status"); if ((selfpipe = selfpipe_init()) == -1) die1sys(111, "Could not create self-pipe"); init_slots(); connection_init(&conn, 0, 0); fds[0].fd = 0; fds[0].events = IOPOLL_READ; fds[1].fd = selfpipe; fds[1].events = IOPOLL_READ; for (;;) { if (iopoll_restart(fds, 2, -1) == -1) die1sys(111, "Poll failed"); if (fds[0].revents) if (connection_read(&conn, handle_packet) <= 0) break; if (fds[1].revents) { read(selfpipe, &i, 1); handle_child(WNOHANG); } } msg1("Waiting for remaining slots to complete"); while (slots_used > 0) handle_child(0); return 0; }
void ICACHE_FLASH_ATTR createServer() { init_slots(); fifo_init(msg_queue, SENT_QUEUE_LENGTH); pTcpServer = (struct espconn *) os_zalloc(sizeof(struct espconn)); if (pTcpServer == NULL) { debug_print_str_uart("TcpServer Failure\r\n"); return; } debug_print_str_uart("createServer \n\r"); pTcpServer->type = ESPCONN_TCP; pTcpServer->state = ESPCONN_NONE; pTcpServer->proto.tcp = (esp_tcp *) os_zalloc(sizeof(esp_tcp)); pTcpServer->proto.tcp->local_port = 300; espconn_regist_connectcb(pTcpServer, at_tcpserver_listen); espconn_accept(pTcpServer); espconn_regist_time(pTcpServer, 180, 0); }
static struct taginfo * init_array_info(TNF *tnf, tnf_ref32_t *tag, struct taginfo *info) { tnf_ref32_t *elt_tag; int defeat; if ((!INFO_ARRAY(info)) || (INFO_DERIVED(info) || INFO_STRUCT(info) || INFO_SCALAR(info))) _tnf_error(tnf, TNF_ERR_INTERNAL); /* XXX special-case abstract array tag */ defeat = (strcmp(info->name, TNF_N_ARRAY) == 0); /* Require all arrays to be self-sized records */ if (!(INFO_TAGGED(info) && (info->size == (size_t)-1))) if (!defeat) _tnf_error(tnf, TNF_ERR_BADTNF); /* Store array header size */ info->hdrsize = _tnf_get_header_size(tnf, tag); /* XXX Temporary sanity check */ if (info->hdrsize != sizeof (struct tnf_array_hdr)) if (!defeat) _tnf_error(tnf, TNF_ERR_BADTNF); /* Get slot information */ init_slots(tnf, tag, info); /* Get info for element type */ elt_tag = (tnf_ref32_t *)_tnf_get_slot_typed(tnf, tag, /* LINTED pointer cast may result in improper alignment */ TNF_N_ELEMENT_TYPE); /* XXX tnf_array has element_type == NULL */ info->base = elt_tag ? _tnf_get_info(tnf, elt_tag): NULL; return (info); }
void ScanAsyncFile::open(StrLen dev_name,StrLen dev_file_name) { if( is_opened ) { Printf(Exception,"CCore::ScanAsyncFile::open(...) : file is already opened"); } TimeScope time_scope(timeout); Packet<uint8> packet=pset.get(time_scope); if( !packet ) { Printf(Exception,"CCore::ScanAsyncFile::open(...) : no packet"); } Packet<uint8,Sys::AsyncFile::OpenExt> packet2=packet.pushExt<Sys::AsyncFile::OpenExt>(); packet2.pushCompleteFunction(function_complete_open()); file.open(packet2,dev_name,dev_file_name,Open_ToRead); pset.wait(time_scope); if( !is_opened ) { file.closeState(); Printf(Exception,"CCore::ScanAsyncFile::open(#.q;,#.q;) : #;",dev_name,dev_file_name,error); } init_slots(); reset(); pump(); }
int tc_filter(frame_list_t *ptr_, char *options){ vframe_list_t * ptr = (vframe_list_t *)ptr_; int frame_slot = 0; static vob_t *vob=NULL; static int slots[TC_FRAME_THREADS_MAX]; if(ptr->tag & TC_FILTER_GET_CONFIG) { optstr_filter_desc (options, MOD_NAME, MOD_CAP, MOD_VERSION, "Julien Tierny", "VRYMO", "1"); optstr_param (options, "font", "Valid PSF font file (provided with the `aart` package)", "%s", "default8x9.psf"); optstr_param (options, "pallete", "Valid pallete file (provided with the `aart` package)", "%s", "colors.pal"); optstr_param(options, "threads", "Use multiple-threaded routine for picture rendering", "%d", "0", "1", "oo"); /* Boolean parameter */ optstr_param(options, "buffer", "Use `aart` internal buffer for output", "", "-1"); return 0; } //---------------------------------- // // filter init // //---------------------------------- if(ptr->tag & TC_FILTER_INIT) { if((vob = tc_get_vob())==NULL) return(-1); /* aart sanity check */ if (tc_test_program("aart") !=0 ) return -1; /* Now, let's handle the options ... */ if((parameters = tc_malloc (sizeof(parameter_struct))) == NULL){ tc_log_error(MOD_NAME, "Out of memory !!!"); return -1; } /* Filter default options */ if (verbose & TC_DEBUG) tc_log_info(MOD_NAME, "Preparing default options."); strncpy(parameters->aart_font, "default8x9.psf", strlen("default8x9.psf")); if (verbose & TC_DEBUG) tc_log_info(MOD_NAME, "Default options correctly formated."); strncpy(parameters->aart_pallete, "colors.pal", strlen("colors.pal")); parameters->aart_threads = 1; parameters->aart_buffer = -1; parameters->tcvhandle = 0; if (options){ /* Get filter options via transcode core */ if (verbose & TC_DEBUG) tc_log_info(MOD_NAME, "Merging options from transcode."); optstr_get(options, "font", "%s", parameters->aart_font); clean_parameter(parameters->aart_font); optstr_get(options, "pallete", "%s", parameters->aart_pallete); clean_parameter(parameters->aart_pallete); optstr_get(options, "threads", "%d", ¶meters->aart_threads); if (optstr_lookup(options, "buffer") != NULL) parameters->aart_buffer=1; if (optstr_lookup(options, "help") != NULL) help_optstr(); if (verbose & TC_DEBUG) tc_log_info(MOD_NAME, "Options correctly merged."); } if (vob->im_v_codec == CODEC_YUV){ if (!(parameters->tcvhandle = tcv_init())) { tc_log_error(MOD_NAME, "Error at image conversion initialization."); return(-1); } } /* Init thread slots (multithread support)*/ init_slots(slots); if(verbose) tc_log_info(MOD_NAME, "%s %s", MOD_VERSION, MOD_CAP); return(0); } //---------------------------------- // // filter close // //---------------------------------- if(ptr->tag & TC_FILTER_CLOSE) { /* * TODO : * Provide a `aart` kill routine in case of cancel. * For the moment, transcode waits for the `aart` * process to finish before exiting. */ tcv_free(parameters->tcvhandle); /* Let's free the parameter structure */ free(parameters); parameters = NULL; return(0); } //---------------------------------- // // filter frame routine // //---------------------------------- if(ptr->tag & TC_POST_M_PROCESS && ptr->tag & TC_VIDEO && !(ptr->attributes & TC_FRAME_IS_SKIPPED)) { frame_slot = find_empty_slot(ptr->id, slots); switch(vob->im_v_codec){ case CODEC_RGB: return aart_render(ptr->video_buf, ptr->v_width, ptr->v_height, frame_slot, parameters->aart_font, parameters->aart_pallete, parameters->aart_threads, parameters->aart_buffer); break; case CODEC_YUV: if (!tcv_convert(parameters->tcvhandle, ptr->video_buf, ptr->video_buf, ptr->v_width, ptr->v_height, IMG_YUV_DEFAULT, IMG_RGB24)){ tc_log_error(MOD_NAME, "cannot convert YUV stream to RGB format !"); return -1; } if (aart_render(ptr->video_buf, ptr->v_width, ptr->v_height, frame_slot, parameters->aart_font, parameters->aart_pallete, parameters->aart_threads, parameters->aart_buffer) == -1){return -1;} if (!tcv_convert(parameters->tcvhandle, ptr->video_buf, ptr->video_buf, ptr->v_width, ptr->v_height, IMG_RGB24, IMG_YUV_DEFAULT)){ tc_log_error(MOD_NAME, "cannot convert RGB stream to YUV format !"); return -1; } break; default: tc_log_error(MOD_NAME, "Internal video codec is not supported."); return -1; } free_slot(ptr->id, slots); } return(0); }