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.
This commit is contained in:
wm4 2019-10-26 19:21:37 +02:00
parent a267452b00
commit 1c984f992f
1 changed files with 4 additions and 4 deletions

View File

@ -258,13 +258,13 @@ int stream_dump(struct MPContext *mpctx, const char *source_filename)
MP_MSG(mpctx, MSGL_STATUS, "Dumping %lld/%lld...", MP_MSG(mpctx, MSGL_STATUS, "Dumping %lld/%lld...",
(long long int)pos, (long long int)size); (long long int)pos, (long long int)size);
} }
bstr data = stream_peek(stream, 4096); uint8_t buf[4096];
if (data.len == 0) { int len = stream_read(stream, buf, sizeof(buf));
if (!len) {
ok &= stream->eof; ok &= stream->eof;
break; break;
} }
ok &= fwrite(data.start, data.len, 1, dest) == 1; ok &= fwrite(buf, len, 1, dest) == 1;
stream_skip(stream, data.len);
mp_wakeup_core(mpctx); // don't actually sleep mp_wakeup_core(mpctx); // don't actually sleep
mp_idle(mpctx); // but process input mp_idle(mpctx); // but process input
} }