GCC Code Coverage Report


Directory: ./
File: playlist/PlaylistEntryCommand.cpp
Date: 2026-10-29 08:11:58
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 2168 PlaylistEntryCommand::PlaylistEntryCommand(Playlist* playlist, PlaylistEntryBase* parent) :
25
1/2
✓ Branch 0 taken 2168 times.
✗ Branch 1 not taken.
2168 PlaylistEntryBase(playlist, parent) {
26
1/2
✓ Branch 0 taken 2168 times.
✗ Branch 1 not taken.
2168 LogDebug(VB_PLAYLIST, "PlaylistEntryCommand::PlaylistEntryCommand()\n");
27
28
1/2
✓ Branch 0 taken 2168 times.
✗ Branch 1 not taken.
2168 m_type = "command";
29 2168 }
30
31 /*
32 *
33 */
34 8252 PlaylistEntryCommand::~PlaylistEntryCommand() {
35 8252 }
36
37 /*
38 *
39 */
40 2168 int PlaylistEntryCommand::Init(Json::Value& config) {
41 2168 LogDebug(VB_PLAYLIST, "PlaylistEntryCommand::Init()\n");
42 2168 m_command = config;
43 2168 return PlaylistEntryBase::Init(config);
44 }
45
46 /*
47 *
48 */
49 3076 int PlaylistEntryCommand::StartPlaying(void) {
50 3076 LogDebug(VB_PLAYLIST, "PlaylistEntryCommand::StartPlaying()\n");
51
52
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3072 times.
3076 if (!CanPlay()) {
53 4 FinishPlay();
54 4 return 0;
55 }
56
57
3/6
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3072 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3072 times.
✗ Branch 5 not taken.
3072 LogDebug(VB_COMMAND, "Playlist entry #%d running command \"%s\"\n", GetPositionInPlaylist(), m_command["command"].asString().c_str());
58
59
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 m_result = std::move(CommandManager::INSTANCE.run(m_command));
60
5/6
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 3068 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 3068 times.
3072 if (m_result->isDone() && m_result->isError()) {
61 // failed, so mark finished
62 4 FinishPlay();
63 4 return 0;
64 }
65 3068 return PlaylistEntryBase::StartPlaying();
66 }
67
68 /*
69 *
70 */
71 2714 int PlaylistEntryCommand::Process(void) {
72 2714 LogDebug(VB_PLAYLIST, "Process()\n");
73
3/6
✓ Branch 0 taken 2714 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2714 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2714 times.
✗ Branch 5 not taken.
2714 if (!m_result || m_result->isDone()) {
74 2714 FinishPlay();
75 }
76 2714 return PlaylistEntryBase::Process();
77 }
78
79 /*
80 *
81 */
82 351 int PlaylistEntryCommand::Stop(void) {
83 351 LogDebug(VB_PLAYLIST, "PlaylistEntryCommand::Stop()\n");
84
85 351 FinishPlay();
86 351 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 34663 Json::Value PlaylistEntryCommand::GetConfig(void) {
105 34663 return m_command;
106 }
107