summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-10-26 19:21:37 +0200
committerwm4 <wm4@nowhere>2019-10-31 11:05:55 +0100
commit1c984f992fdcdc2e9b4d5ae006bfd39466efcce1 (patch)
tree301725d20c2631aec9a073f31bd14181d3d5d8e2
parenta267452b00106993a6b8a34a9c3ca26d15f204aa (diff)
downloadmpv-1c984f992fdcdc2e9b4d5ae006bfd39466efcce1.tar.bz2
mpv-1c984f992fdcdc2e9b4d5ae006bfd39466efcce1.tar.xz
player: simplify --stream-dump code
Not sure why it was so complicated. It avoided allocation data on the stack and copying it twice, but who cares.
-rw-r--r--player/misc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/player/misc.c b/player/misc.c
index b9a280f2cc..ae4550fec5 100644
--- a/player/misc.c
+++ b/player/misc.c
@@ -258,13 +258,13 @@ int stream_dump(struct MPContext *mpctx, const char *source_filename)
MP_MSG(mpctx, MSGL_STATUS, "Dumping %lld/%lld...",
(long long int)pos, (long long int)size);
}
- bstr data = stream_peek(stream, 4096);
- if (data.len == 0) {
+ uint8_t buf[4096];
+ int len = stream_read(stream, buf, sizeof(buf));
+ if (!len) {
ok &= stream->eof;
break;
}
- ok &= fwrite(data.start, data.len, 1, dest) == 1;
- stream_skip(stream, data.len);
+ ok &= fwrite(buf, len, 1, dest) == 1;
mp_wakeup_core(mpctx); // don't actually sleep
mp_idle(mpctx); // but process input
}