summaryrefslogtreecommitdiff
path: root/fftools/ffmpeg_mux.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-03-28 09:59:24 +0200
committerAnton Khirnov <anton@khirnov.net>2023-04-13 15:11:56 +0200
commit5cf81bed881f2aad6f3fec441129d050338b90d7 (patch)
tree7f6009bc7e934d584b2760cbad777076ea9df923 /fftools/ffmpeg_mux.c
parentd99846d2f22b210ce91535a44822b93d522df829 (diff)
downloadffmpeg-5cf81bed881f2aad6f3fec441129d050338b90d7.tar.gz
fftools/ffmpeg: eliminate the main_return_code global
Properly pass muxing return codes through the call stack instead. Slightly changes behavior in case of errors: * the output IO stream is closed even if writing the trailer returns an error, which should be more correct * all files get properly closed with -xerror, even if one of them fails
Diffstat (limited to 'fftools/ffmpeg_mux.c')
-rw-r--r--fftools/ffmpeg_mux.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 5663b8f11d..c2b7993e66 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -602,7 +602,7 @@ int of_write_trailer(OutputFile *of)
{
Muxer *mux = mux_from_of(of);
AVFormatContext *fc = mux->fc;
- int ret;
+ int ret, mux_result = 0;
if (!mux->tq) {
av_log(mux, AV_LOG_ERROR,
@@ -611,14 +611,12 @@ int of_write_trailer(OutputFile *of)
return AVERROR(EINVAL);
}
- ret = thread_stop(mux);
- if (ret < 0)
- main_return_code = ret;
+ mux_result = thread_stop(mux);
ret = av_write_trailer(fc);
if (ret < 0) {
av_log(mux, AV_LOG_ERROR, "Error writing trailer: %s\n", av_err2str(ret));
- return ret;
+ mux_result = err_merge(mux_result, ret);
}
mux->last_filesize = filesize(fc->pb);
@@ -627,11 +625,11 @@ int of_write_trailer(OutputFile *of)
ret = avio_closep(&fc->pb);
if (ret < 0) {
av_log(mux, AV_LOG_ERROR, "Error closing file: %s\n", av_err2str(ret));
- return ret;
+ mux_result = err_merge(mux_result, ret);
}
}
- return 0;
+ return mux_result;
}
static void ost_free(OutputStream **post)