/* And so it begins... */ int main (int argc, char **argv) { /***** Initializations *****/ MPI_Init (&argc, &argv); MPI_Comm_size (MPI_COMM_WORLD, &numtasks); MPI_Comm_rank (MPI_COMM_WORLD, &taskid); task_init (); /* printf ("PID of task %d : %d\n", ID, getpid()); */ /* MASTER */ if (!taskid) { dispatch_input (); receive_output (); } /* SLAVES */ else { receive_input (); send_output (Head); /* Send Blank Line to mark end of transmission */ MPI_Send ("", 50, MPI_UNSIGNED_CHAR, 0, 0, MPI_COMM_WORLD); /* printf ("Done sending output from task %d\n", ID); */ } task_close (); MPI_Finalize (); return 0; }
void GAMECLIENT::on_render() { // update the local character position update_local_character_pos(); // dispatch all input to systems dispatch_input(); // render all systems for(int i = 0; i < all.num; i++) all.components[i]->on_render(); // clear new tick flags new_tick = false; new_predicted_tick = false; }
static void get_input(gpointer data, gint fd, GdkInputCondition condition) { char input[4096]; int i, n; n = read(fd,input,4096); if(n==0) exit(0); for(i=0;i<n;i++) { if(input[i]=='\n') { inpbuff[inplen] = '\0'; dispatch_input(); inplen = 0; continue; } if(inplen<MAXINP-1) inpbuff[inplen++] = input[i]; } }
static void callback_pipes(gpointer data, gint source, GdkInputCondition condition) { char input[4096]; int n, i, number; char *app; number = (int)data; app = app_name(number); n = read(source, input, 4095); if (n<=0) { gdk_input_remove(reader[number]); } if (n==0) { extern int use_yuvdenoise_pipe; extern int use_yuvscaler_pipe; extern int use_yuvplay_pipe; extern int preview_or_render; /* program finished */ if (verbose) printf("%s finished\n", app); /* close pipes/app */ close(pipe_in[number]); if (number != MP2ENC && number != MPEG2ENC && number != YUVSCALER && number != YUVPLAY && number != YUVPLAY_E && number != YUV2LAV && number != YUVDENOISE && number != YUV2DIVX && number != YUV2LAV_E) { close(pipe_out[number]); } close_pipe(number); if (number == LAV2WAV) { close(pipe_out[MP2ENC]); } if (number == LAV2YUV) { if (use_yuvdenoise_pipe) close(pipe_out[YUVDENOISE]); else if (use_yuvscaler_pipe) close(pipe_out[YUVSCALER]); else { extern int studio_enc_format; switch (studio_enc_format) { case STUDIO_ENC_FORMAT_MPEG: close(pipe_out[MPEG2ENC]); break; case STUDIO_ENC_FORMAT_DIVX: close(pipe_out[YUV2DIVX]); break; case STUDIO_ENC_FORMAT_MJPEG: close(pipe_out[YUV2LAV_E]); break; } } if (use_yuvplay_pipe) close(pipe_out[YUVPLAY]); } if (number == YUVDENOISE) { if (use_yuvscaler_pipe) close(pipe_out[YUVSCALER]); else { extern int studio_enc_format; switch (studio_enc_format) { case STUDIO_ENC_FORMAT_MPEG: close(pipe_out[MPEG2ENC]); break; case STUDIO_ENC_FORMAT_DIVX: close(pipe_out[YUV2DIVX]); break; case STUDIO_ENC_FORMAT_MJPEG: close(pipe_out[YUV2LAV_E]); break; } } } if (number == YUVSCALER) { extern int studio_enc_format; switch (studio_enc_format) { case STUDIO_ENC_FORMAT_MPEG: close(pipe_out[MPEG2ENC]); break; case STUDIO_ENC_FORMAT_DIVX: close(pipe_out[YUV2DIVX]); break; case STUDIO_ENC_FORMAT_MJPEG: close(pipe_out[YUV2LAV_E]); break; } } if (number == LAVPIPE) { if (preview_or_render) close(pipe_out[YUV2LAV]); else close(pipe_out[YUVPLAY_E]); } /* trigger callback function for each specific app */ if (number == MPEG2ENC || number == MP2ENC || number == MPLEX || number == YUV2DIVX || number == YUV2LAV_E) { continue_encoding(); } else if (number == LAV2YUV_S) { scene_detection_finished(); } else if (number == LAVPLAY_E) { lavplay_edit_stopped(); } else if (number == LAVPLAY_T) { quit_trimming(NULL,NULL); } else if (number == LAVREC) { lavrec_quit(); } else if (number == LAVPLAY) { lavplay_stopped(); } else if (number == YUV2LAV || number == YUVPLAY_E) { effects_finished(); } /* officially, we should detach the gdk_input here */ gdk_input_remove(reader[number]); } else { int x = 0; char temp[256], endsign; for(i=0;i<n;i++) { if(input[i]=='\n' || input[i]=='\r' || i==n-1) { strncpy(temp, input+x, i-x); if (i-x<255) { if (i==n-1 && input[i]!='\r' && input[i]!='\n') { temp[i-x] = input[i]; if (i-x<254) temp[i-x+1] = '\0'; } else temp[i-x] = '\0'; } endsign = '\n'; if (input[i] == '\n' || input[i] == '\r') endsign = input[i]; if (input[x] == '@') endsign = '\r'; if (number == LAV2YUV_S && strncmp(temp, "--DEBUG: frame", 14)==0) endsign = '\r'; if (number == MPEG2ENC && strncmp(temp, " INFO: Frame", 14)==0) endsign = '\r'; if (number == MP2ENC && strncmp(temp, "--DEBUG: ", 9)==0) endsign = '\r'; if(!(number == LAVPLAY && strncmp(temp, "--DEBUG: frame=", 15)==0)) { if (verbose) { fprintf(stdout, "FROM %10.10s: %s%c", app, temp, endsign); fflush(stdout); } } switch(number) { case MPEG2ENC: case LAV2YUV: case LAV2WAV: case MP2ENC: case MPLEX: case YUVSCALER: case YUVPLAY: case YUV2DIVX: case YUV2LAV_E: lavencode_callback(number, temp); break; case LAV2YUV_S: scene_detection_input_cb(temp); break; case LAVPLAY_E: process_lavplay_edit_input(temp); break; case LAVPLAY: process_lavplay_input(temp); break; case LAVPLAY_T: lavplay_trimming_callback(temp); break; case LAVREC: dispatch_input(temp); break; case YUV2LAV: case YUVPLAY_E: case LAVPIPE: effects_callback(number, temp); break; } x = i+1; } } } }