int main(int argc, char **argv) { ClutterActor *stage; ClutterColor stage_clr = { 0x00, 0x00, 0x00, 0xff }; const gchar *stage_title = { "potassium music player" }; struct sigaction action; g_set_application_name("potassium music player"); clutter_init(&argc, &argv); stage = clutter_stage_get_default(); clutter_actor_set_size(stage, 512, 128); clutter_stage_set_color(CLUTTER_STAGE(stage), &stage_clr); clutter_stage_set_title(CLUTTER_STAGE(stage), stage_title); clutter_actor_set_name(stage, "stage"); clutter_actor_show(stage); /* Setup signal handler for USR1 to dump player state */ memset(&action, 0, sizeof(&action)); sigemptyset(&action.sa_mask); action.sa_handler = dump_data; action.sa_flags = SA_RESTART; sigaction(SIGUSR1, &action, NULL); /* Handle keyboard/mouse events */ g_signal_connect(stage, "event", G_CALLBACK(input_events_cb), NULL); mozart_init(argc, argv); if (argc == 2) { /* * strdup() argv[1] here, as it seems to get mangled by * generate_playlist() */ generate_playlist(strdup(argv[1]), strdup(argv[1])); mozart_switch_playlist(argv[1]); } else { read_checkpoint_data(); } init_icons(stage); g_timeout_add(500, (GSourceFunc)update_display, stage); g_timeout_add_seconds(1, (GSourceFunc)write_checkpoint_data, NULL); g_signal_connect(mozart_bus, "message::state-changed", G_CALLBACK(set_status_icons), stage); clutter_main(); mozart_destroy(); exit(0); }
/* This routine cannot print tons of data, since it is called before the log file is opened. */ void handleRestart(t_commrec *cr, gmx_bool bTryToAppendFiles, const int NFILE, t_filenm fnm[], gmx_bool *bDoAppendFiles, gmx_bool *bStartFromCpt) { gmx_bool bAddPart; int sim_part, sim_part_fn; const char *part_suffix = ".part"; FILE *fpmulti; bAddPart = !bTryToAppendFiles; /* Check if there is ANY checkpoint file available */ sim_part = 1; sim_part_fn = sim_part; if (opt2bSet("-cpi", NFILE, fnm)) { read_checkpoint_data(opt2fn_master("-cpi", NFILE, fnm, cr), &sim_part_fn, cr, bTryToAppendFiles, NFILE, fnm, part_suffix, &bAddPart, bDoAppendFiles); if (sim_part_fn == 0 && MULTIMASTER(cr)) { fprintf(stdout, "No previous checkpoint file present, assuming this is a new run.\n"); } else { sim_part = sim_part_fn + 1; } if (MULTISIM(cr) && MASTER(cr)) { if (MULTIMASTER(cr)) { /* Log file is not yet available, so if there's a * problem we can only write to stderr. */ fpmulti = stderr; } else { fpmulti = NULL; } check_multi_int(fpmulti, cr->ms, sim_part, "simulation part", TRUE); } } else { *bDoAppendFiles = FALSE; } *bStartFromCpt = sim_part > 1; if (!*bDoAppendFiles) { sim_part_fn = sim_part; } if (bAddPart) { char suffix[STRLEN]; /* Rename all output files (except checkpoint files) */ /* create new part name first (zero-filled) */ sprintf(suffix, "%s%04d", part_suffix, sim_part_fn); add_suffix_to_output_names(fnm, NFILE, suffix); if (MULTIMASTER(cr)) { fprintf(stdout, "Checkpoint file is from part %d, new output files will be suffixed '%s'.\n", sim_part-1, suffix); } } }