From 927ea3e9371a89688f73534531ce761f752b41d2 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 6 Aug 2017 23:23:14 +0100 Subject: Wrap new TunerI in a function to be mocked --- p2pvr/devices/devices.cpp | 10 ++++++++-- p2pvr/devices/devices.h | 3 +++ 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 DeliveryProvider; typedef boost::function Target; -- cgit v1.2.3