Skip to content

Commit

Permalink
[PVR] Get rid of magic numbers; use constant PVR_TIMER_NO_EPG_UID ins…
Browse files Browse the repository at this point in the history
…tead. Solve related signed/unsigned problems.
  • Loading branch information
ksooo committed Sep 14, 2015
1 parent 1869562 commit df089eb
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion xbmc/epg/Epg.cpp
Expand Up @@ -260,7 +260,7 @@ CEpgInfoTagPtr CEpg::GetTag(const CDateTime &StartTime) const
return CEpgInfoTagPtr();
}

CEpgInfoTagPtr CEpg::GetTag(int uniqueID) const
CEpgInfoTagPtr CEpg::GetTag(unsigned int uniqueID) const
{
CEpgInfoTagPtr retval;
CSingleLock lock(m_critSection);
Expand Down
2 changes: 1 addition & 1 deletion xbmc/epg/Epg.h
Expand Up @@ -209,7 +209,7 @@ namespace EPG
* @param uniqueID The unique ID of the event to find.
* @return The found tag or an empty tag if it wasn't found.
*/
CEpgInfoTagPtr GetTag(int uniqueID) const;
CEpgInfoTagPtr GetTag(unsigned int uniqueID) const;

/*!
* @brief Update an entry in this EPG.
Expand Down
2 changes: 1 addition & 1 deletion xbmc/epg/EpgContainer.cpp
Expand Up @@ -383,7 +383,7 @@ CEpg *CEpgContainer::GetById(int iEpgId) const
return epgEntry != m_epgs.end() ? epgEntry->second : NULL;
}

CEpgInfoTagPtr CEpgContainer::GetTagById(int iBroadcastId) const
CEpgInfoTagPtr CEpgContainer::GetTagById(unsigned int iBroadcastId) const
{
CEpgInfoTagPtr retval;
CSingleLock lock(m_critSection);
Expand Down
2 changes: 1 addition & 1 deletion xbmc/epg/EpgContainer.h
Expand Up @@ -164,7 +164,7 @@ namespace EPG
* @param iBroadcastId The event id to get
* @return The requested event, or an empty tag when not found
*/
virtual CEpgInfoTagPtr GetTagById(int iBroadcastId) const;
virtual CEpgInfoTagPtr GetTagById(unsigned int iBroadcastId) const;

/*!
* @brief Get an EPG table given a PVR channel.
Expand Down
5 changes: 4 additions & 1 deletion xbmc/epg/EpgDatabase.cpp
Expand Up @@ -227,7 +227,10 @@ int CEpgDatabase::Get(CEpg &epg)
CDateTime firstAired(iFirstAired);
newTag->m_firstAired = firstAired;

newTag->m_iUniqueBroadcastID = m_pDS->fv("iBroadcastUid").get_asInt();
int iBroadcastUID = m_pDS->fv("iBroadcastUid").get_asInt();
// Compat: null value for broadcast uid changed from numerical -1 to 0 with PVR Addon API v4.0.0
newTag->m_iUniqueBroadcastID = iBroadcastUID == -1 ? PVR_TIMER_NO_EPG_UID : iBroadcastUID;

newTag->m_iBroadcastId = m_pDS->fv("idBroadcast").get_asInt();
newTag->m_strTitle = m_pDS->fv("sTitle").get_asString().c_str();
newTag->m_strPlotOutline = m_pDS->fv("sPlotOutline").get_asString().c_str();
Expand Down
10 changes: 5 additions & 5 deletions xbmc/epg/EpgInfoTag.cpp
Expand Up @@ -51,7 +51,7 @@ CEpgInfoTag::CEpgInfoTag(void) :
m_iSeriesNumber(0),
m_iEpisodeNumber(0),
m_iEpisodePart(0),
m_iUniqueBroadcastID(-1),
m_iUniqueBroadcastID(0),
m_iYear(0),
m_epg(NULL)
{
Expand All @@ -67,7 +67,7 @@ CEpgInfoTag::CEpgInfoTag(CEpg *epg, PVR::CPVRChannelPtr pvrChannel, const std::s
m_iSeriesNumber(0),
m_iEpisodeNumber(0),
m_iEpisodePart(0),
m_iUniqueBroadcastID(-1),
m_iUniqueBroadcastID(0),
m_iYear(0),
m_strIconPath(strIconPath),
m_epg(epg),
Expand All @@ -86,7 +86,7 @@ CEpgInfoTag::CEpgInfoTag(const EPG_TAG &data) :
m_iSeriesNumber(0),
m_iEpisodeNumber(0),
m_iEpisodePart(0),
m_iUniqueBroadcastID(-1),
m_iUniqueBroadcastID(0),
m_epg(NULL)
{
m_startTime = (data.startTime + g_advancedSettings.m_iPVRTimeCorrection);
Expand Down Expand Up @@ -289,12 +289,12 @@ CEpgInfoTagPtr CEpgInfoTag::GetPreviousEvent(void) const
return GetTable()->GetPreviousEvent(*this);
}

void CEpgInfoTag::SetUniqueBroadcastID(int iUniqueBroadcastID)
void CEpgInfoTag::SetUniqueBroadcastID(unsigned int iUniqueBroadcastID)
{
m_iUniqueBroadcastID = iUniqueBroadcastID;
}

int CEpgInfoTag::UniqueBroadcastID(void) const
unsigned int CEpgInfoTag::UniqueBroadcastID(void) const
{
return m_iUniqueBroadcastID;
}
Expand Down
6 changes: 3 additions & 3 deletions xbmc/epg/EpgInfoTag.h
Expand Up @@ -143,13 +143,13 @@ namespace EPG
* @brief Change the unique broadcast ID of this event.
* @param iUniqueBroadcastId The new unique broadcast ID.
*/
void SetUniqueBroadcastID(int iUniqueBroadcastID);
void SetUniqueBroadcastID(unsigned int iUniqueBroadcastID);

/*!
* @brief Get the unique broadcast ID.
* @return The unique broadcast ID.
*/
int UniqueBroadcastID(void) const;
unsigned int UniqueBroadcastID(void) const;

/*!
* @brief Get the event's database ID.
Expand Down Expand Up @@ -432,7 +432,7 @@ namespace EPG
int m_iSeriesNumber; /*!< series number */
int m_iEpisodeNumber; /*!< episode number */
int m_iEpisodePart; /*!< episode part number */
int m_iUniqueBroadcastID; /*!< unique broadcast ID */
unsigned int m_iUniqueBroadcastID; /*!< unique broadcast ID */
std::string m_strTitle; /*!< title */
std::string m_strPlotOutline; /*!< plot outline */
std::string m_strPlot; /*!< plot */
Expand Down
2 changes: 1 addition & 1 deletion xbmc/pvr/addons/PVRClient.cpp
Expand Up @@ -313,7 +313,7 @@ void CPVRClient::WriteClientTimerInfo(const CPVRTimerInfoTag &xbmcTimer, PVR_TIM
addonTimer.bStartAnyTime = xbmcTimer.m_bStartAnyTime;
addonTimer.bEndAnyTime = xbmcTimer.m_bEndAnyTime;
addonTimer.firstDay = firstDay - g_advancedSettings.m_iPVRTimeCorrection;
addonTimer.iEpgUid = epgTag ? epgTag->UniqueBroadcastID() : -1;
addonTimer.iEpgUid = epgTag ? epgTag->UniqueBroadcastID() : PVR_TIMER_NO_EPG_UID;
strncpy(addonTimer.strSummary, xbmcTimer.m_strSummary.c_str(), sizeof(addonTimer.strSummary) - 1);
addonTimer.iMarginStart = xbmcTimer.m_iMarginStart;
addonTimer.iMarginEnd = xbmcTimer.m_iMarginEnd;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/pvr/recordings/PVRRecording.cpp
Expand Up @@ -187,7 +187,7 @@ void CPVRRecording::Reset(void)
m_bGotMetaData = false;
m_iRecordingId = 0;
m_bIsDeleted = false;
m_iEpgEventId = -1;
m_iEpgEventId = 0;
m_iSeason = -1;
m_iEpisode = -1;

Expand Down
10 changes: 5 additions & 5 deletions xbmc/pvr/recordings/PVRRecording.h
Expand Up @@ -209,7 +209,7 @@ namespace PVR
/*!
* @return Broadcast id of the EPG event associated with this recording
*/
int EpgEvent(void) const { return m_iEpgEventId; }
unsigned int EpgEvent(void) const { return m_iEpgEventId; }

/*!
* @return Get the channel on which this recording is/was running
Expand All @@ -230,10 +230,10 @@ namespace PVR
std::string EpisodeName(void) const { return m_strShowTitle; };

private:
CDateTime m_recordingTime; /*!< start time of the recording */
bool m_bGotMetaData;
bool m_bIsDeleted; /*!< set if entry is a deleted recording which can be undelete */
int m_iEpgEventId; /*!< epg broadcast id associated with this recording */
CDateTime m_recordingTime; /*!< start time of the recording */
bool m_bGotMetaData;
bool m_bIsDeleted; /*!< set if entry is a deleted recording which can be undelete */
unsigned int m_iEpgEventId; /*!< epg broadcast id associated with this recording */

void UpdatePath(void);
void DisplayError(PVR_ERROR err) const;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/pvr/recordings/PVRRecordings.cpp
Expand Up @@ -513,7 +513,7 @@ void CPVRRecordings::UpdateFromClient(const CPVRRecordingPtr &tag)
void CPVRRecordings::UpdateEpgTags(void)
{
CSingleLock lock(m_critSection);
int iEpgEvent;
unsigned int iEpgEvent;
for (PVR_RECORDINGMAP_ITR it = m_recordings.begin(); it != m_recordings.end(); ++it)
{
iEpgEvent = it->second->EpgEvent();
Expand Down
4 changes: 2 additions & 2 deletions xbmc/pvr/timers/PVRTimerInfoTag.cpp
Expand Up @@ -144,12 +144,12 @@ CPVRTimerInfoTag::CPVRTimerInfoTag(const PVR_TIMER &timer, const CPVRChannelPtr
unsigned int iMustHave = PVR_TIMER_TYPE_ATTRIBUTE_NONE;
unsigned int iMustNotHave = PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES;

if (timer.iEpgUid == 0 && timer.iWeekdays != PVR_WEEKDAY_NONE)
if (timer.iEpgUid == PVR_TIMER_NO_EPG_UID && timer.iWeekdays != PVR_WEEKDAY_NONE)
iMustHave |= PVR_TIMER_TYPE_IS_REPEATING;
else
iMustNotHave |= PVR_TIMER_TYPE_IS_REPEATING;

if (timer.iEpgUid == 0)
if (timer.iEpgUid == PVR_TIMER_NO_EPG_UID)
iMustHave |= PVR_TIMER_TYPE_IS_MANUAL;
else
iMustNotHave |= PVR_TIMER_TYPE_IS_MANUAL;
Expand Down

0 comments on commit df089eb

Please sign in to comment.