X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/0fb354eb517927bd6c8465523800e6ee398a1db7..139531c95ab1bd9ea0da563d43a3d8677b937aa9:/lib/dvb/demux.cpp diff --git a/lib/dvb/demux.cpp b/lib/dvb/demux.cpp index 73cedc36..810b10a5 100644 --- a/lib/dvb/demux.cpp +++ b/lib/dvb/demux.cpp @@ -76,11 +76,12 @@ RESULT eDVBDemux::setSourceFrontend(int fenum) { #if HAVE_DVB_API_VERSION >= 3 int fd = openDemux(); - int n = DMX_SOURCE_FRONT0 + fenum; int res = ::ioctl(fd, DMX_SET_SOURCE, &n); if (res) eDebug("DMX_SET_SOURCE failed! - %m"); + else + source = fenum; ::close(fd); return res; #endif @@ -93,6 +94,7 @@ RESULT eDVBDemux::setSourcePVR(int pvrnum) int fd = openDemux(); int n = DMX_SOURCE_DVR0 + pvrnum; int res = ::ioctl(fd, DMX_SET_SOURCE, &n); + source = -1; ::close(fd); return res; #endif @@ -204,7 +206,7 @@ eDVBSectionReader::eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESUL if (fd >= 0) { - notifier=new eSocketNotifier(context, fd, eSocketNotifier::Read, false); + notifier=eSocketNotifier::create(context, fd, eSocketNotifier::Read, false); CONNECT(notifier->activated, eDVBSectionReader::data); res = 0; } else @@ -218,8 +220,6 @@ DEFINE_REF(eDVBSectionReader) eDVBSectionReader::~eDVBSectionReader() { - if (notifier) - delete notifier; if (fd >= 0) ::close(fd); } @@ -329,7 +329,7 @@ eDVBPESReader::eDVBPESReader(eDVBDemux *demux, eMainloop *context, RESULT &res): { ::ioctl(m_fd, DMX_SET_BUFFER_SIZE, 64*1024); ::fcntl(m_fd, F_SETFL, O_NONBLOCK); - m_notifier = new eSocketNotifier(context, m_fd, eSocketNotifier::Read, false); + m_notifier = eSocketNotifier::create(context, m_fd, eSocketNotifier::Read, false); CONNECT(m_notifier->activated, eDVBPESReader::data); res = 0; } else @@ -343,8 +343,6 @@ DEFINE_REF(eDVBPESReader) eDVBPESReader::~eDVBPESReader() { - if (m_notifier) - delete m_notifier; if (m_fd >= 0) ::close(m_fd); } @@ -407,12 +405,14 @@ public: void setTimingPID(int pid); void saveTimingInformation(const std::string &filename); + int getLastPTS(pts_t &pts); protected: int filterRecordData(const unsigned char *data, int len, size_t ¤t_span_remaining); private: eMPEGStreamParserTS m_ts_parser; eMPEGStreamInformation m_stream_info; off_t m_current_offset; + pts_t m_last_pcr; /* very approximate.. */ int m_pid; }; @@ -432,6 +432,11 @@ void eDVBRecordFileThread::saveTimingInformation(const std::string &filename) m_stream_info.save(filename.c_str()); } +int eDVBRecordFileThread::getLastPTS(pts_t &pts) +{ + return m_ts_parser.getLastPTS(pts); +} + int eDVBRecordFileThread::filterRecordData(const unsigned char *data, int len, size_t ¤t_span_remaining) { m_ts_parser.parseData(m_current_offset, data, len); @@ -591,6 +596,18 @@ RESULT eDVBTSRecorder::stop() return 0; } +RESULT eDVBTSRecorder::getCurrentPCR(pts_t &pcr) +{ + if (!m_running) + return 0; + if (!m_thread) + return 0; + /* XXX: we need a lock here */ + + /* we don't filter PCR data, so just use the last received PTS, which is not accurate, but better than nothing */ + return m_thread->getLastPTS(pcr); +} + RESULT eDVBTSRecorder::connectEvent(const Slot1 &event, ePtr &conn) { conn = new eConnection(this, m_event.connect(event)); @@ -632,7 +649,6 @@ RESULT eDVBTSRecorder::startPID(int pid) } m_pids[pid] = fd; #else - bool retry=false; while(true) { if (::ioctl(m_source_fd, DMX_ADD_PID, pid) < 0) { perror("DMX_ADD_PID");