Mailing List archive

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

[vdr] Re: vdr 1.3.18 cCondWait::SleepMs



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

-- 
(o_  Ludwig.Nussel@gmx.de
//\
V_/_ PGP Key ID: FF8135CE

Attachment: pgp00036.pgp
Description: PGP signature


Home | Main Index | Thread Index