From 04b17df166e9682ca52e4d38f07e8214801a2c4a Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 26 Mar 2006 16:40:50 +0000 Subject: [PATCH] Portability --- Makefile | 3 ++- led.cc | 38 ----------------------------- led.h | 19 +++++---------- ledmvp.cc | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ ledmvp.h | 47 ++++++++++++++++++++++++++++++++++++ ledwin.cc | 57 ++++++++++++++++++++++++++++++++++++++++++++ ledwin.h | 44 ++++++++++++++++++++++++++++++++++ main.cc | 26 ++++++++++---------- surfacemvp.cc | 3 +-- surfacewin.cc | 1 + 10 files changed, 238 insertions(+), 66 deletions(-) create mode 100644 ledmvp.cc create mode 100644 ledmvp.h create mode 100644 ledwin.cc create mode 100644 ledwin.h diff --git a/Makefile b/Makefile index c4e1414..6ddb8ed 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,8 @@ OBJECTS2 = remote.o led.o mtd.o video.o audio.o osd.o surface.o audiomvp.o audiowin.o \ videomvp.o videowin.o \ osdmvp.o osdwin.o \ - surfacemvp.o surfacewin.o + surfacemvp.o surfacewin.o \ + ledmvp.o ledwin.o OBJECTS = $(OBJECTS1) $(OBJECTS2) diff --git a/led.cc b/led.cc index 041b36e..bfa8e9f 100644 --- a/led.cc +++ b/led.cc @@ -26,8 +26,6 @@ Led::Led() { if (instance) return; instance = this; - initted = 0; - device = 0; } Led::~Led() @@ -39,39 +37,3 @@ Led* Led::getInstance() { return instance; } - -int Led::init(int tdevice) -{ - if (initted) return 0; - initted = 1; - device = tdevice; - return 1; -} - -int Led::shutdown() -{ - if (!initted) return 0; - initted = 0; - device = 0; - return 1; -} - -int Led::on() -{ - if (!initted) return 0; - - int result = ioctl(device, IR_SET_LED, 0); - Log::getInstance()->log("LED", Log::DEBUG, "led on %i %i", device, result); - if (result >= 0) return 1; - else return 0; -} - -int Led::off() -{ - if (!initted) return 0; - - int result = ioctl(device, IR_SET_LED, 1); - Log::getInstance()->log("LED", Log::DEBUG, "led off %i %i", device, result); - if (result >= 0) return 1; - else return 0; -} diff --git a/led.h b/led.h index 67cf380..2249a4c 100644 --- a/led.h +++ b/led.h @@ -22,29 +22,22 @@ #define LED_H #include -#include - -#include "stb.h" - -#include "log.h" // temp while fix led on bug! class Led { public: Led(); - ~Led(); + virtual ~Led(); static Led* getInstance(); - int init(int device); - int shutdown(); + virtual int init(int device)=0; + virtual int shutdown()=0; - int on(); - int off(); + virtual int on()=0; + virtual int off()=0; - private: + protected: static Led* instance; - int initted; - int device; }; #endif diff --git a/ledmvp.cc b/ledmvp.cc new file mode 100644 index 0000000..1b79873 --- /dev/null +++ b/ledmvp.cc @@ -0,0 +1,66 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "ledmvp.h" + +LedMVP::LedMVP() +{ + if (instance) return; + initted = 0; + device = 0; +} + +LedMVP::~LedMVP() +{ +} + +int LedMVP::init(int tdevice) +{ + if (initted) return 0; + initted = 1; + device = tdevice; + return 1; +} + +int LedMVP::shutdown() +{ + if (!initted) return 0; + initted = 0; + device = 0; + return 1; +} + +int LedMVP::on() +{ + if (!initted) return 0; + + int result = ioctl(device, IR_SET_LED, 0); + if (result >= 0) return 1; + else return 0; +} + +int LedMVP::off() +{ + if (!initted) return 0; + + int result = ioctl(device, IR_SET_LED, 1); + if (result >= 0) return 1; + else return 0; +} diff --git a/ledmvp.h b/ledmvp.h new file mode 100644 index 0000000..a59400f --- /dev/null +++ b/ledmvp.h @@ -0,0 +1,47 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef LEDMVP_H +#define LEDMVP_H + +#include +#include + +#include "led.h" +#include "stb.h" + +class LedMVP : public Led +{ + public: + LedMVP(); + ~LedMVP(); + + int init(int device); + int shutdown(); + + int on(); + int off(); + + private: + int initted; + int device; +}; + +#endif diff --git a/ledwin.cc b/ledwin.cc new file mode 100644 index 0000000..5968ca9 --- /dev/null +++ b/ledwin.cc @@ -0,0 +1,57 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "ledwin.h" + +LedWin::LedWin() +{ + if (instance) return; + initted = 0; +} + +LedWin::~LedWin() +{ +} + +int LedWin::init(int tdevice) +{ + if (initted) return 0; + initted = 1; + return 1; +} + +int LedWin::shutdown() +{ + if (!initted) return 0; + initted = 0; + return 1; +} + +int LedWin::on() +{ + if (!initted) return 0; + return 0; +} + +int LedWin::off() +{ + if (!initted) return 0; + return 0; +} diff --git a/ledwin.h b/ledwin.h new file mode 100644 index 0000000..f879f62 --- /dev/null +++ b/ledwin.h @@ -0,0 +1,44 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef LEDWIN_H +#define LEDWIN_H + +#include + +#include "led.h" + +class LedWin : public Led +{ + public: + LedWin(); + ~LedWin(); + + int init(int device); + int shutdown(); + + int on(); + int off(); + + private: + int initted; +}; + +#endif diff --git a/main.cc b/main.cc index 70259b3..01943fd 100644 --- a/main.cc +++ b/main.cc @@ -28,21 +28,22 @@ #include "defines.h" #include "log.h" #include "remote.h" -#include "led.h" #include "mtd.h" #include "timers.h" #include "vdr.h" #include "viewman.h" #include "command.h" -#ifndef WIN32 - #include "osdmvp.h" - #include "audiomvp.h" - #include "videomvp.h" -#else +#ifdef WIN32 + #include "ledwin.h" #include "osdwin.h" #include "audiowin.h" #include "videowin.h" +#else + #include "ledmvp.h" + #include "osdmvp.h" + #include "audiomvp.h" + #include "videomvp.h" #endif void sighandler(int signalReceived); @@ -72,17 +73,18 @@ int main(int argc, char** argv) logger = new Log(); remote = new Remote(); mtd = new Mtd(); - led = new Led(); timers = new Timers(); vdr = new VDR(); -#ifndef WIN32 - osd = new OsdMVP(); - audio = new AudioMVP(); - video = new VideoMVP(); -#else +#ifdef WIN32 + led = new LedWin(); osd = new OsdWin(); audio = new AudioWin(); video = new VideoWin(); +#else + led = new LedMVP(); + osd = new OsdMVP(); + audio = new AudioMVP(); + video = new VideoMVP(); #endif viewman = new ViewMan(); command = new Command(); diff --git a/surfacemvp.cc b/surfacemvp.cc index 66626c0..4fe3bcc 100644 --- a/surfacemvp.cc +++ b/surfacemvp.cc @@ -23,9 +23,8 @@ #include "osd.h" SurfaceMVP::SurfaceMVP(int id) +: Surface(id) { - if (id == SCREEN) screen = this; - fdOsd = Osd::getInstance()->getFD(); memset(&surface, 0, sizeof(osd_surface_t)); memset(&surface.sfc, 0, sizeof(stbgfx_sfc_t)); diff --git a/surfacewin.cc b/surfacewin.cc index d17eb24..34034d5 100644 --- a/surfacewin.cc +++ b/surfacewin.cc @@ -23,6 +23,7 @@ #include "osd.h" SurfaceWin::SurfaceWin(int id) +: Surface(id) { } -- 2.39.5