From 1c984f992fdcdc2e9b4d5ae006bfd39466efcce1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 26 Oct 2019 19:21:37 +0200 Subject: [PATCH] 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. --- player/misc.c | 8 ++++---- 1 file 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 }