Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: vdr 1.3.18 cCondWait::SleepMs



Ludwig Nussel wrote:
Klaus Schmidinger wrote:

If you look at the places where cCondWait::SleepMs() is used, you'll
see that these are mainly situations where we just need to wait some
milliseconds, with no condition or whatever else to "wait on".

Wherever it is feasible VDR does wait on conditions.

What about this one?

Index: vdr-1.3.18/dvbplayer.c
===================================================================
--- vdr-1.3.18.orig/dvbplayer.c
+++ vdr-1.3.18/dvbplayer.c
@@ -191,6 +191,7 @@ private:
bool running;
bool firstPacket;
ePlayModes playMode;
+ cCondVar playMode_condition;
ePlayDirs playDir;
int trickSpeed;
int readIndex, writeIndex;
@@ -353,6 +354,7 @@ void cDvbPlayer::Activate(bool On)
}
else if (active) {
running = false;
+ playMode_condition.Broadcast();
Cancel(3);
active = false;
}
@@ -439,7 +441,7 @@ void cDvbPlayer::Action(void)
}
}
else
- cCondWait::SleepMs(1); // this keeps the CPU load low
+ playMode_condition.Wait(mutex);
}
// Store the frame in the buffer:
@@ -521,6 +523,7 @@ void cDvbPlayer::Play(void)
DevicePlay();
playMode = pmPlay;
playDir = pdForward;
+ playMode_condition.Broadcast();
}
}
Index: vdr-1.3.18/thread.h
===================================================================
--- vdr-1.3.18.orig/thread.h
+++ vdr-1.3.18/thread.h
@@ -75,11 +75,11 @@ class cThread {
private:
bool running;
pthread_t childTid;
- cMutex mutex;
char *description;
static bool emergencyExitRequested;
static void *StartThread(cThread *Thread);
protected:
+ cMutex mutex;
void Lock(void) { mutex.Lock(); }
void Unlock(void) { mutex.Unlock(); }
virtual void Action(void) = 0;

cu
Ludwig
Why so complicated?
All that needs to be done is to wait a little while at this point,
making sure the time slice will be given up. It doesn't really matter
whether we wait 1, 2 or 3 milliseconds - even 10 would be ok here.

I'll change the time to 3ms, which, according to what I've seen in other
postings, should not cause a busy wait.

Klaus




Home | Main Index | Thread Index