summaryrefslogtreecommitdiff
path: root/p2pvr/lib/tuner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'p2pvr/lib/tuner.cpp')
-rw-r--r--p2pvr/lib/tuner.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/p2pvr/lib/tuner.cpp b/p2pvr/lib/tuner.cpp
index 25042ba..b958e31 100644
--- a/p2pvr/lib/tuner.cpp
+++ b/p2pvr/lib/tuner.cpp
@@ -152,6 +152,7 @@ Tuner::SendPID(int pid, const P2PVR::RawDataClientPrx & client, const Ice::Curre
void
Tuner::RequestPID(int pid, int demux)
{
+ setBufferSize(demux, 409600);
struct dmx_sct_filter_params sctFilterParams;
memset(&sctFilterParams, 0, sizeof(dmx_sct_filter_params));
sctFilterParams.pid = pid;
@@ -288,6 +289,7 @@ Tuner::StartSendingTS(const P2PVR::PacketIds & pids, const P2PVR::RawDataClientP
}
}
+ setBufferSize(demux, 4096000);
if (ioctl(demux, DMX_START) < 0) {
backgroundClients.erase(demux);
Logger()->messagebf(LOG_ERR, "%s: DMX_START failed (%d: %s)", __PRETTY_FUNCTION__, errno, strerror(errno));
@@ -299,6 +301,16 @@ Tuner::StartSendingTS(const P2PVR::PacketIds & pids, const P2PVR::RawDataClientP
}
void
+Tuner::setBufferSize(int demux, unsigned long size)
+{
+ if (ioctl(demux, DMX_SET_BUFFER_SIZE, size)) {
+ Logger()->messagebf(LOG_ERR, "%s: DMX_SET_BUFFER_SIZE to %d failed (%d: %s)", __PRETTY_FUNCTION__, size, errno, strerror(errno));
+ throw P2PVR::DeviceError("demux", strerror(errno), errno);
+ }
+ Logger()->messagebf(LOG_DEBUG, "%s: DMX_SET_BUFFER_SIZE to %d", __PRETTY_FUNCTION__, size);
+}
+
+void
Tuner::StopSending(int handle, const Ice::Current &)
{
time(&lastUsedTime);
@@ -332,10 +344,12 @@ Tuner::senderThread()
FD_SET(c.first, &rfds);
}
lock.unlock();
+ time(&lastUsedTime);
struct timeval tv { 2, 0 };
switch (select(n, &rfds, NULL, NULL, &tv)) {
case -1: // error
+ Logger()->messagebf(LOG_DEBUG, "%s: select failed (%d:%s)", __PRETTY_FUNCTION__, errno, strerror(errno));
case 0: // nothing to read, but all is well
break;
default:
@@ -347,6 +361,7 @@ Tuner::senderThread()
P2PVR::Data buf(1 << 16);
int nr = read(c.first, &buf.front(), buf.size());
if (nr < 0) {
+ Logger()->messagebf(LOG_DEBUG, "%s: read failed (%d:%s)", __PRETTY_FUNCTION__, errno, strerror(errno));
close(c.first);
backgroundClients.erase(c.first);
break; // backgroundClients has changed, bailout and start again
@@ -377,6 +392,7 @@ Tuner::senderThread()
return false;
}
catch (...) {
+ Logger()->messagebf(LOG_DEBUG, "%s: Client transmit error", __PRETTY_FUNCTION__);
close(a.get<2>());
std::lock_guard<std::mutex> g(lock);
backgroundClients.erase(a.get<2>());