Stefan Schuermans commited on 2011-12-23 22:05:08
Showing 2 changed files, with 31 additions and 1 deletions.
... | ... |
@@ -32,9 +32,11 @@ Priority::Priority(const std::string &name, Mgrs &mgrs, |
32 | 32 |
Module(name, mgrs, dirBase), |
33 | 33 |
m_fileOutStream(dirBase.getFile("outstream"), mgrs.m_streamMgr), |
34 | 34 |
m_inListTracker(*this, dirBase.getSubdir("inputs")), |
35 |
- m_itCurIn(m_inListTracker.m_list.rend()) |
|
35 |
+ m_itCurIn(m_inListTracker.m_list.rend()), |
|
36 |
+ m_updateNeeded(false) |
|
36 | 37 |
{ |
37 | 38 |
m_inListTracker.init(); |
39 |
+ updateSelection(); |
|
38 | 40 |
} |
39 | 41 |
|
40 | 42 |
/// virtual destructor |
... | ... |
@@ -48,6 +50,7 @@ void Priority::updateConfig() |
48 | 50 |
{ |
49 | 51 |
// input list update |
50 | 52 |
m_inListTracker.updateConfig(); |
53 |
+ updateSelection(); |
|
51 | 54 |
|
52 | 55 |
// output stream name file was modified -> re-get output stream |
53 | 56 |
if (m_fileOutStream.checkModified()) |
... | ... |
@@ -68,6 +71,11 @@ void Priority::select(const Input *pInput) |
68 | 71 |
|
69 | 72 |
// send current frame |
70 | 73 |
curFrame(); |
74 |
+ |
|
75 |
+ // return if required stream was successfully selected |
|
76 |
+ if (m_itCurIn == m_inListTracker.m_list.rend() || |
|
77 |
+ m_itCurIn->m_pObj != pInput) |
|
78 |
+ m_updateNeeded = true; |
|
71 | 79 |
} |
72 | 80 |
|
73 | 81 |
/// select lower priority input (called by inputs) |
... | ... |
@@ -91,6 +99,24 @@ void Priority::selectLower() |
91 | 99 |
m_fileOutStream.setFrame(NULL); |
92 | 100 |
} |
93 | 101 |
|
102 |
+/// update current selection |
|
103 |
+void Priority::updateSelection() |
|
104 |
+{ |
|
105 |
+ if (m_updateNeeded) { |
|
106 |
+ m_updateNeeded = false; |
|
107 |
+ |
|
108 |
+ // search for highest priority input with a frame |
|
109 |
+ for (m_itCurIn = m_inListTracker.m_list.rbegin(); |
|
110 |
+ m_itCurIn != m_inListTracker.m_list.rend(); ++m_itCurIn) |
|
111 |
+ if (m_itCurIn->m_pObj->getCurFrame()) |
|
112 |
+ break; |
|
113 |
+ |
|
114 |
+ // send new frame to output stream |
|
115 |
+ curFrame(); |
|
116 |
+ |
|
117 |
+ } // if m_updateNeeded |
|
118 |
+} |
|
119 |
+ |
|
94 | 120 |
/// send current frame to output stream |
95 | 121 |
void Priority::curFrame() |
96 | 122 |
{ |
... | ... |
@@ -66,6 +66,9 @@ protected: |
66 | 66 |
/// select lower priority input (called by inputs) |
67 | 67 |
void selectLower(); |
68 | 68 |
|
69 |
+ /// update current selection |
|
70 |
+ void updateSelection(); |
|
71 |
+ |
|
69 | 72 |
/// send current frame to output stream |
70 | 73 |
void curFrame(); |
71 | 74 |
|
... | ... |
@@ -73,6 +76,7 @@ protected: |
73 | 76 |
OutStreamFile m_fileOutStream; ///< output stream name file |
74 | 77 |
InListTracker m_inListTracker; ///< input list tracker |
75 | 78 |
InListIt m_itCurIn; ///< current input |
79 |
+ bool m_updateNeeded; ///< additional update of selection needed |
|
76 | 80 |
}; // class Priority |
77 | 81 |
|
78 | 82 |
} // namespace Blinker |
79 | 83 |