From f5d81bc8e8dd77f807507019898058d08f14a23d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 8 Aug 2017 20:44:03 +0100 Subject: Support passing a frontend instance into a tuner (easier testing) --- p2pvr/devices/tuner.cpp | 7 ++++++- p2pvr/devices/tuner.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/p2pvr/devices/tuner.cpp b/p2pvr/devices/tuner.cpp index 41a77c3..e7fd2eb 100644 --- a/p2pvr/devices/tuner.cpp +++ b/p2pvr/devices/tuner.cpp @@ -16,17 +16,22 @@ namespace P2PVR { namespace DVB { IceTray::Logging::LoggerPtr TunerI::logger = LOGMANAGER()->getLogger(); -TunerI::TunerI(const boost::filesystem::path & df) : +TunerI::TunerI(const boost::filesystem::path & df, FrontendPtr pfe) : deviceFrontend(df), deviceRoot(df.branch_path()), frontendFD(deviceFrontend, O_RDWR), backgroundThread(NULL) { + if (pfe) { + frontend = pfe; + } + else { struct dvb_frontend_info fe_info; if (ioctl(frontendFD, FE_GET_INFO, &fe_info) < 0) { throw DeviceError(deviceFrontend.string(), strerror(errno), errno); } frontend = FrontendPtr(FrontendFactory::createNew(Frontend::FactoryKey(fe_info.type), this, fe_info)); + } logger->messagebf(LOG::INFO, "%s: Attached to %s (%s, type %s)", __PRETTY_FUNCTION__, deviceRoot, frontend->Info().name, frontend->Type()); } diff --git a/p2pvr/devices/tuner.h b/p2pvr/devices/tuner.h index 7db09e4..8534a3c 100644 --- a/p2pvr/devices/tuner.h +++ b/p2pvr/devices/tuner.h @@ -41,7 +41,7 @@ class TunerI : public Tuner { typedef boost::shared_ptr BackgroundClient; typedef std::map BackgroundClients; - TunerI(const boost::filesystem::path & deviceFrontend); + TunerI(const boost::filesystem::path & deviceFrontend, FrontendPtr = FrontendPtr()); ~TunerI(); void TuneTo(const DVBSI::DeliveryPtr &) override; -- cgit v1.2.3