[vlc-devel] [PATCH 03/23] Maemo: screen unblank the screen when there is a video window
Rémi Denis-Courmont
remi at remlab.net
Sat Oct 3 19:52:10 CEST 2009
* Turn the display on when video starts,
* Poke the screensaver every 9 seconds to avoid blanking.
Unfortunately, we do not check that the video is _not_ paused yet.
OTOH, contrary to the normal VLC screensaver interface, we do not need
an interval timer even when there is no video at all.
---
modules/video_output/Modules.am | 2 +
modules/video_output/xcb/window.c | 67 +++++++++++++++++++++++++++++++++++++
2 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/modules/video_output/Modules.am b/modules/video_output/Modules.am
index 29a4849..2062ed1 100644
--- a/modules/video_output/Modules.am
+++ b/modules/video_output/Modules.am
@@ -49,9 +49,11 @@ libxcb_xv_plugin_la_DEPENDENCIES =
libxcb_window_plugin_la_SOURCES = xcb/window.c xcb/keys.c
libxcb_window_plugin_la_CFLAGS = $(AM_CFLAGS) \
+ $(DBUS_CFLAGS) $(GLIB2_CFLAGS) \
$(XCB_CFLAGS) \
$(XCB_KEYSYMS_CFLAGS)
libxcb_window_plugin_la_LIBADD = $(AM_LIBADD) \
+ -losso \
$(XCB_LIBS) \
$(XCB_KEYSYMS_LIBS)
libxcb_window_plugin_la_DEPENDENCIES =
diff --git a/modules/video_output/xcb/window.c b/modules/video_output/xcb/window.c
index e6f93f9..2cf4c9e 100644
--- a/modules/video_output/xcb/window.c
+++ b/modules/video_output/xcb/window.c
@@ -203,6 +203,71 @@ static void CacheAtoms (vout_window_sys_t *p_sys)
#endif
}
+#define HAVE_OSSO
+#ifdef HAVE_OSSO
+#include <libosso.h>
+
+static struct
+{
+ vlc_mutex_t lock;
+ unsigned refs;
+ osso_context_t *ctx;
+ vlc_timer_t timer;
+} osso = {
+ .lock = VLC_STATIC_MUTEX,
+ .refs = 0,
+};
+
+static void vlc_osso_unblank (void *dummy)
+{
+ (void) dummy;
+
+ vlc_mutex_lock (&osso.lock);
+ osso_display_blanking_pause (osso.ctx);
+ vlc_mutex_unlock (&osso.lock);
+}
+
+static void vlc_osso_initialize (void)
+{
+ vlc_mutex_lock (&osso.lock);
+ if (osso.refs == 0)
+ {
+ /* 10 seconds is the minimum blanking interval */
+ mtime_t start = (mdate() / CLOCK_FREQ + 8) * CLOCK_FREQ;
+ mtime_t interval = 9 * CLOCK_FREQ;
+
+ if (vlc_timer_create (&osso.timer, vlc_osso_unblank, NULL))
+ goto out;
+
+ osso.ctx = osso_initialize (PACKAGE, VERSION, 0, NULL);
+ if (osso.ctx == NULL)
+ {
+ vlc_timer_destroy (osso.timer);
+ goto out;
+ }
+
+ vlc_timer_schedule (osso.timer, true, start, interval);
+ osso_display_state_on (osso.ctx);
+ }
+ osso.refs++;
+out:
+ vlc_mutex_unlock (&osso.lock);
+}
+
+static void vlc_osso_deinitialize (void)
+{
+ vlc_mutex_lock (&osso.lock);
+ if (osso.refs == 1)
+ {
+ vlc_timer_destroy (osso.timer);
+ osso_deinitialize (osso.ctx);
+ }
+ if (osso.refs > 0)
+ osso.refs--;
+ vlc_mutex_unlock (&osso.lock);
+}
+#endif
+
/**
* Create an X11 window.
*/
@@ -337,6 +402,7 @@ static int Open (vlc_object_t *obj)
wnd->handle.xid, XCB_CURRENT_TIME);
#endif
xcb_flush (conn); /* Make sure map_window is sent (should be useless) */
+ vlc_osso_initialize ();
return VLC_SUCCESS;
error:
@@ -355,6 +421,7 @@ static void Close (vlc_object_t *obj)
vout_window_sys_t *p_sys = wnd->sys;
xcb_connection_t *conn = p_sys->conn;
+ vlc_osso_deinitialize ();
if (p_sys->keys)
{
vlc_cancel (p_sys->thread);
--
1.6.4.3
More information about the vlc-devel
mailing list