Unified · Split
| @@ -503,11 +503,13 @@ static void term_init(void) · 502 unmodified lines | ||
| 503 | 503 | #endif |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | −static int decode_interrupt_cb(void) | |
| 506 | +static int decode_interrupt_cb(void *ctx) | |
| 507 | 507 | { |
| 508 | 508 | return received_nb_signals > 1; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | +static const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL }; | |
| 512 | + | |
| 511 | 513 | void exit_program(int ret) |
| 512 | 514 | { |
| 513 | 515 | int i; |
| @@ -2272,6 +2274,7 @@ static int transcode_init(OutputFile *output_files, · 1758 unmodified lines | ||
| 2272 | 2274 | /* open files and write file headers */ |
| 2273 | 2275 | for (i = 0; i < nb_output_files; i++) { |
| 2274 | 2276 | os = output_files[i].ctx; |
| 2277 | + os->interrupt_callback = int_cb; | |
| 2275 | 2278 | if (avformat_write_header(os, &output_files[i].opts) < 0) { |
| 2276 | 2279 | snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i); |
| 2277 | 2280 | ret = AVERROR(EINVAL); |
| @@ -2887,7 +2890,7 @@ static void dump_attachment(AVStream *st, const char *filename) · 609 unmodified lines | ||
| 2887 | 2890 | |
| 2888 | 2891 | assert_file_overwrite(filename); |
| 2889 | 2892 | |
| 2890 | − if ((ret = avio_open (&out, filename, AVIO_FLAG_WRITE)) < 0) { | |
| 2893 | + if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, &int_cb, NULL)) < 0) { | |
| 2891 | 2894 | av_log(NULL, AV_LOG_FATAL, "Could not open file %s for writing.\n", |
| 2892 | 2895 | filename); |
| 2893 | 2896 | exit_program(1); |
| @@ -2945,6 +2948,7 @@ static int opt_input_file(OptionsContext *o, const char *opt, const char *filena · 51 unmodified lines | ||
| 2945 | 2948 | av_dict_set(&format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0); |
| 2946 | 2949 | |
| 2947 | 2950 | ic->flags |= AVFMT_FLAG_NONBLOCK; |
| 2951 | + ic->interrupt_callback = int_cb; | |
| 2948 | 2952 | |
| 2949 | 2953 | /* open the input file with generic libav function */ |
| 2950 | 2954 | err = avformat_open_input(&ic, filename, file_iformat, &format_opts); |
| @@ -3074,12 +3078,12 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV · 123 unmodified lines | ||
| 3074 | 3078 | if (codec_name) { |
| 3075 | 3079 | snprintf(filename, sizeof(filename), "%s%s/%s-%s.avpreset", base[i], |
| 3076 | 3080 | i != 1 ? "" : "/.avconv", codec_name, preset_name); |
| 3077 | − ret = avio_open(s, filename, AVIO_FLAG_READ); | |
| 3081 | + ret = avio_open2(s, filename, AVIO_FLAG_READ, &int_cb, NULL); | |
| 3078 | 3082 | } |
| 3079 | 3083 | if (ret) { |
| 3080 | 3084 | snprintf(filename, sizeof(filename), "%s%s/%s.avpreset", base[i], |
| 3081 | 3085 | i != 1 ? "" : "/.avconv", preset_name); |
| 3082 | − ret = avio_open(s, filename, AVIO_FLAG_READ); | |
| 3086 | + ret = avio_open2(s, filename, AVIO_FLAG_READ, &int_cb, NULL); | |
| 3083 | 3087 | } |
| 3084 | 3088 | } |
| 3085 | 3089 | return ret; |
| @@ -3465,8 +3469,9 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata) · 379 unmodified lines | ||
| 3465 | 3469 | static int read_avserver_streams(OptionsContext *o, AVFormatContext *s, const char *filename) |
| 3466 | 3470 | { |
| 3467 | 3471 | int i, err; |
| 3468 | − AVFormatContext *ic = NULL; | |
| 3472 | + AVFormatContext *ic = avformat_alloc_context(); | |
| 3469 | 3473 | |
| 3474 | + ic->interrupt_callback = int_cb; | |
| 3470 | 3475 | err = avformat_open_input(&ic, filename, NULL, NULL); |
| 3471 | 3476 | if (err < 0) |
| 3472 | 3477 | return err; |
| @@ -3529,6 +3534,7 @@ static void opt_output_file(void *optctx, const char *filename) · 56 unmodified lines | ||
| 3529 | 3534 | } |
| 3530 | 3535 | |
| 3531 | 3536 | oc->oformat = file_oformat; |
| 3537 | + oc->interrupt_callback = int_cb; | |
| 3532 | 3538 | av_strlcpy(oc->filename, filename, sizeof(oc->filename)); |
| 3533 | 3539 | |
| 3534 | 3540 | if (!strcmp(file_oformat->name, "ffm") && |
| @@ -3621,7 +3627,7 @@ static void opt_output_file(void *optctx, const char *filename) · 86 unmodified lines | ||
| 3621 | 3627 | const char *p; |
| 3622 | 3628 | int64_t len; |
| 3623 | 3629 | |
| 3624 | − if ((err = avio_open(&pb, o->attachments[i], AVIO_FLAG_READ)) < 0) { | |
| 3630 | + if ((err = avio_open2(&pb, o->attachments[i], AVIO_FLAG_READ, &int_cb, NULL)) < 0) { | |
| 3625 | 3631 | av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n", |
| 3626 | 3632 | o->attachments[i]); |
| 3627 | 3633 | exit_program(1); |
| @@ -3671,7 +3677,9 @@ static void opt_output_file(void *optctx, const char *filename) · 43 unmodified lines | ||
| 3671 | 3677 | assert_file_overwrite(filename); |
| 3672 | 3678 | |
| 3673 | 3679 | /* open the file */ |
| 3674 | − if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) { | |
| 3680 | + if ((err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE, | |
| 3681 | + &oc->interrupt_callback, | |
| 3682 | + &output_files[nb_output_files - 1].opts)) < 0) { | |
| 3675 | 3683 | print_error(filename, err); |
| 3676 | 3684 | exit_program(1); |
| 3677 | 3685 | } |
| @@ -4219,8 +4227,6 @@ int main(int argc, char **argv) · 541 unmodified lines | ||
| 4219 | 4227 | av_register_all(); |
| 4220 | 4228 | avformat_network_init(); |
| 4221 | 4229 | |
| 4222 | − avio_set_interrupt_cb(decode_interrupt_cb); | |
| 4223 | − | |
| 4224 | 4230 | show_banner(); |
| 4225 | 4231 | |
| 4226 | 4232 | /* parse options */ |