Web lists-archives.com

Re: [MPlayer-dev-eng] [PATCH] Enable energy saving option and screensaver mode when the video is paused.





On 01/12/14 22:40, Reimar Döffinger wrote:
On Mon, Dec 01, 2014 at 05:57:47PM +0200, Ferenc Czumbil wrote:
On 29/11/14 23:58, Hans-Dieter Kosch wrote:
Reimar Döffinger wrote:

On Thu, Nov 27, 2014 at 07:09:26PM +0200, Ferenc Czumbil wrote:
Hi,

Currently, by default, energy saving and the screensaver is disabled
when mplayer starts and is re-enabled on exit.

This re-enables them when the video is paused. Fixes bug #2112
I'm not sure everyone likes this behaviour.
It might be better to add an option to choose the behaviour.
I'd also vote for a selectable behaviour. A user may want to observe a
picture of a paused stream, and then annoyingly the screensaver
interferes...

Should I add a new separate option? Or would it be better to have a single
option for selecting the desired behaviour? Something like:

-stop-xscreensaver true|false|on_playback
The idea sounds nice but I see two issues:
1) It will probably be somewhat more complex
2) It will probably break existing config files

So I'd expect a separate option to be the better solution.
Fair enough. It was a long time ago when I did some programming and I'm not familiar with the source code of mplayer, but the attached patch seams to work (at least for me). I'm open to any further suggestions.



Index: mplayer/cfg-mplayer.h
===================================================================
--- mplayer/cfg-mplayer.h	(revision 37361)
+++ mplayer/cfg-mplayer.h	(working copy)
@@ -189,6 +189,7 @@
     {"stop-xscreensaver", &stop_xscreensaver, CONF_TYPE_FLAG, 0, 0, 1, NULL},
     {"nostop-xscreensaver", &stop_xscreensaver, CONF_TYPE_FLAG, 0, 1, 0, NULL},
     {"stop_xscreensaver", "Use -stop-xscreensaver instead, options with _ have been obsoleted.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
+    {"xsaver-when-paused", &xsaver_when_paused, CONF_TYPE_FLAG, 0, 0, 1, NULL},
     {"fstype", &vo_fstype_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
 #endif
     {"heartbeat-cmd", &heartbeat_cmd, CONF_TYPE_STRING, 0, 0, 0, NULL},
Index: mplayer/libvo/x11_common.c
===================================================================
--- mplayer/libvo/x11_common.c	(revision 37361)
+++ mplayer/libvo/x11_common.c	(working copy)
@@ -90,6 +90,7 @@
 static int old_gravity = NorthWestGravity;
 
 int stop_xscreensaver = 1;
+int xsaver_when_paused = 0;
 
 static int dpms_disabled = 0;
 
Index: mplayer/libvo/x11_common.h
===================================================================
--- mplayer/libvo/x11_common.h	(revision 37361)
+++ mplayer/libvo/x11_common.h	(working copy)
@@ -53,6 +53,7 @@
 extern int vo_mouse_autohide;
 
 extern int stop_xscreensaver;
+extern int xsaver_when_paused;
 
 int vo_init( void );
 void vo_uninit( void );
Index: mplayer/mplayer.c
===================================================================
--- mplayer/mplayer.c	(revision 37361)
+++ mplayer/mplayer.c	(working copy)
@@ -2550,8 +2550,13 @@
     if (use_gui)
         gui(GUI_SET_STATE, (void *)GUI_PAUSE);
 #endif
-    if (mpctx->video_out && mpctx->sh_video && vo_config_count)
+    if (mpctx->video_out && mpctx->sh_video && vo_config_count) {
         mpctx->video_out->control(VOCTRL_PAUSE, NULL);
+#ifdef CONFIG_X11
+        if (xsaver_when_paused && stop_xscreensaver)
+            saver_on(mDisplay);
+#endif
+    }
 
     if (mpctx->audio_out && mpctx->sh_audio)
         mpctx->audio_out->pause();  // pause audio, keep data if possible
@@ -2606,8 +2611,13 @@
         else
             mpctx->audio_out->resume();  // resume audio
     }
-    if (mpctx->video_out && mpctx->sh_video && vo_config_count)
+    if (mpctx->video_out && mpctx->sh_video && vo_config_count) {
         mpctx->video_out->control(VOCTRL_RESUME, NULL);  // resume video
+#ifdef CONFIG_X11
+        if (xsaver_when_paused && stop_xscreensaver)
+            saver_off(mDisplay);
+#endif
+    }
     (void)GetRelativeTime(); // ignore time that passed during pause
 #ifdef CONFIG_GUI
     if (use_gui) {
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng