History

avconv: Set new interrupt callbacks for all AVFormatContexts, use avio_open2() everywhere

Martin Storsjö committed 15 years ago

Commit 2abe9471 parent a4009c61 file · +15 −9Browse files

Unified · Split

avconv.c+15−9
@@ -503,11 +503,13 @@ static void term_init(void) · 502 unmodified lines
503503 #endif
504504 }
505505
506−static int decode_interrupt_cb(void)
506+static int decode_interrupt_cb(void *ctx)
507507 {
508508 return received_nb_signals > 1;
509509 }
510510
511+static const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL };
512+
511513 void exit_program(int ret)
512514 {
513515 int i;
@@ -2272,6 +2274,7 @@ static int transcode_init(OutputFile *output_files, · 1758 unmodified lines
22722274 /* open files and write file headers */
22732275 for (i = 0; i < nb_output_files; i++) {
22742276 os = output_files[i].ctx;
2277+ os->interrupt_callback = int_cb;
22752278 if (avformat_write_header(os, &output_files[i].opts) < 0) {
22762279 snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
22772280 ret = AVERROR(EINVAL);
@@ -2887,7 +2890,7 @@ static void dump_attachment(AVStream *st, const char *filename) · 609 unmodified lines
28872890
28882891 assert_file_overwrite(filename);
28892892
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) {
28912894 av_log(NULL, AV_LOG_FATAL, "Could not open file %s for writing.\n",
28922895 filename);
28932896 exit_program(1);
@@ -2945,6 +2948,7 @@ static int opt_input_file(OptionsContext *o, const char *opt, const char *filena · 51 unmodified lines
29452948 av_dict_set(&format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0);
29462949
29472950 ic->flags |= AVFMT_FLAG_NONBLOCK;
2951+ ic->interrupt_callback = int_cb;
29482952
29492953 /* open the input file with generic libav function */
29502954 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
30743078 if (codec_name) {
30753079 snprintf(filename, sizeof(filename), "%s%s/%s-%s.avpreset", base[i],
30763080 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);
30783082 }
30793083 if (ret) {
30803084 snprintf(filename, sizeof(filename), "%s%s/%s.avpreset", base[i],
30813085 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);
30833087 }
30843088 }
30853089 return ret;
@@ -3465,8 +3469,9 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata) · 379 unmodified lines
34653469 static int read_avserver_streams(OptionsContext *o, AVFormatContext *s, const char *filename)
34663470 {
34673471 int i, err;
3468− AVFormatContext *ic = NULL;
3472+ AVFormatContext *ic = avformat_alloc_context();
34693473
3474+ ic->interrupt_callback = int_cb;
34703475 err = avformat_open_input(&ic, filename, NULL, NULL);
34713476 if (err < 0)
34723477 return err;
@@ -3529,6 +3534,7 @@ static void opt_output_file(void *optctx, const char *filename) · 56 unmodified lines
35293534 }
35303535
35313536 oc->oformat = file_oformat;
3537+ oc->interrupt_callback = int_cb;
35323538 av_strlcpy(oc->filename, filename, sizeof(oc->filename));
35333539
35343540 if (!strcmp(file_oformat->name, "ffm") &&
@@ -3621,7 +3627,7 @@ static void opt_output_file(void *optctx, const char *filename) · 86 unmodified lines
36213627 const char *p;
36223628 int64_t len;
36233629
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) {
36253631 av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n",
36263632 o->attachments[i]);
36273633 exit_program(1);
@@ -3671,7 +3677,9 @@ static void opt_output_file(void *optctx, const char *filename) · 43 unmodified lines
36713677 assert_file_overwrite(filename);
36723678
36733679 /* 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) {
36753683 print_error(filename, err);
36763684 exit_program(1);
36773685 }
@@ -4219,8 +4227,6 @@ int main(int argc, char **argv) · 541 unmodified lines
42194227 av_register_all();
42204228 avformat_network_init();
42214229
4222− avio_set_interrupt_cb(decode_interrupt_cb);
4223−
42244230 show_banner();
42254231
42264232 /* parse options */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t