]> git.vomp.tv Git - vompclient.git/commitdiff
Portability
authorChris Tallon <chris@vomp.tv>
Sun, 26 Mar 2006 16:40:50 +0000 (16:40 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 26 Mar 2006 16:40:50 +0000 (16:40 +0000)
Makefile
led.cc
led.h
ledmvp.cc [new file with mode: 0644]
ledmvp.h [new file with mode: 0644]
ledwin.cc [new file with mode: 0644]
ledwin.h [new file with mode: 0644]
main.cc
surfacemvp.cc
surfacewin.cc

index c4e14149b92a0b6e68671d2999a7301098256398..6ddb8ed00fd4629acf135c44e36cf3c9038b26b6 100644 (file)
--- 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 041b36e11259a144850e3de9b652b686e06051f1..bfa8e9f47ae04a39cc873db4638c0e8e9f091492 100644 (file)
--- 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 67cf380f923ce760282e61012936e3b96dfd1c35..2249a4c335f37e0e4693d1e67049a952aaafac0c 100644 (file)
--- a/led.h
+++ b/led.h
 #define LED_H
 
 #include <stdio.h>
-#include <sys/ioctl.h>
-
-#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 (file)
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 (file)
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 <stdio.h>
+#include <sys/ioctl.h>
+
+#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 (file)
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 (file)
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 <stdio.h>
+
+#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 70259b33e644ae98429cb6f8e8a6259be3f38650..01943fd90d6e3f2da9131a631910b2e79af2bf7b 100644 (file)
--- a/main.cc
+++ b/main.cc
 #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();
index 66626c0b5e0964f45a2c531edd56c5bed74f7a6f..4fe3bccba7a327ebd9bdd054f2af53e8c388f874 100644 (file)
@@ -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));
index d17eb241166173b574391a1976f00f39e057aa47..34034d52e8ebc2b304742a5740876fdee1a1d688 100644 (file)
@@ -23,6 +23,7 @@
 #include "osd.h"
 
 SurfaceWin::SurfaceWin(int id)
+: Surface(id)
 {
 }