@@ -61,20 +61,44 @@ void Streamer::setStreamingMode(StreamingMode mode) {
6161}
6262
6363DataChannel::pointer Streamer::getOutputPort (uint portID) {
64- if (m_outputPOs.count (portID) == 0 ) {
64+ if (m_outputPOs.count (portID) == 0 ) { // Doesn't exist
6565 auto channel = ProcessObject::getOutputPort (portID);
66- m_outputPOs[portID] = RunLambda::create ([](DataObject::pointer data) -> DataList {
66+ auto PO = RunLambda::create ([](DataObject::pointer data) -> DataList {
6767 return DataList (data);
6868 });
69- m_outputPOs[portID]->setInputConnection (channel);
70- }
69+ PO->setInputConnection (channel);
70+ m_outputPOs[portID] = PO;
71+ return PO->getOutputPort ();
72+ } else {
73+ auto PO = m_outputPOs[portID].lock ();
74+ if (!PO) { // Expired, recreate
75+ // TODO duplicate code:
76+ auto channel = ProcessObject::getOutputPort (portID);
77+ auto PO = RunLambda::create ([](DataObject::pointer data) -> DataList {
78+ return DataList (data);
79+ });
80+ PO->setInputConnection (channel);
81+ m_outputPOs[portID] = PO;
82+ }
7183
72- return m_outputPOs[portID]->getOutputPort ();
84+ return PO->getOutputPort ();
85+ }
7386}
7487
7588bool Streamer::isStopped () {
7689 std::lock_guard<std::mutex> lock (m_stopMutex);
7790 return m_stop;
7891}
7992
93+ Streamer::~Streamer () noexcept {
94+ reportInfo () << " Destroying streamer.." << reportEnd ();
95+ stop ();
96+ reportInfo () << " Streamer DESTROYED." << reportEnd ();
97+ }
98+
99+ void Streamer::stopPipeline () {
100+ stop ();
101+ ProcessObject::stopPipeline ();
102+ }
103+
80104}
0 commit comments