summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-10-02 12:33:34 +0200
committerwm4 <wm4@nowhere>2016-10-02 12:33:34 +0200
commit39fc5e1deb0c5753e7123529e4dd5c750aed1e8d (patch)
tree92b460dc2802ccf34c3ea413370daa98428f7a1e /player
parente3a57272a712542e739b97db31efebc4cc17c53a (diff)
downloadmpv-39fc5e1deb0c5753e7123529e4dd5c750aed1e8d.tar.bz2
mpv-39fc5e1deb0c5753e7123529e4dd5c750aed1e8d.tar.xz
player: make --stop-screensaver runtime-changeable
Move the screensaver enable/disable determination to a central place, and call it if the stop-screensaver property is changed. Also, do not stop the screensaver when in idle mode (i.e. no file is loaded). Fixes #3615.
Diffstat (limited to 'player')
-rw-r--r--player/command.c3
-rw-r--r--player/core.h1
-rw-r--r--player/loadfile.c2
-rw-r--r--player/playloop.c17
-rw-r--r--player/video.c5
5 files changed, 20 insertions, 8 deletions
diff --git a/player/command.c b/player/command.c
index 7c0cfb82ee..a714123558 100644
--- a/player/command.c
+++ b/player/command.c
@@ -5720,6 +5720,9 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags)
if (flags & UPDATE_PRIORITY)
update_priority(mpctx);
+
+ if (flags & UPDATE_SCREENSAVER)
+ update_screensaver_state(mpctx);
}
void mp_notify_property(struct MPContext *mpctx, const char *property)
diff --git a/player/core.h b/player/core.h
index 770df4aa6e..bf6a768e82 100644
--- a/player/core.h
+++ b/player/core.h
@@ -542,6 +542,7 @@ void mp_idle(struct MPContext *mpctx);
void idle_loop(struct MPContext *mpctx);
int handle_force_window(struct MPContext *mpctx, bool force);
void seek_to_last_frame(struct MPContext *mpctx);
+void update_screensaver_state(struct MPContext *mpctx);
// scripting.c
struct mp_scripting {
diff --git a/player/loadfile.c b/player/loadfile.c
index ba0e0bd257..ec8ddd6004 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1123,6 +1123,7 @@ reopen_file:
mpctx->playback_initialized = true;
mp_notify(mpctx, MPV_EVENT_FILE_LOADED, NULL);
+ update_screensaver_state(mpctx);
if (mpctx->max_frames == 0) {
if (!mpctx->stop_play)
@@ -1177,6 +1178,7 @@ terminate_playback:
uninit_audio_out(mpctx);
mpctx->playback_initialized = false;
+ update_screensaver_state(mpctx);
if (mpctx->stop_play == PT_RELOAD_FILE) {
mpctx->stop_play = KEEP_PLAYING;
diff --git a/player/playloop.c b/player/playloop.c
index fc4cfe859e..18a51f33d0 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -125,8 +125,7 @@ void pause_player(struct MPContext *mpctx)
{
mpctx->opts->pause = 1;
- if (mpctx->video_out)
- vo_control(mpctx->video_out, VOCTRL_RESTORE_SCREENSAVER, NULL);
+ update_screensaver_state(mpctx);
if (mpctx->paused)
goto end;
@@ -152,8 +151,7 @@ void unpause_player(struct MPContext *mpctx)
{
mpctx->opts->pause = 0;
- if (mpctx->video_out && mpctx->opts->stop_screensaver)
- vo_control(mpctx->video_out, VOCTRL_KILL_SCREENSAVER, NULL);
+ update_screensaver_state(mpctx);
if (!mpctx->paused)
goto end;
@@ -177,6 +175,17 @@ end:
mp_notify(mpctx, mpctx->opts->pause ? MPV_EVENT_PAUSE : MPV_EVENT_UNPAUSE, 0);
}
+void update_screensaver_state(struct MPContext *mpctx)
+{
+ if (!mpctx->video_out)
+ return;
+
+ bool saver_state = mpctx->opts->pause || !mpctx->opts->stop_screensaver ||
+ !mpctx->playback_initialized;
+ vo_control(mpctx->video_out, saver_state ? VOCTRL_RESTORE_SCREENSAVER
+ : VOCTRL_KILL_SCREENSAVER, NULL);
+}
+
void add_step_frame(struct MPContext *mpctx, int dir)
{
if (!mpctx->vo_chain)
diff --git a/player/video.c b/player/video.c
index 69128025b7..ff72f92d8e 100644
--- a/player/video.c
+++ b/player/video.c
@@ -449,7 +449,6 @@ int reinit_video_chain(struct MPContext *mpctx)
int reinit_video_chain_src(struct MPContext *mpctx, struct lavfi_pad *src)
{
- struct MPOpts *opts = mpctx->opts;
struct track *track = NULL;
struct sh_stream *sh = NULL;
if (!src) {
@@ -513,9 +512,7 @@ int reinit_video_chain_src(struct MPContext *mpctx, struct lavfi_pad *src)
recreate_video_filters(mpctx);
- bool saver_state = opts->pause || !opts->stop_screensaver;
- vo_control(vo_c->vo, saver_state ? VOCTRL_RESTORE_SCREENSAVER
- : VOCTRL_KILL_SCREENSAVER, NULL);
+ update_screensaver_state(mpctx);
vo_set_paused(vo_c->vo, mpctx->paused);