Skip to content

Commit

Permalink
Merge pull request kodi-pvr#11 from janbar/tuning_attempts
Browse files Browse the repository at this point in the history
Limit channel tuning attempts
  • Loading branch information
janbar committed Aug 20, 2015
2 parents eaa506a + f32248a commit 9383c9f
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 2 deletions.
14 changes: 14 additions & 0 deletions lib/cppmyth/src/mythlivetvplayback.cpp
Expand Up @@ -48,6 +48,7 @@ LiveTVPlayback::LiveTVPlayback(EventHandler& handler)
, m_eventHandler(handler)
, m_eventSubscriberId(0)
, m_tuneDelay(MIN_TUNE_DELAY)
, m_limitTuneAttempts(true)
, m_recorder()
, m_signal()
, m_chain()
Expand Down Expand Up @@ -132,6 +133,13 @@ void LiveTVPlayback::SetTuneDelay(unsigned delay)
m_tuneDelay = delay;
}

void LiveTVPlayback::SetLimitTuneAttempts(bool limit)
{
// true : Try first tunable card in prefered order
// false: Try all tunable cards in prefered order
m_limitTuneAttempts = limit;
}

bool LiveTVPlayback::SpawnLiveTV(const std::string& chanNum, const ChannelList& channels)
{
// Begin critical section
Expand Down Expand Up @@ -176,6 +184,12 @@ bool LiveTVPlayback::SpawnLiveTV(const std::string& chanNum, const ChannelList&
m_recorder->StopLiveTV();
}
ClearChain();
// Check if we need to stop after first attempt at tuning
if (m_limitTuneAttempts)
{
DBG(MYTH_DBG_DEBUG, "%s: limiting tune attempts to first tunable card\n", __FUNCTION__);
break;
}
// Retry the next preferred card
++card;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/cppmyth/src/mythlivetvplayback.h
Expand Up @@ -45,6 +45,7 @@ namespace Myth
void Close();
bool IsOpen() { return ProtoMonitor::IsOpen(); }
void SetTuneDelay(unsigned delay);
void SetLimitTuneAttempts(bool limit);
bool SpawnLiveTV(const std::string& chanNum, const ChannelList& channels);
bool SpawnLiveTV(const ChannelPtr& thisChannel);
void StopLiveTV();
Expand Down Expand Up @@ -73,6 +74,7 @@ namespace Myth
unsigned m_eventSubscriberId;

unsigned m_tuneDelay;
bool m_limitTuneAttempts;
ProtoRecorderPtr m_recorder;
SignalStatusPtr m_signal;

Expand Down
Expand Up @@ -201,7 +201,11 @@ msgctxt "#30064"
msgid "Enable recording fanart/thumbnails"
msgstr ""

#empty strings from id 30065 to 30099
msgctxt "#30065"
msgid "Limit channel tuning attempts"
msgstr ""

#empty strings from id 30066 to 30099

# Systeminformation labels
msgctxt "#30100"
Expand Down
Expand Up @@ -192,6 +192,10 @@ msgctxt "#30064"
msgid "Enable recording fanart/thumbnails"
msgstr "Afficher les vignettes des enregistrements"

msgctxt "#30065"
msgid "Limit channel tuning attempts"
msgstr "Limiter les tentatives de syntonisation"

msgctxt "#30100"
msgid "Protocol version: %i - Database version: %i"
msgstr "Version du protocole: %i - Version de la base de données: %i"
Expand Down
1 change: 1 addition & 0 deletions pvr.mythtv/resources/settings.xml
Expand Up @@ -28,6 +28,7 @@
<setting id="demuxing" type="bool" label="30052" default="false" />
<setting id="block_shutdown" type="bool" label="30062" default="true" />
<setting id="tunedelay" type="slider" option="int" range="5,1,30" label="30053" />
<setting id="limit_tune_attempts" type="bool" label="30065" default="true" />
<setting id="group_recordings" type="enum" label="30054" lvalues="30055|30056|30057" default="0" />
<setting id="enable_edl" type="enum" label="30058" lvalues="30059|30060|30061" default="0" />
<setting id="channel_icons" type="bool" label="30063" default="true" />
Expand Down
15 changes: 15 additions & 0 deletions src/client.cpp
Expand Up @@ -57,6 +57,7 @@ int g_iTuneDelay = DEFAULT_TUNE_DELAY;
int g_iGroupRecordings = GROUP_RECORDINGS_ALWAYS;
int g_iEnableEDL = ENABLE_EDL_ALWAYS;
bool g_bBlockMythShutdown = DEFAULT_BLOCK_SHUTDOWN;
bool g_bLimitTuneAttempts = DEFAULT_LIMIT_TUNE_ATTEMPTS;

///* Client member variables */
ADDON_STATUS m_CurStatus = ADDON_STATUS_UNKNOWN;
Expand Down Expand Up @@ -301,6 +302,14 @@ ADDON_STATUS ADDON_Create(void *hdl, void *props)
g_bRecordingIcons = DEFAULT_RECORDING_ICONS;
}

