From 1570cf80f81cca2f330163620133def5409a60e3 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Wed, 10 Sep 2008 17:37:28 +0300 Subject: [PATCH] Optimized receiver thread termination. --- HISTORY | 1 + femonreceiver.c | 3 ++- femonreceiver.h | 71 +++++++++++++++++++++++++------------------------ 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/HISTORY b/HISTORY index 5636855..55d0562 100644 --- a/HISTORY +++ b/HISTORY @@ -302,3 +302,4 @@ VDR Plugin 'femon' Revision History 2008-xx-xx: Version 1.6.2 - Converted HISTORY and fi_FI.po to UTF-8. +- Optimized receiver thread termination. diff --git a/femonreceiver.c b/femonreceiver.c index 0be5bcc..036250e 100644 --- a/femonreceiver.c +++ b/femonreceiver.c @@ -58,6 +58,7 @@ cFemonReceiver::cFemonReceiver(tChannelID ChannelID, int Ca, int Vpid, int Apid[ cFemonReceiver::~cFemonReceiver(void) { Dprintf("%s()\n", __PRETTY_FUNCTION__); + m_Sleep.Signal(); if (Running()) Cancel(3); Detach(); @@ -362,6 +363,6 @@ void cFemonReceiver::Action(void) m_AudioPacketCount = 0; m_AC3Bitrate = (10.0 * 8.0 * 184.0 * m_AC3PacketCount) / femonConfig.calcinterval; m_AC3PacketCount = 0; - cCondWait::SleepMs(100 * femonConfig.calcinterval - t.Elapsed()); + m_Sleep.Wait(max((int)(100 * femonConfig.calcinterval - t.Elapsed()), 3)); } } diff --git a/femonreceiver.h b/femonreceiver.h index 0eb4620..93b13c6 100644 --- a/femonreceiver.h +++ b/femonreceiver.h @@ -47,7 +47,7 @@ enum eDolbySurroundMode { DSM_RESERVED = 3, }; -enum eReveiverCodes { +enum eReceiverCodes { FR_RESERVED = -1, FR_FREE = -2, FR_NOTVALID = -3 @@ -55,40 +55,41 @@ enum eReveiverCodes { class cFemonReceiver : public cReceiver, public cThread { private: - int m_VideoPid; - int m_AudioPid; - int m_AC3Pid; - bool m_VideoValid; - int m_VideoPacketCount; - int m_VideoHorizontalSize; - int m_VideoVerticalSize; - int m_VideoAspectRatio; - int m_VideoFormat; - double m_VideoFrameRate; - double m_VideoStreamBitrate; - double m_VideoBitrate; - bool m_AudioValid; - int m_AudioPacketCount; - double m_AudioStreamBitrate; - double m_AudioBitrate; - int m_AudioSamplingFreq; - int m_AudioMPEGLayer; - bool m_AC3Valid; - int m_AC3PacketCount; - double m_AC3Bitrate; - int m_AC3FrameSize; - int m_AC3SamplingFreq; - int m_AC3StreamBitrate; - int m_AC3BitStreamMode; - int m_AC3AudioCodingMode; - int m_AC3CenterMixLevel; - int m_AC3SurroundMixLevel; - int m_AC3DolbySurroundMode; - bool m_AC3LfeOn; - int m_AC3DialogLevel; - void GetVideoInfo(uint8_t *mbuf, int count); - void GetAudioInfo(uint8_t *mbuf, int count); - void GetAC3Info(uint8_t *mbuf, int count); + cCondWait m_Sleep; + int m_VideoPid; + int m_AudioPid; + int m_AC3Pid; + bool m_VideoValid; + int m_VideoPacketCount; + int m_VideoHorizontalSize; + int m_VideoVerticalSize; + int m_VideoAspectRatio; + int m_VideoFormat; + double m_VideoFrameRate; + double m_VideoStreamBitrate; + double m_VideoBitrate; + bool m_AudioValid; + int m_AudioPacketCount; + double m_AudioStreamBitrate; + double m_AudioBitrate; + int m_AudioSamplingFreq; + int m_AudioMPEGLayer; + bool m_AC3Valid; + int m_AC3PacketCount; + double m_AC3Bitrate; + int m_AC3FrameSize; + int m_AC3SamplingFreq; + int m_AC3StreamBitrate; + int m_AC3BitStreamMode; + int m_AC3AudioCodingMode; + int m_AC3CenterMixLevel; + int m_AC3SurroundMixLevel; + int m_AC3DolbySurroundMode; + bool m_AC3LfeOn; + int m_AC3DialogLevel; + void GetVideoInfo(uint8_t *mbuf, int count); + void GetAudioInfo(uint8_t *mbuf, int count); + void GetAC3Info(uint8_t *mbuf, int count); protected: virtual void Activate(bool On);