Skip to content

Commit

Permalink
ExternalRecorder: If ExternalStreamHandler fails to init, release it.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoet committed Dec 28, 2020
1 parent 1cd6fa5 commit 97b0843
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/recorders/ExternalChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ bool ExternalChannel::Open(void)
if (!m_streamHandler || m_streamHandler->HasError())
{
LOG(VB_GENERAL, LOG_ERR, LOC + "Open failed");
Close();
return false;
}

Expand Down
5 changes: 5 additions & 0 deletions mythtv/libs/libmythtv/recorders/ExternalRecChannelFetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ ExternalRecChannelFetcher::ExternalRecChannelFetcher(int cardid,
, m_command(std::move(cmd))
{
m_streamHandler = ExternalStreamHandler::Get(m_command, m_cardid, m_cardid);
if (!m_streamHandler || m_streamHandler->HasError())
{
LOG(VB_GENERAL, LOG_ERR, LOC + "Open failed");
Close();
}
}

ExternalRecChannelFetcher::~ExternalRecChannelFetcher(void)
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/recorders/ExternalRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ bool ExternalRecorder::Open(void)
return true;
}

Close();
LOG(VB_GENERAL, LOG_ERR, LOC + "Open failed");
return false;
}
Expand Down
7 changes: 6 additions & 1 deletion mythtv/libs/libmythtv/recorders/ExternalSignalMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ ExternalSignalMonitor::ExternalSignalMonitor(int db_cardnum,
m_channel->GetInputID(),
m_channel->GetMajorID());
if (!m_streamHandler || m_streamHandler->HasError())
{
LOG(VB_GENERAL, LOG_ERR, LOC + "Open failed");
if (m_streamHandler)
ExternalStreamHandler::Return(m_streamHandler, m_inputid);
}
else
m_lockTimeout = GetLockTimeout() * 1000;

Expand All @@ -63,7 +67,8 @@ ExternalSignalMonitor::~ExternalSignalMonitor()
{
LOG(VB_CHANNEL, LOG_INFO, LOC + "dtor");
ExternalSignalMonitor::Stop();
ExternalStreamHandler::Return(m_streamHandler, m_inputid);
if (m_streamHandler)
ExternalStreamHandler::Return(m_streamHandler, m_inputid);
}

/** \fn ExternalSignalMonitor::Stop(void)
Expand Down

0 comments on commit 97b0843

Please sign in to comment.