/* Read setting "limit_tune_attempts" from settings.xml */
if (!XBMC->GetSetting("limit_tune_attempts", &g_bLimitTuneAttempts))
{
/* If setting is unknown fallback to defaults */
XBMC->Log(LOG_ERROR, "Couldn't get 'limit_tune_attempts' setting, falling back to '%b' as default", DEFAULT_LIMIT_TUNE_ATTEMPTS);
g_bLimitTuneAttempts = DEFAULT_LIMIT_TUNE_ATTEMPTS;
}

free (buffer);
XBMC->Log(LOG_DEBUG, "Loading settings...done");

Expand Down Expand Up @@ -615,6 +624,12 @@ ADDON_STATUS ADDON_SetSetting(const char *settingName, const void *settingValue)
g_bBlockMythShutdown ? g_client->BlockBackendShutdown() : g_client->AllowBackendShutdown();
}
}
else if (str == "limit_tune_attempts")
{
XBMC->Log(LOG_INFO, "Changed Setting 'limit_tune_attempts' from %u to %u", g_bLimitTuneAttempts, *(bool*)settingValue);
if (g_bLimitTuneAttempts != *(bool*)settingValue)
g_bLimitTuneAttempts = *(bool*)settingValue;
}
return ADDON_STATUS_OK;
}

Expand Down
2 changes: 2 additions & 0 deletions src/client.h
Expand Up @@ -62,6 +62,7 @@
#define ENABLE_EDL_DIALOG 1
#define ENABLE_EDL_NEVER 2
#define DEFAULT_BLOCK_SHUTDOWN true
#define DEFAULT_LIMIT_TUNE_ATTEMPTS true

/*!
* @brief PVR macros for string exchange
Expand Down Expand Up @@ -106,6 +107,7 @@ extern int g_iTuneDelay;
extern int g_iGroupRecordings;
extern int g_iEnableEDL;
extern bool g_bBlockMythShutdown;
extern bool g_bLimitTuneAttempts; ///< Limit channel tuning attempts to first card

extern ADDON::CHelper_libXBMC_addon *XBMC;
extern CHelper_libXBMC_pvr *PVR;
Expand Down
3 changes: 2 additions & 1 deletion src/pvrclient-mythtv.cpp
Expand Up @@ -1946,8 +1946,9 @@ bool PVRClientMythTV::OpenLiveStream(const PVR_CHANNEL &channel)
// Suspend fileOps to avoid connection hang
if (m_fileOps)
m_fileOps->Suspend();
// Set tuning delay
// Configure tuning of channel
m_liveStream->SetTuneDelay(g_iTuneDelay);
m_liveStream->SetLimitTuneAttempts(g_bLimitTuneAttempts);
// Try to open
if (m_liveStream->SpawnLiveTV(chanset[0]->chanNum, chanset))
{
Expand Down

0 comments on commit 9383c9f

Please sign in to comment.