int evdev_open(const struct hw_module_t* module, const char* id, struct hw_device_t** device) { #ifdef DEBUG LOGE("evdev_open"); #endif if(strcmp(id, SENSORS_HARDWARE_CONTROL)==0) { #ifdef DEBUG LOGE("evdev_open hw ctl"); #endif struct sensors_control_device_t *dev; *device=malloc(sizeof(struct sensors_control_device_t)); memset(*device, 0, sizeof(struct sensors_control_device_t)); (*device)[0].tag=HARDWARE_DEVICE_TAG; (*device)[0].version=0; (*device)[0].module=module; (*device)[0].close=evdev_close; dev=*device; dev[0].open_data_source=open_data_source; dev[0].activate=activate; dev[0].set_delay=set_delay; dev[0].wake=wake; int i; if(sFD<0) sFD=open_input(); if(sFD<0) return -1; #ifdef DEBUG LOGE("evdev_open hw ctl returning ok"); #endif return 1; } else if(strcmp(id, SENSORS_HARDWARE_DATA)==0) { #ifdef DEBUG LOGE("evdev_open hw data"); #endif struct sensors_data_device_t *dev; *device=malloc(sizeof(struct sensors_data_device_t)); memset(*device, 0, sizeof(struct sensors_data_device_t)); (*device)[0].tag=HARDWARE_DEVICE_TAG; (*device)[0].version=0; (*device)[0].module=module; (*device)[0].close=evdev_close; dev=*device; dev[0].data_open=data_open; dev[0].data_close=data_close; dev[0].poll=data_poll; if(sFD<0) sFD=open_input(); #ifdef DEBUG LOGE("evdev_open hw data returning ok"); #endif return 1; } else { //Hu ? return -1;//Or 0? } }
int main(int argc, char** argv) { if(argc < 2) // insuficient arguments exit(1); if(!open_input(argv[1])) // couldn't open input file exit(1); initMe(); yyparse(); initSemanticAnalyzer(); first_pass(root); verify(root); int eCount = getErrorCount(); if(eCount > 0) { fprintf(stderr,"%d semantic errors\n", eCount); exit(3); } close_input(); exit(0); }
void InputThread::ctrl_open_input(const FXString & uri) { GM_DEBUG_PRINT("[input] ctrl_open_input %s\n",uri.text()); if (uri.empty()) { goto failed; } /// Open Input input=open_input(uri); if (input==NULL) { engine->post(new ErrorMessage(FXString::value("Unable to open %s",uri.text()))); goto failed; } reader = open_reader(); if (reader==NULL) { engine->post(new ErrorMessage(FXString::value("No input plugin available for %s",uri.text()))); goto failed; } if (!reader->init(input)) { engine->post(new ErrorMessage(FXString::value("Failed to initialize plugin"))); goto failed; } streamid++; set_state(StateProcessing,true); return; failed: ctrl_close_input(); set_state(StateIdle,true); }
static void l_output(char *infile, char *define, int extend, char *outfile) { char *include; definition *def; int foundprogram; char *outfilename; open_input(infile, define); outfilename = extend ? extendfile(infile, outfile) : outfile; open_output(infile, outfilename); f_print(fout, "#include <rpc/rpc.h>\n"); f_print(fout, "#include <sys/time.h>\n"); if (infile && (include = extendfile(infile, ".h"))) { f_print(fout, "#include \"%s\"\n", include); free(include); } foundprogram = 0; while ((def = get_definition())) { foundprogram |= (def->def_kind == DEF_PROGRAM); } if (extend && !foundprogram) { (void)unlink(outfilename); return; } write_stubs(); }
/* * Compile into an RPC service */ static void s_output(int argc, char *argv[], char *infile, char *define, int extend, char *outfile, int nomain) { char *include; definition *def; int foundprogram; char *outfilename; open_input(infile, define); outfilename = extend ? extendfile(infile, outfile) : outfile; open_output(infile, outfilename); f_print(fout, "#include <stdio.h>\n"); f_print(fout, "#include <rpc/rpc.h>\n"); if (infile && (include = extendfile(infile, ".h"))) { f_print(fout, "#include \"%s\"\n", include); free(include); } foundprogram = 0; while ((def = get_definition())) { foundprogram |= (def->def_kind == DEF_PROGRAM); } if (extend && !foundprogram) { (void)unlink(outfilename); return; } if (nomain) { write_programs(NULL); } else { write_most(); do_registers(argc, argv); write_rest(); write_programs("static"); } }
int mpl_read_data(MPL *mpl, char *file) { if (mpl->phase != 1) fault("mpl_read_data: invalid call sequence"); if (file == NULL) fault("mpl_read_data: no input filename specified"); /* set up error handler */ if (setjmp(mpl->jump)) goto done; /* process data section */ mpl->phase = 2; print("Reading data section from %s...", file); mpl->flag_d = 1; open_input(mpl, file); /* in this case the keyword 'data' is optional */ if (is_literal(mpl, "data")) { get_token(mpl /* data */); if (mpl->token != T_SEMICOLON) error(mpl, "semicolon missing where expected"); get_token(mpl /* ; */); } data_section(mpl); /* process end statement */ end_statement(mpl); print("%d line%s were read", mpl->line, mpl->line == 1 ? "" : "s") ; close_input(mpl); done: /* return to the calling program */ return mpl->phase; }
/* * generate the dispatch table */ static void t_output (char *infile, char *define, int extend, char *outfile) { definition *def; int foundprogram = 0; char *outfilename; char *incfile; open_input (infile, define); outfilename = extend ? extendfile (infile, outfile) : outfile; incfile = extendfile (infile, ".h"); open_output (infile, outfilename); add_warning (); f_print (fout, "#include \"%s\"\n", incfile); while ((def = get_definition ())) { foundprogram |= (def->def_kind == DEF_PROGRAM); } if (extend && !foundprogram) { (void) unlink (outfilename); return; } write_tables (); }
void InputThread::ctrl_open_inputs(const FXStringList & urls){ for (FXint i=0;i<urls.no();i++){ GM_DEBUG_PRINT("[input] ctrl_open_inputs[%d] %s\n",i,urls[i].text()); if (urls[i].empty()) continue; /// Open Input input=open_input(urls[i]); if (input==NULL) { if (aborted()) break; continue; } /// Open Reader reader = open_reader(); if (reader==NULL) continue; if (!reader->init(input)) continue; streamid++; set_state(StateProcessing,true); return; } ctrl_close_input(); set_state(StateIdle,true); }
static void c_output(const char *infile, const char *define, int extend, const char *outfile) { definition *def; char *include; const char *outfilename; long tell; c_initialize(); open_input(infile, define); outfilename = extend ? extendfile(infile, outfile) : outfile; open_output(infile, outfilename); add_warning(); if (infile && (include = extendfile(infile, ".h"))) { f_print(fout, "#include \"%s\"\n", include); free(include); /* .h file already contains rpc/rpc.h */ } else f_print(fout, "#include <rpc/rpc.h>\n"); tell = ftell(fout); while ( (def = get_definition()) ) emit(def); if (extend && tell == ftell(fout)) unlink(outfilename); }
static int open_camera(struct camera *cam) { int ret = 0, v_st_i; AVDictionary *opts = NULL; if((ret = av_dict_set(&opts, "rtsp_transport", "tcp", 0)) < 0) { av_err_msg ("av_dict_set", ret); return -1; } cam->context = avformat_alloc_context(); snprintf(cam->context->filename, sizeof(cam->context->filename), "%s", cam->url); cam->context->interrupt_callback.callback = &interrupt_callback; cam->context->interrupt_callback.opaque = cam; cam->last_io = time(NULL); if((v_st_i = open_input(cam->context, &opts)) < 0) return -1; cam->video_stream_index = v_st_i; cam->input_stream = cam->context->streams[cam->video_stream_index]; cam->codec = cam->input_stream->codec; av_dict_free(&opts); return 0; }
static int local_init (struct shdec * dec, char *input_filename, char *output_filename) { /* Open input/output stream */ dec->input_fd = dec->output_fd = -1; if (input_filename != NULL && open_input(dec, input_filename)) return -50; if (output_filename != NULL && open_output(dec, output_filename)) return -51; /* Allocate memory for input buffer */ dec->input_buffer = malloc(dec->max_nal_size); if (dec->input_buffer == NULL) return -1; if (dec->input_fd != -1) { /* Fill input buffer */ if ((dec->si_isize = read(dec->input_fd, dec->input_buffer, dec->max_nal_size)) <= 0) { perror(input_filename); return -54; } } return 0; }
int AudioALSA::read_buffer(char *buffer, int size) { //printf("AudioALSA::read_buffer 1\n"); int attempts = 0; int done = 0; if(!get_input()) { sleep(1); return 0; } while(attempts < 1 && !done) { if(snd_pcm_readi(get_input(), buffer, size / (device->in_bits / 8) / device->get_ichannels()) < 0) { printf("AudioALSA::read_buffer overrun at sample %" PRId64 "\n", device->total_samples_read); // snd_pcm_resume(get_input()); close_input(); open_input(); attempts++; } else done = 1; } return 0; }
static int tp_cmd_execute(CmdInterface* thiz, void* ctx) { DECLES_PRIV(priv, thiz); char content[4]; int fd; fd = open_input(SPRD_TS_INPUT_DEV, O_RDONLY); Parcel* reply = parcel_create(); parcel_set_main_cmd(reply, DIAG_AUTOTEST_F); parcel_set_sub_cmd(reply, AUTOTEST_TP); memset(content, 0, sizeof(content)); if (fd > 0) { *(uint8_t*)(content) = AUTOTEST_RET_PASS; close(fd); } else { *(uint8_t*)(content) = AUTOTEST_RET_FAIL; } parcel_set_content(reply, content, 4); cmd_listener_reply(priv->listener, reply); parcel_destroy(reply); return 0; }
int main(int argc, char** argv) { Opts options; int out_start = argc; Input in = { 0, -1, 0 }; Output *outputs = malloc((argc - 1) * sizeof(Output)); int *regular = malloc((argc - 1) * sizeof(int)); int *pipes = malloc((argc - 1) * sizeof(int)); SpillControl spillage = { NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0 }; /* Spillage info. */ int nregular = 0, npipes = 0; struct sigaction sig; if (NULL == outputs || NULL == regular || NULL == pipes) { perror("malloc"); return EXIT_FAILURE; } /* Ignore SIGPIPEs, we want write(2) to get EPIPE instead. */ sig.sa_handler = SIG_IGN; if (0 != sigaction(SIGPIPE, &sig, NULL)) { perror("sigaction"); return EXIT_FAILURE; } if (0 != get_options(argc, argv, &options, &out_start)) { return EXIT_FAILURE; } if (verbosity > 0) { fprintf(stderr, "%.3f Started.\n", get_time()); } if (0 != open_input(&options, &in, &spillage)) { return EXIT_FAILURE; } if (out_start >= argc) { fprintf(stderr, "No output files specified\n"); return EXIT_FAILURE; } /* Open the output files */ if (open_outputs(argc - out_start, argv + out_start, outputs, regular, pipes, &nregular, &npipes) != 0) { return EXIT_FAILURE; } /* Copy input to all outputs */ if (do_copy(&options, &in, argc - out_start, outputs, nregular, regular, npipes, pipes, &spillage) != 0) { return EXIT_FAILURE; } if (verbosity > 0) { fprintf(stderr, "%.3f Finished.\n", get_time()); } return EXIT_SUCCESS; }
// Open both input and output in ESD int AudioESound::open_duplex() { device->duplex_channels = 2; device->duplex_bits = 16; open_input(); open_output(); return 0; }
static native_handle_t* sensors_control_open_data_source(struct sensors_control_device_t *dev) { LOGI("sensors_control_open_data_source"); native_handle * nh = native_handle_create(1, 0); nh->data[0] = open_input(); return nh; }
bool do_copy_file(compilation_env_t *env, compilation_unit_t *unit) { if (!open_input(unit)) return false; if (!open_output(env)) return false; copy_file(env->out, unit->input); close_output(env); return close_input(unit); }
int main(int argc, char** argv) { int ret = EXIT_SUCCESS; /* Initialize param struct to zero */ memset(&P, 0, sizeof(P)); if (!parse_input(argc, argv)) { return EXIT_FAILURE; } /* Initialize parameters corresponding to YUV-format */ setup_param(); if (!sdl_init()) { return EXIT_FAILURE; } if (!open_input()) { return EXIT_FAILURE; } if (!allocate_memory()) { ret = EXIT_FAILURE; goto cleanup; } /* Lets do some basic consistency check on input */ check_input(); /* send event to display first frame */ event.type = SDL_KEYDOWN; event.key.keysym.sym = SDLK_RIGHT; SDL_PushEvent(&event); /* while true */ event_loop(); cleanup: destroy_message_queue(); SDL_FreeYUVOverlay(my_overlay); free(P.raw); free(P.y_data); free(P.cb_data); free(P.cr_data); if (fd) { fclose(fd); } if (P.fd2) { fclose(P.fd2); } return ret; }
int main(int argc, char *argv[]) { struct input_state in = { }; int fd_out; char const *event_filename = NULL; int rc; int repeat_params[2] = { 250 ,100 }; for (;;) { int c; c = getopt_long(argc, argv, "e:D:R:", CMDLINE_OPTIONS, NULL); if (c == -1) break; switch (c) { case 'k': rc = read_keymap(optarg); if (rc != EX_OK) return rc; break; case 'D': repeat_params[0] = atoi(optarg); break; case 'R': repeat_params[1] = atoi(optarg); break; default: fprintf(stderr, "unknown option\n"); return EX_USAGE; } } if (argc < optind + 1) { fprintf(stderr, "missing parameters\n"); return EX_USAGE; } else { event_filename = argv[optind + 0]; } if (!open_input(&in, event_filename, repeat_params)) return EX_OSERR; fd_out = open_uinput(&in); if (fd_out < 0) return EX_OSERR; while (handle_input(&in, fd_out)) ; }
int main(int argc, char ** argv) { if (argc == 1 || argc > 3) { print_usage(); printf("Error: invalid number of parameters!\n"); exit(1); } else if (argc == 3) { serverName = argv[2]; // get UDP server's IP address } platName = argv[1]; // get mote platform's name open_input(); if (serverName != NULL) setup_socket(); while(1){ read_forward(); } }
static void* tp_test_thread(void* ptr) { TestCase* thiz = (TestCase*)ptr; DECLES_PRIV(priv, thiz); fd_set rfds; struct input_event event; struct timeval timeout; int n; int max_points = SPRD_WIDTH_POINTS * 2 + SPRD_HEIGHT_POINTS * 2 - 4; int ts_fd = open_input(SPRD_TS_INPUT_DEV, O_RDONLY); if (ts_fd < 0) { LOGE("%s: fail to get input dev %s", __func__, SPRD_TS_INPUT_DEV); return NULL; } timeout.tv_sec = 3; timeout.tv_usec = 0; while(priv->thread_run == 1) { if (tp_test_check_all_keys(thiz) == max_points) { priv->ts_success = 1; tp_test_show(thiz); break; } FD_ZERO(&rfds); FD_SET(ts_fd, &rfds); n = select(ts_fd + 1, &rfds, NULL, NULL, &timeout); if (n < 0) { LOGE("%s: select ts input error: (%s)", __func__, strerror(errno)); } if (FD_ISSET(ts_fd, &rfds)) { n = read(ts_fd, &event, sizeof(event)); if (n == sizeof(event)) { tp_test_handle_event(thiz, &event); } } else { //LOGE("%s: fd is not set", __func__); } } return NULL; }
int main(int argc, char* argv[]) { int ret; av_register_all(); av_log_set_level(AV_LOG_DEBUG); if(argc < 2) { printf("usage : %s <input>\n", argv[0]); return 0; } if(open_input(argv[1]) < 0) { goto main_end; } // AVPacket은 코덱으로 압축된 스트림 데이터를 저장하는데 사용됩니다. AVPacket pkt; while(1) { ret = av_read_frame(input_ctx.fmt_ctx, &pkt); if(ret == AVERROR_EOF) { // 더 이상 읽어올 패킷이 없습니다. printf("End of frame\n"); break; } if(pkt.stream_index == input_ctx.v_index) { printf("Video packet\n"); } else if(pkt.stream_index == input_ctx.a_index) { printf("Audio packet\n"); } av_free_packet(&pkt); } // while main_end: release(); return 0; }
int mpl_read_model(MPL *mpl, char *file, int skip_data) { if (mpl->phase != 0) xfault("mpl_read_model: invalid call sequence\n"); if (file == NULL) xfault("mpl_read_model: no input filename specified\n"); /* set up error handler */ if (setjmp(mpl->jump)) goto done; /* translate model section */ mpl->phase = 1; xprintf("Reading model section from %s...\n", file); open_input(mpl, file); model_section(mpl); if (mpl->model == NULL) error(mpl, "empty model section not allowed"); /* save name of the input text file containing model section for error diagnostics during the generation phase */ mpl->mod_file = xcalloc(strlen(file)+1, sizeof(char)); strcpy(mpl->mod_file, mpl->in_file); /* allocate content arrays for all model objects */ alloc_content(mpl); /* optional data section may begin with the keyword 'data' */ if (is_keyword(mpl, "data")) { if (skip_data) { warning(mpl, "data section ignored"); goto skip; } mpl->flag_d = 1; get_token(mpl /* data */); if (mpl->token != T_SEMICOLON) error(mpl, "semicolon missing where expected"); get_token(mpl /* ; */); /* translate data section */ mpl->phase = 2; xprintf("Reading data section from %s...\n", file); data_section(mpl); } /* process end statement */ end_statement(mpl); skip: xprintf("%d line%s were read\n", mpl->line, mpl->line == 1 ? "" : "s"); close_input(mpl); done: /* return to the calling program */ return mpl->phase; }
/* * Seed PRNG using randomness from file * Assume file contains at least RANDOM_BYTES_NEEDED 'random' bytes */ u32 SeedPRNGfromFile (const u8 *rfile, RANDOM_STRUCT *r) { FILE *fp; u32 n=RANDOM_BYTES_NEEDED; u32 bytes; u8 *buffer; if (r == NULL) return PRNG_NOT_INIT; if ( (fp = (FILE *)open_input(rfile)) == NULL) { exit(1); } if ( (buffer = (u8 *)malloc(RANDOM_BYTES_NEEDED)) == NULL) { fprintf(stderr, "error in SeedPRNGfromFile: out of memory.\n"); exit (1); } while (GetRandomBytesNeeded (&n, r) > 0) { if ( (bytes = fread (buffer, 1, n, fp)) < n ) { if ( ferror(fp) ) { fprintf(stderr, "error while reading randomness file '%s' : %s\n", rfile, strerror(errno)); exit (1); } if ( feof(fp) ) { fprintf(stderr, "error: not enough bytes in file '%s' to seed PRNG.\n", rfile); fprintf(stderr, "(bytes expected: %d, bytes read: %d).\n", RANDOM_BYTES_NEEDED, bytes); exit (1); } fprintf(stderr, "error in SeedPRNGfromFile: unkown error\n"); exit (1); } RandomUpdate (r, buffer, bytes); } /* zeroize sensitive information */ memset (buffer, 0, RANDOM_BYTES_NEEDED); free (buffer); fclose(fp); }
DeckLinkInputAdapter(unsigned int card_index = 0, unsigned int norm_ = 0, unsigned int input_ = 0, RawFrame::PixelFormat pf_ = RawFrame::CbYCrY8422, bool enable_audio = false) : deckLink(NULL), out_pipe(IN_PIPE_SIZE) { audio_pipe = NULL; pf = pf_; bpf = convert_pf(pf_); deckLink = find_card(card_index); select_input_connection(input_); open_input(norm_); if (enable_audio) { n_channels = 2; select_audio_input_connection( ); open_audio_input( ); } start_capture( ); }
DeckLinkInputAdapter(unsigned int card_index = 0, unsigned int norm_ = 0, unsigned int input_ = 0, RawFrame::PixelFormat pf_ = RawFrame::CbYCrY8422, bool enable_audio = false, unsigned int n_channels = 2, bool enable_video = true) : deckLink(NULL), out_pipe(IN_PIPE_SIZE) { audio_pipe = NULL; started = false; signal_lost = false; rotate = false; this->enable_video = enable_video; n_frames = 0; start_time = 0; avsync = 0; drop_audio = 0; pf = pf_; bpf = convert_pf(pf_); deckLink = find_card(card_index); select_input_connection(input_); open_input(norm_); if (enable_audio) { audio_pipe = new Pipe<IOAudioPacket *>(IN_PIPE_SIZE); } this->n_channels = n_channels; select_audio_input_connection( ); open_audio_input( ); start_capture( ); }
int main(int argc, char **argv) { static m4af_io_callbacks_t m4af_io = { read_callback, write_callback, seek_callback, tell_callback }; aacenc_param_ex_t params = { 0 }; int result = 2; char *output_filename = 0; pcm_reader_t *reader = 0; HANDLE_AACENCODER encoder = 0; AACENC_InfoStruct aacinfo = { 0 }; m4af_ctx_t *m4af = 0; const pcm_sample_description_t *sample_format; int frame_count = 0; int sbr_mode = 0; unsigned scale_shift = 0; setlocale(LC_CTYPE, ""); setbuf(stderr, 0); if (parse_options(argc, argv, ¶ms) < 0) return 1; if ((reader = open_input(¶ms)) == 0) goto END; sample_format = pcm_get_format(reader); sbr_mode = aacenc_is_sbr_active((aacenc_param_t*)¶ms); if (sbr_mode && !aacenc_is_sbr_ratio_available()) { fprintf(stderr, "WARNING: Only dual-rate SBR is available " "for this version\n"); params.sbr_ratio = 2; } scale_shift = aacenc_is_dual_rate_sbr((aacenc_param_t*)¶ms); params.sbr_signaling = (params.transport_format == TT_MP4_LOAS) ? 2 : (params.transport_format == TT_MP4_RAW) ? 1 : 0; if (sbr_mode && !scale_shift) params.sbr_signaling = 2; if (aacenc_init(&encoder, (aacenc_param_t*)¶ms, sample_format, &aacinfo) < 0) goto END; if (!params.output_filename) { const char *ext = params.transport_format ? ".aac" : ".m4a"; output_filename = generate_output_filename(params.input_filename, ext); params.output_filename = output_filename; } if ((params.output_fp = aacenc_fopen(params.output_filename, "wb+")) == 0) { aacenc_fprintf(stderr, "ERROR: %s: %s\n", params.output_filename, strerror(errno)); goto END; } handle_signals(); if (!params.transport_format) { uint32_t scale; unsigned framelen = aacinfo.frameLength; scale = sample_format->sample_rate >> scale_shift; if ((m4af = m4af_create(M4AF_CODEC_MP4A, scale, &m4af_io, params.output_fp)) < 0) goto END; m4af_set_decoder_specific_info(m4af, 0, aacinfo.confBuf, aacinfo.confSize); m4af_set_fixed_frame_duration(m4af, 0, framelen >> scale_shift); m4af_set_vbr_mode(m4af, 0, params.bitrate_mode); m4af_set_priming_mode(m4af, params.gapless_mode + 1); m4af_begin_write(m4af); }
int main(int argc, char **argv) { int i; if(argc == 1) { usage(); return 1; } parse_options(argc,argv); if(!quiet) version(); if(optind >= argc) { fprintf(stderr, _("ERROR: No input files specified. Use -h for help\n")); return 1; } if(argc - optind > 1 && outfilename && !raw) { fprintf(stderr, _("ERROR: Can only specify one input file if output filename is specified\n")); return 1; } if(outfilename && raw) { FILE *infile, *outfile; char *infilename; if(!strcmp(outfilename, "-")) { free(outfilename); outfilename = NULL; } outfile = open_output(outfilename); if(!outfile) return 1; for(i=optind; i < argc; i++) { if(!strcmp(argv[i], "-")) { infilename = NULL; infile = open_input(NULL); } else { infilename = argv[i]; infile = open_input(argv[i]); } if(!infile) { fclose(outfile); free(outfilename); return 1; } if(decode_file(infile, outfile, infilename, outfilename)) { fclose(outfile); return 1; } } fclose(outfile); } else { for(i=optind; i < argc; i++) { char *in, *out; FILE *infile, *outfile; if(!strcmp(argv[i], "-")) in = NULL; else in = argv[i]; if(outfilename) { if(!strcmp(outfilename, "-")) out = NULL; else out = outfilename; } else { char *end = strrchr(argv[i], '.'); end = end?end:(argv[i] + strlen(argv[i]) + 1); out = malloc(strlen(argv[i]) + 10); strncpy(out, argv[i], end-argv[i]); out[end-argv[i]] = 0; if(raw) strcat(out, ".raw"); else strcat(out, ".wav"); } infile = open_input(in); if(!infile) { if(outfilename) free(outfilename); return 1; } outfile = open_output(out); if(!outfile) { fclose(infile); return 1; } if(decode_file(infile, outfile, in, out)) { fclose(outfile); return 1; } if(!outfilename) free(out); fclose(outfile); } } if(outfilename) free(outfilename); return 0; }
int main(int argc, char *argv[]) { char *filename = read_opts(argc, argv); /* set up an rnn context */ rnn_init(); rnndb = rnn_newdb(); rnn_parsefile(rnndb, "fifo/nv_objects.xml"); if (rnndb->estatus) demmt_abort(); rnn_prepdb(rnndb); domain = rnn_finddomain(rnndb, "SUBCHAN"); if (!domain) demmt_abort(); rnndb_g80_texture = rnn_newdb(); rnn_parsefile(rnndb_g80_texture, "graph/g80_texture.xml"); if (rnndb_g80_texture->estatus) demmt_abort(); rnn_parsefile(rnndb_g80_texture, "graph/gm107_texture.xml"); if (rnndb_g80_texture->estatus) demmt_abort(); rnn_prepdb(rnndb_g80_texture); rnndb_gf100_shaders = rnn_newdb(); rnn_parsefile(rnndb_gf100_shaders, "graph/gf100_shaders.xml"); if (rnndb_gf100_shaders->estatus) demmt_abort(); rnn_prepdb(rnndb_gf100_shaders); gf100_shaders_ctx = rnndec_newcontext(rnndb_gf100_shaders); gf100_shaders_ctx->colors = colors; /* doesn't matter which, just needs to exist to make it * possible to modify later. */ rnndec_varadd(gf100_shaders_ctx, "GF100_SHADER_KIND", "FP"); rnndb_nvrm_object = rnn_newdb(); rnn_parsefile(rnndb_nvrm_object, "../docs/nvrm/rnndb/nvrm_object.xml"); if (rnndb_nvrm_object->estatus) demmt_abort(); rnn_prepdb(rnndb_nvrm_object); tic_domain = rnn_finddomain(rnndb_g80_texture, "TIC"); tic2_domain = rnn_finddomain(rnndb_g80_texture, "TIC2"); tsc_domain = rnn_finddomain(rnndb_g80_texture, "TSC"); gf100_sp_header_domain = rnn_finddomain(rnndb_gf100_shaders, "GF100_SP_HEADER"); gf100_fp_header_domain = rnn_finddomain(rnndb_gf100_shaders, "GF100_FP_HEADER"); if (!gf100_sp_header_domain || !gf100_fp_header_domain) demmt_abort(); gk104_cp_header_domain = rnn_finddomain(rnndb, "GK104_COMPUTE_LAUNCH_DESC"); if (!gk104_cp_header_domain) demmt_abort(); if (filename) { close(0); if (open_input(filename) == NULL) { perror("open"); exit(1); } free(filename); } if (pager_enabled) { int pipe_fds[2]; pid_t pid; if (pipe(pipe_fds) < 0) { perror("pipe"); demmt_abort(); } pid = fork(); if (pid < 0) { perror("fork"); demmt_abort(); } if (pid > 0) { char *less_argv[] = { "less", "-ScR", NULL }; close(pipe_fds[1]); dup2(pipe_fds[0], 0); close(pipe_fds[0]); execvp(less_argv[0], less_argv); perror("exec"); demmt_abort(); } close(pipe_fds[0]); dup2(pipe_fds[1], 1); dup2(pipe_fds[1], 2); close(pipe_fds[1]); } #ifdef LIBSECCOMP_AVAILABLE if (seccomp_level) { int rc; scmp_filter_ctx ctx; if (seccomp_level == 2) ctx = seccomp_init(SCMP_ACT_KILL); else ctx = seccomp_init(SCMP_ACT_TRACE(1234)); if (!ctx) { fprintf(stderr, "seccomp_init failed\n"); exit(1); } rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1, SCMP_A0(SCMP_CMP_EQ, 0)); if (rc != 0) exit(1); seccomp_syscall_priority(ctx, SCMP_SYS(read), 254); rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 1, SCMP_A0(SCMP_CMP_LE, 2)); if (rc != 0) exit(1); seccomp_syscall_priority(ctx, SCMP_SYS(write), 255); rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(rt_sigreturn), 0); if (rc != 0) exit(1); rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(fstat), 1, SCMP_A0(SCMP_CMP_EQ, 1)); if (rc != 0) exit(1); rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(mmap), 0); if (rc != 0) exit(1); rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(brk), 0); if (rc != 0) exit(1); rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(munmap), 0); if (rc != 0) exit(1); rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(mremap), 0); if (rc != 0) exit(1); rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(exit_group), 0); if (rc != 0) exit(1); rc = seccomp_rule_add_exact(ctx, SCMP_ACT_ALLOW, SCMP_SYS(ioctl), 2, SCMP_A0(SCMP_CMP_EQ, 1), SCMP_A1(SCMP_CMP_EQ, 0x5401/*TCGETS*/)); if (rc != 0) exit(1); rc = seccomp_load(ctx); if (rc != 0) { fprintf(stderr, "seccomp_load failed with error: %d\n", rc); exit(1); } seccomp_release(ctx); } #endif mmt_decode(&demmt_funcs.base, NULL); fflush(stdout); fini_macrodis(); demmt_cleanup_isas(); rnndec_freecontext(gf100_shaders_ctx); rnn_freedb(rnndb); rnn_freedb(rnndb_g80_texture); rnn_freedb(rnndb_gf100_shaders); rnn_freedb(rnndb_nvrm_object); rnn_fini(); return 0; }
static int read_data(void *opaque, uint8_t *buf, int buf_size) { struct variant *v = opaque; HLSContext *c = v->parent->priv_data; int ret, i; restart: if (!v->input) { /* If this is a live stream and the reload interval has elapsed since * the last playlist reload, reload the variant playlists now. */ int64_t reload_interval = v->n_segments > 0 ? v->segments[v->n_segments - 1]->duration : v->target_duration; reload_interval *= 1000000; reload: if (!v->finished && av_gettime() - v->last_load_time >= reload_interval) { if ((ret = parse_playlist(c, v->url, v, NULL)) < 0) return ret; /* If we need to reload the playlist again below (if * there's still no more segments), switch to a reload * interval of half the target duration. */ reload_interval = v->target_duration * 500000LL; } if (v->cur_seq_no < v->start_seq_no) { av_log(NULL, AV_LOG_WARNING, "skipping %d segments ahead, expired from playlists\n", v->start_seq_no - v->cur_seq_no); v->cur_seq_no = v->start_seq_no; } if (v->cur_seq_no >= v->start_seq_no + v->n_segments) { if (v->finished) return AVERROR_EOF; while (av_gettime() - v->last_load_time < reload_interval) { if (ff_check_interrupt(c->interrupt_callback)) return AVERROR_EXIT; av_usleep(100*1000); } /* Enough time has elapsed since the last reload */ goto reload; } ret = open_input(v); if (ret < 0) return ret; } ret = ffurl_read(v->input, buf, buf_size); if (ret > 0) return ret; ffurl_close(v->input); v->input = NULL; v->cur_seq_no++; c->end_of_segment = 1; c->cur_seq_no = v->cur_seq_no; if (v->ctx && v->ctx->nb_streams && v->parent->nb_streams >= v->stream_offset + v->ctx->nb_streams) { v->needed = 0; for (i = v->stream_offset; i < v->stream_offset + v->ctx->nb_streams; i++) { if (v->parent->streams[i]->discard < AVDISCARD_ALL) v->needed = 1; } } if (!v->needed) { av_log(v->parent, AV_LOG_INFO, "No longer receiving variant %d\n", v->index); return AVERROR_EOF; } goto restart; }