static void _shutdown_threads(void) { #if !TESTING # if defined(__linux__) && !defined(ANDROID) LOG("Emulator waiting for other threads to clean up..."); do { DIR *dir = opendir("/proc/self/task"); if (!dir) { ERRLOG("Cannot open /proc/self/task !"); break; } int thread_count = 0; struct dirent *d = NULL; while ((d = readdir(dir)) != NULL) { if (strncmp(".", d->d_name, 2) == 0) { // ignore } else if (strncmp("..", d->d_name, 3) == 0) { // ignore } else { ++thread_count; } } closedir(dir); assert(thread_count >= 1 && "there must at least be one thread =P"); if (thread_count == 1) { break; } static struct timespec ts = { .tv_sec=0, .tv_nsec=33333333 }; nanosleep(&ts, NULL); // 30Hz framerate } while (1); # endif #endif } void emulator_start(void) { #ifdef INTERFACE_CLASSIC load_settings(); // user prefs c_keys_set_key(kF8); // show credits before emulation start #endif video_init(); timing_startCPU(); video_main_loop(); }
/*----------------------------------------------------------------------------*/ int main(int argc, char* argv[]) { int loop, stop = 0, type = VIDEO_SOURCE_NONE; char *psource = 0x0; my1vmain_t vmain; /* print tool info */ printf("\n%s - %s (%s)\n",MY1APP_PROGNAME,MY1APP_PROGINFO,MY1APP_PROGVERS); printf(" => by [email protected]\n\n"); /* check parameter */ for (loop=1;loop<argc;loop++) { if (!strcmp(argv[loop],"--live")) { if (psource) { printf("Multiple source? (%s&%s)\n",psource,argv[loop]); stop++; } else if (loop<argc-1) /* still with param! */ { /* on linux this should be /dev/video0 or something... */ psource = argv[++loop]; type = VIDEO_SOURCE_LIVE; } else { printf("No param for '--live'?\n"); stop++; } } else { if (psource) { printf("Multiple source? (%s&%s)\n",psource,argv[loop]); stop++; } else { psource = argv[loop]; type = VIDEO_SOURCE_FILE; } } } if (stop) return -stop; /* check video source */ if (!psource) { printf("No video source requested!\n"); exit(-1); } /* initialize gui */ gtk_init(&argc,&argv); /* initialize */ video_main_init(&vmain); vmain.vview.view.draw_more = &video_draw_index; vmain.vview.view.draw_more_data = (void*)&vmain; /* setup filters */ video_main_pass_load(&vmain,IFNAME_GRAYSCALE); video_main_pass_load(&vmain,IFNAME_LAPLACE); /* setup capture */ video_main_capture(&vmain,psource,type); /* setup display */ video_main_display(&vmain,MY1APP_PROGINFO); /* tell them */ printf("Starting main capture loop.\n\n%s",showkeys); /* setup display/capture cycle */ video_main_loop(&vmain,DEFAULT_LOOP_TIME); /* main loop */ gtk_main(); /* clean up */ video_main_free(&vmain); /* we are done */ printf("\n"); return 0; }