diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2012-01-14 03:16:55 +0400 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2012-07-03 23:48:50 +0400 |
commit | 4ad17bc76b70057dfebd5b0977d107546d700e0d (patch) | |
tree | 352c5cdb7aa2d0cc55b2e13f3f69b34de11a0a6c /libavformat/segment.c | |
parent | 71e5a14028a153867bcd267d964c8f8ebb04b22e (diff) |
lavf/segment: move list filename printing logic from segment_end() to segment_start()
Allow to deal with the list file printing only in a single point, thus
simplifying logic, and allow a bit of factorization (no special case
needed when printing the first file name of the list).
Diffstat (limited to 'libavformat/segment.c')
-rw-r--r-- | libavformat/segment.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/libavformat/segment.c b/libavformat/segment.c index a6ddf9017a..17ef20a4bc 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -102,6 +102,18 @@ static int segment_end(AVFormatContext *s) av_log(s, AV_LOG_ERROR, "Failure occurred when ending segment '%s'\n", oc->filename); + if (seg->list) { + if (seg->list_size && !(seg->number % seg->list_size)) { + avio_close(seg->pb); + if ((ret = avio_open2(&seg->pb, seg->list, AVIO_FLAG_WRITE, + &s->interrupt_callback, NULL)) < 0) + goto end; + } + avio_printf(seg->pb, "%s\n", oc->filename); + avio_flush(seg->pb); + } + +end: avio_close(oc->pb); if (oc->oformat->priv_class) av_opt_free(oc->priv_data); @@ -172,11 +184,6 @@ static int seg_write_header(AVFormatContext *s) goto fail; } - if (seg->list) { - avio_printf(seg->pb, "%s\n", oc->filename); - avio_flush(seg->pb); - } - fail: if (ret) { if (oc) { @@ -213,17 +220,6 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt) if (ret) goto fail; - - if (seg->list) { - avio_printf(seg->pb, "%s\n", oc->filename); - avio_flush(seg->pb); - if (seg->list_size && !(seg->number % seg->list_size)) { - avio_close(seg->pb); - if ((ret = avio_open2(&seg->pb, seg->list, AVIO_FLAG_WRITE, - &s->interrupt_callback, NULL)) < 0) - goto fail; - } - } } ret = oc->oformat->write_packet(oc, pkt); |