Looking at 3f75e5116b900f1428aa13041fc7d6301bf1988a, the field was supposed to be private, but during merging the field and the group that had the comment about it got separated. Thus, move the actual privately utilized state of this variable into the private FFIOContext. Additionally, name the private field somewhat better, so that it does not get confused with the amount of bytes written out.
Unified · Split
| @@ -66,6 +66,12 @@ typedef struct FFIOContext { · 65 unmodified lines | ||
| 66 | 66 | * used after probing to ensure seekback and to reset the buffer size |
| 67 | 67 | */ |
| 68 | 68 | int orig_buffer_size; |
| 69 | + | |
| 70 | + /** | |
| 71 | + * Written output size | |
| 72 | + * is updated each time a successful writeout ends up further position-wise | |
| 73 | + */ | |
| 74 | + int64_t written_output_size; | |
| 69 | 75 | } FFIOContext; |
| 70 | 76 | |
| 71 | 77 | static av_always_inline FFIOContext *ffiocontext(AVIOContext *ctx) |
| @@ -164,8 +164,10 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len) · 163 unmodified lines | ||
| 164 | 164 | if (ret < 0) { |
| 165 | 165 | s->error = ret; |
| 166 | 166 | } else { |
| 167 | − if (s->pos + len > s->written) | |
| 168 | − s->written = s->pos + len; | |
| 167 | + if (s->pos + len > ctx->written_output_size) { | |
| 168 | + ctx->written_output_size = s->pos + len; | |
| 169 | + s->written = ctx->written_output_size; | |
| 170 | + } | |
| 169 | 171 | } |
| 170 | 172 | } |
| 171 | 173 | if (ctx->current_type == AVIO_DATA_MARKER_SYNC_POINT || |
| @@ -337,13 +339,14 @@ int64_t avio_skip(AVIOContext *s, int64_t offset) · 165 unmodified lines | ||
| 337 | 339 | |
| 338 | 340 | int64_t avio_size(AVIOContext *s) |
| 339 | 341 | { |
| 342 | + FFIOContext *const ctx = ffiocontext(s); | |
| 340 | 343 | int64_t size; |
| 341 | 344 | |
| 342 | 345 | if (!s) |
| 343 | 346 | return AVERROR(EINVAL); |
| 344 | 347 | |
| 345 | − if (s->written) | |
| 346 | − return s->written; | |
| 348 | + if (ctx->written_output_size) | |
| 349 | + return ctx->written_output_size; | |
| 347 | 350 | |
| 348 | 351 | if (!s->seek) |
| 349 | 352 | return AVERROR(ENOSYS); |