avformat/avio: privatize source of truth for AVIOContext::written

Looking at 3f75e5116b, 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.
This commit is contained in:
Jan Ekström 2021-10-13 22:21:51 +03:00
parent 97cff84f10
commit d39b58dc32
2 changed files with 13 additions and 4 deletions

View file

@ -164,8 +164,10 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len)
if (ret < 0) {
s->error = ret;
} else {
if (s->pos + len > s->written)
s->written = s->pos + len;
if (s->pos + len > ctx->written_output_size) {
ctx->written_output_size = s->pos + len;
s->written = ctx->written_output_size;
}
}
}
if (ctx->current_type == AVIO_DATA_MARKER_SYNC_POINT ||
@ -337,13 +339,14 @@ int64_t avio_skip(AVIOContext *s, int64_t offset)
int64_t avio_size(AVIOContext *s)
{
FFIOContext *const ctx = ffiocontext(s);
int64_t size;
if (!s)
return AVERROR(EINVAL);
if (s->written)
return s->written;
if (ctx->written_output_size)
return ctx->written_output_size;
if (!s->seek)
return AVERROR(ENOSYS);