From a8c065639ad31f46bfbb38e25c9cde27c9f0aff8 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Wed, 12 Nov 2008 17:58:32 +0200 Subject: [PATCH] Fixed a memory leak. Added a check for the minimum OSD height. --- HISTORY | 2 ++ femonosd.c | 41 ++++++++++++++++++++++------------------- femonosd.h | 48 +++++++++++++++++++++++++----------------------- 3 files changed, 49 insertions(+), 42 deletions(-) diff --git a/HISTORY b/HISTORY index 3ec0294..78b4ad3 100644 --- a/HISTORY +++ b/HISTORY @@ -315,3 +315,5 @@ VDR Plugin 'femon' Revision History - Added getVideoStream() and getAudioStream() functions. - Updated Italian translation (Thanks to Diego Pierotto). +- Fixed a memory leak. +- Added a check for the minimum OSD height. diff --git a/femonosd.c b/femonosd.c index 779623b..9b529e0 100644 --- a/femonosd.c +++ b/femonosd.c @@ -126,26 +126,29 @@ cFemonOsd *cFemonOsd::Instance(bool create) } cFemonOsd::cFemonOsd() -:cOsdObject(true), cThread("femon osd") +: cOsdObject(true), cThread("femon osd"), + m_Osd(NULL), + m_Receiver(NULL), + m_Frontend(-1), + m_SvdrpFrontend(-1), + m_SvdrpVideoBitrate(-1), + m_SvdrpAudioBitrate(-1), + m_SvdrpPlugin(NULL), + m_Number(0), + m_OldNumber(0), + m_SNR(0), + m_Signal(0), + m_BER(0), + m_UNC(0), + m_DisplayMode(femonConfig.displaymode), + m_InputTime(0), + m_Sleep(), + m_Mutex() { Dprintf("%s()\n", __PRETTY_FUNCTION__); - m_Osd = NULL; - m_Receiver = NULL; - m_Frontend = -1; - m_SvdrpVideoBitrate = -1.0; - m_SvdrpAudioBitrate = -1.0; - m_SvdrpFrontend = -1; m_SvdrpConnection.handle = -1; - m_SvdrpPlugin = NULL; - m_Number = 0; - m_OldNumber = 0; - m_Signal = 0; - m_SNR = 0; - m_BER = 0; - m_UNC = 0; - m_DisplayMode = femonConfig.displaymode; - m_InputTime.Set(0); - m_Mutex = new cMutex(); + if (femonConfig.osdheight < (OSDSTATUSHEIGHT + OSDROWHEIGHT + OSDSTATUSHEIGHT)) + femonConfig.osdheight = (OSDSTATUSHEIGHT + OSDROWHEIGHT + OSDSTATUSHEIGHT); if (Setup.UseSmallFont == 0) { // Dirty hack to force the small fonts... Setup.UseSmallFont = 1; @@ -176,7 +179,7 @@ cFemonOsd::~cFemonOsd(void) void cFemonOsd::DrawStatusWindow(void) { - cMutexLock lock(m_Mutex); + cMutexLock lock(&m_Mutex); cBitmap *bm = NULL; int snr = m_SNR / 655; int signal = m_Signal / 655; @@ -282,7 +285,7 @@ void cFemonOsd::DrawStatusWindow(void) void cFemonOsd::DrawInfoWindow(void) { - cMutexLock lock(m_Mutex); + cMutexLock lock(&m_Mutex); int offset = 0; cChannel *channel = Channels.GetByNumber(cDevice::CurrentChannel()); eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack(); diff --git a/femonosd.h b/femonosd.h index fdd2b67..a8e1f7f 100644 --- a/femonosd.h +++ b/femonosd.h @@ -25,27 +25,29 @@ class cFemonOsd : public cOsdObject, public cThread, public cStatus { private: static cFemonOsd *pInstance; - cOsd *m_Osd; - cFemonReceiver *m_Receiver; - int m_Frontend; - int m_SvdrpFrontend; - double m_SvdrpVideoBitrate; - double m_SvdrpAudioBitrate; + + cOsd *m_Osd; + cFemonReceiver *m_Receiver; + int m_Frontend; + int m_SvdrpFrontend; + double m_SvdrpVideoBitrate; + double m_SvdrpAudioBitrate; SvdrpConnection_v1_0 m_SvdrpConnection; - cPlugin *m_SvdrpPlugin; + cPlugin *m_SvdrpPlugin; struct dvb_frontend_info m_FrontendInfo; - int m_Number; - int m_OldNumber; - uint16_t m_SNR; - uint16_t m_Signal; - uint32_t m_BER; - uint32_t m_UNC; - fe_status_t m_FrontendStatus; - int m_DisplayMode; - const cFont *m_Font; - cTimeMs m_InputTime; - cCondWait m_Sleep; - cMutex* m_Mutex; + int m_Number; + int m_OldNumber; + uint16_t m_SNR; + uint16_t m_Signal; + uint32_t m_BER; + uint32_t m_UNC; + fe_status_t m_FrontendStatus; + int m_DisplayMode; + const cFont *m_Font; + cTimeMs m_InputTime; + cCondWait m_Sleep; + cMutex m_Mutex; + void DrawStatusWindow(void); void DrawInfoWindow(void); bool SvdrpConnect(void); @@ -66,10 +68,10 @@ public: virtual void Show(void); virtual eOSState ProcessKey(eKeys Key); - bool DeviceSwitch(int direction); - double GetVideoBitrate(void); - double GetAudioBitrate(void); - double GetDolbyBitrate(void); + bool DeviceSwitch(int direction); + double GetVideoBitrate(void); + double GetAudioBitrate(void); + double GetDolbyBitrate(void); }; #endif //__FEMONOSD_H