GCC Code Coverage Report


Directory: ./
File: channeloutput/processors/OutputProcessor.cpp
Date: 2026-12-01 12:27:28
Exec Total Coverage
Lines: 167 179 93.3%
Functions: 16 16 100.0%
Branches: 200 358 55.9%

Line Branch Exec Source
1 /*
2 * This file is part of the Falcon Player (FPP) and is Copyright (C)
3 * 2013-2022 by the Falcon Player Developers.
4 *
5 * The Falcon Player (FPP) is free software, and is covered under
6 * multiple Open Source licenses. Please see the included 'LICENSES'
7 * file for descriptions of what files are covered by each license.
8 *
9 * This source file is covered under the LGPL v2.1 as described in the
10 * included LICENSE.LGPL file.
11 */
12
13 #include "fpp-pch.h"
14
15 #include "fpp-json.h"
16
17 #include <algorithm>
18 #include <stdexcept>
19 #include <string>
20 #include <vector>
21
22 #include "../../log.h"
23
24 #include "OutputProcessor.h"
25 #include "../../Warnings.h"
26
27 #include "BrightnessOutputProcessor.h"
28 #include "ClampValueOutputProcessor.h"
29 #include "ColorOrderOutputProcessor.h"
30 #include "FoldOutputProcessor.h"
31 #include "HoldValueOutputProcessor.h"
32 #include "OverrideZeroOutputProcessor.h"
33 #include "RemapOutputProcessor.h"
34 #include "ScaleValueOutputProcessor.h"
35 #include "SetValueOutputProcessor.h"
36 #include "ThreeToFourOutputProcessor.h"
37 #include "../../overlays/PixelOverlay.h"
38 #include "../../overlays/PixelOverlayModel.h"
39
40 3252 OutputProcessors::OutputProcessors() {
41 3252 }
42 600 OutputProcessors::~OutputProcessors() {
43 600 removeAll();
44 600 }
45
46 196891 void OutputProcessors::ProcessData(unsigned char* channelData) const {
47
1/2
✓ Branch 0 taken 196891 times.
✗ Branch 1 not taken.
196891 std::lock_guard<std::mutex> lock(processorsLock);
48
2/2
✓ Branch 0 taken 1752 times.
✓ Branch 1 taken 196891 times.
198643 for (OutputProcessor* a : processors) {
49
1/2
✓ Branch 0 taken 1752 times.
✗ Branch 1 not taken.
1752 if (a->isActive()) {
50
1/2
✓ Branch 0 taken 1752 times.
✗ Branch 1 not taken.
1752 a->ProcessData(channelData);
51 }
52 }
53 196891 }
54
55 // Whether the processor's channels lie inside the sequence buffer, recording a
56 // warning when they do not. Caller holds processorsLock.
57 125 bool OutputProcessors::rangeIsValid(OutputProcessor* p) {
58 // ProcessData() writes straight into the sequence buffer, which is
59 // FPPD_MAX_CHANNELS long, over the channels the processor reports here.
60 // The UI only checks that numbers are positive, so a start or a count (or
61 // count * loops) can put that past the end - where it overwrites the
62 // off/white sentinel channels just past the buffer, or faults on every
63 // frame. Refuse it rather than trust each processor to clamp. An
64 // inverted range is how a processor with nothing to do reports.
65 125 bool bad = false;
66 125 int badMin = 0;
67 125 int badMax = -1;
68
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 p->GetRequiredChannelRanges([&bad, &badMin, &badMax](int m1, int m2) {
69
7/8
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 122 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 115 times.
125 if (!bad && m2 >= m1 && (m1 < 0 || m2 >= (int)FPPD_MAX_CHANNELS)) {
70 9 bad = true;
71 9 badMin = m1;
72 9 badMax = m2;
73 }
74 125 });
75
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9 times.
125 if (!bad) {
76 116 return true;
77 }
78
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
18 std::string warning = "Output processor needs channels " + std::to_string(badMin + 1) + "-" +
79
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
36 std::to_string(badMax + 1) + ", outside 1-" + std::to_string(FPPD_MAX_CHANNELS) +
80
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 ". Processor disabled.";
81
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 LogErr(VB_CHANNELOUT, "%s\n", warning.c_str());
82
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 WarningHolder::AddWarning(warning);
83
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 rejectedWarnings.push_back(warning);
84 9 return false;
85 9 }
86
87 2 void OutputProcessors::addProcessor(OutputProcessor* p) {
88
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (p == nullptr) {
89 ✗ return;
90 }
91
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 std::lock_guard<std::mutex> lock(processorsLock);
92
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if (rangeIsValid(p)) {
93
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 processors.push_back(p);
94 } else {
95 ✗ delete p; // rejected; nothing else owns it
96 }
97 2 }
98 2 void OutputProcessors::removeProcessor(OutputProcessor* p) {
99 // ProcessData() walks the chain under processorsLock, so once the
100 // processor is out of the list (under the same lock) nothing can be using
101 // it. Removed processors used to be leaked.
102
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 std::lock_guard<std::mutex> lock(processorsLock);
103
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 auto it = std::find(processors.begin(), processors.end(), p);
104
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (it != processors.end()) {
105 2 processors.erase(it);
106 // One loaded from outputprocessors.json (a playlist Remap "remove"
107 // matches those too) is also on fromJsonProcessors, which the next
108 // loadFromJSON() frees: take it off, or that frees it a second time.
109 2 fromJsonProcessors.remove(p);
110
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 delete p;
111 }
112 2 }
113 600 void OutputProcessors::removeAll() {
114
1/2
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
600 std::lock_guard<std::mutex> lock(processorsLock);
115 // Everything in the chain, and the JSON processors rangeIsValid() kept
116 // out of it, which are on fromJsonProcessors alone.
117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 600 times.
600 for (OutputProcessor* a : fromJsonProcessors) {
118 ✗ if (std::find(processors.begin(), processors.end(), a) == processors.end()) {
119 ✗ delete a;
120 }
121 }
122 600 fromJsonProcessors.clear();
123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 600 times.
600 for (OutputProcessor* a : processors) {
124 ✗ delete a;
125 }
126 600 processors.clear();
127 600 }
128
129 2694 void OutputProcessors::loadFromJSON(const Json::Value& config) {
130 // Build the whole new chain first and swap it in under one lock: removing
131 // the old processors, unlocking and adding the new ones one at a time let
132 // the output thread run a frame with part of the chain (a brightness or
133 // current limit missing for a frame). Only the processors created from
134 // JSON are replaced; plugins may have added their own.
135 2694 std::list<OutputProcessor*> created;
136 // A processor whose JSON holds a value of the wrong type ("1" for a
137 // number, a list, null) threw Json::LogicError out of its constructor,
138 // past everything up to std::terminate -- at startup, so with the config
139 // saved fppd crash looped. Refuse that one processor instead, with a
140 // warning (raised below, once last time's are retracted).
141 2694 std::vector<std::string> failed;
142 129 auto tryCreate = [this, &created, &failed](const Json::Value& v) {
143 try {
144
4/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 123 times.
✓ Branch 3 taken 2 times.
129 if (OutputProcessor* p = create(v)) {
145
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 created.push_back(p);
146 }
147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 } catch (const std::exception& e) {
148 4 std::string what;
149
6/12
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
4 if (v.isObject() && v["type"].isString()) {
150
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 what = v["type"].asString();
151 }
152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (what.empty()) {
153 ✗ what = "an entry";
154 }
155
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
8 failed.push_back("Output processor " + what + " could not be loaded (" + e.what() +
156
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 "). Processor disabled.");
157 4 }
158 129 };
159
6/10
✓ Branch 0 taken 2694 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2794 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2794 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 100 times.
✓ Branch 9 taken 2694 times.
2794 for (Json::Value::const_iterator itr = config.begin(); itr != config.end(); ++itr) {
160
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 std::string name = itr.key().asString();
161
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if (name == "outputProcessors") {
162
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 Json::Value val = *itr;
163
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if (val.isArray()) {
164
3/4
✓ Branch 0 taken 229 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 100 times.
229 for (int x = 0; x < val.size(); x++) {
165
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129 times.
✗ Branch 3 not taken.
129 tryCreate(val[x]);
166 }
167 } else {
168 ✗ tryCreate(val);
169 }
170 100 }
171 100 }
172
173 2694 std::list<OutputProcessor*> old;
174 {
175
1/2
✓ Branch 0 taken 2694 times.
✗ Branch 1 not taken.
2694 std::lock_guard<std::mutex> lock(processorsLock);
176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2694 times.
2694 for (auto& w : rejectedWarnings) {
177 ✗ WarningHolder::RemoveWarning(w);
178 }
179 2694 rejectedWarnings.clear();
180
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2694 times.
2698 for (auto& w : failed) {
181
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 LogErr(VB_CHANNELOUT, "%s\n", w.c_str());
182
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 WarningHolder::AddWarning(w);
183
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 rejectedWarnings.push_back(w);
184 }
185
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 2694 times.
2736 for (auto a : fromJsonProcessors) {
186 42 processors.remove(a);
187 }
188 2694 old.swap(fromJsonProcessors);
189
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 2694 times.
2817 for (auto p : created) {
190
3/4
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 9 times.
123 if (rangeIsValid(p)) {
191
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 processors.push_back(p);
192 }
193 // owned either way, freed on the next reload
194
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 fromJsonProcessors.push_back(p);
195 }
196 2694 }
197 // not running any more, and no longer reachable by the output thread
198
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 2694 times.
2736 for (auto a : old) {
199
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 delete a;
200 }
201 2694 }
202 129 OutputProcessor* OutputProcessors::create(const Json::Value& config) {
203 129 int active = config["active"].asInt();
204
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 1 times.
129 if (active == 1) {
205
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
128 std::string type = config["type"].asString();
206
3/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 118 times.
128 if (type == "Remap") {
207
5/8
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
10 return new RemapOutputProcessor(config);
208
3/4
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 62 times.
118 } else if (type == "Brightness") {
209
5/8
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
56 return new BrightnessOutputProcessor(config);
210
3/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 60 times.
62 } else if (type == "Hold Value") {
211
3/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 return new HoldValueOutputProcessor(config);
212
3/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 20 times.
60 } else if (type == "Set Value") {
213
5/8
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 39 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
40 return new SetValueOutputProcessor(config);
214
3/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 19 times.
20 } else if (type == "Clamp Value") {
215
3/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 return new ClampValueOutputProcessor(config);
216
3/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 17 times.
19 } else if (type == "Scale Value") {
217
3/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 return new ScaleValueOutputProcessor(config);
218
3/4
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 13 times.
17 } else if (type == "Reorder Colors") {
219
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 return new ColorOrderOutputProcessor(config);
220
3/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 10 times.
13 } else if (type == "Three to Four") {
221
3/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3 return new ThreeToFourOutputProcessor(config);
222
3/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8 times.
10 } else if (type == "Override Zero") {
223
3/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 return new OverrideZeroOutputProcessor(config);
224
3/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 1 times.
8 } else if (type == "Fold") {
225
3/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7 return new FoldOutputProcessor(config);
226 } else {
227
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 LogErr(VB_CHANNELOUT, "Unknown OutputProcessor type: %s\n", type.c_str());
228 }
229
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 123 times.
128 } else {
230 1 LogDebug(VB_CHANNELOUT, "Skipping disabled OutputProcessor\n");
231 }
232 2 return nullptr;
233 }
234
235 6 OutputProcessor* OutputProcessors::find(std::function<bool(OutputProcessor*)> f) const {
236
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 std::lock_guard<std::mutex> lock(processorsLock);
237
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 for (OutputProcessor* a : processors) {
238
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if (f(a)) {
239 4 return a;
240 }
241 }
242 2 return nullptr;
243 6 }
244
245 2950 void OutputProcessors::GetRequiredChannelRanges(const std::function<void(int, int)>& addRange) {
246 // a playlist Remap entry adds and removes processors from other threads
247
1/2
✓ Branch 0 taken 2950 times.
✗ Branch 1 not taken.
2950 std::lock_guard<std::mutex> lock(processorsLock);
248
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 2950 times.
3064 for (OutputProcessor* a : processors) {
249
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 a->GetRequiredChannelRanges(addRange);
250 }
251 2950 }
252
253 129 OutputProcessor::OutputProcessor() :
254 129 description(),
255 129 active(true) {
256 129 }
257
258 96 OutputProcessor::~OutputProcessor() {
259 96 }
260
261 116 void ProcessModelConfig(const Json::Value& config, std::string& model, int& start, int& count) {
262
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 111 times.
116 if (config.isMember("model")) {
263
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 model = config["model"].asString();
264
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (model != "<Use Start Channel>") {
265
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 auto m_model = PixelOverlayManager::INSTANCE.getModelShared(model);
266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!m_model) {
267 ✗ LogErr(VB_CHANNELOUT, "Invalid Pixel Overlay Model: '%s'\n", model.c_str());
268 } else {
269
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 int m_channel = m_model->getChannelCount();
270
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 LogDebug(VB_CHANNELOUT, "Before Model applied: %d-%d => Model: %s (%d channels)\n",
271 start, start + count - 1,
272 model.c_str(), m_channel);
273
274 // start arrives 1-based within the model; getStartChannel() is the
275 // model's 0-based absolute start, so the span still available from
276 // offset is m_channel - offset + 1 channels.
277 5 int offset = start;
278
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 start = m_model->getStartChannel() + start - 1;
279
280
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
5 if (offset + count - 1 > m_channel) {
281 2 count = m_channel - offset + 1;
282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (count < 0) {
283 ✗ count = 0;
284 }
285
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 LogWarn(VB_CHANNELOUT, "Output processor for Model: %s starting at channel %d would run past the end of the model (%d channels). Restricting to %d channels\n",
286 model.c_str(), offset, m_channel, count);
287
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 } else if (offset + count - 1 < m_channel) {
288
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 LogInfo(VB_CHANNELOUT, "Output processor for Model: %s is using less channels (%d starting at %d) than overlay model has (%d). This may be intentional\n",
289 model.c_str(), count, offset, m_channel);
290 }
291 }
292 5 } else {
293 ✗ model = "";
294 ✗ --start;
295 }
296 } else {
297 111 model = "";
298 111 --start;
299 }
300 // Processors report start + count * (1, 3 or 4) in an int. A start or a
301 // count in the billions overflowed it into the inverted range that means
302 // "nothing to do", rangeIsValid() let the processor through, and its
303 // ProcessData() then wrote count channels from start: at boot, from
304 // outputprocessors.json, so fppd crash looped. Pin both just outside the
305 // buffer instead, where the range still fails the check, and can't overflow.
306
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 114 times.
116 if (start < 0) {
307 2 start = -1;
308
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 112 times.
114 } else if (start > (int)FPPD_MAX_CHANNELS) {
309 2 start = FPPD_MAX_CHANNELS;
310 }
311
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 114 times.
116 if (count > (int)FPPD_MAX_CHANNELS + 1) {
312 2 count = FPPD_MAX_CHANNELS + 1;
313 }
314 116 }
315