controlapi.cpp: try to fix build errors if member 'time' is not found

Ensure backward compatibility for rc_sync and channelEPGformated

- Added conditional compilation in rc_sync to check for input_event_sec macro.
- Used input_event_sec and input_event_usec macros if defined.
- Provided fallback to direct timeval members for older versions.
- Minor formatting adjustment in channelEPGformated for consistency.

This should ensure compatibility with both newer and older
kernel versions, different C library implementations,
and possible standard settings of build systems.
Addressing different definitions of the input_event structure maintains
robustness across kernel, library, and build system configurations.
This commit is contained in:
2024-07-04 16:08:36 +02:00
parent 637539bdee
commit 11b0b2a2fa

View File

@@ -993,7 +993,18 @@ void CControlAPI::rc_sync(int fd)
{ {
struct input_event ev; struct input_event ev;
gettimeofday(&ev.time, NULL); // Check if input_event_sec macro is defined
#ifdef input_event_sec
// Use input_event_sec and input_event_usec macros if they are defined
struct timeval tv;
gettimeofday(&tv, NULL);
ev.input_event_sec = tv.tv_sec;
ev.input_event_usec = tv.tv_usec;
#else
// Fallback for older versions that use timeval directly
gettimeofday(&ev.time, NULL);
#endif
ev.type = EV_SYN; ev.type = EV_SYN;
ev.code = SYN_REPORT; ev.code = SYN_REPORT;
ev.value = 0; ev.value = 0;
@@ -1795,6 +1806,7 @@ std::string CControlAPI::channelEPGformated(CyhookHandler *hh, int bouquetnr, t_
return result; return result;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Detailed EPG list in XML or JSON // Detailed EPG list in XML or JSON
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------