History

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

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.

Jan Ekström committed 5 years ago

Commit d39b58d1 parent 97cff842 files · +13 −4Browse files

Unified · Split

2 files
  1. libavformat/avio_internal.h +6 −0
  2. libavformat/aviobuf.c +7 −4
libavformat/avio_internal.h+6−0
@@ -66,6 +66,12 @@ typedef struct FFIOContext { · 65 unmodified lines
66 * used after probing to ensure seekback and to reset the buffer size66 * used after probing to ensure seekback and to reset the buffer size
67 */67 */
68 int orig_buffer_size;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} FFIOContext;75} FFIOContext;
70 76
71static av_always_inline FFIOContext *ffiocontext(AVIOContext *ctx)77static av_always_inline FFIOContext *ffiocontext(AVIOContext *ctx)
libavformat/aviobuf.c+7−4
@@ -164,8 +164,10 @@ static void writeout(AVIOContext *s, const uint8_t *data, int len) · 163 unmodified lines
164 if (ret < 0) {164 if (ret < 0) {
165 s->error = ret;165 s->error = ret;
166 } else {166 } else {
167 if (s->pos + len > s->written)167 if (s->pos + len > ctx->written_output_size) {
168 s->written = s->pos + len;168 ctx->written_output_size = s->pos + len;
169 s->written = ctx->written_output_size;
170 }
169 }171 }
170 }172 }
171 if (ctx->current_type == AVIO_DATA_MARKER_SYNC_POINT ||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
338int64_t avio_size(AVIOContext *s)340int64_t avio_size(AVIOContext *s)
339{341{
342 FFIOContext *const ctx = ffiocontext(s);
340 int64_t size;343 int64_t size;
341 344
342 if (!s)345 if (!s)
343 return AVERROR(EINVAL);346 return AVERROR(EINVAL);
344 347
345 if (s->written)348 if (ctx->written_output_size)
346 return s->written;349 return ctx->written_output_size;
347 350
348 if (!s->seek)351 if (!s->seek)
349 return AVERROR(ENOSYS);352 return AVERROR(ENOSYS);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t