Skip to content

Commit

Permalink
Fix crash with Remap playlist items
Browse files Browse the repository at this point in the history
  • Loading branch information
dkulp committed Oct 24, 2019
1 parent d73450c commit ac1419b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/channeloutput/processors/RemapOutputProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ RemapOutputProcessor::RemapOutputProcessor(const Json::Value &config) {

RemapOutputProcessor::RemapOutputProcessor(int src, int dst, int c, int l, int r) {
active = true;
sourceChannel = src - 1;
destChannel = dst - 1;
sourceChannel = src;
destChannel = dst;
count = c;
loops = l;
reverse = r;
Expand Down
31 changes: 18 additions & 13 deletions src/playlist/PlaylistEntryRemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ PlaylistEntryRemap::PlaylistEntryRemap(PlaylistEntryBase *parent)
m_dstChannel(0),
m_channelCount(0),
m_loops(0),
m_reverse(0),
m_processor(nullptr)
m_reverse(0)
{
LogDebug(VB_PLAYLIST, "PlaylistEntryRemap::PlaylistEntryRemap()\n");

Expand All @@ -53,9 +52,6 @@ PlaylistEntryRemap::PlaylistEntryRemap(PlaylistEntryBase *parent)
*/
PlaylistEntryRemap::~PlaylistEntryRemap()
{
if (m_processor) {
delete m_processor;
}
}

/*
Expand Down Expand Up @@ -102,7 +98,15 @@ int PlaylistEntryRemap::Init(Json::Value &config)
m_loops = config["loops"].asInt();
m_reverse = config["reverse"].asInt();

m_processor = new RemapOutputProcessor(m_srcChannel, m_dstChannel, m_channelCount, m_loops, m_reverse);

// need to be 0 based
if (m_srcChannel) {
m_srcChannel--;
}
if (m_dstChannel) {
m_dstChannel--;
}

return PlaylistEntryBase::Init(config);
}

Expand All @@ -122,16 +126,17 @@ int PlaylistEntryRemap::StartPlaying(void)
PlaylistEntryBase::StartPlaying();

if (m_action == "add") {
outputProcessors.addProcessor(m_processor);
RemapOutputProcessor *processor = new RemapOutputProcessor(m_srcChannel, m_dstChannel, m_channelCount, m_loops, m_reverse);
outputProcessors.addProcessor(processor);
} else if (m_action == "remove") {
auto f = [this] (OutputProcessor*p2) -> bool {
if (p2->getType() == OutputProcessor::REMAP) {
RemapOutputProcessor *rp = (RemapOutputProcessor*)p2;
return rp->getSourceChannel() == this->m_srcChannel
&& rp->getDestChannel() == this->m_dstChannel
&& rp->getLoops() == this->m_loops
&& rp->getCount() == this->m_channelCount
&& rp->getReverse() == this->m_reverse;
&& rp->getDestChannel() == this->m_dstChannel
&& rp->getLoops() == this->m_loops
&& rp->getCount() == this->m_channelCount
&& rp->getReverse() == this->m_reverse;
}
return false;
};
Expand Down Expand Up @@ -164,8 +169,8 @@ Json::Value PlaylistEntryRemap::GetConfig(void)
{
Json::Value result = PlaylistEntryBase::GetConfig();

result["source"] = m_srcChannel;
result["destination"] = m_dstChannel;
result["source"] = m_srcChannel+1;
result["destination"] = m_dstChannel+1;
result["count"] = m_channelCount;
result["loops"] = m_loops;

Expand Down
1 change: 0 additions & 1 deletion src/playlist/PlaylistEntryRemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class PlaylistEntryRemap : public PlaylistEntryBase {
int m_channelCount;
int m_loops;
int m_reverse;
RemapOutputProcessor *m_processor;
};

#endif

0 comments on commit ac1419b

Please sign in to comment.