// FIXME rename to Control and move stuff from main to here
+#ifndef WIN32
+#include <unistd.h> // for reboot
+#include <linux/reboot.h>
+#include <sys/reboot.h>
+#endif
-#include "control.h"
+#include <time.h>
#ifdef WIN32
#include "inputwin.h"
#include "wjpeg.h"
#include "osdvector.h"
+#include "control.h"
Control* Control::instance = NULL;
initted = true;
crashed = tcrashed;
+
+ SkinFactory::InitSkin(0);
+
+
logger = Log::getInstance();
- boxstack = BoxStack::getInstance();
+
+
+ bool success;
+ boxstack = new BoxStack();
+
+ success = boxstack->init();
+ if (success)
+ {
+ logger->log("Core", Log::INFO, "BoxStack module initialised");
+ }
+ else
+ {
+ logger->log("Core", Log::EMERG, "BoxStack module failed to initialise");
+ shutdown();
+ }
+
+
+
+
inputMan = InputMan::getInstance();
if (!logger || !boxstack || !inputMan)
return 0;
}
- SkinFactory::InitSkin(0);
+
+
return 1;
}
int Control::shutdown()
{
+ if (boxstack)
+ {
+ boxstack->shutdown();
+ delete boxstack;
+ boxstack = NULL;
+ logger->log("Core", Log::NOTICE, "BoxStack module shut down");
+ }
+
if (!initted) return 0;
initted = false;
return 1;
#ifndef COMMAND_H
#define COMMAND_H
-#ifndef WIN32
-#include <unistd.h> // for reboot
-#include <linux/reboot.h>
-#include <sys/reboot.h>
-#endif
-
-#include <time.h>
-#ifndef WIN32
-#include <pthread.h> // why?
-#endif
-
#include <string>
#include <vector>
ASLPrefList &getASLList() { return langcodes; };
private:
+ // I own:
+ BoxStack* boxstack{};
+
+
+
void handleCommand(int);
void doStandby();
void doPowerOn();
static Control* instance;
Log* logger;
- BoxStack* boxstack;
InputMan* inputMan;
bool initted{};
along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
+// FIXME
+// Work towards main and winmain only containing what they need for their own platforms
+// Move anything common to utils or control. Move any module startup / shutdown that can
+// be done in control to there.
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "log.h"
#include "timers.h"
#include "vdr.h"
-#include "boxstack.h"
#include "control.h"
#include "inputman.h"
#include "wol.h"
Led* led;
Osd* osd;
Timers* timers;
-BoxStack* boxstack;
Control* control;
VDR* vdr;
Video* video;
audio = new Audio_TYPE();
video = new Video_TYPE();
- boxstack = new BoxStack();
control = new Control();
wol = new Wol();
sleeptimer = new Sleeptimer();
- if (!logger || !timers || !inputMan || !led || !osd || !video || !audio || !boxstack || !control || !wol || !sleeptimer)
+ if (!logger || !timers || !inputMan || !led || !osd || !video || !audio || !control || !wol || !sleeptimer)
{
printf("Could not create objects. Memory problems?\n");
shutdown(1);
shutdown(1);
}
- success = boxstack->init();
- if (success)
- {
- logger->log("Core", Log::INFO, "BoxStack module initialised");
- }
- else
- {
- logger->log("Core", Log::EMERG, "BoxStack module failed to initialise");
- shutdown(1);
- }
+
+
+
success = control->init(crashed);
if (success)
control->run();
// When that returns quit ------------------------------------------------------------------------------------------
+
+ control->shutdown();
+
shutdown(0);
return 0;
}
void shutdown(int code)
{
- if (boxstack)
- {
- boxstack->shutdown();
- delete boxstack;
- logger->log("Core", Log::NOTICE, "BoxStack module shut down");
- }
-
// FIXME, send a del all to boxstack first, then get rid of it after control?
if (control) // shut down control here in case views have posted messages
{
- control->shutdown();
delete control;
control = NULL;
logger->log("Core", Log::NOTICE, "Control module shut down");
#else
#include "osdwinvector.h"
#endif
-#include "boxstack.h"
#include "control.h"
#include "wol.h"
#include "vsleeptimer.h"
Led* led;
Osd* osd;
Timers* timers;
-BoxStack* boxstack;
Control* control;
VDR* vdr;
Video* video;
DWORD WINAPI controlthreadStart(void *arg)
{
control->run();
+ control->shutdown();
return 0;
}
vdr = new VDR();
video = new VideoWin();
audio = new AudioWin();
- boxstack = new BoxStack();
control = new Control();
wol = new Wol();
sleeptimer = new Sleeptimer();
- if (!logger || !remote || !led || !osd || !video || !audio || !boxstack || !control || !sleeptimer)
+ if (!logger || !remote || !led || !osd || !video || !audio || !control || !sleeptimer)
{
ERROR_MSG("Could not create objects. Memory problems?\n");
shutdown(1);
return 0;
}
- success = boxstack->init();
- if (success)
- {
- logger->log("Core", Log::INFO, "BoxStack module initialised");
- }
- else
- {
- logger->log("Core", Log::EMERG, "BoxStack module failed to initialise");
- shutdown(1);
- WSACleanup();
- return 0;
- }
-
success = control->init();
if (success)
{
void shutdown(int code)
{
- if (boxstack)
- {
- boxstack->shutdown();
- delete boxstack;
- logger->log("Core", Log::NOTICE, "BoxStack module shut down");
- }
-
if (control) // shut down control here in case views have posted messages
{
control->shutdown();