aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlwin Esch <alwin.esch@web.de>2022-09-04 10:57:57 +0200
committerAlwin Esch <alwin.esch@web.de>2022-09-04 10:57:57 +0200
commit4d4be8b4016b3e533acf2a529672a3535ab9fe67 (patch)
treeab6f69e63978357f374393594201a9536149d4aa
parenteab635c8c1faaf53b5c6d1e54f0ec20fc469a9f3 (diff)
[pvr] not use instance id to get client id inside first running one
As background to allow backward compatibility about database, becomes with this change the add of instance id to create pvr client id not used. This allows to use already defined values of older add-ons inside an new one.
-rw-r--r--xbmc/pvr/addons/PVRClients.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp
index 127207c751..121bd1df02 100644
--- a/xbmc/pvr/addons/PVRClients.cpp
+++ b/xbmc/pvr/addons/PVRClients.cpp
@@ -33,11 +33,15 @@ using namespace PVR;
namespace
{
-int ClientIdFromAddonId(const std::string& addonID, ADDON::AddonInstanceId instance)
+int ClientIdFromAddonIdAndInstanceId(const std::string& addonID, ADDON::AddonInstanceId instanceID)
{
std::hash<std::string> hasher;
- int iClientId =
- static_cast<int>(hasher((instance > 0 ? std::to_string(instance) + "@" : "") + addonID));
+
+ // Note: For database backwards compatibility reasons the hash of the first instance
+ // must be calculated just from the addonId, not from addonId and instanceId.
+ int iClientId = static_cast<int>(
+ hasher((instanceID > ADDON::ADDON_FIRST_INSTANCE_ID ? std::to_string(instanceID) + "@" : "") +
+ addonID));
if (iClientId < 0)
iClientId = -iClientId;
return iClientId;
@@ -145,7 +149,7 @@ void CPVRClients::UpdateAddons(const std::string& changedAddonId /*= ""*/,
if (instanceEnabled &&
(!IsKnownClient(addon->ID(), instanceId) || !IsCreatedClient(addon->ID(), instanceId)))
{
- int iClientId = ClientIdFromAddonId(addon->ID(), instanceId);
+ int iClientId = ClientIdFromAddonIdAndInstanceId(addon->ID(), instanceId);
std::shared_ptr<CPVRClient> client;
if (IsKnownClient(addon->ID(), instanceId))
@@ -438,7 +442,8 @@ std::vector<CVariant> CPVRClients::GetClientProviderInfos() const
if (IsKnownClient(addonInfo->ID(), instanceId))
clientProviderInfo["clientid"] = GetClientId(addonInfo->ID(), instanceId);
else
- clientProviderInfo["clientid"] = ClientIdFromAddonId(addonInfo->ID(), instanceId);
+ clientProviderInfo["clientid"] =
+ ClientIdFromAddonIdAndInstanceId(addonInfo->ID(), instanceId);
clientProviderInfo["addonid"] = addonInfo->ID();
clientProviderInfo["instanceid"] = instanceId;
clientProviderInfo["enabled"] =
@@ -478,7 +483,7 @@ PVR_ERROR CPVRClients::GetCallableClients(CPVRClientMap& clientsReady,
std::vector<ADDON::AddonInstanceId> instanceIds = addon->GetKnownInstanceIds();
for (const auto& instanceId : instanceIds)
{
- int iClientId = ClientIdFromAddonId(addon->ID(), instanceId);
+ int iClientId = ClientIdFromAddonIdAndInstanceId(addon->ID(), instanceId);
std::shared_ptr<CPVRClient> client;
GetClient(iClientId, client);