diff --git a/CONTRIBUTORS b/CONTRIBUTORS index de4ede68..a104c177 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1026,3 +1026,6 @@ J Philip Lawatsch for debugging a buffer overflow in eit.c + +Jouni Karvo + for suggesting to make the cOsd constructor 'protected' diff --git a/HISTORY b/HISTORY index a5f24577..7c2a0e87 100644 --- a/HISTORY +++ b/HISTORY @@ -2905,3 +2905,4 @@ Video Disk Recorder Revision History of UTF-8 at program start, and if it is, exists and tells the user to turn off UTF-8 before starting VDR. - Some changes to the SPU decoder interface (thanks to Sven Goethel). +- Some improvements in cOsd creation (thanks to some suggestions by Jouni Karvo). diff --git a/dvbosd.c b/dvbosd.c index d21bcefb..8056499f 100644 --- a/dvbosd.c +++ b/dvbosd.c @@ -4,13 +4,15 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbosd.c 1.22 2004/05/01 15:10:44 kls Exp $ + * $Id: dvbosd.c 1.23 2004/06/12 13:10:03 kls Exp $ */ #include "dvbosd.h" +#include #include #include #include +#include "dvbdevice.h" #include "tools.h" // --- cDvbOsd --------------------------------------------------------------- @@ -18,6 +20,18 @@ #define MAXNUMWINDOWS 7 // OSD windows are counted 1...7 #define MAXOSDMEMORY 92000 // number of bytes available to the OSD (depends on firmware version, but there is no way of determining the actual value) +class cDvbOsd : public cOsd { +private: + int osdDev; + bool shown; + void Cmd(OSD_Command cmd, int color = 0, int x0 = 0, int y0 = 0, int x1 = 0, int y1 = 0, const void *data = NULL); +public: + cDvbOsd(int Left, int Top, int OsdDev); + virtual ~cDvbOsd(); + virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas); + virtual void Flush(void); + }; + cDvbOsd::cDvbOsd(int Left, int Top, int OsdDev) :cOsd(Left, Top) { diff --git a/dvbosd.h b/dvbosd.h index bac43f51..752b9fa1 100644 --- a/dvbosd.h +++ b/dvbosd.h @@ -4,28 +4,14 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbosd.h 1.17 2004/04/30 13:44:16 kls Exp $ + * $Id: dvbosd.h 1.18 2004/06/12 13:09:52 kls Exp $ */ #ifndef __DVBOSD_H #define __DVBOSD_H -#include -#include "dvbdevice.h" #include "osd.h" -class cDvbOsd : public cOsd { -private: - int osdDev; - bool shown; - void Cmd(OSD_Command cmd, int color = 0, int x0 = 0, int y0 = 0, int x1 = 0, int y1 = 0, const void *data = NULL); -public: - cDvbOsd(int Left, int Top, int OsdDev); - virtual ~cDvbOsd(); - virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas); - virtual void Flush(void); - }; - class cDvbOsdProvider : public cOsdProvider { private: int osdDev; diff --git a/osd.c b/osd.c index ac950ff6..6bfa1e5b 100644 --- a/osd.c +++ b/osd.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: osd.c 1.52 2004/06/05 16:52:51 kls Exp $ + * $Id: osd.c 1.53 2004/06/12 13:24:42 kls Exp $ */ #include "osd.h" @@ -713,6 +713,10 @@ cOsdProvider::~cOsdProvider() cOsd *cOsdProvider::NewOsd(int Left, int Top) { + if (cOsd::IsOpen()) { + esyslog("ERROR: attempt to open OSD while it is already open!"); + return NULL; + } if (osdProvider) return osdProvider->CreateOsd(Left, Top); esyslog("ERROR: no OSD provider available - using dummy OSD!"); diff --git a/osd.h b/osd.h index 947e076f..172c4757 100644 --- a/osd.h +++ b/osd.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: osd.h 1.45 2004/06/05 12:38:44 kls Exp $ + * $Id: osd.h 1.46 2004/06/12 13:14:48 kls Exp $ */ #ifndef __OSD_H @@ -208,13 +208,14 @@ struct tArea { #define MAXOSDAREAS 16 class cOsd { + friend class cOsdProvider; private: static bool isOpen; cBitmap *savedRegion; cBitmap *bitmaps[MAXOSDAREAS]; int numBitmaps; int left, top, width, height; -public: +protected: cOsd(int Left, int Top); ///< Initializes the OSD with the given coordinates. ///< By default it is assumed that the full area will be able to display @@ -231,6 +232,7 @@ public: ///< and should require only the minimum necessary color depth. This is ///< because a derived cOsd class may or may not be able to handle more ///< than one area. +public: virtual ~cOsd(); ///< Shuts down the OSD. static bool IsOpen(void) { return isOpen; }