GCC Code Coverage Report


Directory: ./
File: playlist/PlaylistEntryCommand.cpp
Date: 2026-12-01 12:27:28
Exec Total Coverage
Lines: 39 39 100.0%
Functions: 8 8 100.0%
Branches: 26 44 59.1%

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 "../log.h"
18
19 #include "PlaylistEntryCommand.h"
20
21 /*
22 *
23 */
24 3323 PlaylistEntryCommand::PlaylistEntryCommand(Playlist* playlist, PlaylistEntryBase* parent) :
25
1/2
✓ Branch 0 taken 3323 times.
✗ Branch 1 not taken.
3323 PlaylistEntryBase(playlist, parent) {
26
1/2
✓ Branch 0 taken 3323 times.
✗ Branch 1 not taken.
3323 LogDebug(VB_PLAYLIST, "PlaylistEntryCommand::PlaylistEntryCommand()\n");
27
28
1/2
✓ Branch 0 taken 3323 times.
✗ Branch 1 not taken.
3323 m_type = "command";
29 3323 }
30
31 /*
32 *
33 */
34 12844 PlaylistEntryCommand::~PlaylistEntryCommand() {
35 12844 }
36
37 /*
38 *
39 */
40 3323 int PlaylistEntryCommand::Init(Json::Value& config) {
41 3323 LogDebug(VB_PLAYLIST, "PlaylistEntryCommand::Init()\n");
42 3323 m_command = config;
43 3323 return PlaylistEntryBase::Init(config);
44 }
45
46 /*
47 *
48 */
49 3846 int PlaylistEntryCommand::StartPlaying(void) {
50 3846 LogDebug(VB_PLAYLIST, "PlaylistEntryCommand::StartPlaying()\n");
51
52
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3842 times.
3846 if (!CanPlay()) {
53 4 FinishPlay();
54 4 return 0;
55 }
56
57
3/6
✓ Branch 0 taken 3842 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3842 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3842 times.
✗ Branch 5 not taken.
3842 LogDebug(VB_COMMAND, "Playlist entry #%d running command \"%s\"\n", GetPositionInPlaylist(), m_command["command"].asString().c_str());
58
59
1/2
✓ Branch 0 taken 3842 times.
✗ Branch 1 not taken.
3842 m_result = std::move(CommandManager::INSTANCE.run(m_command));
60
5/6
✓ Branch 0 taken 3842 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 3838 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 3838 times.
3842 if (m_result->isDone() && m_result->isError()) {
61 // failed, so mark finished
62 4 FinishPlay();
63 4 return 0;
64 }
65 3838 return PlaylistEntryBase::StartPlaying();
66 }
67
68 /*
69 *
70 */
71 3511 int PlaylistEntryCommand::Process(void) {
72 3511 LogDebug(VB_PLAYLIST, "Process()\n");
73
3/6
✓ Branch 0 taken 3511 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3511 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3511 times.
✗ Branch 5 not taken.
3511 if (!m_result || m_result->isDone()) {
74 3511 FinishPlay();
75 }
76 3511 return PlaylistEntryBase::Process();
77 }
78
79 /*
80 *
81 */
82 324 int PlaylistEntryCommand::Stop(void) {
83 324 LogDebug(VB_PLAYLIST, "PlaylistEntryCommand::Stop()\n");
84
85 324 FinishPlay();
86 324 return PlaylistEntryBase::Stop();
87 }
88
89 /*
90 *
91 */
92 6 void PlaylistEntryCommand::Dump(void) {
93 6 PlaylistEntryBase::Dump();
94
95
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 LogDebug(VB_PLAYLIST, "Command: %s\n", m_command["command"].asString().c_str());
96
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 6 times.
39 for (int x = 0; x < m_command["args"].size(); x++) {
97
4/8
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
33 LogDebug(VB_PLAYLIST, " \"%s\"\n", m_command["args"][x].asString().c_str());
98 }
99 6 }
100
101 /*
102 *
103 */
104 33078 Json::Value PlaylistEntryCommand::GetConfig(void) {
105 33078 return m_command;
106 }
107