On Friday 26 November 2004 16:54, Hans Meine wrote:
> BTW: Yesterday, I managed to implement hibernate support within Freevo (has
> to be polished) using ivtv (where the kernel module has to be unloaded in
> order to suspend), without leaving Freevo! :-) I can even suspend with the
> detached audio player still running, and it will resume to exactly that
> situation. :-) (Total startup time after pressing power button reduced from
> 57sec. to 33.)
>
> In order to do so, I made the following changes in Freevo:
> - closing ivtv file descriptors in order to make unloading ivtv possible
At first, I did this at another place, but it turned out to be as easy as this 
one-liner (also attached):

@@ -128,6 +128,7 @@ class MPlayer:
                 ivtv_dev.init_settings()
                 ivtv_dev.setinput(vg.input_num)
                 #ivtv_dev.print_settings()
+                ivtv_dev.close()
                 self.fc.chanSet(tuner_channel)

                 tvcmd = vg.vdev

> - added suspend/resume hooks to the Lirc class
>    (also needed since lirc does not work after resuming otherwise)

I attached this patch, too; it introduces suspend/resume on input handlers.

-- 
Ciao, /  /                                                    .o.
     /--/                                                     ..o
    /  / ANS                                                  ooo
Index: tv/plugins/mplayer.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/tv/plugins/mplayer.py,v
retrieving revision 1.38
diff -u -3 -p -d -b -r1.38 mplayer.py
--- tv/plugins/mplayer.py	11 Jul 2004 11:32:47 -0000	1.38
+++ tv/plugins/mplayer.py	28 Nov 2004 18:13:48 -0000
@@ -128,6 +128,7 @@ class MPlayer:
                 ivtv_dev.init_settings()
                 ivtv_dev.setinput(vg.input_num)
                 #ivtv_dev.print_settings()
+                ivtv_dev.close()
                 self.fc.chanSet(tuner_channel)
             
                 tvcmd = vg.vdev
Index: rc.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/Attic/rc.py,v
retrieving revision 1.36.2.1
diff -u -3 -p -d -b -r1.36.2.1 rc.py
--- rc.py	20 Oct 2004 18:31:46 -0000	1.36.2.1
+++ rc.py	28 Nov 2004 18:14:35 -0000
@@ -161,22 +161,22 @@ class Lirc:
     """
     def __init__(self):
         try:
+            global pylirc
             import pylirc
         except ImportError:
             print 'WARNING: PyLirc not found, lirc remote control disabled!'
-            raise Exception
+            raise
         try:
             if os.path.isfile(config.LIRCRC):
-                pylirc.init('freevo', config.LIRCRC)
-                pylirc.blocking(0)
+                self.resume()
             else:
                 raise IOError
         except RuntimeError:
             print 'WARNING: Could not initialize PyLirc!'
-            raise Exception
+            raise
         except IOError:
             print 'WARNING: %s not found!' % config.LIRCRC
-            raise Exception
+            raise
 
         self.nextcode = pylirc.nextcode
 
@@ -193,6 +193,21 @@ class Lirc:
         PYLIRC = True
 
         
+    def resume(self):
+        """
+        (re-)initialize pylirc, e.g. after calling close()
+        """
+        pylirc.init('freevo', config.LIRCRC)
+        pylirc.blocking(0)
+
+
+    def suspend(self):
+        """
+        cleanup pylirc, close devices
+        """
+        pylirc.exit()
+
+
     def get_last_code(self):
         """
         read the lirc interface
@@ -443,6 +458,18 @@ class EventHandler:
         self.lock.release()
 
         
+    def suspend(self):
+        for i in self.inputs:
+            if hasattr(i, 'suspend'):
+                i.suspend()
+
+
+    def resume(self):
+        for i in self.inputs:
+            if hasattr(i, 'resume'):
+                i.resume()
+
+
     def shutdown(self):
         """
         shutdown the rc

Reply via email to