summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-14 00:03:32 +0200
committerwm4 <wm4@nowhere>2013-06-14 00:37:39 +0200
commit648c3d790a2e5123fdea0f02743058b59e85dd94 (patch)
tree86a23dc42467be861ed85c7b152178d3c3a45f19
parent297aad1f3b18f7cbf7afd646ca863e0e40857bcb (diff)
downloadmpv-648c3d790a2e5123fdea0f02743058b59e85dd94.tar.bz2
mpv-648c3d790a2e5123fdea0f02743058b59e85dd94.tar.xz
core: introduce separate VOCTRLs for screensaver stop/resume
This is slightly better because VOCTRL_RESUME/VOCTRL_PAUSE are usually needed by VOs to know whether video is actually being played (for whatever reason), and they wouldn't be passed to the backend's VOCTRL handler, like vo_x11_control(). Also try to make sure that these flags (both pause state and screensaver state) are set consistently in some corner cases. For example, it seems enabling video in the middle of playing a file while the player is paused would not set the paused flag. If codec initialization fails, destroy the VO instead of keeping it around to make sure the state is consistent. Framestepping is implemented by unpausing the player for the duration of a frame. Remove the special handling of VOCTRL_PAUSE/RESUME in these cases. It was most likely needed because these VOCTRLs used to be important for screen redrawing (blatant guess), which is now handled completely differently. The only potentially bad side-effect is that the screensaver will be disabled/reenabled for the duration of one frame.
-rw-r--r--core/mplayer.c22
-rw-r--r--video/out/cocoa_common.m5
-rw-r--r--video/out/vo.h3
3 files changed, 19 insertions, 11 deletions
diff --git a/core/mplayer.c b/core/mplayer.c
index 990d29bd64..8b98e12bf0 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -2474,6 +2474,12 @@ int reinit_video_chain(struct MPContext *mpctx)
mpctx->initialized_flags |= INITIALIZED_VCODEC;
+ vo_control(mpctx->video_out, opts->pause ? VOCTRL_RESTORE_SCREENSAVER
+ : VOCTRL_KILL_SCREENSAVER, NULL);
+
+ vo_control(mpctx->video_out, mpctx->paused ? VOCTRL_PAUSE
+ : VOCTRL_RESUME, NULL);
+
sh_video->last_pts = MP_NOPTS_VALUE;
sh_video->num_buffered_pts = 0;
sh_video->next_frame_time = 0;
@@ -2486,8 +2492,7 @@ int reinit_video_chain(struct MPContext *mpctx)
return 1;
err_out:
- if (!opts->fixed_vo)
- uninit_player(mpctx, INITIALIZED_VO);
+ uninit_player(mpctx, INITIALIZED_VO);
cleanup_demux_stream(mpctx, STREAM_VIDEO);
no_video:
mpctx->current_track[STREAM_VIDEO] = NULL;
@@ -2720,6 +2725,9 @@ void pause_player(struct MPContext *mpctx)
{
mpctx->opts.pause = 1;
+ if (mpctx->video_out)
+ vo_control(mpctx->video_out, VOCTRL_RESTORE_SCREENSAVER, NULL);
+
if (mpctx->paused)
return;
mpctx->paused = true;
@@ -2746,6 +2754,9 @@ void unpause_player(struct MPContext *mpctx)
{
mpctx->opts.pause = 0;
+ if (mpctx->video_out)
+ vo_control(mpctx->video_out, VOCTRL_KILL_SCREENSAVER, NULL);
+
if (!mpctx->paused)
return;
// Don't actually unpause while cache is loading.
@@ -2756,8 +2767,7 @@ void unpause_player(struct MPContext *mpctx)
if (mpctx->ao && mpctx->sh_audio)
ao_resume(mpctx->ao);
- if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok
- && !mpctx->step_frames)
+ if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok)
vo_control(mpctx->video_out, VOCTRL_RESUME, NULL); // resume video
(void)get_relative_time(mpctx); // ignore time that passed during pause
}
@@ -2786,8 +2796,6 @@ void add_step_frame(struct MPContext *mpctx, int dir)
{
if (dir > 0) {
mpctx->step_frames += 1;
- if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok)
- vo_control(mpctx->video_out, VOCTRL_PAUSE, NULL);
unpause_player(mpctx);
} else if (dir < 0) {
if (!mpctx->backstep_active && !mpctx->hrseek_active) {
@@ -4155,8 +4163,6 @@ static void play_current_file(struct MPContext *mpctx)
if (opts->ass_style_override)
ass_set_style_overrides(mpctx->ass_library, opts->ass_force_style_list);
#endif
- if (mpctx->video_out && mpctx->video_out->config_ok)
- vo_control(mpctx->video_out, VOCTRL_RESUME, NULL);
mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Playing %s.\n", mpctx->filename);
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index 57d453018c..01ccc34d98 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -149,7 +149,6 @@ static void disable_power_management(struct vo *vo)
int vo_cocoa_init(struct vo *vo)
{
vo->cocoa = vo_cocoa_init_state(vo);
- disable_power_management(vo);
return 1;
}
@@ -556,10 +555,10 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg)
vo_cocoa_set_cursor_visibility(vo, visible);
return VO_TRUE;
}
- case VOCTRL_PAUSE:
+ case VOCTRL_RESTORE_SCREENSAVER:
vo_cocoa_pause(vo);
return VO_TRUE;
- case VOCTRL_RESUME:
+ case VOCTRL_KILL_SCREENSAVER:
vo_cocoa_resume(vo);
return VO_TRUE;
}
diff --git a/video/out/vo.h b/video/out/vo.h
index 3dcc58b6c3..c1ab0eff8b 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -63,6 +63,9 @@ enum mp_voctrl {
VOCTRL_SET_CURSOR_VISIBILITY, // bool
+ VOCTRL_KILL_SCREENSAVER,
+ VOCTRL_RESTORE_SCREENSAVER,
+
VOCTRL_SET_DEINTERLACE,
VOCTRL_GET_DEINTERLACE,