GCC Code Coverage Report


Directory: ./
File: channeloutput/ThreadedChannelOutput.h
Date: 2026-10-29 08:11:58
Exec Total Coverage
Lines: 0 1 0.0%
Functions: 0 1 0.0%
Branches: 0 0 -%

Line Branch Exec Source
1 #pragma once
2 /*
3 * This file is part of the Falcon Player (FPP) and is Copyright (C)
4 * 2013-2022 by the Falcon Player Developers.
5 *
6 * The Falcon Player (FPP) is free software, and is covered under
7 * multiple Open Source licenses. Please see the included 'LICENSES'
8 * file for descriptions of what files are covered by each license.
9 *
10 * This source file is covered under the LGPL v2.1 as described in the
11 * included LICENSE.LGPL file.
12 */
13
14 #include <string>
15 #include "fpp-json-fwd.h"
16 #include <vector>
17
18 #include <condition_variable>
19 #include <mutex>
20 #include <thread>
21
22 #include "ChannelOutput.h"
23
24 class ThreadedChannelOutput : public ChannelOutput {
25 public:
26 ThreadedChannelOutput(unsigned int startChannel = 1,
27 unsigned int channelCount = 1);
28 virtual ~ThreadedChannelOutput();
29
30 virtual int Init(Json::Value config) override;
31 virtual int Close(void) override;
32
33 virtual int SendData(unsigned char* channelData) override;
34
35 void OutputThread(void);
36
37 // Public so the output loader can stop the worker before Close(): a
38 // subclass Close() tears down its own state first and only then reaches
39 // ThreadedChannelOutput::Close(). Idempotent.
40 int StopOutputThread(void);
41
42 private:
43 int Init(void);
44
45 protected:
46 virtual void DumpConfig(void) override;
47 virtual int RawSendData(unsigned char* channelData) = 0;
48 ✗ virtual void WaitTimedOut() {}
49 // Returns false if the worker thread could not be created; Init() fails
50 // the output in that case rather than waiting for a thread that will
51 // never run.
52 bool StartOutputThread(void);
53 int SendOutputBuffer(void);
54
55 unsigned int m_maxWait;
56 unsigned int m_threadIsRunning;
57
58 // m_runThread and m_dataWaiting are the worker's wait predicate: every
59 // write to either, and every read the worker acts on, is under m_sendLock.
60 unsigned int m_runThread;
61 volatile unsigned int m_dataWaiting;
62
63 unsigned int m_useDoubleBuffer;
64
65 // Converted from pthread_t/pthread_mutex_t/pthread_cond_t to the
66 // std:: equivalents. Default-constructed std::thread is
67 // non-joinable (equivalent to the old m_threadID == 0 sentinel), and
68 // std::mutex/std::condition_variable need no explicit init/destroy.
69 std::thread m_thread;
70 std::mutex m_bufLock;
71 std::mutex m_sendLock;
72 std::condition_variable m_sendCond;
73
74 unsigned char* m_inBuf;
75 unsigned char* m_outBuf;
76 };
77