diff options
author | Marton Balint <cus@passwd.hu> | 2021-11-30 00:38:30 +0100 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2021-12-12 00:32:20 +0100 |
commit | 64834bb86a133400970d203656a30ae6a3d2832f (patch) | |
tree | 5a037263437ff816b44b5209c18d8e61c6c99915 /libavformat/internal.h | |
parent | 8d66a07d657ba7ed8c5e95345d4eec770b55e438 (diff) |
avformat: introduce AVFormatContext io_close2 which returns an int
Otherwise there is no way to detect an error returned by avio_close() because
ff_format_io_close cannot get the return value.
Checking the return value of the close function is important in order to check
if all data was successfully written and the underlying close() operation was
successful.
It can also be useful even for read mode because it can return any pending
AVIOContext error, so the user don't have to manually check AVIOContext->error.
In order to still support if the user overrides io_close, the generic code only
uses io_close2 if io_close is either NULL or the default io_close callback.
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat/internal.h')
-rw-r--r-- | libavformat/internal.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libavformat/internal.h b/libavformat/internal.h index 878c4f1164..eb8239cd3f 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -916,8 +916,16 @@ int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **op /* * A wrapper around AVFormatContext.io_close that should be used * instead of calling the pointer directly. + * + * @param s AVFormatContext + * @param *pb the AVIOContext to be closed and freed. Can be NULL. + * @return >=0 on success, negative AVERROR in case of failure */ -void ff_format_io_close(AVFormatContext *s, AVIOContext **pb); +int ff_format_io_close(AVFormatContext *s, AVIOContext **pb); + +/* Default io_close callback, not to be used directly, use ff_format_io_close + * instead. */ +void ff_format_io_close_default(AVFormatContext *s, AVIOContext *pb); /** * Utility function to check if the file uses http or https protocol |