Re: [PATCH] Hang when moving between editing marks
Commit Message
Klaus Schmidinger wrote:
> Here's another suggestion (line numbers may be a little off).
> The only difference to Reinhard's patch is that the sleep is done
> outside the locked area.
Why not just get rid of that sleep completely?
cu
Ludwig
===================================================================
@@ -191,6 +191,7 @@ private:
bool running;
bool firstPacket;
ePlayModes playMode;
+ cCondVar playMode_condition;
ePlayDirs playDir;
int trickSpeed;
int readIndex, writeIndex;
@@ -355,6 +356,7 @@ void cDvbPlayer::Activate(bool On)
}
else if (active) {
running = false;
+ playMode_condition.Broadcast();
Cancel(3);
active = false;
}
@@ -372,14 +374,9 @@ void cDvbPlayer::Action(void)
nonBlockingFileReader = new cNonBlockingFileReader;
int Length = 0;
- bool Sleep = false;
running = true;
while (running && (NextFile() || readIndex >= 0 || ringBuffer->Available() || !DeviceFlush(100))) {
- if (Sleep) {
- cCondWait::SleepMs(3); // this keeps the CPU load low
- Sleep = false;
- }
cPoller Poller;
if (DevicePoll(Poller, 100)) {
@@ -454,7 +451,7 @@ void cDvbPlayer::Action(void)
}
}
else
- Sleep = true;
+ playMode_condition.Wait(mutex);
// Get the next frame from the buffer:
@@ -528,6 +525,7 @@ void cDvbPlayer::Play(void)
DevicePlay();
playMode = pmPlay;
playDir = pdForward;
+ playMode_condition.Broadcast();
}
}
===================================================================
@@ -77,11 +77,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;