From 899dfa957f23bc92c2fa54bda9b856435639fd8c Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 2 Jul 2015 14:02:32 +0200 Subject: player: unentangle --stream-dump The final goal is making opening the demuxer and opening the stream the same operation. Stream dumping is a rather uninteresting feature, but has a small number of vocal users, and it's easy to keep. --- player/misc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'player/misc.c') diff --git a/player/misc.c b/player/misc.c index f3d9214828..613b475365 100644 --- a/player/misc.c +++ b/player/misc.c @@ -200,17 +200,17 @@ void error_on_track(struct MPContext *mpctx, struct track *track) } } -void stream_dump(struct MPContext *mpctx) +int stream_dump(struct MPContext *mpctx, const char *source_filename) { struct MPOpts *opts = mpctx->opts; - char *filename = opts->stream_dump; - stream_t *stream = mpctx->stream; - assert(stream && filename); + stream_t *stream = stream_open(source_filename, mpctx->global); + if (!stream) + return -1; int64_t size = 0; stream_control(stream, STREAM_CTRL_GET_SIZE, &size); - stream_set_capture_file(stream, filename); + stream_set_capture_file(stream, opts->stream_dump); while (mpctx->stop_play == KEEP_PLAYING && !stream->eof) { if (!opts->quiet && ((stream->pos / (1024 * 1024)) % 2) == 1) { @@ -221,6 +221,9 @@ void stream_dump(struct MPContext *mpctx) stream_fill_buffer(stream); mp_process_input(mpctx); } + + free_stream(stream); + return 0; } void merge_playlist_files(struct playlist *pl) -- cgit v1.2.3