cache movie filelengths in .meta file, by luke_s
[enigma2.git] / lib / service / servicedvb.cpp
index 90195d9b13e438a790f077c5974f6f3e8703b1fc..dcd7017c97ab427b3257557d0b4a02690d57caab 100644 (file)
@@ -536,14 +536,25 @@ int eStaticServiceDVBPVRInformation::getLength(const eServiceReference &ref)
        
        eDVBTSTools tstools;
        
+       struct stat s;
+       stat(ref.path.c_str(), &s);
+
        if (tstools.openFile(ref.path.c_str()))
                return 0;
 
+                       /* check if cached data is still valid */
+       if (m_parser.m_data_ok && (s.st_size == m_parser.m_filesize) && (m_parser.m_length))
+               return m_parser.m_length / 90000;
+
+                       /* otherwise, re-calc length and update meta file */
        pts_t len;
        if (tstools.calcLen(len))
                return 0;
 
-       return len / 90000;
+       m_parser.m_length = len;
+       m_parser.m_filesize = s.st_size;
+       m_parser.updateMeta(ref.path);
+       return m_parser.m_length / 90000;
 }
 
 int eStaticServiceDVBPVRInformation::getInfo(const eServiceReference &ref, int w)