Skip to content
This repository has been archived by the owner on Sep 30, 2018. It is now read-only.

Commit

Permalink
libxbmc: when headless, sleep to emulate ~60fps
Browse files Browse the repository at this point in the history
This keeps cpu low when we don't have a GUI slowing us down.
  • Loading branch information
theuni committed Jun 7, 2012
1 parent b2a4e88 commit 7828296
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions xbmc/XBApplicationEx.cpp
Expand Up @@ -21,6 +21,7 @@
#include "system.h" #include "system.h"
#include "XBApplicationEx.h" #include "XBApplicationEx.h"
#include "utils/log.h" #include "utils/log.h"
#include "threads/SystemClock.h"
#ifdef HAS_PERFORMANCE_SAMPLE #ifdef HAS_PERFORMANCE_SAMPLE
#include "utils/PerformanceSample.h" #include "utils/PerformanceSample.h"
#else #else
Expand Down Expand Up @@ -75,6 +76,9 @@ INT CXBApplicationEx::Run(bool renderGUI)
BYTE processExceptionCount = 0; BYTE processExceptionCount = 0;
BYTE frameMoveExceptionCount = 0; BYTE frameMoveExceptionCount = 0;
BYTE renderExceptionCount = 0; BYTE renderExceptionCount = 0;
unsigned int lastFrameTime = 0;
unsigned int frameTime = 0;
const unsigned int noRenderFrameTime = 15; // Simulates ~66fps


#ifndef _DEBUG #ifndef _DEBUG
const BYTE MAX_EXCEPTION_COUNT = 10; const BYTE MAX_EXCEPTION_COUNT = 10;
Expand All @@ -93,6 +97,7 @@ INT CXBApplicationEx::Run(bool renderGUI)
try try
{ {
#endif #endif
lastFrameTime = XbmcThreads::SystemClockMillis();
Process(); Process();
//reset exception count //reset exception count
processExceptionCount = 0; processExceptionCount = 0;
Expand Down Expand Up @@ -143,6 +148,13 @@ INT CXBApplicationEx::Run(bool renderGUI)
{ {
#endif #endif
if (renderGUI && !m_bStop) Render(); if (renderGUI && !m_bStop) Render();
else if (!renderGUI)
{
frameTime = XbmcThreads::SystemClockMillis() - lastFrameTime;
if(frameTime < noRenderFrameTime)
Sleep(noRenderFrameTime - frameTime);
}

//reset exception count //reset exception count
renderExceptionCount = 0; renderExceptionCount = 0;


Expand Down

0 comments on commit 7828296

Please sign in to comment.