summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-08-06 23:23:14 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2017-08-06 23:23:14 +0100
commit927ea3e9371a89688f73534531ce761f752b41d2 (patch)
treedf0ce2ec9d4fc2050212fb2093cbf7f2609e8139
parentTidy demux code to use file handles (diff)
downloadp2pvr-927ea3e9371a89688f73534531ce761f752b41d2.tar.bz2
p2pvr-927ea3e9371a89688f73534531ce761f752b41d2.tar.xz
p2pvr-927ea3e9371a89688f73534531ce761f752b41d2.zip
Wrap new TunerI in a function to be mocked
-rw-r--r--p2pvr/devices/devices.cpp10
-rw-r--r--p2pvr/devices/devices.h3
2 files changed, 11 insertions, 2 deletions
diff --git a/p2pvr/devices/devices.cpp b/p2pvr/devices/devices.cpp
index 541cfa5..420632d 100644
--- a/p2pvr/devices/devices.cpp
+++ b/p2pvr/devices/devices.cpp
@@ -52,7 +52,7 @@ DevicesI::getTuner()
}
for (auto devItr = devices.begin(); devItr != devices.end(); devItr++) {
try {
- return new DVB::TunerI(*devItr);
+ return openTuner(*devItr);
}
catch (...) {
logger->messagebf(LOG::DEBUG, "%s: Failed to open device %s", __PRETTY_FUNCTION__,
@@ -79,7 +79,7 @@ DevicesI::getTuner(const DVBSI::DeliveryPtr & delivery)
}
for (auto devItr = devices.begin(); devItr != devices.end(); devItr++) {
try {
- TunerPtr tuner = new DVB::TunerI(*devItr);
+ TunerPtr tuner = openTuner(*devItr);
tuner->TuneTo(delivery);
openDevices.insert({ delivery->TransportStreamId, OpenTunerPtr(new OpenTuner(delivery, tuner)) });
devices.erase(devItr);
@@ -109,6 +109,12 @@ DevicesI::getTuner(const DeliveryProvider & provider)
return getTuner(provider());
}
+TunerPtr
+DevicesI::openTuner(const boost::filesystem::path & path) const
+{
+ return new DVB::TunerI(path);
+}
+
void
DevicesI::releaseTuner(const TunerPtr & tuner)
{
diff --git a/p2pvr/devices/devices.h b/p2pvr/devices/devices.h
index 30e0848..d32971f 100644
--- a/p2pvr/devices/devices.h
+++ b/p2pvr/devices/devices.h
@@ -43,6 +43,9 @@ class DLL_PUBLIC DevicesI : public Tuners {
void Remove(const std::string & frontend, const Ice::Current &) override;
::Ice::Int TunerCount(const Ice::Current &) override;
+ protected:
+ virtual TunerPtr openTuner(const boost::filesystem::path &) const;
+
private:
typedef boost::function<DVBSI::DeliveryPtr()> DeliveryProvider;
typedef boost::function<void(TunerPtr)> Target;