diff options
Diffstat (limited to 'p2pvr/lib/tuner.cpp')
-rw-r--r-- | p2pvr/lib/tuner.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/p2pvr/lib/tuner.cpp b/p2pvr/lib/tuner.cpp index 3cfb8a4..b20cc75 100644 --- a/p2pvr/lib/tuner.cpp +++ b/p2pvr/lib/tuner.cpp @@ -23,7 +23,8 @@ Tuner::Tuner(const boost::filesystem::path & df) : deviceFrontend(df), deviceRoot(df.branch_path()), timeout(20000), - backgroundThread(NULL) + backgroundThread(NULL), + lastUsedTime(time(NULL)) { int fd = open(deviceFrontend.string().c_str(), O_RDWR); if (fd < 0) { @@ -65,12 +66,14 @@ Tuner::TuneTo(const DVBSI::DeliveryPtr & mp, const Ice::Current&) int Tuner::GetStatus(const Ice::Current &) { + time(&lastUsedTime); return frontend->GetStatus(); } std::string Tuner::Device() const { + time(&lastUsedTime); return deviceRoot.string(); } @@ -87,6 +90,7 @@ Tuner::OpenDemux() const void Tuner::ScanAndSendNetworkInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current & ice) { + time(&lastUsedTime); frontend->FrequencyScan([this, &client, &ice](long) { try { return (SendPID(0x10, client, ice) > 0); @@ -136,6 +140,7 @@ Tuner::SendEventInformation(const P2PVR::RawDataClientPrx & client, const Ice::C uint64_t Tuner::SendPID(int pid, const P2PVR::RawDataClientPrx & client, const Ice::Current & ice) const { + time(&lastUsedTime); Logger()->messagebf(LOG_DEBUG, "%s: pid = 0x%x", __PRETTY_FUNCTION__, pid); ice.con->createProxy(client->ice_getIdentity()); @@ -200,6 +205,7 @@ Tuner::ReadDemuxAndSend(int demux, const P2PVR::RawDataClientPrx & client) const asyncs.push_back(client->begin_NewData(buf)); packetsSent += 1; + time(&lastUsedTime); asyncs.erase(std::remove_if(asyncs.begin(), asyncs.end(), [&exitFlag, &client](const Ice::AsyncResultPtr & a) { if (a->isCompleted()) { @@ -219,6 +225,7 @@ Tuner::ReadDemuxAndSend(int demux, const P2PVR::RawDataClientPrx & client) const int Tuner::StartSendingTS(const P2PVR::PacketIds & pids, const P2PVR::RawDataClientPrx & client, const Ice::Current &) { + time(&lastUsedTime); Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); if (pids.empty()) { throw P2PVR::DeviceError("demux", "Packet Id list cannot be empty", 0); @@ -265,6 +272,7 @@ Tuner::StartSendingTS(const P2PVR::PacketIds & pids, const P2PVR::RawDataClientP void Tuner::StopSendingTS(int handle, const Ice::Current &) { + time(&lastUsedTime); Logger()->message(LOG_DEBUG, __PRETTY_FUNCTION__); std::lock_guard<std::mutex> g(lock); if (backgroundClients.find(handle) != backgroundClients.end()) { @@ -326,6 +334,7 @@ Tuner::senderThread() } // Clean up finished async requests asyncs.erase(std::remove_if(asyncs.begin(), asyncs.end(), [this](const AsyncCall & a) { + time(&lastUsedTime); try { if (a.get<1>()->isCompleted()) { if (!a.get<0>()->end_NewData(a.get<1>())) { @@ -357,6 +366,12 @@ Tuner::senderThread() backgroundThread = NULL; Logger()->messagebf(LOG_DEBUG, "%s: Unlocking", __PRETTY_FUNCTION__); lock.unlock(); +} + +Ice::Long +Tuner::GetLastUsedTime(const Ice::Current &) +{ + return lastUsedTime; } bool |