From 2c320fb609dde644bcfa3389e6a2664baa38ee2b Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 28 Oct 2014 19:51:44 +0100 Subject: player: add an option to abort playback on partial init failures This is probably what libmpv users want; and it also improves error reporting (or we'd have to add a way to communicate such mid-playback failures as events). --- DOCS/client-api-changes.rst | 2 ++ DOCS/man/options.rst | 6 ++++++ options/options.c | 2 ++ options/options.h | 1 + player/client.c | 1 + player/loadfile.c | 2 +- player/misc.c | 5 +++-- 7 files changed, 16 insertions(+), 3 deletions(-) diff --git a/DOCS/client-api-changes.rst b/DOCS/client-api-changes.rst index e868d554d3..48d1facd95 100644 --- a/DOCS/client-api-changes.rst +++ b/DOCS/client-api-changes.rst @@ -28,6 +28,8 @@ API changes 1.9 - add enum mpv_end_file_reason for mpv_event_end_file.reason - add MPV_END_FILE_REASON_ERROR and the mpv_event_end_file.error field for slightly better error reporting on playback failure + - add --stop-playback-on-init-failure option, and make it the default + behavior for libmpv only 1.8 - add qthelper.hpp 1.7 - add mpv_command_node(), mpv_command_node_async() 1.6 - modify "core-idle" property behavior diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index ab548354bc..6a45cbb8ab 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -252,6 +252,12 @@ Playback Control Without ``--hr-seek``, skipping will snap to keyframes. +``--stop-playback-on-init-failure=`` + Stop playback if either audio or video fails to initialize. Currently, + the default behavior is ``no`` for the command line player, but ``yes`` + for libmpv. With ``no``, playback will continue in video-only or audio-only + mode if one of them fails. This doesn't affect playback of audio-only or + video-only files. Program Behavior ---------------- diff --git a/options/options.c b/options/options.c index da8cd4035d..473e04f56e 100644 --- a/options/options.c +++ b/options/options.c @@ -478,6 +478,8 @@ const m_option_t mp_opts[] = { OPT_STRING("stream-capture", stream_capture, M_OPT_FIXED | M_OPT_FILE), OPT_STRING("stream-dump", stream_dump, M_OPT_FIXED | M_OPT_FILE), + OPT_FLAG("stop-playback-on-init-failure", stop_playback_on_init_failure, 0), + OPT_CHOICE_OR_INT("loop", loop_times, M_OPT_GLOBAL, 2, 10000, ({"no", -1}, {"1", -1}, {"inf", 0})), diff --git a/options/options.h b/options/options.h index cbbd0ad4ef..d9065c1877 100644 --- a/options/options.h +++ b/options/options.h @@ -110,6 +110,7 @@ typedef struct MPOpts { int untimed; char *stream_capture; char *stream_dump; + int stop_playback_on_init_failure; int loop_times; int loop_file; int shuffle; diff --git a/player/client.c b/player/client.c index 2308555a1e..8e2bc4d1b7 100644 --- a/player/client.c +++ b/player/client.c @@ -417,6 +417,7 @@ mpv_handle *mpv_create(void) mpv_set_option_string(ctx, "input-appleremote", "no"); mpv_set_option_string(ctx, "input-media-keys", "no"); mpv_set_option_string(ctx, "input-app-events", "no"); + mpv_set_option_string(ctx, "stop-playback-on-init-failure", "yes"); } else { mp_destroy(mpctx); } diff --git a/player/loadfile.c b/player/loadfile.c index 440b29d6a9..b68926f507 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -1091,7 +1091,7 @@ goto_reopen_demuxer: ; struct demuxer *d = mpctx->demuxer; MP_FATAL(mpctx, "No video or audio streams selected.\n"); if (d->stream->uncached_type == STREAMTYPE_DVB) { - int dir = mpctx->last_dvb_step; + int dir = mpctx->last_dvb_step; if (demux_stream_control(d, STREAM_CTRL_DVB_STEP_CHANNEL, &dir) > 0) mpctx->stop_play = PT_RELOAD_DEMUXER; } diff --git a/player/misc.c b/player/misc.c index c178ec7b39..6ddbc31f52 100644 --- a/player/misc.c +++ b/player/misc.c @@ -189,8 +189,9 @@ void error_on_track(struct MPContext *mpctx, struct track *track) MP_INFO(mpctx, "Audio: no audio\n"); if (track->type == STREAM_VIDEO) MP_INFO(mpctx, "Video: no video\n"); - if (!mpctx->current_track[0][STREAM_AUDIO] && - !mpctx->current_track[0][STREAM_VIDEO]) + if (mpctx->opts->stop_playback_on_init_failure || + (!mpctx->current_track[0][STREAM_AUDIO] && + !mpctx->current_track[0][STREAM_VIDEO])) { mpctx->stop_play = PT_ERROR; if (mpctx->error_playing >= 0) -- cgit v1.2.3