[vlc-commits] inhibit: add separate flags for audio and video

Rémi Denis-Courmont git at videolan.org
Fri Nov 30 18:13:40 CET 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Nov 30 19:13:24 2012 +0200| [405da96034f4cf70855c2706ba5a1e20f2c9fded] | committer: Rémi Denis-Courmont

inhibit: add separate flags for audio and video

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=405da96034f4cf70855c2706ba5a1e20f2c9fded
---

 include/vlc_inhibit.h               |   16 +++++++++++++++-
 modules/misc/inhibit/mce.c          |    5 +++--
 modules/misc/inhibit/xdg.c          |    3 ++-
 modules/misc/inhibit/xscreensaver.c |    5 +++--
 src/video_output/inhibit.h          |    5 -----
 src/video_output/window.c           |    4 ++--
 6 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/include/vlc_inhibit.h b/include/vlc_inhibit.h
index 5ac460c..b1f7330 100644
--- a/include/vlc_inhibit.h
+++ b/include/vlc_inhibit.h
@@ -29,12 +29,26 @@
 typedef struct vlc_inhibit vlc_inhibit_t;
 typedef struct vlc_inhibit_sys vlc_inhibit_sys_t;
 
+enum vlc_inhibit_flags
+{
+    VLC_INHIBIT_NONE=0 /*< No inhibition */,
+    VLC_INHIBIT_SUSPEND=0x1 /*< Processor is in use - do not suspend */,
+    VLC_INHIBIT_DISPLAY=0x2 /*< Display is in use - do not blank/lock */,
+#define VLC_INHIBIT_AUDIO (VLC_INHIBIT_SUSPEND)
+#define VLC_INHIBIT_VIDEO (VLC_INHIBIT_SUSPEND|VLC_INHIBIT_DISPLAY)
+};
+
 struct vlc_inhibit
 {
     VLC_COMMON_MEMBERS
 
     vlc_inhibit_sys_t *p_sys;
-    void             (*inhibit) (vlc_inhibit_t *, bool);
+    void (*inhibit) (vlc_inhibit_t *, unsigned flags);
 };
 
+static inline void vlc_inhibit_Set (vlc_inhibit_t *ih, unsigned flags)
+{
+    ih->inhibit (ih, flags);
+}
+
 #endif
diff --git a/modules/misc/inhibit/mce.c b/modules/misc/inhibit/mce.c
index d49e969..71834b9 100644
--- a/modules/misc/inhibit/mce.c
+++ b/modules/misc/inhibit/mce.c
@@ -44,7 +44,7 @@ vlc_module_begin ()
     set_callbacks (Open, Close)
 vlc_module_end ()
 
-static void Inhibit (vlc_inhibit_t *, bool);
+static void Inhibit (vlc_inhibit_t *, unsigned);
 static void Timer (void *data);
 
 struct vlc_inhibit_sys
@@ -97,9 +97,10 @@ static void Close (vlc_object_t *obj)
     free (sys);
 }
 
-static void Inhibit (vlc_inhibit_t *ih, bool unblank)
+static void Inhibit (vlc_inhibit_t *ih, unsigned flags)
 {
     vlc_inhibit_sys_t *sys = ih->p_sys;
+    bool unblank = (flags & VLC_INHIBIT_DISPLAY) != 0;
 
     /* The shortest blanking interval is 10s on N900, 15s on N9 */
     const mtime_t interval = 9 * CLOCK_FREQ;
diff --git a/modules/misc/inhibit/xdg.c b/modules/misc/inhibit/xdg.c
index 56d065b7..191568a 100644
--- a/modules/misc/inhibit/xdg.c
+++ b/modules/misc/inhibit/xdg.c
@@ -75,9 +75,10 @@ static void Timer (void *data)
     }
 }
 
-static void Inhibit (vlc_inhibit_t *ih, bool suspend)
+static void Inhibit (vlc_inhibit_t *ih, unsigned mask)
 {
     vlc_inhibit_sys_t *sys = ih->p_sys;
+    bool suspend = (mask & VLC_INHIBIT_DISPLAY) != 0;
     mtime_t delay = suspend ? 30 * CLOCK_FREQ : INT64_C(0);
 
     vlc_timer_schedule (sys->timer, false, delay, delay);
diff --git a/modules/misc/inhibit/xscreensaver.c b/modules/misc/inhibit/xscreensaver.c
index 819d74f..c219c66 100644
--- a/modules/misc/inhibit/xscreensaver.c
+++ b/modules/misc/inhibit/xscreensaver.c
@@ -48,7 +48,7 @@ static int  Activate     ( vlc_object_t * );
 static void  Deactivate   ( vlc_object_t * );
 
 static void Timer( void * );
-static void Inhibit( vlc_inhibit_t *, bool );
+static void Inhibit( vlc_inhibit_t *, unsigned );
 
 struct vlc_inhibit_sys
 {
@@ -122,8 +122,9 @@ static void Deactivate( vlc_object_t *p_this )
     free( p_sys );
 }
 
-static void Inhibit( vlc_inhibit_t *p_ih, bool suspend )
+static void Inhibit( vlc_inhibit_t *p_ih, unsigned mask )
 {
+    bool suspend = (mask & VLC_INHIBIT_DISPLAY) != 0;
     mtime_t d = suspend ? 30*CLOCK_FREQ : 0;
     vlc_timer_schedule( p_ih->p_sys->timer, false, d, d );
 }
diff --git a/src/video_output/inhibit.h b/src/video_output/inhibit.h
index 2df2c82..764b8a9 100644
--- a/src/video_output/inhibit.h
+++ b/src/video_output/inhibit.h
@@ -25,9 +25,4 @@
 
 vlc_inhibit_t *vlc_inhibit_Create (vlc_object_t *);
 void vlc_inhibit_Destroy (vlc_inhibit_t *);
-
-static inline void vlc_inhibit_Set (vlc_inhibit_t *ih, bool suspend)
-{
-    ih->inhibit (ih, suspend);
-}
 #endif
diff --git a/src/video_output/window.c b/src/video_output/window.c
index 7efc8eb..4f1951f 100644
--- a/src/video_output/window.c
+++ b/src/video_output/window.c
@@ -97,7 +97,7 @@ vout_window_t *vout_window_New(vlc_object_t *obj,
         cfg->type == VOUT_WINDOW_TYPE_XID) {
         w->inhibit = vlc_inhibit_Create(VLC_OBJECT (window));
         if (w->inhibit != NULL)
-            vlc_inhibit_Set(w->inhibit, true);
+            vlc_inhibit_Set(w->inhibit, VLC_INHIBIT_VIDEO);
             /* FIXME: ^ wait for vout activation, pause */
     }
     else
@@ -121,7 +121,7 @@ void vout_window_Delete(vout_window_t *window)
     window_t *w = (window_t *)window;
     if (w->inhibit)
     {
-        vlc_inhibit_Set (w->inhibit, false);
+        vlc_inhibit_Set (w->inhibit, VLC_INHIBIT_NONE);
         vlc_inhibit_Destroy (w->inhibit);
     }
 



More information about the vlc-commits mailing list