Prevent system from going into Standby or Hibernation while an encode is running.
This commit is contained in:
parent
1f0cd5add0
commit
581ea2563c
@ -1709,6 +1709,23 @@ bool x264_shutdown_computer(const QString &message, const unsigned long timeout,
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Inform the system that it is in use, thereby preventing the system from entering sleep
|
||||
*/
|
||||
bool x264_set_thread_execution_state(const bool systemRequired)
|
||||
{
|
||||
EXECUTION_STATE state = NULL;
|
||||
if(systemRequired)
|
||||
{
|
||||
state = SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED);
|
||||
}
|
||||
else
|
||||
{
|
||||
state = SetThreadExecutionState(ES_CONTINUOUS);
|
||||
}
|
||||
return (state != NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for debugger (detect routine)
|
||||
*/
|
||||
|
@ -121,6 +121,7 @@ bool x264_play_sound(const unsigned short uiSoundIdx, const bool bAsync, const w
|
||||
bool x264_portable(void);
|
||||
unsigned int x264_process_id(void);
|
||||
QString x264_query_reg_string(const bool bUser, const QString &path, const QString &name);
|
||||
bool x264_set_thread_execution_state(const bool systemRequired);
|
||||
bool x264_shutdown_computer(const QString &message, const unsigned long timeout, const bool forceShutdown);
|
||||
void x264_sleep(const unsigned int delay);
|
||||
bool x264_suspendProcess(const QProcess *proc, const bool suspend);
|
||||
|
@ -42,6 +42,30 @@
|
||||
*/
|
||||
QMutex EncodeThread::m_mutex_startProcess;
|
||||
|
||||
/*
|
||||
* RAII execution state handler
|
||||
*/
|
||||
static class ExecutionStateHandler
|
||||
{
|
||||
public:
|
||||
ExecutionStateHandler(void)
|
||||
{
|
||||
x264_set_thread_execution_state(true);
|
||||
}
|
||||
~ExecutionStateHandler(void)
|
||||
{
|
||||
x264_set_thread_execution_state(false);
|
||||
}
|
||||
private:
|
||||
//Disable copy constructor and assignment
|
||||
ExecutionStateHandler(const ExecutionStateHandler &other) {}
|
||||
ExecutionStateHandler &operator=(const ExecutionStateHandler &) {}
|
||||
|
||||
//Prevent object allocation on the heap
|
||||
void *operator new(size_t); void *operator new[](size_t);
|
||||
void operator delete(void *); void operator delete[](void*);
|
||||
};
|
||||
|
||||
/*
|
||||
* Macros
|
||||
*/
|
||||
@ -169,6 +193,7 @@ void EncodeThread::checkedRun(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
ExecutionStateHandler executionStateHandler;
|
||||
encode();
|
||||
}
|
||||
catch(char *msg)
|
||||
|
@ -26,7 +26,7 @@
|
||||
#define VER_X264_MAJOR 2
|
||||
#define VER_X264_MINOR 2
|
||||
#define VER_X264_PATCH 5
|
||||
#define VER_X264_BUILD 623
|
||||
#define VER_X264_BUILD 625
|
||||
|
||||
#define VER_X264_MINIMUM_REV 2363
|
||||
#define VER_X264_CURRENT_API 140
|
||||
|
Loading…
Reference in New Issue
Block a user