mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
ff25c0ad7d
commit
899dfa957f
|
@ -425,7 +425,7 @@ float mp_get_cache_percent(struct MPContext *mpctx);
|
|||
bool mp_get_cache_idle(struct MPContext *mpctx);
|
||||
void update_window_title(struct MPContext *mpctx, bool force);
|
||||
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);
|
||||
int mpctx_run_reentrant(struct MPContext *mpctx, void (*thread_fn)(void *arg),
|
||||
void *thread_arg);
|
||||
struct mpv_global *create_sub_global(struct MPContext *mpctx);
|
||||
|
|
|
@ -1079,6 +1079,12 @@ static void play_current_file(struct MPContext *mpctx)
|
|||
if (process_open_hooks(mpctx) < 0)
|
||||
goto terminate_playback;
|
||||
|
||||
if (opts->stream_dump && opts->stream_dump[0]) {
|
||||
if (stream_dump(mpctx, mpctx->stream_open_filename) < 0)
|
||||
mpctx->error_playing = 1;
|
||||
goto terminate_playback;
|
||||
}
|
||||
|
||||
int stream_flags = STREAM_READ;
|
||||
if (!opts->load_unsafe_playlists)
|
||||
stream_flags |= mpctx->playing->stream_flags;
|
||||
|
@ -1087,12 +1093,6 @@ static void play_current_file(struct MPContext *mpctx)
|
|||
if (!mpctx->stream)
|
||||
goto terminate_playback;
|
||||
|
||||
if (opts->stream_dump && opts->stream_dump[0]) {
|
||||
stream_dump(mpctx);
|
||||
mpctx->error_playing = 1;
|
||||
goto terminate_playback;
|
||||
}
|
||||
|
||||
// Must be called before enabling cache.
|
||||
mp_nav_init(mpctx);
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue