GCC Code Coverage Report


Directory: ./
File: playlist/PlaylistEntryBoth.cpp
Date: 2026-12-01 12:27:28
Exec Total Coverage
Lines: 149 197 75.6%
Functions: 13 15 86.7%
Branches: 203 426 47.7%

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 <thread>
18
19 #include "../common.h"
20 #include "../log.h"
21
22 #include "PlaylistEntryBoth.h"
23 #include "mediadetails.h"
24 #include "../MultiSync.h"
25 #include "../Sequence.h"
26
27 // Longest the sequence waits for the media to become audible. Covers a cold
28 // audio output (~0.6 s on an AM335x, a PipeWire output stream gives up at 3 s)
29 // with margin; past it the sequence starts and the sync servo takes over.
30 static constexpr long long AUDIO_START_HOLD_MS = 4000;
31 // Most a song's lights go on past the end of its media for the sound still on
32 // its way to the speaker (the output stream's queue and the card's). Any
33 // more than this and the media didn't reach its end: it failed or was
34 // stopped, and its lights stop with it.
35 static constexpr uint64_t MAX_SOUND_TAIL_MS = 500;
36
37 72 PlaylistEntryBoth::PlaylistEntryBoth(Playlist* playlist, PlaylistEntryBase* parent) :
38 PlaylistEntryBase(playlist, parent),
39 72 m_duration(0),
40 72 m_mediaEntry(NULL),
41 72 m_sequenceEntry(NULL) {
42
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 LogDebug(VB_PLAYLIST, "PlaylistEntryBoth::PlaylistEntryBoth()\n");
43
44
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 m_type = "both";
45 72 }
46
47 236 PlaylistEntryBoth::~PlaylistEntryBoth() {
48
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
118 if (m_sequenceEntry) {
49
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
118 delete m_sequenceEntry;
50 }
51
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 1 times.
118 if (m_mediaOwned) {
52
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
116 delete m_mediaOwned;
53 }
54 236 }
55
56 /*
57 *
58 */
59 72 int PlaylistEntryBoth::Init(Json::Value& config) {
60 72 LogDebug(VB_PLAYLIST, "PlaylistEntryBoth::Init()\n");
61
62
2/6
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
72 m_sequenceEntry = new PlaylistEntrySequence(m_parentPlaylist, this);
63
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if (!m_sequenceEntry)
64 ✗ return 0;
65
66
2/6
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
72 m_mediaOwned = new PlaylistEntryMedia(m_parentPlaylist, this);
67 72 m_mediaEntry = m_mediaOwned;
68
69
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 71 times.
72 if (!m_mediaEntry->Init(config)) {
70 // Media init failed — run sequence-only. The rest of this class
71 // already null-checks m_mediaEntry; the unconditional GetMediaName()
72 // call that used to sit below this branch dereferenced the pointer
73 // just nulled here.
74
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 delete m_mediaOwned;
75 1 m_mediaOwned = nullptr;
76 1 m_mediaEntry = nullptr;
77 } else {
78
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 m_mediaName = m_mediaEntry->GetMediaName();
79 }
80
81
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if (!m_sequenceEntry->Init(config))
82 ✗ return 0;
83
84 72 m_sequenceName = m_sequenceEntry->GetSequenceName();
85 72 return PlaylistEntryBase::Init(config);
86 }
87
88 38 void PlaylistEntryBoth::PrepareAhead() {
89
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 std::unique_lock<std::recursive_mutex> seqLock(m_mutex);
90
4/8
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 38 times.
✗ Branch 7 not taken.
38 if (CanPlay() && m_mediaOwned) {
91
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 m_mediaOwned->PrepareAhead();
92 }
93 38 }
94
95 /*
96 *
97 */
98 79 int PlaylistEntryBoth::StartPlaying(void) {
99
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 LogDebug(VB_PLAYLIST, "PlaylistEntryBoth::StartPlaying()\n");
100
101
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 std::unique_lock<std::recursive_mutex> seqLock(m_mutex);
102
2/4
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79 times.
79 if (!CanPlay()) {
103 ✗ FinishPlay();
104 ✗ return 0;
105 }
106
107 // The sequence may start later than this (held until the media is
108 // audible, or after a media offset), and Process() acts on whether it is
109 // started or finished. On a repeating playlist's next pass it still
110 // carries the last pass's "started and finished" -- which ended the entry
111 // at once, so a repeating playlist ran through every entry in a fraction
112 // of a second at the wrap and never played again.
113
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 m_sequenceEntry->ResetPlayState();
114
115 // Each pass decides afresh whether it has media.
116 79 m_mediaEntry = m_mediaOwned;
117
5/8
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 78 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 78 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 79 times.
79 if (m_mediaEntry && !m_mediaEntry->PreparePlay()) {
118 ✗ m_mediaEntry = nullptr;
119 }
120
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 78 times.
79 if (!m_mediaEntry) {
121
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 LogDebug(VB_PLAYLIST, "Skipping media playlist entry, likely blacklisted audio: %s\n", m_mediaName.c_str());
122 }
123 // The media drives the timing when there is media; without it this pass,
124 // the sequence has to keep its own time.
125 79 m_sequenceEntry->setAdjustTiming(m_mediaEntry == nullptr);
126 // A sequence held until its media is audible (below) is opened only then,
127 // by its StartPlaying(). Opening it shows its first frame at once, and
128 // takes over from the sequence before it -- which is still playing the
129 // end of its own song's sound (see Process()) while this song's sound,
130 // carried on right behind it in the output stream, comes up.
131
5/6
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 78 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✓ Branch 5 taken 10 times.
79 bool openLater = m_mediaEntry && m_mediaEntry->GetMediaOffsetMS() <= 0;
132
5/8
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 79 times.
79 if (!openLater && !m_sequenceEntry->PreparePlay()) {
133 ✗ LogDebug(VB_PLAYLIST, "Problems starting sequence: %s\n", m_sequenceEntry->GetSequenceName().c_str());
134 }
135
9/10
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50 times.
✓ Branch 5 taken 18 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 46 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 75 times.
79 if (openLater && !sequence->IsSequenceRunning() && multiSync->isMultiSyncEnabled()) {
136 // With nothing running, the remotes have no tail to finish either:
137 // tell them now, so they read the file ahead of its start rather
138 // than at it. Our own open sends it again at the start, which a
139 // remote with the file open and not yet started takes as a no-op.
140
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 multiSync->SendSeqOpenPacket(m_sequenceEntry->GetSequenceName());
141 }
142
143
6/8
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 74 times.
79 if (multiSync->isMultiSyncEnabled() && m_mediaEntry && m_mediaEntry->m_openTime) {
144
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 long long st = GetMonotonicTimeMS() - m_mediaEntry->m_openTime;
145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (st < PlaylistEntryMedia::m_openStartDelay) {
146 ✗ std::this_thread::sleep_for(std::chrono::milliseconds(PlaylistEntryMedia::m_openStartDelay - st - 2));
147 }
148 }
149
150 // With media, the sequence normally starts from Process() once the media
151 // is audible rather than here. Starting both together put the lights
152 // ahead of the sound by however long the audio output took to come up --
153 // most of a second on slow boards -- and they only caught up as the sync
154 // servo slowed them, which looks like the first second of audio is missing.
155
5/6
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 78 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✓ Branch 5 taken 10 times.
79 m_holdingForAudio = m_mediaEntry && m_mediaEntry->GetMediaOffsetMS() <= 0;
156
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 78 times.
79 if (!m_mediaEntry) {
157
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if (!m_sequenceEntry->StartPlaying()) {
158 ✗ LogDebug(VB_PLAYLIST, "Could not start sequence: %s\n", m_sequenceEntry->GetSequenceName().c_str());
159 ✗ FinishPlay();
160 ✗ return 0;
161 }
162 }
163
7/8
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 78 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 77 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 78 times.
79 if (m_mediaEntry && !m_mediaEntry->StartPlaying()) {
164
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 LogDebug(VB_PLAYLIST, "Could not start media: %s\n", m_mediaName.c_str());
165
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 m_mediaEntry->Stop();
166 1 m_mediaEntry = nullptr;
167 1 m_holdingForAudio = false;
168
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 m_sequenceEntry->Stop();
169
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 FinishPlay();
170 1 return 0;
171 }
172
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 m_holdStartMS = GetMonotonicTimeMS();
173
174
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 return PlaylistEntryBase::StartPlaying();
175 79 }
176
177 /*
178 *
179 */
180 129079 int PlaylistEntryBoth::Process(void) {
181
1/2
✓ Branch 0 taken 129079 times.
✗ Branch 1 not taken.
129079 LogExcess(VB_PLAYLIST, "PlaylistEntryBoth::Process()\n");
182
1/2
✓ Branch 0 taken 129079 times.
✗ Branch 1 not taken.
129079 std::unique_lock<std::recursive_mutex> seqLock(m_mutex);
183
184
2/2
✓ Branch 0 taken 128887 times.
✓ Branch 1 taken 192 times.
129079 if (m_mediaEntry)
185
1/2
✓ Branch 0 taken 128887 times.
✗ Branch 1 not taken.
128887 m_mediaEntry->Process();
186
187
3/4
✓ Branch 0 taken 874 times.
✓ Branch 1 taken 128205 times.
✓ Branch 2 taken 874 times.
✗ Branch 3 not taken.
129079 if (m_holdingForAudio && m_mediaEntry) {
188
1/2
✓ Branch 0 taken 874 times.
✗ Branch 1 not taken.
874 long long held = GetMonotonicTimeMS() - m_holdStartMS;
189
6/8
✓ Branch 0 taken 874 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 809 times.
✓ Branch 3 taken 65 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 809 times.
✓ Branch 6 taken 65 times.
✓ Branch 7 taken 809 times.
874 if (m_mediaEntry->IsAudible() || held >= AUDIO_START_HOLD_MS) {
190 65 m_holdingForAudio = false;
191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
65 if (held >= AUDIO_START_HOLD_MS) {
192 ✗ LogWarn(VB_PLAYLIST, "No sound from %s after %lld ms, starting sequence %s anyway\n",
193 m_mediaName.c_str(), held, m_sequenceEntry->GetSequenceName().c_str());
194 } else {
195
1/2
✓ Branch 0 taken 65 times.
✗ Branch 1 not taken.
65 LogDebug(VB_PLAYLIST, "Media audible after %lld ms, starting sequence %s\n",
196 held, m_sequenceEntry->GetSequenceName().c_str());
197 }
198
2/4
✓ Branch 0 taken 65 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 65 times.
65 if (!m_sequenceEntry->StartPlaying()) {
199 ✗ LogDebug(VB_PLAYLIST, "Could not start sequence: %s\n", m_sequenceEntry->GetSequenceName().c_str());
200 ✗ m_mediaEntry->Stop();
201 ✗ FinishPlay();
202 ✗ return PlaylistEntryBase::Process();
203 }
204 }
205 }
206
207
7/8
✓ Branch 0 taken 128887 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 128887 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1832 times.
✓ Branch 5 taken 127055 times.
✓ Branch 6 taken 1832 times.
✓ Branch 7 taken 127247 times.
129079 if (m_mediaEntry && m_mediaEntry->GetMediaOffsetMS() > 0) {
208
1/2
✓ Branch 0 taken 1832 times.
✗ Branch 1 not taken.
1832 long long ct = GetMonotonicTimeMS();
209 1832 long long df = ct - m_mediaEntry->m_startTime;
210
3/4
✓ Branch 0 taken 1832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1574 times.
✓ Branch 3 taken 258 times.
1832 if (df > (m_mediaEntry->GetMediaOffsetMS() - m_sequenceEntry->GetSequenceFrameTime())) {
211
3/4
✓ Branch 0 taken 1574 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1564 times.
1574 if (!m_sequenceEntry->IsStarted()) {
212
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 m_sequenceEntry->StartPlaying();
213 }
214 }
215 }
216
3/4
✓ Branch 0 taken 129079 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128012 times.
✓ Branch 3 taken 1067 times.
129079 if (m_sequenceEntry->IsStarted()) {
217
1/2
✓ Branch 0 taken 128012 times.
✗ Branch 1 not taken.
128012 m_sequenceEntry->Process();
218 }
219
220
7/8
✓ Branch 0 taken 128887 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 128887 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✓ Branch 5 taken 128833 times.
✓ Branch 6 taken 54 times.
✓ Branch 7 taken 129025 times.
129079 if (m_mediaEntry && m_mediaEntry->IsFinished()) {
221
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 FinishPlay();
222
3/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 1 times.
54 if (!m_sequenceEntry->IsFinished()) {
223 // The media ends as its last sound is handed to the output, and
224 // that sound is then still to play: the stream's queue and the
225 // card's, as far as the lights following it are behind the end.
226 // They play to the end of it; the next song's sequence takes over
227 // when its own sound starts.
228 // As measured where the output knows (the sound still queued for
229 // the card when the media ended); else the media's length less
230 // how far the sequence has got, which is only as good as the
231 // length (a VBR mp3's can be off).
232 uint64_t tail;
233 53 uint64_t soundEnd = m_mediaEntry->SoundEndMS();
234
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (soundEnd) {
235
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 uint64_t now = GetMonotonicTimeMS();
236
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 tail = soundEnd > now ? soundEnd - now : 0;
237 } else {
238 ✗ uint64_t length = m_mediaEntry->GetLengthInMS();
239 ✗ uint64_t at = m_sequenceEntry->GetElapsedMS();
240 ✗ tail = length > at ? length - at : 0;
241 }
242
5/10
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 53 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 53 times.
✗ Branch 9 not taken.
53 if (m_sequenceEntry->IsStarted() && tail > 0 && tail <= MAX_SOUND_TAIL_MS) {
243
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 m_sequenceEntry->StopAfter((int)tail);
244 } else {
245 ✗ m_sequenceEntry->Stop();
246 }
247 }
248 }
249
250
9/12
✓ Branch 0 taken 129079 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 129020 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 58 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 58 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 59 times.
✓ Branch 11 taken 129020 times.
129079 if (m_sequenceEntry->IsFinished() && (!m_mediaEntry || !m_mediaEntry->HasExtraAtEnd())) {
251
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 FinishPlay();
252
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 1 times.
59 if (m_mediaEntry)
253
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 m_mediaEntry->Stop();
254 }
255
256 // FIXME PLAYLIST, handle sync in here somehow
257
258
1/2
✓ Branch 0 taken 129079 times.
✗ Branch 1 not taken.
129079 return PlaylistEntryBase::Process();
259 129079 }
260
261 /*
262 *
263 */
264 12 int PlaylistEntryBoth::Stop(void) {
265
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 LogDebug(VB_PLAYLIST, "PlaylistEntryBoth::Stop()\n");
266
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 std::unique_lock<std::recursive_mutex> seqLock(m_mutex);
267 12 m_holdingForAudio = false;
268
269
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if (m_mediaEntry)
270
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 m_mediaEntry->Stop();
271
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 m_sequenceEntry->Stop();
272
273
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
24 return PlaylistEntryBase::Stop();
274 12 }
275
276 /*
277 *
278 */
279 ✗ void PlaylistEntryBoth::Dump(void) {
280 ✗ std::unique_lock<std::recursive_mutex> seqLock(m_mutex);
281 ✗ PlaylistEntryBase::Dump();
282
283 ✗ if (m_mediaEntry)
284 ✗ m_mediaEntry->Dump();
285 ✗ m_sequenceEntry->Dump();
286 ✗ }
287
288 130514 uint64_t PlaylistEntryBoth::GetLengthInMS() {
289
1/2
✓ Branch 0 taken 130514 times.
✗ Branch 1 not taken.
130514 std::unique_lock<std::recursive_mutex> seqLock(m_mutex);
290
3/4
✓ Branch 0 taken 130300 times.
✓ Branch 1 taken 214 times.
✓ Branch 2 taken 130300 times.
✗ Branch 3 not taken.
130514 uint64_t m = m_mediaEntry ? m_mediaEntry->GetLengthInMS() : 0;
291
2/4
✓ Branch 0 taken 130514 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130514 times.
✗ Branch 3 not taken.
130514 uint64_t s = m_sequenceEntry ? m_sequenceEntry->GetLengthInMS() : 0;
292
4/4
✓ Branch 0 taken 130287 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 452 times.
✓ Branch 3 taken 129835 times.
130514 if (m && m < s) {
293 // media drives it, when media completes, we stop
294 452 return m;
295 }
296 130062 return s;
297 130514 }
298 131949 uint64_t PlaylistEntryBoth::GetElapsedMS() {
299
1/2
✓ Branch 0 taken 131949 times.
✗ Branch 1 not taken.
131949 std::unique_lock<std::recursive_mutex> seqLock(m_mutex);
300
2/2
✓ Branch 0 taken 131713 times.
✓ Branch 1 taken 236 times.
131949 if (m_mediaEntry) {
301
1/2
✓ Branch 0 taken 131713 times.
✗ Branch 1 not taken.
131713 return m_mediaEntry->GetElapsedMS();
302 }
303
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 if (m_sequenceEntry) {
304
1/2
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
236 return m_sequenceEntry->GetElapsedMS();
305 }
306 ✗ return 0;
307 131949 }
308
309 /*
310 *
311 */
312 223 Json::Value PlaylistEntryBoth::GetConfig(void) {
313
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 std::unique_lock<std::recursive_mutex> seqLock(m_mutex);
314
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 Json::Value result = PlaylistEntryBase::GetConfig();
315
316
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 3 times.
223 if (m_mediaEntry) {
317
2/4
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 220 times.
✗ Branch 3 not taken.
220 result["media"] = m_mediaEntry->GetConfig();
318 } else {
319 // fake it so the display will display the times
320 // where the sequence is
321
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 result["media"] = m_sequenceEntry->GetConfig();
322 }
323
2/4
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 223 times.
✗ Branch 3 not taken.
223 result["sequence"] = m_sequenceEntry->GetConfig();
324
325 223 return result;
326 223 }
327
328 ✗ Json::Value PlaylistEntryBoth::GetMqttStatus(void) {
329 ✗ std::unique_lock<std::recursive_mutex> seqLock(m_mutex);
330 ✗ Json::Value result = PlaylistEntryBase::GetMqttStatus();
331 ✗ if (m_mediaEntry) {
332 ✗ uint64_t l = m_mediaEntry->GetLengthInMS();
333 ✗ uint64_t e = m_mediaEntry->GetElapsedMS();
334 ✗ result["secondsRemaining"] = (int)((l - e) / 1000);
335 ✗ result["secondsTotal"] = (int)(l / 1000);
336 ✗ result["secondsElapsed"] = (int)(e / 1000);
337 ✗ result["mediaName"] = m_mediaEntry->GetMediaName();
338 }
339 ✗ if (m_sequenceEntry) {
340 ✗ Json::Value se = m_sequenceEntry->GetMqttStatus();
341 ✗ result["sequenceName"] = se["sequenceName"];
342 ✗ result["secondsRemaining"] = se["secondsRemaining"];
343 ✗ result["secondsTotal"] = se["secondsTotal"];
344 ✗ result["secondsElapsed"] = se["secondsElapsed"];
345 ✗ }
346
347 ✗ result["mediaTitle"] = MediaDetails::INSTANCE.title;
348 ✗ result["mediaArtist"] = MediaDetails::INSTANCE.artist;
349
350 ✗ return result;
351 ✗ }
352
353 3 void PlaylistEntryBoth::Pause() {
354
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 std::unique_lock<std::recursive_mutex> seqLock(m_mutex);
355
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (m_mediaEntry)
356
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 m_mediaEntry->Pause();
357
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 m_sequenceEntry->Pause();
358 3 }
359 258563 bool PlaylistEntryBoth::IsPaused() {
360
1/2
✓ Branch 0 taken 258563 times.
✗ Branch 1 not taken.
258563 std::unique_lock<std::recursive_mutex> seqLock(m_mutex);
361
2/2
✓ Branch 0 taken 258177 times.
✓ Branch 1 taken 386 times.
258563 if (m_mediaEntry) {
362
1/2
✓ Branch 0 taken 258177 times.
✗ Branch 1 not taken.
258177 return m_mediaEntry->IsPaused();
363 }
364
1/2
✓ Branch 0 taken 386 times.
✗ Branch 1 not taken.
386 return m_sequenceEntry->IsPaused();
365 258563 }
366 3 void PlaylistEntryBoth::Resume() {
367
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 std::unique_lock<std::recursive_mutex> seqLock(m_mutex);
368
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (m_mediaEntry)
369
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 m_mediaEntry->Resume();
370
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 m_sequenceEntry->Resume();
371 3 }
372