From: ghost Date: Wed, 20 Oct 2010 22:24:44 +0000 (+0200) Subject: add possibility to set demux buffer size for PES Reader, Section Reader and TS Recorder X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=commitdiff_plain;h=2c12949f63d76781a3ad187488560159b1fd13ac add possibility to set demux buffer size for PES Reader, Section Reader and TS Recorder --- diff --git a/lib/dvb/demux.cpp b/lib/dvb/demux.cpp index 4fba8fa..081059b 100644 --- a/lib/dvb/demux.cpp +++ b/lib/dvb/demux.cpp @@ -247,6 +247,14 @@ eDVBSectionReader::~eDVBSectionReader() ::close(fd); } +RESULT eDVBSectionReader::setBufferSize(int size) +{ + int res=::ioctl(fd, DMX_SET_BUFFER_SIZE, size); + if (res < 0) + eDebug("eDVBSectionReader DMX_SET_BUFFER_SIZE failed(%m)"); + return res; +} + RESULT eDVBSectionReader::start(const eDVBSectionFilterMask &mask) { RESULT res; @@ -279,8 +287,7 @@ RESULT eDVBSectionReader::start(const eDVBSectionFilterMask &mask) memcpy(sct.filter.mask, mask.mask, DMX_FILTER_SIZE); #if HAVE_DVB_API_VERSION >= 3 memcpy(sct.filter.mode, mask.mode, DMX_FILTER_SIZE); - if (::ioctl(fd, DMX_SET_BUFFER_SIZE, 8192*8) < 0) - eDebug("DMX_SET_BUFFER_SIZE failed(%m)"); + setBufferSize(8192*8); #endif res = ::ioctl(fd, DMX_SET_FILTER, &sct); @@ -352,7 +359,7 @@ eDVBPESReader::eDVBPESReader(eDVBDemux *demux, eMainloop *context, RESULT &res): if (m_fd >= 0) { - ::ioctl(m_fd, DMX_SET_BUFFER_SIZE, 64*1024); + setBufferSize(64*1024); ::fcntl(m_fd, F_SETFL, O_NONBLOCK); m_notifier = eSocketNotifier::create(context, m_fd, eSocketNotifier::Read, false); CONNECT(m_notifier->activated, eDVBPESReader::data); @@ -364,6 +371,14 @@ eDVBPESReader::eDVBPESReader(eDVBDemux *demux, eMainloop *context, RESULT &res): } } +RESULT eDVBPESReader::setBufferSize(int size) +{ + int res = ::ioctl(m_fd, DMX_SET_BUFFER_SIZE, size); + if (res < 0) + eDebug("eDVBPESReader DMX_SET_BUFFER_SIZE failed(%m)"); + return res; +} + DEFINE_REF(eDVBPESReader) eDVBPESReader::~eDVBPESReader() @@ -484,7 +499,7 @@ eDVBTSRecorder::eDVBTSRecorder(eDVBDemux *demux): m_demux(demux) m_running = 0; m_target_fd = -1; m_thread = new eDVBRecordFileThread(); - CONNECT(m_thread->m_event, eDVBTSRecorder::filepushEvent); + CONNECT(m_thread->m_event, eDVBTSRecorder::filepushEvent); #ifndef HAVE_ADD_PID m_demux->m_dvr_busy = 1; #endif @@ -536,8 +551,8 @@ RESULT eDVBTSRecorder::start() eDebug("FAILED to open demux (%s) in ts recoder (%m)", filename); return -3; } - - ::ioctl(m_source_fd, DMX_SET_BUFFER_SIZE, 1024*1024); + + setBufferSize(1024*1024); dmx_pes_filter_params flt; #if HAVE_DVB_API_VERSION > 3 @@ -577,6 +592,14 @@ RESULT eDVBTSRecorder::start() return 0; } +RESULT eDVBTSRecorder::setBufferSize(int size) +{ + int res = ::ioctl(m_source_fd, DMX_SET_BUFFER_SIZE, size); + if (res < 0) + eDebug("eDVBTSRecorder DMX_SET_BUFFER_SIZE failed(%m)"); + return res; +} + RESULT eDVBTSRecorder::addPID(int pid) { if (m_pids.find(pid) != m_pids.end()) diff --git a/lib/dvb/demux.h b/lib/dvb/demux.h index 7a697d4..d43c41b 100644 --- a/lib/dvb/demux.h +++ b/lib/dvb/demux.h @@ -56,9 +56,9 @@ class eDVBSectionReader: public iDVBSectionReader, public Object void data(int); ePtr notifier; public: - eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res); virtual ~eDVBSectionReader(); + RESULT setBufferSize(int size); RESULT start(const eDVBSectionFilterMask &mask); RESULT stop(); RESULT connectRead(const Slot1 &read, ePtr &conn); @@ -76,6 +76,7 @@ class eDVBPESReader: public iDVBPESReader, public Object public: eDVBPESReader(eDVBDemux *demux, eMainloop *context, RESULT &res); virtual ~eDVBPESReader(); + RESULT setBufferSize(int size); RESULT start(int pid); RESULT stop(); RESULT connectRead(const Slot2 &read, ePtr &conn); @@ -90,6 +91,7 @@ public: eDVBTSRecorder(eDVBDemux *demux); ~eDVBTSRecorder(); + RESULT setBufferSize(int size); RESULT start(); RESULT addPID(int pid); RESULT removePID(int pid); diff --git a/lib/dvb/idemux.h b/lib/dvb/idemux.h index e92b1e7..86b35fd 100644 --- a/lib/dvb/idemux.h +++ b/lib/dvb/idemux.h @@ -6,6 +6,7 @@ class iDVBSectionReader: public iObject { public: + virtual RESULT setBufferSize(int size)=0; virtual RESULT start(const eDVBSectionFilterMask &mask)=0; virtual RESULT stop()=0; virtual RESULT connectRead(const Slot1 &read, ePtr &conn)=0; @@ -15,6 +16,7 @@ public: class iDVBPESReader: public iObject { public: + virtual RESULT setBufferSize(int size)=0; virtual RESULT start(int pid)=0; virtual RESULT stop()=0; virtual RESULT connectRead(const Slot2 &read, ePtr &conn)=0; @@ -26,6 +28,7 @@ public: class iDVBTSRecorder: public iObject { public: + virtual RESULT setBufferSize(int size) = 0; virtual RESULT start() = 0; virtual RESULT addPID(int pid) = 0; virtual RESULT removePID(int pid) = 0;