summaryrefslogtreecommitdiff
path: root/p2pvr/lib/tuner.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2013-12-03 03:40:35 +0000
committerrandomdan <randomdan@localhost>2013-12-03 03:40:35 +0000
commit41c1a2777f87c25a092cd122f1d9c422d71d9ff4 (patch)
treea42440dbb9605ac76c2b9593a95bea47f114444a /p2pvr/lib/tuner.cpp
parentRemove tuner from adapter only when there are no more users (diff)
downloadp2pvr-41c1a2777f87c25a092cd122f1d9c422d71d9ff4.tar.bz2
p2pvr-41c1a2777f87c25a092cd122f1d9c422d71d9ff4.tar.xz
p2pvr-41c1a2777f87c25a092cd122f1d9c422d71d9ff4.zip
Changes to add downloading program association table and program map (big mess in maintenance.cpp now)
Supporting changes in slice, general libs etc Wait for lock after tuning, throw on fail Don't register tuner as in use until tuning has succeeded Tweaks in table parser to be more helpful Count packets transmitted in a demux send
Diffstat (limited to 'p2pvr/lib/tuner.cpp')
-rw-r--r--p2pvr/lib/tuner.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/p2pvr/lib/tuner.cpp b/p2pvr/lib/tuner.cpp
index e508152..3cfb8a4 100644
--- a/p2pvr/lib/tuner.cpp
+++ b/p2pvr/lib/tuner.cpp
@@ -89,8 +89,7 @@ Tuner::ScanAndSendNetworkInformation(const P2PVR::RawDataClientPrx & client, con
{
frontend->FrequencyScan([this, &client, &ice](long) {
try {
- SendNetworkInformation(client, ice);
- return true;
+ return (SendPID(0x10, client, ice) > 0);
}
catch (...) {
return false;
@@ -117,12 +116,24 @@ Tuner::SendServiceDescriptions(const P2PVR::RawDataClientPrx & client, const Ice
}
void
+Tuner::SendProgramMap(Ice::Int pid, const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
+{
+ SendPID(pid, client, ice);
+}
+
+void
+Tuner::SendProgramAssociationTable(const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
+{
+ SendPID(0x00, client, ice);
+}
+
+void
Tuner::SendEventInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
{
SendPID(0x12, client, ice);
}
-void
+uint64_t
Tuner::SendPID(int pid, const P2PVR::RawDataClientPrx & client, const Ice::Current & ice) const
{
Logger()->messagebf(LOG_DEBUG, "%s: pid = 0x%x", __PRETTY_FUNCTION__, pid);
@@ -138,15 +149,16 @@ Tuner::SendPID(int pid, const P2PVR::RawDataClientPrx & client, const Ice::Curre
throw P2PVR::DeviceError("demux", strerror(errno), errno);
}
- ReadDemuxAndSend(demux, client);
+ return ReadDemuxAndSend(demux, client);
}
-void
+uint64_t
Tuner::ReadDemuxAndSend(int demux, const P2PVR::RawDataClientPrx & client) const
{
Logger()->messagebf(LOG_DEBUG, "%s: begin", __PRETTY_FUNCTION__);
std::vector<Ice::AsyncResultPtr> asyncs;
struct pollfd ufd;
+ uint64_t packetsSent = 0;
bool exitFlag = false;
do {
// Wait for data to appear
@@ -155,7 +167,7 @@ Tuner::ReadDemuxAndSend(int demux, const P2PVR::RawDataClientPrx & client) const
ufd.events = POLLIN;
if (poll(&ufd, 1, timeout) < 1) {
Logger()->messagebf(LOG_DEBUG, "%s: Timed out waiting for data", __PRETTY_FUNCTION__);
- throw P2PVR::DeviceError("demux", "Timed out. Tuned to a multiplex?", 0);
+ break;
}
// Read it
@@ -187,6 +199,7 @@ Tuner::ReadDemuxAndSend(int demux, const P2PVR::RawDataClientPrx & client) const
}
asyncs.push_back(client->begin_NewData(buf));
+ packetsSent += 1;
asyncs.erase(std::remove_if(asyncs.begin(), asyncs.end(), [&exitFlag, &client](const Ice::AsyncResultPtr & a) {
if (a->isCompleted()) {
@@ -200,6 +213,7 @@ Tuner::ReadDemuxAndSend(int demux, const P2PVR::RawDataClientPrx & client) const
client->end_NewData(a);
}
Logger()->messagebf(LOG_DEBUG, "%s: end", __PRETTY_FUNCTION__);
+ return packetsSent;
}
int