From 6fc3cd7c978d70114ec8a6b205f15495ca0550cb Mon Sep 17 00:00:00 2001
From: Chris Tallon <chris@vomp.tv>
Date: Sat, 17 Dec 2005 18:07:09 +0000
Subject: [PATCH] Fixed a few bugs. Standby off main menu, video off signal,
 numbers after del on recordings list

---
 command.cc        | 11 ++++++++++-
 command.h         |  1 +
 playervideo.cc    | 11 ++++++++---
 vlivebanner.cc    |  6 +++---
 vrecordinglist.cc |  3 +--
 vwelcome.cc       |  4 ++--
 6 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/command.cc b/command.cc
index 23e3323..815309a 100644
--- a/command.cc
+++ b/command.cc
@@ -154,12 +154,21 @@ void Command::postMessage(Message* m)
   // remote->getButtonPress to break
   // locking the mutex ensures that the master thread is waiting on getButtonPress
 
+
   pthread_mutex_lock(&masterLock);
   MessageQueue::postMessage(m);
   kill(mainPid, SIGURG);
   pthread_mutex_unlock(&masterLock);
 }
 
+void Command::postMessageNoLock(Message* m)
+{
+  // As above but use this one if this message is being posted because of a button press
+  // the mutex is already locked, locking around postMessage is not needed as the
+  // queue is guaranteed to be run when the button has been processed
+  MessageQueue::postMessage(m);
+}
+
 bool Command::postMessageIfNotBusy(Message* m)
 {
   // This is for the timers module
@@ -286,8 +295,8 @@ void Command::doStandby()
   }
   else
   {
-    Video::getInstance()->signalOff();
     viewman->removeAll();
+    Video::getInstance()->signalOff();
     viewman->updateView(wallpaper);
 
     VDR::getInstance()->configSave("General", "Last Power State", "Off");
diff --git a/command.h b/command.h
index 2da9f78..13db4e2 100644
--- a/command.h
+++ b/command.h
@@ -68,6 +68,7 @@ class Command : public MessageQueue
     void stop();
     void doReboot();
     void postMessage(Message* m); // override of MessageQueue::postMessage
+    void postMessageNoLock(Message* m); // override of MessageQueue::postMessage
     bool postMessageIfNotBusy(Message* m); // for timers, when masterMutex might be locked
     void sig1();
 
diff --git a/playervideo.cc b/playervideo.cc
index a0e572a..5c6d71d 100644
--- a/playervideo.cc
+++ b/playervideo.cc
@@ -195,13 +195,11 @@ int PlayerVideo::play()
   video->sync();
   video->unPause();
   video->sync();
-
 // ------------------------ This one doesn't work, but it should, and would allow for prebuffering.
 
 /*
-
   threadStart();
-  sleep(2);
+//  sleep(1);
 
 //  struct timespec delay;
 //  delay.tv_sec = 1;
@@ -214,7 +212,14 @@ int PlayerVideo::play()
   audio->play();
   video->sync();
   audio->sync();
+
+  video->pause();
+      usleep(500000); // SYNC
+  video->sync();
+  video->unPause();
+  video->sync();
 */
+
 // ------------------------------------------------------------------------------------------------
 
   playing = 1;
diff --git a/vlivebanner.cc b/vlivebanner.cc
index 9323b74..1ca5a9f 100644
--- a/vlivebanner.cc
+++ b/vlivebanner.cc
@@ -125,10 +125,10 @@ void VLiveBanner::setChannel(Channel* tChannel)
       event->index = sl.addOption(tempString, first);
       first = 0;
     }
-
-    // Reset the timer as it probably took 1-2 seconds to change the channel
-    Timers::getInstance()->setTimer(this, 1, (struct timespec){4, 0});
   }
+
+  // Reset the timer as it probably took 1-2 seconds to change the channel
+  Timers::getInstance()->setTimer(this, 1, (struct timespec){4, 0});
 }
 
 void VLiveBanner::draw()
diff --git a/vrecordinglist.cc b/vrecordinglist.cc
index f7bc485..452876a 100644
--- a/vrecordinglist.cc
+++ b/vrecordinglist.cc
@@ -120,6 +120,7 @@ void VRecordingList::drawData()
   sl.hintSetCurrent(saveIndex);
   sl.hintSetTop(saveTop);
   sl.draw();
+  doShowingBar();
 }
 
 void VRecordingList::draw()
@@ -172,8 +173,6 @@ void VRecordingList::draw()
   // All static stuff done
 
   drawData();
-  sl.draw();
-  doShowingBar();
 }
 
 void VRecordingList::doShowingBar()
diff --git a/vwelcome.cc b/vwelcome.cc
index a065206..5208f61 100644
--- a/vwelcome.cc
+++ b/vwelcome.cc
@@ -149,7 +149,7 @@ int VWelcome::handleCommand(int command)
     {
       Message* m = new Message(); // Must be done after this view deleted
       m->message = Message::STANDBY;
-      Command::getInstance()->postMessage(m);
+      Command::getInstance()->postMessageNoLock(m);
       return 4;
     }
     case Remote::SIX:
@@ -183,7 +183,7 @@ int VWelcome::handleCommand(int command)
       {
         Message* m = new Message(); // Must be done after this view deleted
         m->message = Message::STANDBY;
-        Command::getInstance()->postMessage(m);
+        Command::getInstance()->postMessageNoLock(m);
         return 4;
       }
       else if (option == 5)
-- 
2.39.5