void Renderer::on_ctx_create() { ctx_create(); if (app_alive()) app().on_graphics_created(); }
/* === entry point === */ int main(int argc, char** argv) { char cmdbuf[4096]; tsk_buffer_t* buffer = tsk_null; cmd_t* cmd = tsk_null; tsk_bool_t comment = tsk_false; int ret; int i, index; const char* start = tsk_null, *end = tsk_null; int a = 32 | 1 | 2; /* Copyright */ printf("Doubango Project (tinyDEMO)\nCopyright (C) 2009 - 2013 Mamadou Diop \n\n"); /* Initialize Network Layer ==> Mandatory */ tnet_startup(); /* Initialize Doubango Audio/Video Framework ==> will register all plugins(codecs and sessions) * Not mandatory if you have your own plugins*/ tdav_init(); /* Print Usage */ //cmd_print_help(); /* create user's ctx */ if(!(ctx = ctx_create()) || !ctx->stack){ TSK_DEBUG_ERROR("Failed to create user's ctx."); goto bail; } /* create new buffer */ if(!(buffer = tsk_buffer_create_null())){ TSK_DEBUG_ERROR("Failed to create new buffer."); goto bail; } /* initial args */ for(i=1 /* index zero contains the exe path */, index=0; i<argc && argv[i]; i++){ if(index){ tsk_buffer_append(buffer, " ", 1); } tsk_buffer_append(buffer, argv[i], tsk_strlen(argv[i])); } /* If initial args ==> parse it now */ if(buffer->size){ TSK_DEBUG_INFO("Initial command-line: %s", buffer->data); goto init_buffer; } /* always use fgets() instead of gets. gets() is considered to be unsafe.(Android and Mac OS X will warn) */ while(fgets(cmdbuf, sizeof(cmdbuf), stdin)){ TSK_DEBUG_INFO("Command-Line: %s", cmdbuf); tsk_buffer_cleanup(buffer); /* cannot read from console while executing scenario */ tsk_buffer_append(buffer, cmdbuf, tsk_strlen(cmdbuf)); init_buffer: start = buffer->data; //start = trim(start); end = start + buffer->size; if(start >= end){ TSK_DEBUG_INFO("Empty buffer"); continue; } parse_buffer: TSK_OBJECT_SAFE_FREE(cmd); /* Free old value */ cmd = cmd_parse(start, (end-start), &comment, ctx->params); if(cmd){ if(comment || cmd->type == cmd_none){ goto nex_line; } } else{ continue; } /* Load from scenario file? */ if(cmd->type == cmd_scenario){ FILE* file; const opt_t* opt; tsk_size_t read = 0; tsk_bool_t rm_lf = tsk_false; if((opt = opt_get_by_type(cmd->opts, opt_path)) && !tsk_strnullORempty(opt->value)){ /* --path option */ if((file = fopen(opt->value, "r"))){ memset(cmdbuf, '\0', sizeof(cmdbuf)), cmdbuf[0] = '\n'; read = fread(cmdbuf+1, sizeof(uint8_t), sizeof(cmdbuf)-1, file); fclose(file), file = tsk_null; if(read == 0){ TSK_DEBUG_ERROR("[%s] is empty.", opt->value); goto nex_line; } else if(read == sizeof(cmdbuf)-1){ TSK_DEBUG_ERROR("Buffer too short."); goto nex_line; } read++; /* \n */ /* repplace all '\' with spaces (easier than handling that in the ragel file) */ for(i=0; ((tsk_size_t)i)<read; i++){ if(cmdbuf[i] == '\\'){ cmdbuf[i] = ' '; rm_lf = tsk_true; } else if(rm_lf && cmdbuf[i] == '\n'){ cmdbuf[i] = ' '; rm_lf = tsk_false; } } cmdbuf[read] = '\n'; /* insert embedded scenario */ if((index = tsk_strindexOf(start, (end-start), "\n")) == -1){ /* ++sn line */ index = buffer->size; } else{ index += (start - ((const char*)buffer->data)); } if(tsk_buffer_insert(buffer, index, cmdbuf, read)){ continue; } else{ start = ((const char*)buffer->data) + index; // because insert use realloc() end = (((const char*)buffer->data) + buffer->size); goto nex_line; } } else{ TSK_DEBUG_ERROR("Failed to open scenario-file [%s].", opt->value); goto nex_line; } continue; } else{ TSK_DEBUG_ERROR("++scenario command must have --path option."); continue; } } /* execute current command */ switch(cmd->type){ case cmd_exit: TSK_DEBUG_INFO("Exit/Quit"); goto bail; default: ret = execute(cmd); break; } /* next line */ nex_line: if((index = tsk_strindexOf(start, (end - start), "\n")) !=-1){ start += index; while((start < end) && isspace(*start)){ start ++; } if((start + 2/*++*/) < end){ goto parse_buffer; /* next line */ } else{ continue; /* wait for new commands */ } } } /* while(buffer) */ bail: /* Free current command */ TSK_OBJECT_SAFE_FREE(cmd); /* Free buffer */ TSK_OBJECT_SAFE_FREE(buffer); /* Destroy the user's ctx */ TSK_OBJECT_SAFE_FREE(ctx); /* Deinitialize Doubango Audio/Video Framework ==> will unregister all plugins(codecs and sessions) * Not mandatory */ tdav_init(); /* Uninitilize Network Layer */ tnet_cleanup(); #if ANDROID exit(0); #endif return 0; }
int shmem_ctx_create(long options, shmem_ctx_t *ctx) { return MCA_SPML_CALL(ctx_create(options, ctx)); }