From c5a7598544d8a18e8135451e6b3f82f2992874bf Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Wed, 10 Sep 2008 17:22:36 +0300 Subject: [PATCH] Optimized streamer thread termination. --- HISTORY | 1 + streamer.c | 5 +++-- streamer.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/HISTORY b/HISTORY index 3fdf09a..475a6c5 100644 --- a/HISTORY +++ b/HISTORY @@ -70,3 +70,4 @@ VDR Plugin 'iptv' Revision History - Tweaked pid scanner parameters for HD broadcasts. - Fixed opening of fifo tap. - Updated iptvstream.sh script to support optional video resolution settings. +- Optimized streamer thread termination. diff --git a/streamer.c b/streamer.c index c1109f8..cf28660 100644 --- a/streamer.c +++ b/streamer.c @@ -45,11 +45,11 @@ void cIptvStreamer::Action(void) } else { mutex->Unlock(); - cCondWait::SleepMs(100); // to reduce cpu load + sleep.Wait(100); // to reduce cpu load } } else - cCondWait::SleepMs(100); // and avoid busy loop + sleep.Wait(100); // and avoid busy loop } debug("cIptvStreamer::Action(): Exiting\n"); } @@ -69,6 +69,7 @@ bool cIptvStreamer::Close(void) { debug("cIptvStreamer::Close()\n"); // Stop thread + sleep.Signal(); if (Running()) Cancel(3); // Close the protocol. A mutex should be taken here to avoid a race condition diff --git a/streamer.h b/streamer.h index d24ff10..b8bbb34 100644 --- a/streamer.h +++ b/streamer.h @@ -20,6 +20,7 @@ class cIptvStreamer : public cThread, public cIptvStreamerStatistics { private: cRingBufferLinear* ringBuffer; cMutex* mutex; + cCondWait sleep; unsigned char* readBuffer; unsigned int readBufferLen; cIptvProtocolIf* protocol;