Skip to content

Commit

Permalink
switch channels
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Ehrnsperger committed Jan 27, 2024
1 parent 1e5c9f0 commit 0ff1ded
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 32 deletions.
8 changes: 8 additions & 0 deletions pages/ibox.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,18 @@ TimerConflictNotifier timerNotifier();
cChannel* Channel = (cChannel *)Channels->GetByNumber(cDevice::CurrentChannel());

cChannel* tmp = (cChannel *)Channels->GetByNumber(Channels->GetPrevNormal(cDevice::CurrentChannel()), -SKIP_GAP);
#if VDRVERSNUM >= 20606
if (tmp)
#else
if (tmp && cDevice::PrimaryDevice() && cDevice::PrimaryDevice()->HasDecoder() )
#endif
prev_chan = tmp->GetChannelID();
tmp = (cChannel *)Channels->GetByNumber(Channels->GetNextNormal(cDevice::CurrentChannel()), SKIP_GAP);
#if VDRVERSNUM >= 20606
if (tmp)
#else
if (tmp && cDevice::PrimaryDevice() && cDevice::PrimaryDevice()->HasDecoder() )
#endif
next_chan = tmp->GetChannelID();

const std::string chanName(Channel->Name());
Expand Down
22 changes: 0 additions & 22 deletions recman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,28 +428,6 @@ template void StringAppendFrameParams<cToSvConcat<255>>(cToSvConcat<255> &s, con
return first->scraperReleaseDate() < second->scraperReleaseDate();
}

/*
int RecordingsItemPtrCompare::compareLC(const char *first, const char *second, int *numEqualChars) {
// if numEqualChars != NULL: Add the number of equal characters to *numEqualChars
bool fe = !first || !first[0]; // is first string empty string?
bool se = !second || !second[0]; // is second string empty string?
if (fe && se) return 0;
if (se) return 1;
if (fe) return -1;
// compare strings case-insensitive
for(; *first && *second; ) {
wint_t flc = std::tolower<wchar_t>(getNextUtfCodepoint(first), g_locale);
wint_t slc = std::tolower<wchar_t>(getNextUtfCodepoint(second), g_locale);
if ( flc < slc ) return -1;
if ( flc > slc ) return 1;
if (numEqualChars) (*numEqualChars)++;
}
if (*second ) return -1;
if (*first ) return 1;
return 0;
}
*/

tCompRec RecordingsItemPtrCompare::getComp(eSortOrder sortOrder) {
switch (sortOrder) {
case eSortOrder::name: return &RecordingsItemPtrCompare::ByAscendingNameDescSort;
Expand Down
1 change: 0 additions & 1 deletion recman.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ template<typename T>
static bool ByAscendingNameSort(const RecordingsItemDirPtr & first, const RecordingsItemDirPtr & second);
static bool BySeason(const RecordingsItemDirPtr & first, const RecordingsItemDirPtr & second);
// helpers
// static int compareLC(const char *first, const char *second, int *numEqualChars = NULL); // as std::compare, but compare lower case
static int FindBestMatch(RecordingsItemRecPtr &BestMatch, const std::vector<RecordingsItemRecPtr>::const_iterator & First, const std::vector<RecordingsItemRecPtr>::const_iterator & Last, const RecordingsItemRecPtr & EPG_Entry);

static tCompRec getComp(eSortOrder sortOrder);
Expand Down
16 changes: 16 additions & 0 deletions stringhelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class cSv: public std::string_view {
public:
utf8_iterator utf8_begin() const;
utf8_iterator utf8_end() const;
int compareLowerCase(cSv other, const std::locale &loc);
};

// iterator for utf8
Expand Down Expand Up @@ -180,6 +181,21 @@ class utf8_iterator {
inline utf8_iterator cSv::utf8_begin() const { return utf8_iterator(*this, 0); }
inline utf8_iterator cSv::utf8_end() const { return utf8_iterator(*this, length() ); }

inline int cSv::compareLowerCase(cSv other, const std::locale &loc) {
// compare strings case-insensitive
utf8_iterator ls = utf8_begin();
utf8_iterator rs = other.utf8_begin();
for (; ls != utf8_end() && rs != other.utf8_end(); ++ls, ++rs) {
wint_t llc = std::tolower<wchar_t>(*ls, loc);
wint_t rlc = std::tolower<wchar_t>(*rs, loc);
if ( llc < rlc ) return -1;
if ( llc > rlc ) return 1;
}
if (rs != other.utf8_end() ) return -1;
if (ls != utf8_end() ) return 1;
return 0;
}


// =========================================================
// cStr: similar to cSv, but support c_str()
Expand Down
9 changes: 0 additions & 9 deletions tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,14 @@ StickyTask::~StickyTask()

void SwitchChannelTask::Action()
{
#if VDRVERSNUM >= 20301
LOCK_CHANNELS_READ;
cChannel* channel = (cChannel *)Channels->GetByChannelID( m_channel );
#else
ReadLock lock( Channels );
cChannel* channel = Channels.GetByChannelID( m_channel );
#endif
if ( channel == 0 ) {
SetError( tr("Couldn't find channel or no channels available.") );
return;
}

#if VDRVERSNUM >= 20301
if ( !Channels->SwitchTo( channel->Number() ) )
#else
if ( !Channels.SwitchTo( channel->Number() ) )
#endif
SetError( tr("Couldn't switch to channel.") );
}

Expand Down

0 comments on commit 0ff1ded

Please sign in to comment.