summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-09-03 00:29:40 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-09-03 00:29:40 +0100
commit2a551c907b3fd0c282bce46970066cfd402a594c (patch)
treec901e9b084900cf7e169848aeb54991a3a6da0a4
parentUse libadhocutil (diff)
downloadp2pvr-2a551c907b3fd0c282bce46970066cfd402a594c.tar.bz2
p2pvr-2a551c907b3fd0c282bce46970066cfd402a594c.tar.xz
p2pvr-2a551c907b3fd0c282bce46970066cfd402a594c.zip
Use libadhocutil
-rw-r--r--p2pvr/Jamfile.jam6
-rw-r--r--p2pvr/daemon/Jamfile.jam1
-rw-r--r--p2pvr/daemon/dbClient.h4
-rw-r--r--p2pvr/daemon/maintenance.cpp2
-rw-r--r--p2pvr/daemon/muxedFileSink.cpp19
-rw-r--r--p2pvr/daemon/muxedFileSink.h6
-rw-r--r--p2pvr/daemon/recorder.cpp6
-rw-r--r--p2pvr/daemon/unittests/Jamfile.jam16
-rw-r--r--p2pvr/daemon/unittests/mockDefs.cpp12
-rw-r--r--p2pvr/daemon/unittests/testErrorHandling.cpp3
-rw-r--r--p2pvr/daemon/unittests/testMaint.cpp3
-rw-r--r--p2pvr/daemon/unittests/testRecording.cpp3
-rw-r--r--p2pvr/daemon/unittests/testRecordings.cpp3
-rw-r--r--p2pvr/daemon/unittests/testSched.cpp2
-rw-r--r--p2pvr/daemon/unittests/testSi.cpp2
-rw-r--r--p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp2
-rw-r--r--p2pvr/daemon/unittests/testp2ice.cpp6
-rw-r--r--p2pvr/daemonbase/Jamfile.jam1
-rw-r--r--p2pvr/devices/Jamfile.jam2
-rw-r--r--p2pvr/devices/tuner.cpp4
-rw-r--r--p2pvr/dvb/Jamfile.jam1
-rw-r--r--p2pvr/dvb/siParsers/network.cpp15
-rw-r--r--p2pvr/dvb/unittests/createBroadcast.cpp1
-rw-r--r--p2pvr/dvb/unittests/createSamples.cpp4
-rw-r--r--p2pvr/ice/Jamfile.jam2
-rw-r--r--p2pvr/ice/commonHelpers.cpp1
-rw-r--r--p2pvr/lib/Jamfile.jam4
-rw-r--r--p2pvr/lib/muxer.cpp22
-rw-r--r--p2pvr/lib/muxer.h6
-rw-r--r--p2pvr/p2comp/Jamfile.jam1
-rw-r--r--p2pvr/p2comp/recordingStream.cpp1
-rw-r--r--p2pvr/p2comp/serviceStream.cpp1
32 files changed, 78 insertions, 84 deletions
diff --git a/p2pvr/Jamfile.jam b/p2pvr/Jamfile.jam
index 0504b65..9be3180 100644
--- a/p2pvr/Jamfile.jam
+++ b/p2pvr/Jamfile.jam
@@ -3,6 +3,7 @@ import type ;
import generators ;
lib boost_utf : : <name>boost_unit_test_framework ;
+lib adhocutil : : : : <include>/usr/include/adhocutil ;
alias glibmm : : : :
<cflags>"`pkg-config --cflags glibmm-2.4`"
@@ -23,12 +24,9 @@ alias p2xml : glibmm : : :
;
alias p2sql : glibmm : : :
<include>/usr/include/project2/sql
+ <include>/usr/include/project2/basics
<linkflags>"-lp2sql -ldbpp"
;
-alias p2lib : glibmm : : :
- <include>/usr/include/project2/lib
- <linkflags>"-lp2lib"
-;
alias p2streams : glibmm : : :
<include>/usr/include/project2/streams
<linkflags>"-lp2streams"
diff --git a/p2pvr/daemon/Jamfile.jam b/p2pvr/daemon/Jamfile.jam
index a2a20c0..c565234 100644
--- a/p2pvr/daemon/Jamfile.jam
+++ b/p2pvr/daemon/Jamfile.jam
@@ -21,6 +21,7 @@ lib p2pvrdaemon :
<library>..//p2sql
<library>../devices//p2pvrdevices
<library>../daemonbase//p2pvrdaemonbase
+ <library>..//adhocutil
<implicit-dependency>../../libtmdb//tmdb
<library>slicer
<slicer>yes
diff --git a/p2pvr/daemon/dbClient.h b/p2pvr/daemon/dbClient.h
index 84cf5e7..cd846e5 100644
--- a/p2pvr/daemon/dbClient.h
+++ b/p2pvr/daemon/dbClient.h
@@ -6,7 +6,7 @@
#include <list>
#include <selectcommand.h>
#include <modifycommand.h>
-#include <scopeObject.h>
+#include <scopeExit.h>
#include <rdbmsDataSource.h>
#include <sqlVariableBinder.h>
#include <sqlHandleAsVariableType.h>
@@ -28,7 +28,7 @@ class DatabaseClient : public virtual CommonObjects {
private:
const DatabaseClient * client;
- ScopeObject so;
+ AdHoc::ScopeExit so;
};
template <typename... Args>
diff --git a/p2pvr/daemon/maintenance.cpp b/p2pvr/daemon/maintenance.cpp
index e3747b3..f6878ec 100644
--- a/p2pvr/daemon/maintenance.cpp
+++ b/p2pvr/daemon/maintenance.cpp
@@ -64,7 +64,7 @@ Maintenance::ScheduledUpdate()
if (!updateRunning) {
std::thread update([this] {
try {
- ScopeObject notRunning([this]{ updateRunning = false; });
+ AdHoc::ScopeExit notRunning([this]{ updateRunning = false; });
updateRunning = true;
auto si = P2PVR::MaintenancePrx::checkedCast(adapter->createProxy(adapter->getCommunicator()->stringToIdentity("Maintenance")));
time_t now = time(NULL);
diff --git a/p2pvr/daemon/muxedFileSink.cpp b/p2pvr/daemon/muxedFileSink.cpp
index 3008aa7..16a3588 100644
--- a/p2pvr/daemon/muxedFileSink.cpp
+++ b/p2pvr/daemon/muxedFileSink.cpp
@@ -1,7 +1,6 @@
#include <pch.hpp>
#include "muxedFileSink.h"
#include <logger.h>
-#include <misc.h>
#include <poll.h>
#include <sys/wait.h>
#include <fcntl.h>
@@ -19,21 +18,19 @@ MuxedFileSink::MuxedFileSink(const boost::filesystem::path & t, const std::strin
c = t.string();
}
}
- muxerPid = popenrwe(params, fds);
- fcntl(fds[0], F_SETFL, O_NONBLOCK);
+ fds = ProcessPipesPtr(new AdHoc::System::ProcessPipes(params, true, true, true));
+ fcntl(fds->fdIn(), F_SETFL, O_NONBLOCK);
Logger()->messagebf(LOG_INFO, "Muxer::%p started with command '%s' for %s", this, cmd, t);
}
MuxedFileSink::~MuxedFileSink()
{
- close(fds[0]);
+ close(fds->fdIn());
int status;
- while (waitpid(muxerPid, &status, WNOHANG) == 0) {
+ while (waitpid(fds->pid(), &status, WNOHANG) == 0) {
ReadMuxer(5);
}
Logger()->messagebf(LOG_INFO, "Muxer::%p finished with status %d", this, status);
- close(fds[1]);
- close(fds[2]);
}
bool
@@ -45,7 +42,7 @@ MuxedFileSink::NewData(const P2PVR::Data & data, const Ice::Current &)
if (ReadWaiting())
return true;
// Send some input
- auto w = write(fds[0], &data[off], data.size() - off);
+ auto w = write(fds->fdIn(), &data[off], data.size() - off);
if (w == -1 && errno != EAGAIN && errno != EWOULDBLOCK) {
Logger()->messagebf(LOG_ERR, "Muxer::%p write failed (%d:%s)", this, errno, strerror(errno));
throw MuxerFailure();
@@ -59,7 +56,7 @@ MuxedFileSink::NewData(const P2PVR::Data & data, const Ice::Current &)
bool
MuxedFileSink::ReadWaiting() const
{
- pollfd fd = { fds[0], POLLOUT, 0 };
+ pollfd fd = { fds->fdIn(), POLLOUT, 0 };
while (true) {
auto p = poll(&fd, 1, 0);
if (p < 0) {
@@ -88,7 +85,7 @@ MuxedFileSink::ReadAvailable() const
bool
MuxedFileSink::ReadMuxer(int waitTime) const
{
- pollfd fd[2] = { { fds[1], POLLIN | POLLHUP, 0 }, { fds[2], POLLIN | POLLHUP, 0 } };
+ pollfd fd[2] = { { fds->fdOut(), POLLIN | POLLHUP, 0 }, { fds->fdError(), POLLIN | POLLHUP, 0 } };
while (true) {
auto p = poll(fd, 2, waitTime);
if (p < 0) {
@@ -104,7 +101,7 @@ MuxedFileSink::ReadMuxer(int waitTime) const
for (int i = 0; i < 2; ++i) {
if (fd[i].revents & (POLLIN | POLLHUP)) {
P2PVR::Data buf(BUFSIZ);
- auto len = read(fds[i + 1], &buf.front(), buf.size());
+ auto len = read(fd[i].fd, &buf.front(), buf.size());
if (len == 0) {
// ok, proc exit
closed = true;
diff --git a/p2pvr/daemon/muxedFileSink.h b/p2pvr/daemon/muxedFileSink.h
index 9cca6fa..ec22a62 100644
--- a/p2pvr/daemon/muxedFileSink.h
+++ b/p2pvr/daemon/muxedFileSink.h
@@ -4,6 +4,8 @@
#include <dvb.h>
#include <mutex>
#include <boost/filesystem/path.hpp>
+#include <boost/shared_ptr.hpp>
+#include <processPipes.h>
class MuxedFileSink : public P2PVR::RawDataClient {
public:
@@ -16,8 +18,8 @@ class MuxedFileSink : public P2PVR::RawDataClient {
bool ReadWaiting() const;
bool ReadAvailable() const;
bool ReadMuxer(int wait) const;
- int fds[3];
- pid_t muxerPid;
+ typedef boost::shared_ptr<AdHoc::System::ProcessPipes> ProcessPipesPtr;
+ ProcessPipesPtr fds;
mutable std::mutex lock;
};
diff --git a/p2pvr/daemon/recorder.cpp b/p2pvr/daemon/recorder.cpp
index 3c97fc6..e965253 100644
--- a/p2pvr/daemon/recorder.cpp
+++ b/p2pvr/daemon/recorder.cpp
@@ -4,7 +4,7 @@
#include <boost/bind.hpp>
#include <logger.h>
#include <commonHelpers.h>
-#include <scopeObject.h>
+#include <scopeExit.h>
#include "serviceStreamer.h"
#include "storage.h"
#include "muxer.h"
@@ -66,14 +66,14 @@ Recorder::StartRecording(P2PVR::SchedulePtr schedule, DVBSI::ServicePtr service,
auto id = boost::lexical_cast<std::string>(boost::uuids::random_generator()());
auto store = storage->OpenForWrite(id);
- ScopeObject _store(NULL, NULL, [this,&store,&storage,&id]() { storage->Close(store); storage->Delete(id); });
+ AdHoc::ScopeExit _store(NULL, NULL, [this,&store,&storage,&id]() { storage->Close(store); storage->Delete(id); });
auto target = store;
P2PVR::RawDataClientPrx muxer;
if (!muxerCommand.empty()) {
muxer = P2PVR::RawDataClientPrx::checkedCast(adapter->addWithUUID(new Muxer(store, muxerCommand)));
target = muxer;
}
- ScopeObject _muxer(NULL, NULL, [this,&muxer]() { if (muxer) adapter->remove(muxer->ice_getIdentity()); });
+ AdHoc::ScopeExit _muxer(NULL, NULL, [this,&muxer]() { if (muxer) adapter->remove(muxer->ice_getIdentity()); });
auto ss = ServiceStreamerPtr(new ServiceStreamer(service->ServiceId, target, adapter->getCommunicator(), adapter));
ss->Start();
diff --git a/p2pvr/daemon/unittests/Jamfile.jam b/p2pvr/daemon/unittests/Jamfile.jam
index 0acbd9e..2097b7a 100644
--- a/p2pvr/daemon/unittests/Jamfile.jam
+++ b/p2pvr/daemon/unittests/Jamfile.jam
@@ -29,7 +29,7 @@ lib testCommon :
<library>p2sqlmodPQ
<library>../..//p2sql
<library>../..//p2common
- <library>../..//p2lib
+ <library>../..//adhocutil
<library>../..//p2ut
<define>ROOT=\"$(me)\"
<library>boost_system
@@ -70,7 +70,7 @@ run
<define>BOOST_TEST_DYN_LINK
<library>../..//p2common
<library>../..//p2basics
- <library>../..//p2lib
+ <library>../..//adhocutil
<library>../..//p2xml
<library>../..//p2ut
<library>..//p2pvrdaemon
@@ -93,7 +93,7 @@ run
<define>BOOST_TEST_DYN_LINK
<library>../..//p2common
<library>../..//p2basics
- <library>../..//p2lib
+ <library>../..//adhocutil
<library>../..//p2xml
<library>../..//p2ut
<library>..//p2pvrdaemon
@@ -116,7 +116,7 @@ run
<define>BOOST_TEST_DYN_LINK
<library>../..//p2common
<library>../..//p2basics
- <library>../..//p2lib
+ <library>../..//adhocutil
<library>../..//p2xml
<library>../..//p2ut
<library>..//p2pvrdaemon
@@ -140,7 +140,7 @@ run
<define>BOOST_TEST_DYN_LINK
<library>../..//p2common
<library>../..//p2basics
- <library>../..//p2lib
+ <library>../..//adhocutil
<library>../..//p2xml
<library>../..//p2ut
<library>..//p2pvrdaemon
@@ -162,7 +162,7 @@ run
<define>BOOST_TEST_DYN_LINK
<library>../..//p2common
<library>../..//p2basics
- <library>../..//p2lib
+ <library>../..//adhocutil
<library>../..//p2xml
<library>../..//p2ut
<library>..//p2pvrdaemon
@@ -185,7 +185,7 @@ run
<define>BOOST_TEST_DYN_LINK
<library>../..//p2common
<library>../..//p2basics
- <library>../..//p2lib
+ <library>../..//adhocutil
<library>../..//p2xml
<library>../..//p2ut
<library>..//p2pvrdaemon
@@ -208,7 +208,7 @@ run
<define>BOOST_TEST_DYN_LINK
<library>../..//p2common
<library>../..//p2basics
- <library>../..//p2lib
+ <library>../..//adhocutil
<library>../..//p2xml
<library>../..//p2ut
<library>..//p2pvrdaemon
diff --git a/p2pvr/daemon/unittests/mockDefs.cpp b/p2pvr/daemon/unittests/mockDefs.cpp
index 466bfe2..76abb80 100644
--- a/p2pvr/daemon/unittests/mockDefs.cpp
+++ b/p2pvr/daemon/unittests/mockDefs.cpp
@@ -3,22 +3,22 @@
SchemaOnlyMockDatabase::SchemaOnlyMockDatabase() :
MockPqDatabase("user=postgres dbname=postgres", "postgres", {
- RootDir.parent_path().parent_path() / "datasources" / "schema.sql" })
+ rootDir.parent_path().parent_path() / "datasources" / "schema.sql" })
{
}
StandardMockDatabase::StandardMockDatabase() :
MockPqDatabase("user=postgres dbname=postgres", "postgres", {
- RootDir.parent_path().parent_path() / "datasources/schema.sql",
- RootDir / "datasources" / "data.sql" })
+ rootDir.parent_path().parent_path() / "datasources/schema.sql",
+ rootDir / "datasources" / "data.sql" })
{
}
StandardMockDatabasePlusOffset::StandardMockDatabasePlusOffset() :
MockPqDatabase("user=postgres dbname=postgres", "postgres", {
- RootDir.parent_path().parent_path() / "datasources" / "schema.sql",
- RootDir / "datasources" / "data.sql",
- RootDir / "datasources" / "eventOffset.sql" })
+ rootDir.parent_path().parent_path() / "datasources" / "schema.sql",
+ rootDir / "datasources" / "data.sql",
+ rootDir / "datasources" / "eventOffset.sql" })
{
}
diff --git a/p2pvr/daemon/unittests/testErrorHandling.cpp b/p2pvr/daemon/unittests/testErrorHandling.cpp
index 9c720a2..b522557 100644
--- a/p2pvr/daemon/unittests/testErrorHandling.cpp
+++ b/p2pvr/daemon/unittests/testErrorHandling.cpp
@@ -4,7 +4,6 @@
#include <testOptionsSource.h>
#include <Ice/ObjectAdapter.h>
#include <Ice/Service.h>
-#include <scopeObject.h>
#include <maintenance.h>
#include <mockTuner.h>
#include "mockDevices.h"
@@ -26,7 +25,7 @@ class Core : public TestAppInstance {
ic = Ice::initialize(paramCount, NULL);
adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12006");
TestOptionsSource::LoadTestOptions({
- { "common.datasourceRoot", (RootDir / "datasources").string() },
+ { "common.datasourceRoot", (rootDir / "datasources").string() },
});
adapter->add(new MockDevices(), ic->stringToIdentity("GlobalDevices"));
adapter->add(new SI(), ic->stringToIdentity("SI"));
diff --git a/p2pvr/daemon/unittests/testMaint.cpp b/p2pvr/daemon/unittests/testMaint.cpp
index 0d7d5a0..38c9478 100644
--- a/p2pvr/daemon/unittests/testMaint.cpp
+++ b/p2pvr/daemon/unittests/testMaint.cpp
@@ -4,7 +4,6 @@
#include <testOptionsSource.h>
#include <Ice/ObjectAdapter.h>
#include <Ice/Service.h>
-#include <scopeObject.h>
#include <maintenance.h>
#include <mockTuner.h>
#include "mockDevices.h"
@@ -27,7 +26,7 @@ class Core : public CommonObjects, public TestAppInstance {
ic = Ice::initialize(paramCount, NULL);
auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12000");
TestOptionsSource::LoadTestOptions({
- { "common.datasourceRoot", (RootDir / "datasources").string() },
+ { "common.datasourceRoot", (rootDir / "datasources").string() },
});
adapter->add(new MockDevices(), ic->stringToIdentity("GlobalDevices"));
adapter->add(new MockScheduler(), ic->stringToIdentity("Schedules"));
diff --git a/p2pvr/daemon/unittests/testRecording.cpp b/p2pvr/daemon/unittests/testRecording.cpp
index 720b868..d3ecee6 100644
--- a/p2pvr/daemon/unittests/testRecording.cpp
+++ b/p2pvr/daemon/unittests/testRecording.cpp
@@ -4,7 +4,6 @@
#include <testOptionsSource.h>
#include <Ice/ObjectAdapter.h>
#include <Ice/Service.h>
-#include <scopeObject.h>
#include <maintenance.h>
#include <mockTuner.h>
#include "mockDevices.h"
@@ -29,7 +28,7 @@ class Core : public CommonObjects, public TestAppInstance {
ic = Ice::initialize(paramCount, NULL);
adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12005");
TestOptionsSource::LoadTestOptions({
- { "common.datasourceRoot", (RootDir / "datasources").string() },
+ { "common.datasourceRoot", (rootDir / "datasources").string() },
});
adapter->add(new MockDevices(), ic->stringToIdentity("GlobalDevices"));
adapter->add(new MockScheduler(), ic->stringToIdentity("Schedules"));
diff --git a/p2pvr/daemon/unittests/testRecordings.cpp b/p2pvr/daemon/unittests/testRecordings.cpp
index eb3d5db..ff8f676 100644
--- a/p2pvr/daemon/unittests/testRecordings.cpp
+++ b/p2pvr/daemon/unittests/testRecordings.cpp
@@ -4,7 +4,6 @@
#include <testOptionsSource.h>
#include <Ice/ObjectAdapter.h>
#include <Ice/Service.h>
-#include <scopeObject.h>
#include <maintenance.h>
#include <mockTuner.h>
#include <si.h>
@@ -25,7 +24,7 @@ class Core : public TestAppInstance {
ic = Ice::initialize(paramCount, NULL);
auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12001");
TestOptionsSource::LoadTestOptions({
- { "common.datasourceRoot", (RootDir / "datasources").string() },
+ { "common.datasourceRoot", (rootDir / "datasources").string() },
});
adapter->add(new Recordings(), ic->stringToIdentity("Recordings"));
adapter->add(new SI(), ic->stringToIdentity("SI"));
diff --git a/p2pvr/daemon/unittests/testSched.cpp b/p2pvr/daemon/unittests/testSched.cpp
index 3a513d0..9afdaad 100644
--- a/p2pvr/daemon/unittests/testSched.cpp
+++ b/p2pvr/daemon/unittests/testSched.cpp
@@ -26,7 +26,7 @@ class Core : public TestAppInstance {
ic = Ice::initialize(paramCount, NULL);
auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12003");
TestOptionsSource::LoadTestOptions({
- { "common.datasourceRoot", (RootDir / "datasources").string() },
+ { "common.datasourceRoot", (rootDir / "datasources").string() },
});
adapter->add(new Schedules(), ic->stringToIdentity("Schedules"));
adapter->add(new MockDevices(), ic->stringToIdentity("GlobalDevices"));
diff --git a/p2pvr/daemon/unittests/testSi.cpp b/p2pvr/daemon/unittests/testSi.cpp
index 6cc810b..9e42e74 100644
--- a/p2pvr/daemon/unittests/testSi.cpp
+++ b/p2pvr/daemon/unittests/testSi.cpp
@@ -23,7 +23,7 @@ class Core : public TestAppInstance {
ic = Ice::initialize(paramCount, NULL);
auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12002");
TestOptionsSource::LoadTestOptions({
- { "common.datasourceRoot", (RootDir / "datasources").string() },
+ { "common.datasourceRoot", (rootDir / "datasources").string() },
});
adapter->add(new SI(), ic->stringToIdentity("SI"));
adapter->activate();
diff --git a/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp b/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp
index 2608fd8..077486c 100644
--- a/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp
+++ b/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp
@@ -20,7 +20,7 @@ class TestCommonObjects : public CommonObjects, public TestAppInstance {
TestCommonObjects()
{
TestOptionsSource::LoadTestOptions({
- { "common.datasourceRoot", (RootDir / "datasources").string() },
+ { "common.datasourceRoot", (rootDir / "datasources").string() },
});
}
};
diff --git a/p2pvr/daemon/unittests/testp2ice.cpp b/p2pvr/daemon/unittests/testp2ice.cpp
index 4d29cc9..8229bf5 100644
--- a/p2pvr/daemon/unittests/testp2ice.cpp
+++ b/p2pvr/daemon/unittests/testp2ice.cpp
@@ -6,9 +6,9 @@
#include <sourceObject.h>
#include <testAppInstance.h>
-const boost::filesystem::path variant = BinDir.leaf();
-const boost::filesystem::path compiler = BinDir.parent_path().leaf();
-const boost::filesystem::path root = RootDir.parent_path().parent_path();
+const boost::filesystem::path variant = binDir.leaf();
+const boost::filesystem::path compiler = binDir.parent_path().leaf();
+const boost::filesystem::path root = rootDir.parent_path().parent_path();
const boost::filesystem::path iceroot = root / "ice";
static
diff --git a/p2pvr/daemonbase/Jamfile.jam b/p2pvr/daemonbase/Jamfile.jam
index d25bdcf..f02a172 100644
--- a/p2pvr/daemonbase/Jamfile.jam
+++ b/p2pvr/daemonbase/Jamfile.jam
@@ -14,6 +14,7 @@ lib p2pvrdaemonbase :
<library>..//p2common
<library>../lib//p2pvrlib
<library>../ice//p2pvrice
+ <library>..//adhocutil
<implicit-dependency>../ice//p2pvrice
: :
<implicit-dependency>../ice//p2pvrice
diff --git a/p2pvr/devices/Jamfile.jam b/p2pvr/devices/Jamfile.jam
index 8e18afa..f39256b 100644
--- a/p2pvr/devices/Jamfile.jam
+++ b/p2pvr/devices/Jamfile.jam
@@ -23,6 +23,7 @@ lib p2pvrdevices :
<library>../ice//p2pvrice
<library>../lib//p2pvrlib
<library>..//p2common
+ <library>..//adhocutil
<implicit-dependency>../ice//p2pvrice
: :
<library>boost_filesystem
@@ -56,6 +57,7 @@ lib p2pvrMockTuner :
<library>../ice//p2pvrice
<library>../lib//p2pvrlib
<library>..//p2common
+ <library>..//adhocutil
<implicit-dependency>../ice//p2pvrice
: :
<library>boost_filesystem
diff --git a/p2pvr/devices/tuner.cpp b/p2pvr/devices/tuner.cpp
index ee1625a..ea3ccad 100644
--- a/p2pvr/devices/tuner.cpp
+++ b/p2pvr/devices/tuner.cpp
@@ -5,7 +5,6 @@
#include <sys/ioctl.h>
#include <poll.h>
#include <logger.h>
-#include <misc.h>
#include <plugable.h>
#include <linux/dvb/frontend.h>
#include <linux/dvb/dmx.h>
@@ -18,7 +17,8 @@
class FrontendNotSupported : public NotSupported {
public:
FrontendNotSupported(fe_type t) : NotSupported(stringbf("Frontend not supported: %s", t))
- { }
+ {
+ }
};
Tuner::Tuner(const boost::filesystem::path & df) :
diff --git a/p2pvr/dvb/Jamfile.jam b/p2pvr/dvb/Jamfile.jam
index 2dbbbda..e71093a 100644
--- a/p2pvr/dvb/Jamfile.jam
+++ b/p2pvr/dvb/Jamfile.jam
@@ -7,6 +7,7 @@ lib p2pvrdvb :
[ glob-tree *.cpp : unittests ]
:
<library>../ice//p2pvrice
+ <library>..//adhocutil
<implicit-dependency>../ice//p2pvrice
: :
<implicit-dependency>../ice//p2pvrice
diff --git a/p2pvr/dvb/siParsers/network.cpp b/p2pvr/dvb/siParsers/network.cpp
index b91da1a..6527d58 100644
--- a/p2pvr/dvb/siParsers/network.cpp
+++ b/p2pvr/dvb/siParsers/network.cpp
@@ -3,7 +3,6 @@
#include <boost/bind.hpp>
#include <linux/dvb/frontend.h>
#include <safeMapFind.h>
-#include <misc.h>
struct NetworkStreamsHeader {
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
@@ -219,16 +218,16 @@ SiNetworkInformationParser::parseDescriptor_TerrestrialDelivery(DVBSI::NetworkTr
DVBSI::TerrestrialDeliveryPtr td = new DVBSI::TerrestrialDelivery;
td->Frequency = ((uint64_t)ntohl(tdd->Frequency)) * 10;
td->TransportStreamId = nts->TransportStreamId;
- td->Bandwidth = safeMapLookup<BandwidthNotSupported>(tbandwidths, tdd->Bandwidth);
+ td->Bandwidth = AdHoc::safeMapLookup<BandwidthNotSupported>(tbandwidths, tdd->Bandwidth);
td->Priority = tdd->Priority;
td->TimeSlicing = tdd->TimeSlicing;
td->MpeFec = tdd->MpeFec;
- td->Constellation = safeMapLookup<ConstellationNotSupported>(tconstellations, tdd->Constellation);
- td->Hierarchy = safeMapLookup<HierarchyNotSupported>(thierarchies, tdd->Hierarchy);
- td->CodeRateHP = safeMapLookup<CodeRateNotSupported>(tcoderates, tdd->CodeRateHP);
- td->CodeRateLP = safeMapLookup<CodeRateNotSupported>(tcoderates, tdd->CodeRateLP);
- td->GuardInterval = safeMapLookup<GuardIntervalNotSupported>(tguardintervals, tdd->GuardInterval);
- td->TransmissionMode = safeMapLookup<TransmissionModeNotSupported>(ttransmitmodes, tdd->TransmissionMode);
+ td->Constellation = AdHoc::safeMapLookup<ConstellationNotSupported>(tconstellations, tdd->Constellation);
+ td->Hierarchy = AdHoc::safeMapLookup<HierarchyNotSupported>(thierarchies, tdd->Hierarchy);
+ td->CodeRateHP = AdHoc::safeMapLookup<CodeRateNotSupported>(tcoderates, tdd->CodeRateHP);
+ td->CodeRateLP = AdHoc::safeMapLookup<CodeRateNotSupported>(tcoderates, tdd->CodeRateLP);
+ td->GuardInterval = AdHoc::safeMapLookup<GuardIntervalNotSupported>(tguardintervals, tdd->GuardInterval);
+ td->TransmissionMode = AdHoc::safeMapLookup<TransmissionModeNotSupported>(ttransmitmodes, tdd->TransmissionMode);
td->OtherFrequencyFlag = tdd->OtherFrequencyFlag;
nts->Terrestrial = td;
}
diff --git a/p2pvr/dvb/unittests/createBroadcast.cpp b/p2pvr/dvb/unittests/createBroadcast.cpp
index c65c9ad..1b13d37 100644
--- a/p2pvr/dvb/unittests/createBroadcast.cpp
+++ b/p2pvr/dvb/unittests/createBroadcast.cpp
@@ -7,7 +7,6 @@
#include <boost/tuple/tuple.hpp>
#include <Ice/ObjectAdapter.h>
#include <Ice/Service.h>
-#include <scopeObject.h>
#include <linux/dvb/frontend.h>
#include "serviceStreamerCore.h"
#include "bindDataHandler.h"
diff --git a/p2pvr/dvb/unittests/createSamples.cpp b/p2pvr/dvb/unittests/createSamples.cpp
index 1bb8f92..b9f2aaa 100644
--- a/p2pvr/dvb/unittests/createSamples.cpp
+++ b/p2pvr/dvb/unittests/createSamples.cpp
@@ -6,7 +6,7 @@
#include <boost/tuple/tuple.hpp>
#include <Ice/ObjectAdapter.h>
#include <Ice/Service.h>
-#include <scopeObject.h>
+#include <scopeExit.h>
#include <linux/dvb/frontend.h>
#include <siParsers/network.h>
#include <siParsers/service.h>
@@ -70,7 +70,7 @@ CaptureAndSave(const boost::filesystem::path & fileName, const boost::function<v
auto ic = boost::get<0>(icp);
auto adap = boost::get<1>(icp);
auto p = boost::get<2>(icp);
- ScopeObject _([&ic]{ ic->destroy(); });
+ ScopeExit _([&ic]{ ic->destroy(); });
auto devs = P2PVR::DevicesPrx::checkedCast(ic->stringToProxy("Devices:tcp -h defiant -p 10000"));
auto parser = P2PVR::RawDataClientPrx::checkedCast(adap->createProxy(ic->stringToIdentity("parser")));
diff --git a/p2pvr/ice/Jamfile.jam b/p2pvr/ice/Jamfile.jam
index 5720bf1..ca27324 100644
--- a/p2pvr/ice/Jamfile.jam
+++ b/p2pvr/ice/Jamfile.jam
@@ -9,7 +9,7 @@ lib p2pvrice :
<library>IceUtil
<library>pthread
<library>..//p2common
- <library>..//p2lib
+ <library>..//adhocutil
<library>..//p2ice
<library>slicer
<slicer>yes
diff --git a/p2pvr/ice/commonHelpers.cpp b/p2pvr/ice/commonHelpers.cpp
index 6ad120b..9344438 100644
--- a/p2pvr/ice/commonHelpers.cpp
+++ b/p2pvr/ice/commonHelpers.cpp
@@ -1,5 +1,4 @@
#include "commonHelpers.h"
-#include <misc.h>
#include <boost/numeric/conversion/cast.hpp>
namespace Common {
diff --git a/p2pvr/lib/Jamfile.jam b/p2pvr/lib/Jamfile.jam
index 2083c30..31974b7 100644
--- a/p2pvr/lib/Jamfile.jam
+++ b/p2pvr/lib/Jamfile.jam
@@ -6,7 +6,7 @@ cpp-pch pch : pch.hpp :
<library>boost_system
<library>boost_filesystem
<library>..//p2common
- <library>..//p2lib
+ <library>..//adhocutil
<implicit-dependency>../ice//p2pvrice
;
@@ -19,7 +19,7 @@ lib p2pvrlib :
<library>../ice//p2pvrice
<library>../dvb//p2pvrdvb
<library>..//p2common
- <library>..//p2lib
+ <library>..//adhocutil
<implicit-dependency>../ice//p2pvrice
<library>slicer
: :
diff --git a/p2pvr/lib/muxer.cpp b/p2pvr/lib/muxer.cpp
index 15152a2..cfec6d0 100644
--- a/p2pvr/lib/muxer.cpp
+++ b/p2pvr/lib/muxer.cpp
@@ -1,7 +1,7 @@
#include <pch.hpp>
#include "muxer.h"
#include <logger.h>
-#include <misc.h>
+#include <processPipes.h>
#include <poll.h>
#include <sys/wait.h>
#include <fcntl.h>
@@ -15,21 +15,19 @@ Muxer::Muxer(const P2PVR::RawDataClientPrx & t, const std::string & cmd) :
{
std::vector<std::string> params;
boost::algorithm::split(params, cmd, isspace, boost::algorithm::token_compress_on);
- muxerPid = popenrwe(params, fds);
- fcntl(fds[0], F_SETFL, O_NONBLOCK);
+ fds = ProcessPipesPtr(new AdHoc::System::ProcessPipes(params, true, true, true));
+ fcntl(fds->fdIn(), F_SETFL, O_NONBLOCK);
Logger()->messagebf(LOG_INFO, "Muxer::%p started with command '%s'", this, cmd);
}
Muxer::~Muxer()
{
- close(fds[0]);
+ close(fds->fdIn());
int status;
- while (waitpid(muxerPid, &status, WNOHANG) == 0) {
+ while (waitpid(fds->pid(), &status, WNOHANG) == 0) {
ReadMuxerAndSend(5);
}
Logger()->messagebf(LOG_INFO, "Muxer::%p finished with status %d", this, status);
- close(fds[1]);
- close(fds[2]);
}
bool
@@ -41,7 +39,7 @@ Muxer::NewData(const P2PVR::Data & data, const Ice::Current &)
if (ReadWaiting())
return true;
// Send some input
- auto w = write(fds[0], &data[off], data.size() - off);
+ auto w = write(fds->fdIn(), &data[off], data.size() - off);
if (w == -1 && errno != EAGAIN && errno != EWOULDBLOCK) {
Logger()->messagebf(LOG_ERR, "Muxer::%p write failed (%d:%s)", this, errno, strerror(errno));
throw MuxerFailure();
@@ -55,7 +53,7 @@ Muxer::NewData(const P2PVR::Data & data, const Ice::Current &)
bool
Muxer::ReadWaiting() const
{
- pollfd fd = { fds[0], POLLOUT, 0 };
+ pollfd fd = { fds->fdIn(), POLLOUT, 0 };
while (true) {
auto p = poll(&fd, 1, 0);
if (p < 0) {
@@ -84,7 +82,7 @@ Muxer::ReadAvailable() const
bool
Muxer::ReadMuxerAndSend(int waitTime) const
{
- pollfd fd[2] = { { fds[1], POLLIN | POLLHUP, 0 }, { fds[2], POLLIN | POLLHUP, 0 } };
+ pollfd fd[2] = { { fds->fdOut(), POLLIN | POLLHUP, 0 }, { fds->fdError(), POLLIN | POLLHUP, 0 } };
while (true) {
auto p = poll(fd, 2, waitTime);
if (p < 0) {
@@ -99,7 +97,7 @@ Muxer::ReadMuxerAndSend(int waitTime) const
bool closed = false;
if (fd[0].revents & (POLLIN | POLLHUP)) {
P2PVR::Data buf(BUFSIZ);
- auto len = read(fds[1], &buf.front(), buf.size());
+ auto len = read(fds->fdOut(), &buf.front(), buf.size());
if (len == 0) {
// ok, proc exit
closed = true;
@@ -113,7 +111,7 @@ Muxer::ReadMuxerAndSend(int waitTime) const
}
if (fd[1].revents & (POLLIN | POLLHUP)) {
P2PVR::Data buf(BUFSIZ);
- auto len = read(fds[2], &buf.front(), buf.size());
+ auto len = read(fds->fdError(), &buf.front(), buf.size());
if (len == 0) {
// ok, proc exit
closed = true;
diff --git a/p2pvr/lib/muxer.h b/p2pvr/lib/muxer.h
index 3a492bd..cf0db1c 100644
--- a/p2pvr/lib/muxer.h
+++ b/p2pvr/lib/muxer.h
@@ -3,6 +3,8 @@
#include <dvb.h>
#include <mutex>
+#include <boost/shared_ptr.hpp>
+#include <processPipes.h>
class Muxer : public P2PVR::RawDataClient {
public:
@@ -16,8 +18,8 @@ class Muxer : public P2PVR::RawDataClient {
bool ReadAvailable() const;
bool ReadMuxerAndSend(int wait) const;
const P2PVR::RawDataClientPrx target;
- int fds[3];
- pid_t muxerPid;
+ typedef boost::shared_ptr<AdHoc::System::ProcessPipes> ProcessPipesPtr;
+ ProcessPipesPtr fds;
mutable std::mutex lock;
};
diff --git a/p2pvr/p2comp/Jamfile.jam b/p2pvr/p2comp/Jamfile.jam
index 6a847b7..10b7fea 100644
--- a/p2pvr/p2comp/Jamfile.jam
+++ b/p2pvr/p2comp/Jamfile.jam
@@ -6,5 +6,6 @@ lib p2pvrp2comp :
<library>..//p2streams
<library>..//p2ice
<library>..//p2cgi
+ <library>..//adhocutil
<implicit-dependency>../ice//p2pvrice
;
diff --git a/p2pvr/p2comp/recordingStream.cpp b/p2pvr/p2comp/recordingStream.cpp
index b77a2ce..74d8ba0 100644
--- a/p2pvr/p2comp/recordingStream.cpp
+++ b/p2pvr/p2comp/recordingStream.cpp
@@ -1,6 +1,5 @@
#include <p2pvr.h>
#include <options.h>
-#include <misc.h>
#include <temporaryIceAdapterObject.h>
#include "streamSinkWrapper.h"
#include "streamBase.h"
diff --git a/p2pvr/p2comp/serviceStream.cpp b/p2pvr/p2comp/serviceStream.cpp
index 02d19d1..323234f 100644
--- a/p2pvr/p2comp/serviceStream.cpp
+++ b/p2pvr/p2comp/serviceStream.cpp
@@ -2,7 +2,6 @@
#include <iceDataSource.h>
#include <serviceStreamer.h>
#include <options.h>
-#include <misc.h>
#include <muxer.h>
#include <future>
#include <temporaryIceAdapterObject.h>