Skip to content

Commit

Permalink
fix allow backend shutdown on reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
janbar committed Jan 9, 2020
1 parent 49e6f02 commit 2aa30af
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pvr.mythtv/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</category>
<category label="30050">
<setting id="extradebug" type="bool" label="30005" default="false" />
<setting id="block_shutdown" type="bool" label="30062" default="true" />
<setting id="allow_shutdown" type="bool" label="30062" default="true" />
<setting id="tunedelay" type="slider" option="int" range="5,1,30" label="30053" default="5" />
<setting id="limit_tune_attempts" type="bool" label="30065" default="true" />
<setting id="backend_bookmarks" type="bool" label="30068" default="true" />
Expand Down
22 changes: 9 additions & 13 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int g_iTuneDelay = DEFAULT_TUNE_DELAY;
int g_iGroupRecordings = GROUP_RECORDINGS_ALWAYS;
bool g_bUseAirdate = DEFAULT_USE_AIRDATE;
int g_iEnableEDL = ENABLE_EDL_ALWAYS;
bool g_bBlockMythShutdown = DEFAULT_BLOCK_SHUTDOWN;
bool g_bAllowMythShutdown = DEFAULT_ALLOW_SHUTDOWN;
bool g_bLimitTuneAttempts = DEFAULT_LIMIT_TUNE_ATTEMPTS;
bool g_bShowNotRecording = DEFAULT_SHOW_NOT_RECORDING;
bool g_bPromptDeleteAtEnd = DEFAULT_PROMPT_DELETE;
Expand Down Expand Up @@ -276,12 +276,12 @@ ADDON_STATUS ADDON_Create(void *hdl, void *props)
g_iEnableEDL = ENABLE_EDL_ALWAYS;
}

/* Read setting "block_shutdown" from settings.xml */
if (!XBMC->GetSetting("block_shutdown", &g_bBlockMythShutdown))
/* Read setting "allow_shutdown" from settings.xml */
if (!XBMC->GetSetting("allow_shutdown", &g_bAllowMythShutdown))
{
/* If setting is unknown fallback to defaults */
XBMC->Log(LOG_ERROR, "Couldn't get 'block_shutdown' setting, falling back to '%u' as default", DEFAULT_BLOCK_SHUTDOWN);
g_bBlockMythShutdown = DEFAULT_BLOCK_SHUTDOWN;
XBMC->Log(LOG_ERROR, "Couldn't get 'allow_shutdown' setting, falling back to '%u' as default", DEFAULT_ALLOW_SHUTDOWN);
g_bAllowMythShutdown = DEFAULT_ALLOW_SHUTDOWN;
}

/* Read setting "channel_icons" from settings.xml */
Expand Down Expand Up @@ -638,15 +638,11 @@ ADDON_STATUS ADDON_SetSetting(const char *settingName, const void *settingValue)
if (g_iEnableEDL != *(int*)settingValue)
g_iEnableEDL = *(int*)settingValue;
}
else if (str == "block_shutdown")
else if (str == "allow_shutdown")
{
XBMC->Log(LOG_INFO, "Changed Setting 'block_shutdown' from %u to %u", g_bBlockMythShutdown, *(bool*)settingValue);
if (g_bBlockMythShutdown != *(bool*)settingValue)
{
g_bBlockMythShutdown = *(bool*)settingValue;
if (g_client)
g_bBlockMythShutdown ? g_client->BlockBackendShutdown() : g_client->AllowBackendShutdown();
}
XBMC->Log(LOG_INFO, "Changed Setting 'allow_shutdown' from %u to %u", g_bAllowMythShutdown, *(bool*)settingValue);
if (g_bAllowMythShutdown != *(bool*)settingValue)
g_bAllowMythShutdown = *(bool*)settingValue;
}
else if (str == "limit_tune_attempts")
{
Expand Down
4 changes: 2 additions & 2 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#define ENABLE_EDL_DIALOG 1
#define ENABLE_EDL_NEVER 2
#define ENABLE_EDL_SCENE 3
#define DEFAULT_BLOCK_SHUTDOWN true
#define DEFAULT_ALLOW_SHUTDOWN true
#define DEFAULT_LIMIT_TUNE_ATTEMPTS true
#define DEFAULT_SHOW_NOT_RECORDING true
#define DEFAULT_PROMPT_DELETE false
Expand Down Expand Up @@ -115,7 +115,7 @@ extern int g_iTuneDelay;
extern int g_iGroupRecordings;
extern bool g_bUseAirdate;
extern int g_iEnableEDL;
extern bool g_bBlockMythShutdown;
extern bool g_bAllowMythShutdown;
extern bool g_bLimitTuneAttempts; ///< Limit channel tuning attempts to first card
extern bool g_bShowNotRecording;
extern bool g_bPromptDeleteAtEnd;
Expand Down
11 changes: 8 additions & 3 deletions src/pvrclient-mythtv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bool PVRClientMythTV::Connect()
assert(m_control == NULL);

SetDebug(true);
Myth::Control *control = new Myth::Control(g_szMythHostname, g_iProtoPort, g_iWSApiPort, g_szWSSecurityPin, g_bBlockMythShutdown, true);
Myth::Control *control = new Myth::Control(g_szMythHostname, g_iProtoPort, g_iWSApiPort, g_szWSSecurityPin, true);
if (!control->IsOpen())
{
switch(control->GetProtoError())
Expand Down Expand Up @@ -258,13 +258,15 @@ void PVRClientMythTV::OnWake()

void PVRClientMythTV::OnDeactivatedGUI()
{
AllowBackendShutdown();
if (g_bAllowMythShutdown && m_control && m_control->IsOpen())
AllowBackendShutdown();
m_powerSaving = true;
}

void PVRClientMythTV::OnActivatedGUI()
{
if (g_bBlockMythShutdown)
// block shutdown if backend is connected
if (g_bAllowMythShutdown && m_control && m_control->IsOpen())
BlockBackendShutdown();
m_powerSaving = false;
}
Expand Down Expand Up @@ -305,6 +307,9 @@ void PVRClientMythTV::HandleBackendMessage(Myth::EventMessagePtr msg)
m_scheduleManager->OpenControl();
m_hang = false;
XBMC->QueueNotification(QUEUE_INFO, XBMC->GetLocalizedString(30303)); // Connection to MythTV restored
// still in mode power saving I have to allow shutdown again
if (m_powerSaving && g_bAllowMythShutdown)
AllowBackendShutdown();
}
// Refreshing all
HandleChannelChange();
Expand Down

0 comments on commit 2aa30af

Please sign in to comment.