static GESTimelinePipeline * create_pipeline (gchar * load_path, gchar * save_path, int argc, char **argv, gchar * audio, gchar * video) { GESTimelinePipeline *pipeline = NULL; GESTimeline *timeline = NULL; /* Timeline creation */ if (load_path) { gchar *uri; g_printf ("Loading project from : %s\n", load_path); if (!(uri = ensure_uri (load_path))) { g_error ("couldn't create uri for '%s'", load_path); goto failure; } g_printf ("reading from '%s' (arguments ignored)\n", load_path); if (!(timeline = ges_timeline_new_from_uri (uri))) { g_error ("failed to create timeline from file '%s'", load_path); goto failure; } g_printf ("loaded project successfully\n"); g_free (uri); } else /* Normal timeline creation */ if (!(timeline = create_timeline (argc, argv, audio, video))) goto failure; /* save project if path is given. we do this now in case GES crashes or * hangs during playback. */ if (save_path) { gchar *uri; if (!(uri = ensure_uri (save_path))) { g_error ("couldn't create uri for '%s", save_path); goto failure; } ges_timeline_save_to_uri (timeline, uri); g_free (uri); } /* In order to view our timeline, let's grab a convenience pipeline to put * our timeline in. */ pipeline = ges_timeline_pipeline_new (); /* Add the timeline to that pipeline */ if (!ges_timeline_pipeline_add_timeline (pipeline, timeline)) goto failure; return pipeline; failure: { if (timeline) g_object_unref (timeline); if (pipeline) g_object_unref (pipeline); return NULL; } }
int main (int argc, gchar ** argv) { GError *err = NULL; GOptionEntry options[] = { {NULL} }; GOptionContext *ctx; GMainLoop *mainloop; GstBus *bus; ctx = g_option_context_new ("tests thumbnail supoprt (produces no output)"); g_option_context_set_summary (ctx, ""); g_option_context_add_main_entries (ctx, options, NULL); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", err->message); g_option_context_free (ctx); exit (1); } g_option_context_free (ctx); /* Initialize the GStreamer Editing Services */ ges_init (); /* Create the pipeline */ pipeline = create_timeline (); if (!pipeline) exit (-1); ges_pipeline_set_mode (pipeline, TIMELINE_MODE_PREVIEW); /* Play the pipeline */ mainloop = g_main_loop_new (NULL, FALSE); g_print ("thumbnailing every 1 seconds\n"); g_timeout_add (1000, thumbnail_cb, pipeline); bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_add_signal_watch (bus); g_signal_connect (bus, "message", G_CALLBACK (bus_message_cb), mainloop); if (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { g_print ("Failed to start the encoding\n"); return 1; } g_main_loop_run (mainloop); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); gst_object_unref (pipeline); return 0; }
/* **level\_data** is created and populated with * level specific entities. Some entities require further * initialization, such as the timeline. * A timeline allows creating a sequence of events * on a, well.. time line. Each event has a start time, * duration and callback function the will get called * each time the timeline is updated and if the event * is active. * We use a timeline to animate the title, creating 3 * events: (1) slide the title into the screen (2) * make the title "bling" and (3) slide the title out * of the screen. * Using the SECOND and SECONDS constant is for * the sake of readability only. */ static struct level_data* create_level_data(void) { struct level_data* ldata = calloc(1, sizeof(*ldata)); if (ldata == NULL) goto error; ldata->wizard = create_wizard(); if (ldata->wizard == NULL) goto cleanup_level_data; if (prepare_title(&ldata->title) != 0) goto cleanup_level_data; if (prepare_tree(&ldata->tree) != 0) goto cleanup_level_data; ldata->grass_tile = create_image("res/grass_tile.png"); if (ldata->grass_tile == NULL) goto cleanup_level_data; ldata->earth_tile = create_image("res/earth_tile.png"); if (ldata->earth_tile == NULL) goto cleanup_level_data; play_animation(ldata->tree.sprite, ldata->tree.windblow); ldata->timeline = create_timeline(); if (ldata->timeline == NULL) goto cleanup_level_data; append_event(ldata->timeline, 0, 1 * SECOND, before_title_in); append_event(ldata->timeline, 0, 1 * SECOND, slide_title_in); append_event(ldata->timeline, 0, 4 * SECONDS, bling_title); append_event(ldata->timeline, 0, 1 * SECOND, slide_title_out); ldata->font = create_font("res/font.png", 32, 4); if (ldata->font == NULL) goto cleanup_level_data; ldata->music = create_sound("res/wizard.ogg"); play_sound(ldata->music, -1); return ldata; cleanup_level_data: destroy_level_data(ldata); error: ERROR("Unable to create level data"); return NULL; }
static void local_startrunSimparams() { io_logging_section(global_io.log, "Setting simulation parameter"); io_logging_subsection(global_io.log, "Information from file"); # ifdef WITH_MPI if (global_mpi.rank != 0) { io_logging_msg(global_io.log, INT32_C(4), "Not setting up myself, will receive."); fflush(NULL); } else { # else { # endif int32_t no_timestep; io_file_get(global_io.log, global_io.file, IO_FILE_GET_BOXSIZE, (void *)&(simu.boxsize)); io_file_get(global_io.log, global_io.file, IO_FILE_GET_OMEGA0, (void *)&(simu.omega0)); io_file_get(global_io.log, global_io.file, IO_FILE_GET_OMEGAL, (void *)&(simu.lambda0)); io_file_get(global_io.log, global_io.file, IO_FILE_GET_PMASS, (void *)&(simu.pmass)); io_file_get(global_io.log, global_io.file, IO_FILE_GET_NOPART, (void *)&(simu.no_part)); # ifdef MULTIMASS io_file_get(global_io.log, global_io.file, IO_FILE_GET_NOVPART, (void *)&(simu.no_vpart)); # else simu.no_vpart = (double)(simu.no_part); # endif io_file_get(global_io.log, global_io.file, IO_FILE_GET_NOSPECIES, (void *)&(simu.no_species)); io_file_get(global_io.log, global_io.file, IO_FILE_GET_AINITIAL, (void *)&(simu.a_initial)); io_file_get(global_io.log, global_io.file, IO_FILE_GET_DOUBLE, (void *)&(simu.double_precision)); io_file_get(global_io.log, global_io.file, IO_FILE_GET_MMASS, (void *)&(simu.multi_mass)); io_file_get(global_io.log, global_io.file, IO_FILE_GET_MINWEIGHT, (void *)&(simu.min_weight)); io_file_get(global_io.log, global_io.file, IO_FILE_GET_MAXWEIGHT, (void *)&(simu.max_weight)); /* Copy over the information contained in the parameter file */ simu.NGRID_DOM = global_io.params->NGRID_DOM; simu.NGRID_MIN = simu.NGRID_DOM; simu.Nth_dom = global_io.params->Nth_dom; simu.Nth_ref = global_io.params->Nth_ref; simu.lb_level = global_io.params->lb_level; //fprintf(stderr,"simu.lb_level=%d global_io.params->lb_level=%d\n",simu.lb_level,global_io.params->lb_level); simu.MaxGatherRad = global_io.params->MaxGatherRad; simu.UserDvir = global_io.params->UserDvir; simu.UseRhoBack = global_io.params->UseRhoBack; simu.NGRID_MAX = global_io.params->NGRID_MAX; simu.AHF_MINPART = global_io.params->AHF_MINPART; simu.AHF_VTUNE = global_io.params->AHF_VTUNE; simu.GADGET_m2Msunh= global_io.params->GADGET_m2Msunh; simu.GADGET_l2Mpch = global_io.params->GADGET_l2Mpch; # ifdef AHF_LRSI simu.lrsi_beta = global_io.params->lrsi_beta; simu.lrsi_r_s = global_io.params->lrsi_r_s; # endif #if (defined AHFmixHaloIDandSnapID || defined SUSSING2013) simu.isnap = global_io.params->isnap; #endif /* Set quantities given by constants */ # ifdef NP_LIMIT simu.np_limit = TRUE; # else simu.np_limit = FALSE; # endif simu.mean_dens = (double) 1.0; #ifdef MULTIMASS simu.multi_mass = 1; #endif simu.mmfocus = 0; simu.hydro = 0; simu.magneto = 0; /* Set the time unit */ simu.t_unit = 1/H0; // we assume that we only ever deal with // cosmological simulations... /* Set derived quantities */ simu.SHIFT = ((double)0.5000000/(double) simu.NGRID_DOM); simu.z_initial = (double)1.0/simu.a_initial - (double)1.0; simu.a_final = (double)1.0/((double)1.0 + simu.z_final); simu.FourPiG = 1.5*simu.omega0; /* Do some sanity checks */ io_file_get(global_io.log, global_io.file, IO_FILE_GET_NOTSTEP, (void *)&(no_timestep)); if ( isless(fabs(simu.a_initial-simu.a_final), ZERO) ) { io_logging_warn(global_io.log, INT32_C(3), "Since a_initial = %g is equal to " "a_final = %g, create_timeline will not " "function correctly, setting " "a_initial = .1 * a_final = %g", simu.a_initial, simu.a_final, simu.a_final / 10.0); simu.a_initial = simu.a_final / 10.0; } if ( simu.a_initial > simu.a_final ) { io_logging_warn(global_io.log, INT32_C(3), "Since a_initial = %g is greater than " "a_final = %g, create_timeline will not " "function correctly, setting " "a_initial = 0.001", simu.a_initial, simu.a_final); simu.a_initial = 0.001; simu.z_initial = 1./simu.a_initial - 1.; } } /* End of stuff done solely by process 0 */ io_logging_subsection(global_io.log, "Gathering from reading processes"); # ifdef WITH_MPI io_logging_msg(global_io.log, INT32_C(4), "Broadcast of simulation parameters!"); MPI_Bcast(&simu, sizeof(struct param_simu), MPI_BYTE, 0, MPI_COMM_WORLD); io_logging_msg(global_io.log, INT32_C(4), "Broadcast done."); # endif /* Create timeline */ io_logging_subsection(global_io.log, "Local setup"); io_logging_msg(global_io.log, INT32_C(2), "Creating timeline from a = %g to a = %g", simu.a_initial/10., simu.a_final); create_timeline(simu.a_initial/10., simu.a_final, &simu.timeline); io_logging_msg(global_io.log, INT32_C(2), "Timeline created"); /* Set the SFC information */ io_logging_msg(global_io.log, INT32_C(2), "Setting volume boundaries"); # ifdef AHFrestart if(global_io.params->ic_filetype != IO_FILE_ARES) { fprintf(stderr,"AHFrestart only works together with ic_filetype=5\nPlease make sure that your input file is of this type and adjust AHF.input\nExiting now!\n"); exit(0); } global_info.minkey = (sfc_key_t)( ((io_ares_t)(global_io.file))->header->minkey); global_info.maxkey = (sfc_key_t)( ((io_ares_t)(global_io.file))->header->maxkey); global_info.level = ((io_ares_t)(global_io.file))->header->lb_level; # else // global_info.level = LOADBALANCE_DOMAIN_LEVEL; global_info.level = global_io.params->lb_level; global_info.minkey = (sfc_key_t)0; global_info.maxkey = (sfc_key_t)((1<<(3*global_info.level))-1); # endif global_info.ctype = SFC_CURVE_HILBERT; io_logging_msg(global_io.log, INT32_C(2), " minkey: %"SFC_PRIkey, global_info.minkey); io_logging_msg(global_io.log, INT32_C(2), " maxkey: %"SFC_PRIkey, global_info.maxkey); io_logging_msg(global_io.log, INT32_C(2), " level : %i", global_info.level); io_logging_msg(global_io.log, INT32_C(2), " ctype : %s", sfc_curve_typestr(global_info.ctype)); /* Now that we have the timeline, set the time variables */ simu.super_t_initial = calc_super_t(simu.a_initial); simu.super_t_final = calc_super_t(simu.a_final); simu.t_initial = calc_t(simu.a_initial); simu.t_final = calc_t(simu.a_final); /* FIXME * Not set or not properly set simu-structure members: * * Hydro variables: * gamma * omegab * omegaDM * f_b * H_frac * T_init * e_init * med_weight * l_unit * m_unit * * AHF variable: * no_halos * * Unkown: * ifdef GAS_PARTICLES: no_gas * ifdef GADGET: no_stars * */ /* Will use dummy values */ simu.gamma = 0.0; simu.omegab = 0.0; simu.omegaDM = simu.omega0; simu.f_b = 0.0; simu.H_frac = 0.0; simu.T_init = 0.0; simu.B_init = 0.0; simu.e_init = 0.0; simu.no_halos = 0; simu.med_weight = simu.max_weight; // TODO: this is very conservative yet leads to more credible halos simu.l_unit = 0.0; simu.m_unit = 0.0; simu.no_gas = 0; simu.no_stars = 0; //# ifdef VERBOSE /* Be so kind and write everything to the logfile */ io_logging_subsection(global_io.log, "Used simulation parameters"); io_logging_msg(global_io.log, INT32_C(5), "simu.omega0 : %g", simu.omega0); io_logging_msg(global_io.log, INT32_C(5), "simu.lambda0 : %g", simu.lambda0); io_logging_msg(global_io.log, INT32_C(5), "simu.boxsize : %g", simu.boxsize); io_logging_msg(global_io.log, INT32_C(5), "simu.a_initial : %g", simu.a_initial); io_logging_msg(global_io.log, INT32_C(5), "simu.a_final : %g", simu.a_final); io_logging_msg(global_io.log, INT32_C(5), "simu.z_initial : %g", simu.z_initial); io_logging_msg(global_io.log, INT32_C(5), "simu.z_final : %g", simu.z_final); io_logging_msg(global_io.log, INT32_C(5), "simu.t_initial : %g", simu.t_initial); io_logging_msg(global_io.log, INT32_C(5), "simu.t_final : %g", simu.t_final); io_logging_msg(global_io.log, INT32_C(5), "simu.super_t_initial : %g", simu.super_t_initial); io_logging_msg(global_io.log, INT32_C(5), "simu.super_t_final : %g", simu.super_t_final); io_logging_msg(global_io.log, INT32_C(5), "simu.mean_dens : %g", simu.mean_dens); io_logging_msg(global_io.log, INT32_C(5), "simu.FourPiG : %g", simu.FourPiG); io_logging_msg(global_io.log, INT32_C(5), "simu.pmass : %g", simu.pmass); io_logging_msg(global_io.log, INT32_C(5), "simu.t_unit : %g", simu.t_unit); io_logging_msg(global_io.log, INT32_C(5), "simu.gamma : %g", simu.gamma); io_logging_msg(global_io.log, INT32_C(5), "simu.timeline (ptr) : %p", (void*)&(simu.timeline)); io_logging_msg(global_io.log, INT32_C(5), "simu.no_part : %lu", simu.no_part); io_logging_msg(global_io.log, INT32_C(5), "simu.no_vpart : %g", simu.no_vpart); io_logging_msg(global_io.log, INT32_C(5), "simu.no_species : %i", simu.no_species); io_logging_msg(global_io.log, INT32_C(5), "simu.no_halos : %lu", simu.no_halos); io_logging_msg(global_io.log, INT32_C(5), "simu.NGRID_DOM : %i", simu.NGRID_DOM); io_logging_msg(global_io.log, INT32_C(5), "simu.NGRID_MIN : %i", simu.NGRID_MIN); io_logging_msg(global_io.log, INT32_C(5), "simu.NGRID_MAX : %i", simu.NGRID_MAX); io_logging_msg(global_io.log, INT32_C(5), "simu.Nth_dom : %g", simu.Nth_dom); io_logging_msg(global_io.log, INT32_C(5), "simu.Nth_ref : %g", simu.Nth_ref); io_logging_msg(global_io.log, INT32_C(5), "simu.MaxGatherRad : %g", simu.MaxGatherRad); io_logging_msg(global_io.log, INT32_C(5), "simu.lb_level : %d", simu.lb_level); io_logging_msg(global_io.log, INT32_C(5), "simu.min_weight : %g", simu.min_weight); io_logging_msg(global_io.log, INT32_C(5), "simu.max_weight : %g", simu.max_weight); io_logging_msg(global_io.log, INT32_C(5), "simu.np_limit : %i", simu.np_limit); io_logging_msg(global_io.log, INT32_C(5), "simu.mmfocus : %i", simu.mmfocus); io_logging_msg(global_io.log, INT32_C(5), "simu.multi_mass : %i", simu.multi_mass); io_logging_msg(global_io.log, INT32_C(5), "simu.double_precision: %i", simu.double_precision); //# endif /* VERBOSE */ //fprintf(stderr,"simu.lb_level=%d global_io.params->lb_level=%d\n",simu.lb_level,global_io.params->lb_level); return; } static void local_startrunRetset(double *timecounter, double *timestep, int32_t *no_first_timestep) { io_logging_subsection(global_io.log, "Setting time counter"); # ifdef WITH_MPI if (global_mpi.rank == 0) { # else { # endif double a_current; io_file_get(global_io.log, global_io.file, IO_FILE_GET_NOTSTEP, (void *)no_first_timestep); io_file_get(global_io.log, global_io.file, IO_FILE_GET_TSTEP, (void *)timestep); io_file_get(global_io.log, global_io.file, IO_FILE_GET_A, (void *)&a_current); *timecounter = calc_super_t(a_current); } # ifdef WITH_MPI MPI_Bcast(timecounter, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); MPI_Bcast(timestep, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); MPI_Bcast(no_first_timestep, 1, MPI_INT, 0, MPI_COMM_WORLD); # endif return; }