BuxtonBackend *backend_for_layer(BuxtonConfig *config, BuxtonLayer *layer) { BuxtonBackend *backend; int ret; assert(layer); if (!config->databases) { config->databases = hashmap_new(string_hash_func, string_compare_func); if (!config->databases) { abort(); } } if ((backend = (BuxtonBackend*)hashmap_get(config->databases, layer->name.value)) == NULL) { /* attempt load of backend */ init_backend(config, layer, &backend); ret = hashmap_put(config->databases, layer->name.value, backend); if (ret != 1) { abort(); } } return (BuxtonBackend*)hashmap_get(config->databases, layer->name.value); }
int main (int argc, char *argv[]) { guint64 duration; guint width, height, fps_n, fps_d, par_n, par_d; gchar *container, *audio_codec, *video_codec; GstDiscovererResult res; gchar *uri; GError *err = NULL; init_backend (0, NULL); if (argc != 2) { g_print("Usage: test-discoverer file_uri\n"); return 1; } g_print ("Discovering file %s\n", argv[1]); res = lgm_discover_uri (argv[1], &duration, &width, &height, &fps_n, &fps_d, &par_n, &par_d, &container, &video_codec, &audio_codec, &err); if (err != NULL) { g_print ("ERROR: %s\n", err->message); exit (1); } else if (res != GST_DISCOVERER_OK) { g_print ("ERROR: %d\n", res); exit (1); } g_print ("Duration: %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (duration)); if (container != NULL) { g_print ("Container: %s\n", container); } if (video_codec != NULL) { g_print ("Video: %s %dx%d@%d/%d\n", video_codec, width, height, fps_n, fps_d); } if (audio_codec != NULL) { g_print ("Audio: %s\n", audio_codec); } }
BuxtonBackend* backend_for_layer(BuxtonLayer *layer) { BuxtonBackend *backend; assert(layer); if (!_databases) _databases = hashmap_new(string_hash_func, string_compare_func); if ((backend = (BuxtonBackend*)hashmap_get(_databases, layer->name)) == NULL) { /* attempt load of backend */ backend = malloc0(sizeof(BuxtonBackend)); if (!backend) return NULL; if (!init_backend(layer, backend)) { buxton_log("backend_for_layer(): failed to initialise backend for layer: %s\n", layer->name); free(backend); return NULL; } hashmap_put(_databases, layer->name, backend); } return (BuxtonBackend*)hashmap_get(_databases, layer->name); }
int main(int argc, char* argv[]){ ui = new UI(); init_gui(); ui->arranger->take_focus(); load_config(); if(init_backend(&argc, &argv) < 0){ return 1; } if(argc > 1){ if(loadsmf(argv[1])<0){ if(load(argv[1])<0){ reset_song(); } } } else{ reset_song(); } int ret = fltk::run(); shutdown_backend(); delete ui; return ret; }
int main(int argc, char *argv[]) { const char *backend_opts = "X11"; int opt; int pause_flag = 0; while ((opt = getopt(argc, argv, "b:Ii:Ps:r:")) != -1) { switch (opt) { case 'b': backend_opts = optarg; break; default: fprintf(stderr, "Invalid paramter '%c'\n", opt); } } // GP_SetDebugLevel(10); signal(SIGINT, sighandler); signal(SIGSEGV, sighandler); signal(SIGBUS, sighandler); signal(SIGABRT, sighandler); init_backend(backend_opts); context = backend->context; black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context); white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context); GP_Fill(context, black_pixel); GP_BackendFlip(backend); struct space *space; space = space_create(160, 10<<8, 10<<8, (context->w - 10)<<8, (context->h - 10)<<8); for (;;) { if (backend->Poll) GP_BackendPoll(backend); usleep(1000); /* Read and parse events */ GP_Event ev; while (GP_BackendGetEvent(backend, &ev)) { GP_EventDump(&ev); switch (ev.type) { case GP_EV_KEY: if (ev.code != GP_EV_KEY_DOWN) continue; switch (ev.val.key.key) { case GP_KEY_ESC: case GP_KEY_ENTER: case GP_KEY_Q: GP_BackendExit(backend); return 0; break; case GP_KEY_P: pause_flag = !pause_flag; break; case GP_KEY_G: space->gay = 1; break; case GP_KEY_T: space->gay = 0; break; } break; } } if (!pause_flag) { space_time_tick(space, 1); space_draw_particles(context, space); GP_BackendFlip(backend); } } GP_BackendExit(backend); return 0; }
void init_table(struct Table *table) { struct Backend *iter; STAILQ_FOREACH(iter, &table->backends, entries) init_backend(iter); }
int main(int argc, char *argv[]) { char buffer[256]; char *p; BOOLEAN multipleFiles = FALSE; int rv; char realOutFile[260]; char oldOutFile[260]; srand(time(0)); /* signal(SIGSEGV,internalError) ;*/ /* signal(SIGFPE, internalError) ;*/ /* initialize back end */ if (!init_backend(&argc,argv)) fatal("Could not initialize back end"); if (chosenAssembler->Args) { CMDLIST *newArgs = calloc(sizeof(Args) + sizeof(Args[0]) * chosenAssembler->ArgCount, 1); if (newArgs) { memcpy(&newArgs[0], chosenAssembler->Args, chosenAssembler->ArgCount *sizeof(Args[0])); memcpy(&newArgs[chosenAssembler->ArgCount], &Args[0], sizeof(Args)); ArgList = newArgs; } } /* parse environment variables, command lines, and config files */ ccinit(argc, argv); /* loop through and preprocess all the files on the file list */ if (clist && clist->next) multipleFiles = TRUE; #ifdef PARSER_ONLY strcpy(buffer, clist->data); strcpy(realOutFile, outfile); outputfile(realOutFile, buffer, ".ods"); if (!ccDBOpen(realOutFile)) fatal("Cannot open database file %s", realOutFile); #else BitInit(); regInit(); #endif while (clist) { cparams.prm_cplusplus = FALSE; strcpy(buffer, clist->data); #ifndef PARSER_ONLY strcpy(realOutFile, outfile); if (cparams.prm_asmfile) outputfile(realOutFile, buffer, chosenAssembler->asmext); else outputfile(realOutFile, buffer, chosenAssembler->objext); strcpy(oldOutFile, realOutFile); StripExt(oldOutFile); AddExt(oldOutFile, ".tmp"); #else ccNewFile(buffer, TRUE); #endif AddExt(buffer, ".C"); p = strrchr(buffer, '.'); if (*(p - 1) != '.') { if (p[1] == 'h' || p[1] == 'H') // compile H files as C++ for the IDE cparams.prm_cplusplus = TRUE; if (p[1] == 'c' || p[1] == 'C') if (p[2] == 'p' || p[2] == 'P') { if (p[3] == 'p' || p[3] == 'P') cparams.prm_cplusplus = TRUE; } else { if (p[2] == 'x' || p[2] == 'X') { if (p[3] == 'x' || p[3] == 'X') cparams.prm_cplusplus = TRUE; } } else if ((p[2] == 'c' ||p[2] == 'C' ) && !p[3]) { cparams.prm_cplusplus = TRUE; } else { if (p[2] == '+') { if (p[3] == '+') cparams.prm_cplusplus = TRUE; } } } inputFile = SrchPth2(buffer, "", "r"); if (!inputFile) fatal("Cannot open input file %s", buffer); strcpy(infile, buffer); if (cparams.prm_makestubs) { MakeStubs(); } else { #ifndef PARSER_ONLY unlink(oldOutFile); rename(realOutFile, oldOutFile); outputFile = fopen(realOutFile, cparams.prm_asmfile ? "w" : "wb"); if (!outputFile) { fclose(inputFile); fatal("Cannot open output file %s", realOutFile); } setvbuf(outputFile,0,_IOFBF,32768); #endif if (cparams.prm_cppfile) { StripExt(buffer); AddExt(buffer, ".i"); strcpy(cppfile, buffer); cppFile = fopen(buffer, "w"); if (!cppFile) { fclose(inputFile); fclose(outputFile); fatal("Cannot open preprocessor output file %s", buffer); } } if (cparams.prm_listfile) { StripExt(buffer); AddExt(buffer, ".lst"); listFile = fopen(buffer, "w"); if (!listFile) { fclose(inputFile); fclose(cppFile); fclose(outputFile); fatal("Cannot open list file %s", buffer); } } if (cparams.prm_errfile) { StripExt(buffer); AddExt(buffer, ".err"); errFile = fopen(buffer, "w"); if (!errFile) { fclose(inputFile); fclose(cppFile); fclose(listFile); fclose(outputFile); fatal("Cannot open error file %s", buffer); } } if (cparams.prm_browse) { char name[260]; strcpy(name, outfile); StripExt(name); AddExt(name, ".cbr"); browseFile = fopen(name, "wb"); if (!browseFile) { fclose(errFile); fclose(inputFile); fclose(cppFile); fclose(listFile); fclose(outputFile); fatal("Cannot open browse file %s", buffer); } setvbuf(browseFile,0,_IOFBF,32768); } if (cparams.prm_icdfile) { StripExt(buffer); AddExt(buffer, ".icd"); icdFile = fopen(buffer, "w"); if (!icdFile) { fclose(browseFile); fclose(errFile); fclose(inputFile); fclose(cppFile); fclose(listFile); fclose(outputFile); fatal("Cannot open error file %s", buffer); } setvbuf(icdFile,0,_IOFBF,32768); } if (multipleFiles && !cparams.prm_quiet) printf("%s\n", clist->data); compile(); } #ifdef PARSER_ONLY localFree(); #endif globalFree(); if (cparams.prm_diag) { mem_summary(); printf("Intermediate stats:\n"); printf(" Block peak: %d\n", maxBlocks); printf(" Temp peak: %d\n", maxTemps); printf(" Allocation Spills: %d\n", maxAllocationSpills); printf(" Allocation Passes: %d\n", maxAllocationPasses); printf(" Allocation Accesses: %d\n", maxAllocationAccesses); } maxBlocks = maxTemps = maxAllocationSpills = maxAllocationPasses = maxAllocationAccesses = 0; #ifdef PARSER_ONLY ccCloseFile(inputFile); #else fclose(inputFile); #endif if (outputFile) fclose(outputFile); if (cppFile) fclose(cppFile); if (listFile) fclose(listFile); if (errFile) fclose(errFile); if (browseFile) fclose(browseFile); if (icdFile) fclose(icdFile); if (total_errors) { unlink(realOutFile); rename(oldOutFile, realOutFile); } else { unlink (oldOutFile); } /* Flag to stop if there are any errors */ stoponerr |= total_errors; clist = clist->next; } rv = !!stoponerr ; if (!cparams.prm_makestubs) { if (!cparams.prm_compileonly && !stoponerr) { rv = 0 ; if (chosenAssembler->compiler_postprocess) { char buf[260]; #ifdef MICROSOFT GetModuleFileNameA(NULL, buffer, sizeof(buffer)); #else strcpy(buffer, argv[0]); #endif rv = chosenAssembler->compiler_postprocess(buffer); } } if (chosenAssembler->rundown) chosenAssembler->rundown(); } return rv; }
static int do_ncc(char *cppfile, char *nccfile, int is_tmpfile) { static int inits_done; int fildes; FILE *input; FILE *fd; char *p; static struct timeval tv; static int timing_init; static int timing_lex; static int timing_analysis; static int timing_gen; struct stat sbuf; if (timeflag) { /* Time initialization stuff */ start_timer(&tv); } /* Generate in CWD */ if ((p = strrchr(nccfile, '/')) != NULL) { nccfile = p+1; } generated_asm_file = nccfile; atexit(remove_garbage); if (inits_done == 0) { init_keylookup(); init_oplookup(); inits_done = 1; } toklist = NULL; funclist = NULL; if (!write_fcat_flag) { input = fopen(cppfile, "r"); if (input == NULL) { perror(cppfile); return EXIT_FAILURE; } if (generated_cpp_file == cppfile) { /* * 20141123: What we just opened is a preprocessor * output file. It can now be removed. This should * fix a longstanding problem with stale .cpp files * left in /var/tmp */ (void) remove(generated_cpp_file); } } if (dump_macros_flag) { char buf[1024]; while (fgets(buf, sizeof buf, input) != NULL) { printf("%s", buf); } return 0; } if (write_fcat_flag) { fd = NULL; } else { (void) unlink(nccfile); /* trash stale .asm file */ if ((fildes = open(nccfile, O_CREAT | O_EXCL | O_RDWR, S_IRWXU)) == -1) { perror(nccfile); if (is_tmpfile) remove(cppfile); return EXIT_FAILURE; } if ((fd = fdopen(fildes, "r+")) == NULL) { perror(nccfile); REM_EXIT(cppfile, nccfile); return EXIT_FAILURE; } } /* * It is important to initialize the backend before doing * lexical analysis because architecture and ABI information * are needed */ if (init_backend(fd, &global_scope) != 0) { REM_EXIT(cppfile, nccfile); } #if USE_ZONE_ALLOCATOR zalloc_create(); zalloc_init(Z_CONTROL, sizeof(struct control), 1, 0); /* * 10/20/09: Disable label memory reclaimation for now. This is * needed since the switch label changes were made, or else the * ctrl->labels (ctrl_to_icode() for TOK_KEY_SWITCH) list will * end up containing a member that links to itself. */ zalloc_init(Z_LABEL, sizeof(struct label), 1, 1); zalloc_init(Z_EXPR, sizeof(struct expr), 1, 0); /* XXX doesn't work */ zalloc_init(Z_INITIALIZER, sizeof(struct initializer), 1, 1); zalloc_init(Z_STATEMENT, sizeof(struct statement), 1, 1); zalloc_init(Z_FUNCTION, sizeof(struct function), 1, 1); zalloc_init(Z_ICODE_INSTR, sizeof(struct icode_instr), 1, 0); zalloc_init(Z_ICODE_LIST, sizeof(struct icode_list), 1, 0); zalloc_init(Z_VREG, sizeof(struct vreg), 1, 0); zalloc_init(Z_STACK_BLOCK, sizeof(struct stack_block), 1, 0); zalloc_init(Z_S_EXPR, sizeof(struct s_expr), 1, 0); zalloc_init(Z_FCALL_DATA, sizeof(struct fcall_data), 1, 0); /* zalloc_init(Z_IDENTIFIER, sizeof(struct control), 1);*/ #if FAST_SYMBOL_LOOKUP zalloc_init(Z_FASTSYMHASH, sizeof(struct fast_sym_hash_entry), 1, 0); #endif zalloc_init(Z_CEXPR_BUF, 16, 1, 1); /* XXX */ #endif if (write_fcat_flag) { /* * 07/27/09: Parse function catalog and write index file. * We do this here because there are various parser * initializations which shouldn't be missed */ if (is_tmpfile) (void) remove(cppfile); (void) remove(nccfile); return fcat_write_index_file("fcatalog.idx", "fcatalog"); } if (stat(INSTALLDIR "/nwcc/lib/fcatalog.idx", &sbuf) == 0) { (void) fcat_open_index_file(INSTALLDIR "/nwcc/lib/fcatalog.idx"); } else { (void) fcat_open_index_file("fcatalog.idx"); } if (timeflag) { timing_init = stop_timer(&tv); start_timer(&tv); } if (lex_nwcc(create_input_file(input)) != 0) { REM_EXIT(cppfile, nccfile); } if (timeflag) { timing_lex = stop_timer(&tv); start_timer(&tv); } #if XLATE_IMMEDIATELY /* Prepare .asm file for code generation */ backend->gen_prepare_output(); #endif /* Now compile all code */ if (analyze(NULL) != 0) { REM_EXIT(cppfile, nccfile); } #if XLATE_IMMEDIATELY if (!errors) { /* Finish code generation */ backend->gen_finish_output(); } #endif if (timeflag) { timing_analysis = stop_timer(&tv); start_timer(&tv); } #if ! XLATE_IMMEDIATELY /* * All code has been parsed and translated to icode, and can now * be written as a whole .asm file in one step */ if (errors || backend->generate_program() != 0) { ; } #endif if (timeflag) { timing_gen = stop_timer(&tv); } /* destroy_toklist(&toklist); */ if (!using_ucpp) { /* ucpp already closes the file in free_lexer_state() apparently */ fclose(input); } if (is_tmpfile) { if (!save_bad_translation_unit_flag) { remove(cppfile); } } if (color_flag) { reset_text_color(); } (void) fprintf(stderr, "%s - %u error(s), %u warning(s)\n", cppfile, (unsigned)errors, (unsigned)warnings); if (timeflag) { int timing_total = timing_cpp + timing_init + timing_lex + timing_analysis + timing_gen; #define RESULT(x) x / 1000000.0, (float)x / timing_total * 100 (void) fprintf(stderr, "=== Timing of nwcc1 ===\n"); (void) fprintf(stderr, " Preprocessing: %f sec " "(%f%% of total)\n", RESULT(timing_cpp)); (void) fprintf(stderr, " Initialization: %f sec " "(%f%% of total)\n", RESULT(timing_init)); (void) fprintf(stderr, " Lexing: %f sec " "(%f%% of total)\n", RESULT(timing_lex)); (void) fprintf(stderr, " Parsing+icode: %f sec " "(%f%% of total)\n", RESULT(timing_analysis)); (void) fprintf(stderr, " Emission: %f sec " "(%f%% of total)\n", RESULT(timing_gen)); } if (errors) { remove(nccfile); return EXIT_FAILURE; } return 0; }
static MPGLContext *init_backend(struct vo *vo, const struct mpgl_driver *driver, bool probing, int vo_flags) { MPGLContext *ctx = talloc_ptrtype(NULL, ctx); *ctx = (MPGLContext) { .gl = talloc_zero(ctx, GL), .vo = vo, .driver = driver, }; if (probing) vo_flags |= VOFLAG_PROBING; bool old_probing = vo->probing; vo->probing = probing; // hack; kill it once backends are separate MP_VERBOSE(vo, "Initializing OpenGL backend '%s'\n", ctx->driver->name); ctx->priv = talloc_zero_size(ctx, ctx->driver->priv_size); if (ctx->driver->init(ctx, vo_flags) < 0) { vo->probing = old_probing; talloc_free(ctx); return NULL; } vo->probing = old_probing; if (!ctx->gl->version && !ctx->gl->es) goto cleanup; if (probing && ctx->gl->es && (vo_flags & VOFLAG_NO_GLES)) { MP_VERBOSE(ctx->vo, "Skipping GLES backend.\n"); goto cleanup; } if (ctx->gl->mpgl_caps & MPGL_CAP_SW) { MP_WARN(ctx->vo, "Suspected software renderer or indirect context.\n"); if (vo->probing && !(vo_flags & VOFLAG_SW)) goto cleanup; } ctx->gl->debug_context = !!(vo_flags & VOFLAG_GL_DEBUG); set_current_context(ctx); return ctx; cleanup: mpgl_uninit(ctx); return NULL; } // Create a VO window and create a GL context on it. // vo_flags: passed to the backend's create window function MPGLContext *mpgl_init(struct vo *vo, const char *backend_name, int vo_flags) { MPGLContext *ctx = NULL; int index = mpgl_find_backend(backend_name); if (index == -1) { for (int n = 0; n < MP_ARRAY_SIZE(backends); n++) { ctx = init_backend(vo, backends[n], true, vo_flags); if (ctx) break; } // VO forced, but no backend is ok => force the first that works at all if (!ctx && !vo->probing) { for (int n = 0; n < MP_ARRAY_SIZE(backends); n++) { ctx = init_backend(vo, backends[n], false, vo_flags); if (ctx) break; } } } else if (index >= 0) { ctx = init_backend(vo, backends[index], false, vo_flags); } return ctx; }
int main(int argc, char *argv[]) { const char *backend_opts = "X11"; int opt; int pause_flag = 0; int particles = 160; while ((opt = getopt(argc, argv, "b:n:")) != -1) { switch (opt) { case 'b': backend_opts = optarg; break; case 'n': particles = atoi(optarg); break; default: fprintf(stderr, "Invalid paramter '%c'\n", opt); } } signal(SIGINT, sighandler); signal(SIGSEGV, sighandler); signal(SIGBUS, sighandler); signal(SIGABRT, sighandler); init_backend(backend_opts); pixmap = backend->pixmap; black_pixel = gp_rgb_to_pixmap_pixel(0x00, 0x00, 0x00, pixmap); white_pixel = gp_rgb_to_pixmap_pixel(0xff, 0xff, 0xff, pixmap); gp_fill(pixmap, black_pixel); gp_backend_flip(backend); struct space *space; space = space_create(particles, 10<<8, 10<<8, (pixmap->w - 10)<<8, (pixmap->h - 10)<<8); for (;;) { if (backend->poll) gp_backend_poll(backend); usleep(1000); /* Read and parse events */ gp_event ev; while (gp_backend_get_event(backend, &ev)) { gp_event_dump(&ev); switch (ev.type) { case GP_EV_KEY: if (ev.code != GP_EV_KEY_DOWN) continue; switch (ev.val.key.key) { case GP_KEY_ESC: case GP_KEY_ENTER: case GP_KEY_Q: gp_backend_exit(backend); return 0; break; case GP_KEY_P: pause_flag = !pause_flag; break; case GP_KEY_G: space->gay = 1; break; case GP_KEY_T: space->gay = 0; break; } break; case GP_EV_SYS: switch(ev.code) { case GP_EV_SYS_QUIT: gp_backend_exit(backend); exit(0); break; case GP_EV_SYS_RESIZE: gp_backend_resize_ack(backend); space_destroy(space); space = space_create(particles, 10<<8, 10<<8, (pixmap->w - 10)<<8, (pixmap->h - 10)<<8); break; } break; } } if (!pause_flag) { space_time_tick(space, 1); space_draw_particles(pixmap, space); gp_backend_flip(backend); } } gp_backend_exit(backend); return 0; }