mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +02:00
try to fix shutdown after wakeup, if several recordings was done,
cancel shutdown after wakeup, if remote used, based on code (c) martii <m4rtii@gmx.de>
This commit is contained in:
@@ -52,6 +52,7 @@
|
|||||||
#include <global.h>
|
#include <global.h>
|
||||||
#include <driver/shutdown_count.h>
|
#include <driver/shutdown_count.h>
|
||||||
#include <neutrino.h>
|
#include <neutrino.h>
|
||||||
|
#include <timerd/timermanager.h>
|
||||||
#include <cs_api.h>
|
#include <cs_api.h>
|
||||||
|
|
||||||
//#define RCDEBUG
|
//#define RCDEBUG
|
||||||
@@ -136,6 +137,7 @@ CRCInput::CRCInput()
|
|||||||
repeat_block = repeat_block_generic = 0;
|
repeat_block = repeat_block_generic = 0;
|
||||||
open();
|
open();
|
||||||
rc_last_key = KEY_MAX;
|
rc_last_key = KEY_MAX;
|
||||||
|
firstKey = true;
|
||||||
|
|
||||||
//select and setup remote control hardware
|
//select and setup remote control hardware
|
||||||
set_rc_hw();
|
set_rc_hw();
|
||||||
@@ -1194,6 +1196,10 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6
|
|||||||
if(ret != sizeof(t_input_event))
|
if(ret != sizeof(t_input_event))
|
||||||
continue;
|
continue;
|
||||||
SHTDCNT::getInstance()->resetSleepTimer();
|
SHTDCNT::getInstance()->resetSleepTimer();
|
||||||
|
if (firstKey) {
|
||||||
|
firstKey = false;
|
||||||
|
CTimerManager::getInstance()->cancelShutdownOnWakeup();
|
||||||
|
}
|
||||||
uint32_t trkey = translate(ev.code, i);
|
uint32_t trkey = translate(ev.code, i);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("key: %04x value %d, translate: %04x -%s-\n", ev.code, ev.value, trkey, getKeyName(trkey).c_str());
|
printf("key: %04x value %d, translate: %04x -%s-\n", ev.code, ev.value, trkey, getKeyName(trkey).c_str());
|
||||||
|
@@ -151,6 +151,7 @@ class CRCInput
|
|||||||
|
|
||||||
int fd_max;
|
int fd_max;
|
||||||
int clickfd;
|
int clickfd;
|
||||||
|
bool firstKey;
|
||||||
__u16 rc_last_key;
|
__u16 rc_last_key;
|
||||||
void set_dsp();
|
void set_dsp();
|
||||||
|
|
||||||
|
@@ -727,11 +727,12 @@ bool CTimerManager::shutdown()
|
|||||||
void CTimerManager::shutdownOnWakeup(int currEventID)
|
void CTimerManager::shutdownOnWakeup(int currEventID)
|
||||||
{
|
{
|
||||||
time_t nextAnnounceTime=0;
|
time_t nextAnnounceTime=0;
|
||||||
if(wakeup == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
wakeup = 0;
|
|
||||||
pthread_mutex_lock(&tm_eventsMutex);
|
pthread_mutex_lock(&tm_eventsMutex);
|
||||||
|
if(wakeup == 0) {
|
||||||
|
pthread_mutex_unlock(&tm_eventsMutex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CTimerEventMap::iterator pos = events.begin();
|
CTimerEventMap::iterator pos = events.begin();
|
||||||
for(;pos != events.end();++pos)
|
for(;pos != events.end();++pos)
|
||||||
@@ -756,10 +757,23 @@ void CTimerManager::shutdownOnWakeup(int currEventID)
|
|||||||
{ // in den naechsten 10 min steht nix an
|
{ // in den naechsten 10 min steht nix an
|
||||||
dprintf("Programming shutdown event\n");
|
dprintf("Programming shutdown event\n");
|
||||||
CTimerEvent_Shutdown* event = new CTimerEvent_Shutdown(now+120, now+180);
|
CTimerEvent_Shutdown* event = new CTimerEvent_Shutdown(now+120, now+180);
|
||||||
addEvent(event);
|
shutdown_eventID = addEvent(event);
|
||||||
|
wakeup = 0;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&tm_eventsMutex);
|
pthread_mutex_unlock(&tm_eventsMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CTimerManager::cancelShutdownOnWakeup()
|
||||||
|
{
|
||||||
|
pthread_mutex_lock(&tm_eventsMutex);
|
||||||
|
if (shutdown_eventID > -1) {
|
||||||
|
removeEvent(shutdown_eventID);
|
||||||
|
shutdown_eventID = -1;
|
||||||
|
}
|
||||||
|
wakeup = 0;
|
||||||
|
pthread_mutex_unlock(&tm_eventsMutex);
|
||||||
|
}
|
||||||
|
|
||||||
void CTimerManager::setRecordingSafety(int pre, int post)
|
void CTimerManager::setRecordingSafety(int pre, int post)
|
||||||
{
|
{
|
||||||
m_extraTimeStart=pre;
|
m_extraTimeStart=pre;
|
||||||
|
@@ -212,6 +212,7 @@ class CTimerManager
|
|||||||
private:
|
private:
|
||||||
void Init(void);
|
void Init(void);
|
||||||
int eventID;
|
int eventID;
|
||||||
|
int shutdown_eventID;
|
||||||
CEventServer *eventServer;
|
CEventServer *eventServer;
|
||||||
CTimerEventMap events;
|
CTimerEventMap events;
|
||||||
pthread_t thrTimer;
|
pthread_t thrTimer;
|
||||||
@@ -247,6 +248,7 @@ public:
|
|||||||
void getRecordingSafety(int &pre, int &post){pre=m_extraTimeStart;post=m_extraTimeEnd;}
|
void getRecordingSafety(int &pre, int &post){pre=m_extraTimeStart;post=m_extraTimeEnd;}
|
||||||
void setRecordingSafety(int pre, int post);
|
void setRecordingSafety(int pre, int post);
|
||||||
void loadRecordingSafety();
|
void loadRecordingSafety();
|
||||||
|
void cancelShutdownOnWakeup();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user