mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +02:00
CLastChannel: fix narrowing conversion warnings in lastchannel.cpp
- Changed _LastCh.timestamp to int64_t for compatibility with tv.tv_sec. - Updated store method to cast tv.tv_sec to int64_t, preventing warnings. - Ensured timestamp calculations use int64_t for consistency. This shoold resolve compilation warnings and improve platform independence.
This commit is contained in:
@@ -42,8 +42,8 @@ void CLastChannel::clear (void)
|
|||||||
void CLastChannel::store(t_channel_id channel_id)
|
void CLastChannel::store(t_channel_id channel_id)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
unsigned long lastTimestamp(0);
|
int64_t lastTimestamp(0);
|
||||||
unsigned long timeDiff;
|
int64_t timeDiff;
|
||||||
std::list<_LastCh>::iterator It;
|
std::list<_LastCh>::iterator It;
|
||||||
|
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
@@ -53,21 +53,22 @@ void CLastChannel::store (t_channel_id channel_id)
|
|||||||
|
|
||||||
timeDiff = tv.tv_sec - lastTimestamp;
|
timeDiff = tv.tv_sec - lastTimestamp;
|
||||||
|
|
||||||
/* prev zap time was less than treshhold, remove prev channel */
|
/* prev zap time was less than threshold, remove prev channel */
|
||||||
if (!this->lastChannels.empty() && (timeDiff <= secs_diff_before_store))
|
if (!this->lastChannels.empty() && (timeDiff <= secs_diff_before_store))
|
||||||
this->lastChannels.pop_front();
|
this->lastChannels.pop_front();
|
||||||
|
|
||||||
/* push new channel to the head */
|
/* push new channel to the head */
|
||||||
_LastCh newChannel = {/*channel,*/ channel_id, tv.tv_sec, CNeutrinoApp::getInstance()->GetChannelMode()};
|
_LastCh newChannel = {/*channel,*/ channel_id, static_cast<int64_t>(tv.tv_sec), CNeutrinoApp::getInstance()->GetChannelMode()};
|
||||||
|
|
||||||
this->lastChannels.push_front(newChannel);
|
this->lastChannels.push_front(newChannel);
|
||||||
|
|
||||||
/* this zap time was more than treshhold, it will stay, remove last in the list */
|
/* this zap time was more than threshold, it will stay, remove last in the list */
|
||||||
if ((timeDiff > secs_diff_before_store) && (this->lastChannels.size() > this->maxSize))
|
if ((timeDiff > secs_diff_before_store) && (this->lastChannels.size() > this->maxSize))
|
||||||
this->lastChannels.pop_back();
|
this->lastChannels.pop_back();
|
||||||
|
|
||||||
/* remove this channel at other than 0 position */
|
/* remove this channel at other than 0 position */
|
||||||
if(this->lastChannels.size() > 1) {
|
if (this->lastChannels.size() > 1)
|
||||||
|
{
|
||||||
It = this->lastChannels.begin();
|
It = this->lastChannels.begin();
|
||||||
++It;
|
++It;
|
||||||
for (; It != this->lastChannels.end(); ++It)
|
for (; It != this->lastChannels.end(); ++It)
|
||||||
|
@@ -27,12 +27,11 @@ nicht gespeichert werden.
|
|||||||
|
|
||||||
class CLastChannel
|
class CLastChannel
|
||||||
{
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct _LastCh
|
struct _LastCh
|
||||||
{
|
{
|
||||||
t_channel_id channel_id;
|
t_channel_id channel_id;
|
||||||
long int timestamp;
|
int64_t timestamp;
|
||||||
int channel_mode;
|
int channel_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user