From b255b5ad32fe49e4c01060ae01c67d246b5d6d38 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Mon, 23 Apr 2012 21:52:54 +0300 Subject: core: uninitialize VO and AO when no track plays Uninitialize video and audio outputs when switching to a file without a corresponding track (audio-only file / file with no sound), or when entering --idle mode. Switching track choice to "off" during playback already did this. It could be useful to have a mode where the video window stays open even when no video plays, but implementing that properly would require more than just leaving the window on screen like the code did before this commit. --- mplayer.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mplayer.c b/mplayer.c index f3a9cbdc10..0f63907df8 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1760,8 +1760,10 @@ void reinit_audio_chain(struct MPContext *mpctx) { struct MPOpts *opts = &mpctx->opts; struct ao *ao; - if (!mpctx->sh_audio) + if (!mpctx->sh_audio) { + uninit_player(mpctx, INITIALIZED_AO); return; + } if (!(mpctx->initialized_flags & INITIALIZED_ACODEC)) { current_module = "init_audio_codec"; mp_msg(MSGT_CPLAYER, MSGL_INFO, "==========================================================================\n"); @@ -2615,8 +2617,10 @@ int reinit_video_chain(struct MPContext *mpctx) { struct MPOpts *opts = &mpctx->opts; sh_video_t * const sh_video = mpctx->sh_video; - if (!sh_video) + if (!sh_video) { + uninit_player(mpctx, INITIALIZED_VO); return 0; + } double ar = -1.0; //================== Init VIDEO (codec & libvo) ========================== if (!opts->fixed_vo || !(mpctx->initialized_flags & INITIALIZED_VO)) { @@ -4244,17 +4248,12 @@ play_next_file: mp_msg(MSGT_CPLAYER, MSGL_DBG2, "\n[[[init getch2]]]\n"); } - // ================= GUI idle loop (STOP state) ========================= + // ================= idle loop (STOP state) ========================= while (opts->player_idle_mode && !mpctx->filename) { + uninit_player(mpctx, INITIALIZED_AO | INITIALIZED_VO); play_tree_t *entry = NULL; mp_cmd_t *cmd; - if (mpctx->video_out && mpctx->video_out->config_ok) - vo_control(mpctx->video_out, VOCTRL_PAUSE, NULL); - while (!(cmd = mp_input_get_cmd(mpctx->input, 0, 0))) { - if (mpctx->video_out) - vo_check_events(mpctx->video_out); - usec_sleep(20000); - } + while (!(cmd = mp_input_get_cmd(mpctx->input, 500, false))); switch (cmd->id) { case MP_CMD_LOADFILE: // prepare a tree entry with the new filename -- cgit v1.2.3