aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Sommerfeld <kai.sommerfeld@gmx.com>2019-10-29 08:26:36 +0100
committerGitHub <noreply@github.com>2019-10-29 08:26:36 +0100
commit94b7cd85c60e106f063cc6df1d3429c7efea8b34 (patch)
treebf920c98a87ce50ca31189ab0aef8d5e2099dfca
parentfb042e90b4dfc1dbbedf7c10fd5f25a207a51066 (diff)
parentb19893ef972dea94a795c5c5af88888597731f0f (diff)
Merge pull request #16832 from ksooo/fix-epg-db-leia
[PVR] Fix and simplify store epg event to db on update from pvr addon.
-rw-r--r--xbmc/addons/PVRClient.cpp22
-rw-r--r--xbmc/addons/PVRClient.h3
-rw-r--r--xbmc/pvr/epg/Epg.cpp4
-rw-r--r--xbmc/pvr/epg/Epg.h3
-rw-r--r--xbmc/pvr/epg/EpgContainer.cpp11
5 files changed, 18 insertions, 25 deletions
diff --git a/xbmc/addons/PVRClient.cpp b/xbmc/addons/PVRClient.cpp
index 2513710a89..f5f337f4ce 100644
--- a/xbmc/addons/PVRClient.cpp
+++ b/xbmc/addons/PVRClient.cpp
@@ -612,11 +612,10 @@ PVR_ERROR CPVRClient::RenameChannel(const CPVRChannelPtr &channel)
PVR_ERROR CPVRClient::GetEPGForChannel(const std::shared_ptr<CPVREpgChannelData>& channelData,
CPVREpg* epg,
- time_t start /* = 0 */,
- time_t end /* = 0 */,
- bool bSaveInDb /* = false */)
+ time_t start,
+ time_t end)
{
- return DoAddonCall(__FUNCTION__, [this, channelData, epg, start, end, bSaveInDb](const AddonInstance* addon) {
+ return DoAddonCall(__FUNCTION__, [this, channelData, epg, start, end](const AddonInstance* addon) {
//! @todo PVR Addon API Change: Change GetEPGForChannel param from 'PVR_CHANNEL channel' to 'int iUniqueId'.
PVR_CHANNEL addonChannel = {0};
@@ -630,10 +629,9 @@ PVR_ERROR CPVRClient::GetEPGForChannel(const std::shared_ptr<CPVREpgChannelData>
strncpy(addonChannel.strIconPath, channelData->IconPath().c_str(), sizeof(addonChannel.strIconPath) - 1);
addonChannel.bIsHidden = channelData->IsHidden();
- ADDON_HANDLE_STRUCT handle;
+ ADDON_HANDLE_STRUCT handle = {0};
handle.callerAddress = this;
handle.dataAddress = epg;
- handle.dataIdentifier = bSaveInDb ? 1 : 0; // used by the callback method CPVRClient::cb_transfer_epg_entry()
int iPVRTimeCorrection = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_iPVRTimeCorrection;
@@ -807,7 +805,7 @@ PVR_ERROR CPVRClient::GetChannelGroupsAmount(int &iGroups)
PVR_ERROR CPVRClient::GetChannelGroups(CPVRChannelGroups *groups)
{
return DoAddonCall(__FUNCTION__, [this, groups](const AddonInstance* addon) {
- ADDON_HANDLE_STRUCT handle;
+ ADDON_HANDLE_STRUCT handle = {0};
handle.callerAddress = this;
handle.dataAddress = groups;
return addon->GetChannelGroups(&handle, groups->IsRadio());
@@ -817,7 +815,7 @@ PVR_ERROR CPVRClient::GetChannelGroups(CPVRChannelGroups *groups)
PVR_ERROR CPVRClient::GetChannelGroupMembers(CPVRChannelGroup *group)
{
return DoAddonCall(__FUNCTION__, [this, group](const AddonInstance* addon) {
- ADDON_HANDLE_STRUCT handle;
+ ADDON_HANDLE_STRUCT handle = {0};
handle.callerAddress = this;
handle.dataAddress = group;
@@ -839,7 +837,7 @@ PVR_ERROR CPVRClient::GetChannelsAmount(int &iChannels)
PVR_ERROR CPVRClient::GetChannels(CPVRChannelGroup &channels, bool radio)
{
return DoAddonCall(__FUNCTION__, [this, &channels, radio](const AddonInstance* addon) {
- ADDON_HANDLE_STRUCT handle;
+ ADDON_HANDLE_STRUCT handle = {0};
handle.callerAddress = this;
handle.dataAddress = &channels;
return addon->GetChannels(&handle, radio);
@@ -858,7 +856,7 @@ PVR_ERROR CPVRClient::GetRecordingsAmount(bool deleted, int &iRecordings)
PVR_ERROR CPVRClient::GetRecordings(CPVRRecordings *results, bool deleted) {
return DoAddonCall(__FUNCTION__, [this, results, deleted](const AddonInstance* addon)
{
- ADDON_HANDLE_STRUCT handle;
+ ADDON_HANDLE_STRUCT handle = {0};
handle.callerAddress = this;
handle.dataAddress = results;
return addon->GetRecordings(&handle, deleted);
@@ -969,7 +967,7 @@ PVR_ERROR CPVRClient::GetTimersAmount(int &iTimers)
PVR_ERROR CPVRClient::GetTimers(CPVRTimersContainer *results)
{
return DoAddonCall(__FUNCTION__, [this, results](const AddonInstance* addon) {
- ADDON_HANDLE_STRUCT handle;
+ ADDON_HANDLE_STRUCT handle = {0};
handle.callerAddress = this;
handle.dataAddress = results;
return addon->GetTimers(&handle);
@@ -1548,7 +1546,7 @@ void CPVRClient::cb_transfer_epg_entry(void *kodiInstance, const ADDON_HANDLE ha
}
/* transfer this entry to the epg */
- kodiEpg->UpdateEntry(epgentry, client->GetID(), handle->dataIdentifier == 1 /* update db */);
+ kodiEpg->UpdateEntry(epgentry, client->GetID());
}
void CPVRClient::cb_transfer_channel_entry(void *kodiInstance, const ADDON_HANDLE handle, const PVR_CHANNEL *channel)
diff --git a/xbmc/addons/PVRClient.h b/xbmc/addons/PVRClient.h
index 604ad2b166..3e7fbe9e6d 100644
--- a/xbmc/addons/PVRClient.h
+++ b/xbmc/addons/PVRClient.h
@@ -405,10 +405,9 @@ namespace PVR
* @param epg The table to write the data to.
* @param start The start time to use.
* @param end The end time to use.
- * @param bSaveInDb If true, tell the callback method to save any new entry in the database or not. see CAddonCallbacksPVR::PVRTransferEpgEntry()
* @return PVR_ERROR_NO_ERROR if the table has been fetched successfully.
*/
- PVR_ERROR GetEPGForChannel(const std::shared_ptr<CPVREpgChannelData>& channelData, CPVREpg* epg, time_t start = 0, time_t end = 0, bool bSaveInDb = false);
+ PVR_ERROR GetEPGForChannel(const std::shared_ptr<CPVREpgChannelData>& channelData, CPVREpg* epg, time_t start, time_t end);
/*!
* Tell the client the time frame to use when notifying epg events back to Kodi. The client might push epg events asynchronously
diff --git a/xbmc/pvr/epg/Epg.cpp b/xbmc/pvr/epg/Epg.cpp
index 860dc3257d..4c2b1fa927 100644
--- a/xbmc/pvr/epg/Epg.cpp
+++ b/xbmc/pvr/epg/Epg.cpp
@@ -327,13 +327,13 @@ bool CPVREpg::UpdateEntries(const CPVREpg &epg, bool bStoreInDb /* = true */)
return true;
}
-bool CPVREpg::UpdateEntry(const EPG_TAG *data, int iClientId, bool bUpdateDatabase)
+bool CPVREpg::UpdateEntry(const EPG_TAG *data, int iClientId)
{
if (!data)
return false;
const std::shared_ptr<CPVREpgInfoTag> tag = std::make_shared<CPVREpgInfoTag>(*data, iClientId, m_channelData, m_iEpgID);
- return UpdateEntry(tag, bUpdateDatabase);
+ return UpdateEntry(tag, !CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_EPG_IGNOREDBFORCLIENT));
}
bool CPVREpg::UpdateEntry(const CPVREpgInfoTagPtr &tag, bool bUpdateDatabase)
diff --git a/xbmc/pvr/epg/Epg.h b/xbmc/pvr/epg/Epg.h
index 84f423f4b5..0006324f08 100644
--- a/xbmc/pvr/epg/Epg.h
+++ b/xbmc/pvr/epg/Epg.h
@@ -159,10 +159,9 @@ namespace PVR
* @brief Update an entry in this EPG.
* @param data The tag to update.
* @param iClientId The id of the pvr client this event belongs to.
- * @param bUpdateDatabase If set to true, this event will be persisted in the database.
* @return True if it was updated successfully, false otherwise.
*/
- bool UpdateEntry(const EPG_TAG *data, int iClientId, bool bUpdateDatabase);
+ bool UpdateEntry(const EPG_TAG *data, int iClientId);
/*!
* @brief Update an entry in this EPG.
diff --git a/xbmc/pvr/epg/EpgContainer.cpp b/xbmc/pvr/epg/EpgContainer.cpp
index 1d4bdc966f..22092616dc 100644
--- a/xbmc/pvr/epg/EpgContainer.cpp
+++ b/xbmc/pvr/epg/EpgContainer.cpp
@@ -68,7 +68,9 @@ private:
void CEpgTagStateChange::Deliver()
{
- const std::shared_ptr<CPVREpg> epg = CServiceBroker::GetPVRManager().EpgContainer().GetByChannelUid(m_epgtag->ClientID(), m_epgtag->UniqueChannelID());
+ CPVREpgContainer& epgContainer = CServiceBroker::GetPVRManager().EpgContainer();
+
+ const std::shared_ptr<CPVREpg> epg = epgContainer.GetByChannelUid(m_epgtag->ClientID(), m_epgtag->UniqueChannelID());
if (!epg)
{
CLog::LogF(LOGERROR, "Unable to obtain EPG for client %d and channel %d! Unable to deliver state change for tag '%d'!",
@@ -83,12 +85,7 @@ void CEpgTagStateChange::Deliver()
m_epgtag->SetChannelData(epg->GetChannelData());
}
- // update
- if (!epg->UpdateEntry(m_epgtag, m_state, false))
- CLog::LogF(LOGWARNING, "State update failed for epgtag (%s | %s | %s | %s | %s)",
- m_state == EPG_EVENT_DELETED ? "DELETED" : m_state == EPG_EVENT_UPDATED ? "UPDTAED" : m_state == EPG_EVENT_CREATED ? "CREATED" : "UNKNOWN",
- epg->GetChannelData()->ChannelName().c_str(), m_epgtag->StartAsLocalTime().GetAsDBDateTime(), m_epgtag->EndAsLocalTime().GetAsDBDateTime(),
- m_epgtag->Title().c_str());
+ epg->UpdateEntry(m_epgtag, m_state, !epgContainer.IgnoreDB());
}
CPVREpgContainer::CPVREpgContainer(void) :