fix wrap around with enabled movemode
[enigma2.git] / lib / service / servicedvbrecord.cpp
index 10ab8ae7279c572ba3583432955064f01f0a26fe..bded7cc9c757b602a86934b08434688e70c6802b 100644 (file)
@@ -102,9 +102,13 @@ int eDVBServiceRecord::doRecord()
                int fd = ::open(m_filename.c_str(), O_WRONLY|O_CREAT|O_LARGEFILE, 0644);
                if (fd == -1)
                {
-                       eDebug("eDVBServiceRecord - can't open hardcoded recording file!");
+                       eDebug("eDVBServiceRecord - can't open recording file!");
                        return -1;
                }
+               
+                       /* turn off kernel caching strategies */
+               posix_fadvise(fd, 0, 0, POSIX_FADV_RANDOM);
+               
                ePtr<iDVBDemux> demux;
                if (m_service_handler.getDataDemux(demux))
                {
@@ -118,6 +122,7 @@ int eDVBServiceRecord::doRecord()
                        return -3;
                }
                m_record->setTargetFD(fd);
+               m_record->setTargetFilename(m_filename.c_str());
        }
        eDebug("starting recording..");
        
@@ -133,6 +138,8 @@ int eDVBServiceRecord::doRecord()
                if (program.pmtPid != -1)
                        pids_to_record.insert(program.pmtPid); // PMT
                
+               int timing_pid = -1;
+               
                eDebugNoNewLine("RECORD: have %d video stream(s)", program.videoStreams.size());
                if (!program.videoStreams.empty())
                {
@@ -142,6 +149,10 @@ int eDVBServiceRecord::doRecord()
                                i != program.videoStreams.end(); ++i)
                        {
                                pids_to_record.insert(i->pid);
+                               
+                               if (timing_pid == -1)
+                                       timing_pid = i->pid;
+                               
                                if (i != program.videoStreams.begin())
                                        eDebugNoNewLine(", ");
                                eDebugNoNewLine("%04x", i->pid);
@@ -157,16 +168,23 @@ int eDVBServiceRecord::doRecord()
                                i != program.audioStreams.end(); ++i)
                        {
                                pids_to_record.insert(i->pid);
+
+                               if (timing_pid == -1)
+                                       timing_pid = i->pid;
+                               
                                if (i != program.audioStreams.begin())
                                        eDebugNoNewLine(", ");
                                eDebugNoNewLine("%04x", i->pid);
                        }
                        eDebugNoNewLine(")");
                }
-               eDebug(", and the pcr pid is %04x", program.pcrPid);
+               eDebugNoNewLine(", and the pcr pid is %04x", program.pcrPid);
                if (program.pcrPid != 0x1fff)
                        pids_to_record.insert(program.pcrPid);
-               
+               eDebug(", and the text pid is %04x", program.textPid);
+               if (program.textPid != -1)
+                       pids_to_record.insert(program.textPid); // Videotext
+
                        /* find out which pids are NEW and which pids are obsolete.. */
                std::set<int> new_pids, obsolete_pids;
                
@@ -191,6 +209,9 @@ int eDVBServiceRecord::doRecord()
                        m_record->removePID(*i);
                }
                
+               if (timing_pid != -1)
+                       m_record->setTimingPID(timing_pid);
+               
                m_pids_active = pids_to_record;
                
                if (m_state != stateRecording)