Optimized streamer thread termination.

This commit is contained in:
Rolf Ahrenberg 2008-09-10 17:22:36 +03:00
parent 4e8e26a4b3
commit c5a7598544
3 changed files with 5 additions and 2 deletions

View File

@ -70,3 +70,4 @@ VDR Plugin 'iptv' Revision History
- Tweaked pid scanner parameters for HD broadcasts. - Tweaked pid scanner parameters for HD broadcasts.
- Fixed opening of fifo tap. - Fixed opening of fifo tap.
- Updated iptvstream.sh script to support optional video resolution settings. - Updated iptvstream.sh script to support optional video resolution settings.
- Optimized streamer thread termination.

View File

@ -45,11 +45,11 @@ void cIptvStreamer::Action(void)
} }
else { else {
mutex->Unlock(); mutex->Unlock();
cCondWait::SleepMs(100); // to reduce cpu load sleep.Wait(100); // to reduce cpu load
} }
} }
else else
cCondWait::SleepMs(100); // and avoid busy loop sleep.Wait(100); // and avoid busy loop
} }
debug("cIptvStreamer::Action(): Exiting\n"); debug("cIptvStreamer::Action(): Exiting\n");
} }
@ -69,6 +69,7 @@ bool cIptvStreamer::Close(void)
{ {
debug("cIptvStreamer::Close()\n"); debug("cIptvStreamer::Close()\n");
// Stop thread // Stop thread
sleep.Signal();
if (Running()) if (Running())
Cancel(3); Cancel(3);
// Close the protocol. A mutex should be taken here to avoid a race condition // Close the protocol. A mutex should be taken here to avoid a race condition

View File

@ -20,6 +20,7 @@ class cIptvStreamer : public cThread, public cIptvStreamerStatistics {
private: private:
cRingBufferLinear* ringBuffer; cRingBufferLinear* ringBuffer;
cMutex* mutex; cMutex* mutex;
cCondWait sleep;
unsigned char* readBuffer; unsigned char* readBuffer;
unsigned int readBufferLen; unsigned int readBufferLen;
cIptvProtocolIf* protocol; cIptvProtocolIf* protocol;