mirror of https://github.com/mpv-player/mpv
player: fix exiting if both audio and video fail initializing
The player was supposed to exit playback if both video and audio failed to initialize (or if one of the streams was not selected when the other stream failed). This didn't work; for one this check was missing from one of the failure paths. And more importantly, both checked the current_track array incorrectly. Fix these issues, and move the failure handling code into a common function. CC: @mpv-player/stable
This commit is contained in:
parent
809fbc6fc1
commit
c9234d769d
|
@ -285,11 +285,8 @@ init_error:
|
|||
uninit_audio_chain(mpctx);
|
||||
uninit_audio_out(mpctx);
|
||||
no_audio:
|
||||
mp_deselect_track(mpctx, track);
|
||||
if (track)
|
||||
MP_INFO(mpctx, "Audio: no audio\n");
|
||||
if (!mpctx->current_track[STREAM_VIDEO])
|
||||
mpctx->stop_play = PT_NEXT_ENTRY;
|
||||
error_on_track(mpctx, track);
|
||||
}
|
||||
|
||||
// Return pts value corresponding to the end point of audio written to the
|
||||
|
|
|
@ -419,6 +419,7 @@ void merge_playlist_files(struct playlist *pl);
|
|||
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 mpctx_run_non_blocking(struct MPContext *mpctx, void (*thread_fn)(void *arg),
|
||||
void *thread_arg);
|
||||
|
|
|
@ -179,6 +179,24 @@ void update_window_title(struct MPContext *mpctx, bool force)
|
|||
}
|
||||
}
|
||||
|
||||
void error_on_track(struct MPContext *mpctx, struct track *track)
|
||||
{
|
||||
if (!track)
|
||||
return;
|
||||
mp_deselect_track(mpctx, track);
|
||||
if (track) {
|
||||
if (track->type == STREAM_AUDIO)
|
||||
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])
|
||||
mpctx->stop_play = PT_NEXT_ENTRY;
|
||||
mpctx->error_playing = true;
|
||||
mpctx->sleeptime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void stream_dump(struct MPContext *mpctx)
|
||||
{
|
||||
struct MPOpts *opts = mpctx->opts;
|
||||
|
|
|
@ -327,7 +327,7 @@ err_out:
|
|||
no_video:
|
||||
uninit_video_chain(mpctx);
|
||||
if (track)
|
||||
mp_deselect_track(mpctx, track);
|
||||
error_on_track(mpctx, track);
|
||||
handle_force_window(mpctx, true);
|
||||
return 0;
|
||||
}
|
||||
|
@ -836,9 +836,7 @@ void write_video(struct MPContext *mpctx, double endpts)
|
|||
error:
|
||||
MP_FATAL(mpctx, "Could not initialize video chain.\n");
|
||||
uninit_video_chain(mpctx);
|
||||
if (!mpctx->current_track[STREAM_AUDIO])
|
||||
mpctx->stop_play = PT_NEXT_ENTRY;
|
||||
mpctx->error_playing = true;
|
||||
error_on_track(mpctx, mpctx->current_track[STREAM_VIDEO][0]);
|
||||
handle_force_window(mpctx, true);
|
||||
mpctx->sleeptime = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue