]> git.vomp.tv Git - vompclient.git/commitdiff
Connection failure detection
authorChris Tallon <chris@vomp.tv>
Sun, 12 Mar 2006 22:13:08 +0000 (22:13 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 12 Mar 2006 22:13:08 +0000 (22:13 +0000)
player.cc
player.h
vepg.cc
vlivebanner.cc
voptions.cc
voptions.h
voptionsmenu.cc
vvideolive.cc
vvideorec.cc

index a48f557d84ed7ad553d95714cc0d321af0c965c2..c0893af9360207eea002c98b2dc1edeab71772f7 100644 (file)
--- a/player.cc
+++ b/player.cc
@@ -281,6 +281,7 @@ void Player::skipForward(int seconds)
 
   ULONG wantedFrameNumber = video->timecodeToFrameNumber(getPositionTS() + (seconds * 90000));
   ULLONG newPosition = VDR::getInstance()->positionFromFrameNumber(wantedFrameNumber);
+  if (!VDR::getInstance()->isConnected()) { doConnectionLost(); return; }
   logger->log("Player", Log::DEBUG, "wantedframe %i feedpos %llu goto %llu", wantedFrameNumber, feedPosition, newPosition);
 
   vfeed.stop();
@@ -316,6 +317,7 @@ void Player::skipBackward(int seconds)
   {
     ULONG wantedFrameNumber = video->timecodeToFrameNumber((ULLONG)newTimeCode);
     newPosition = VDR::getInstance()->positionFromFrameNumber(wantedFrameNumber);
+    if (!VDR::getInstance()->isConnected()) { doConnectionLost(); return; }
     logger->log("Player", Log::DEBUG, "wantedframe %i feedpos %llu goto %llu", wantedFrameNumber, feedPosition, newPosition);
   }
 
@@ -505,6 +507,14 @@ void Player::call(void* caller)
   }
 }
 
+void Player::doConnectionLost()
+{
+  Message* m = new Message();
+  m->message = Message::CONNECTION_LOST;
+  m->to = this;
+  commandMessageQueue->postMessage(m);
+}
+
 // Feed thread
 
 void Player::threadMethod()
@@ -528,14 +538,7 @@ void Player::threadMethod()
     if (isRecording && ((lastRescan + 60) < time(NULL)))
     {
       streamLength = vdr->rescanRecording();
-      if (!vdr->isConnected())
-      {
-        Message* m = new Message();
-        m->message = Message::CONNECTION_LOST;
-        m->to = this;
-        commandMessageQueue->postMessage(m);
-        return;
-      }
+      if (!vdr->isConnected()) { doConnectionLost(); return; }
       logger->log("Player", Log::DEBUG, "Rescanned and reset length: %llu", streamLength);
       lastRescan = time(NULL);
       setEndTS();
@@ -571,10 +574,7 @@ void Player::threadMethod()
     threadBuffer = vdr->getBlock(feedPosition, askFor, &thisRead);
     if (!vdr->isConnected())
     {
-      Message* m = new Message();
-      m->message = Message::CONNECTION_LOST;
-      m->to = this;
-      commandMessageQueue->postMessage(m);
+      doConnectionLost();
       return;
     }
 
@@ -670,6 +670,7 @@ void Player::setStartTS(UINT dataInBuffer)
 
     UINT thisRead;
     UCHAR* tempBuffer = VDR::getInstance()->getBlock(0, 100000, &thisRead);
+    if (!tempBuffer && !VDR::getInstance()->isConnected()) { doConnectionLost(); return; }
     if (!tempBuffer) return;
     if (thisRead) demuxer.findVideoPTS(tempBuffer, thisRead, &startTS);
     free(tempBuffer);
@@ -686,6 +687,7 @@ void Player::setEndTS()
 
   UINT thisRead;
   UCHAR* tempBuffer = VDR::getInstance()->getBlock((streamLength - 100000), 100000, &thisRead);
+  if (!tempBuffer && !VDR::getInstance()->isConnected()) { doConnectionLost(); return; }
   if (!tempBuffer) return;
   if (thisRead) demuxer.findVideoPTS(tempBuffer, thisRead, &endTS);
   free(tempBuffer);
index c490c0cb4db614253f9630949026abd3988efd7c..24f5e180588354874502ca11ccf8f10fa277b00f 100644 (file)
--- a/player.h
+++ b/player.h
@@ -75,6 +75,7 @@ class Player : public Thread, public Callback
     void resyncVideo();
     void setStartTS(UINT dataInBuffer);
     void setEndTS();
+    void doConnectionLost();
 
    int initted;
     MessageQueue* commandMessageQueue;
diff --git a/vepg.cc b/vepg.cc
index 0f7ae5ac9797a9dfdbf677515b02a9d3a43faf1a..9aaca603a8fbfa2e9b29b94c6fb8370d7135a277 100644 (file)
--- a/vepg.cc
+++ b/vepg.cc
@@ -118,19 +118,23 @@ VEpg::VEpg(VVideoLive* v, UINT currentChannel)
 
 
   // populate channel list\r
-  Channel* chan;\r
-  int first = 1;\r
-  for (UINT i = 0; i < chanList->size(); i++)\r
-  {\r
-    chan = (*chanList)[i];\r
-    if (i == currentChannel)\r
-      first = 1;\r
-    chan->index = chanListbox.addOption(chan->name, first);\r
-    first = 0;\r
-  }\r
+  if (chanList)
+  {
+    Channel* chan;\r
+    int first = 1;\r
+    for (UINT i = 0; i < chanList->size(); i++)\r
+    {\r
+      chan = (*chanList)[i];\r
+      if (i == currentChannel)\r
+        first = 1;\r
+      chan->index = chanListbox.addOption(chan->name, first);\r
+      first = 0;\r
+    }\r
+    chanName.setText((*chanList)[chanListbox.getCurrentOption()]->name);
+  }
+
   listTop = chanListbox.getTopOption();\r
   chanListbox.draw(); // doing this to allow chanListbox.getBottomOption() in updateEventList() to work\r
-  chanName.setText((*chanList)[chanListbox.getCurrentOption()]->name);\r
   time(&ltime); // set ltime to now\r
   ltime = prevHour(&ltime); // set ltime to previous hour TODO make this half hour?\r
   time(&selTime); // set selTime to now\r
@@ -340,6 +344,7 @@ int VEpg::handleCommand(int command)
     }\r
     case Remote::RECORD:\r
     {\r
+      if (!chanList) return 2;
       Log::getInstance()->log("VEPG", Log::DEBUG, "ID %lu TIME %lu DURATION %lu TITLE %s", thisEvent.id, thisEvent.time, thisEvent.duration, thisEvent.title);
       VEpgSetTimer* vs = new VEpgSetTimer(&thisEvent, (*chanList)[chanListbox.getCurrentOption()]);
       vs->draw();
@@ -350,7 +355,10 @@ int VEpg::handleCommand(int command)
     case Remote::PLAY:\r
     case Remote::GO:\r
     case Remote::OK:\r
-    { // select programme and display menu TODO currently just changes to selected channel\r
+    {
+      if (!chanList) return 2;
+
+      // select programme and display menu TODO currently just changes to selected channel\r
       videoLive->channelChange(VVideoLive::NUMBER, (*chanList)[chanListbox.getCurrentOption()]->number);
 
       if(command == Remote::GO)\r
@@ -529,6 +537,7 @@ void VEpg::drawgrid() // redraws grid and select programme
 \r
 void VEpg::updateEventList()\r
 {\r
+  if (!chanList) return;
   Channel* chan;\r
   for(UINT listIndex = 0; listIndex < gridRows; listIndex++)\r
   {\r
@@ -540,7 +549,9 @@ void VEpg::updateEventList()
     if(listTop + listIndex >= UINT(chanListbox.getBottomOption()))\r
       continue;\r
     chan = (*chanList)[listTop + listIndex];\r
-    eventLista[listIndex] = VDR::getInstance()->getChannelSchedule(chan->number, ltime - 1, WINDOW_WIDTH * 60 + 2); // ltime - 1 to get prog before window (allows cursor left past ltime). + 2 to get prog after window\r
+\r
+    EventList* newEventList = VDR::getInstance()->getChannelSchedule(chan->number, ltime - 1, WINDOW_WIDTH * 60 + 2); // ltime - 1 to get prog before window (allows cursor left past ltime). + 2 to get prog after window\r
+    if (newEventList) eventLista[listIndex] = newEventList;\r
   }\r
 }\r
 \r
index 6e53cf9f693cc7f0e229389a4e6698f02343f961..a973dca8901c9ae6e32a7a527f7a10d538721857 100644 (file)
@@ -96,9 +96,7 @@ void VLiveBanner::setChannel(Channel* tChannel)
   snprintf(ttitleText, 99, "%03lu - %s", currentChannel->number, currentChannel->name);
 
   setTitleText(ttitleText);
-    Log::getInstance()->log("Banner", Log::DEBUG, "Start get ch");
   eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number);
-    Log::getInstance()->log("Banner", Log::DEBUG, "End get ch");
 
   if (!eventList)
   {
index a2d224665374e8195b79d1de7c9e05603a855842..47c9fd791d059d034e0928d540b45419455dba0c 100644 (file)
@@ -119,6 +119,8 @@ VOptions::VOptions(View* tparent, const char* title, const OPTIONDATA* toptionDa
   {
     setScreenPos(94, 70 + voff);
   }
+
+  if (!vdr->isConnected()) Command::getInstance()->connectionLost();
 }
 
 VOptions::~VOptions()
index 0d1481cff1df666ec33199678dfb2e0de31ddd44..d30dbade8c45384c1cd37fbdc915260072fcfc14 100644 (file)
@@ -30,6 +30,7 @@
 #include "woptionbox.h"
 #include "wsymbol.h"
 #include "i18n.h"
+#include "command.h"
 
 typedef struct
 {
index d3c0508e500384ac13e5b3f30382e8412707b31d..508187ccfcc9eb8476e14fbd3bee28e83eb4b121 100644 (file)
@@ -144,6 +144,8 @@ void VOptionsMenu::processMessage(Message* m)
   {
     doApplyChanges((map<int,int>*)m->parameter);
     viewman->removeView(this);
+
+    if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
   }
 }
 
index 0b233765613afd1f82ead90f710873cdc83c4651..95b03a34c5ca9762849c22be03c2439d96580c81 100644 (file)
@@ -297,6 +297,7 @@ void VVideoLive::play(int noShowVLB)
   {
     if (!noShowVLB) doBanner(false);
     showUnavailable(1);
+    if (!vdr->isConnected()) { Command::getInstance()->connectionLost(); return; }
   }
   else
   {
@@ -313,6 +314,7 @@ void VVideoLive::stop(int noRemoveVLB)
   player->stop();
   Log::getInstance()->log("VVideoLive", Log::DEBUG, "Delay starts here due to time taken by plugin to stop");
   vdr->stopStreaming();
+  if (!vdr->isConnected()) { Command::getInstance()->connectionLost(); return; }
   Log::getInstance()->log("VVideoLive", Log::DEBUG, "Delay ends here due to time taken by plugin to stop");
 }
 
index 63cb0bc921c07a2f5a14fbccaefcab8eba817743..d8d5b16d20b1be79eac1d14d85a8b0a94ae52ae3 100644 (file)
@@ -276,6 +276,7 @@ void VVideoRec::stopPlay()
 
   playing = false;
 
+  if (!vdr->isConnected()) { Command::getInstance()->connectionLost(); return; }
   Log::getInstance()->log("VVideoRec", Log::DEBUG, "Post stopPlay");
 }