diff options
Diffstat (limited to 'core/mplayer.c')
-rw-r--r-- | core/mplayer.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/core/mplayer.c b/core/mplayer.c index ed8de9eb36..abd306426d 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -4105,6 +4105,35 @@ static void idle_loop(struct MPContext *mpctx) } } +static void stream_dump(struct MPContext *mpctx) +{ + struct MPOpts *opts = &mpctx->opts; + char *filename = opts->stream_dump; + stream_t *stream = mpctx->stream; + assert(stream && filename); + + stream_set_capture_file(stream, filename); + + while (mpctx->stop_play == KEEP_PLAYING && !stream->eof) { + if (!opts->quiet && ((stream->pos / (1024 * 1024)) % 2) == 1) { + uint64_t pos = stream->pos - stream->start_pos; + uint64_t end = stream->end_pos - stream->start_pos; + char *line = talloc_asprintf(NULL, "Dumping %lld/%lld...", + (long long int)pos, (long long int)end); + write_status_line(mpctx, line); + talloc_free(line); + } + stream_fill_buffer(stream); + for (;;) { + mp_cmd_t *cmd = mp_input_get_cmd(mpctx->input, 0, false); + if (!cmd) + break; + run_command(mpctx, cmd); + talloc_free(cmd); + } + } +} + // Start playing the current playlist entry. // Handle initialization and deinitialization. static void play_current_file(struct MPContext *mpctx) @@ -4221,6 +4250,11 @@ static void play_current_file(struct MPContext *mpctx) } mpctx->stream->start_pos += opts->seek_to_byte; + if (opts->stream_dump && opts->stream_dump[0]) { + stream_dump(mpctx); + goto terminate_playback; + } + // CACHE2: initial prefill: 20% later: 5% (should be set by -cacheopts) #ifdef CONFIG_DVBIN goto_enable_cache: ; |