]> git.vomp.tv Git - vompclient.git/commitdiff
New options code, enable radio, other stuff for dongle 15
authorChris Tallon <chris@vomp.tv>
Mon, 31 Oct 2005 14:29:08 +0000 (14:29 +0000)
committerChris Tallon <chris@vomp.tv>
Mon, 31 Oct 2005 14:29:08 +0000 (14:29 +0000)
command.cc
playervideo.cc
playervideo.h
tcp.cc
vchannellist.cc
voptions.cc
voptions.h
vvideolive.cc
vvideorec.cc
woptionbox.cc
woptionbox.h

index 18633ba8e284ec311a7e5270207a463130e3c2a4..f440396fc865bad495819a543c5d064152437409 100644 (file)
@@ -331,18 +331,18 @@ void Command::doJustConnected(VConnect* vconnect)
 
   // Go S-Video if config says so
 
-  config = vdr->configLoad("TV", "S-Video");
+  config = vdr->configLoad("TV", "Connection");
 
   if (config)
   {
-    if (!strcasecmp(config, "Yes"))
+    if (!strcasecmp(config, "S-Video"))
     {
-      logger->log("Command", Log::INFO, "Switching to S-Video as S-Video=%s", config);
+      logger->log("Command", Log::INFO, "Switching to S-Video as Connection=%s", config);
       video->setConnection(Video::SVIDEO);
     }
     else
     {
-      logger->log("Command", Log::INFO, "Leaving video output as S-Video=%s", config);
+      logger->log("Command", Log::INFO, "Switching to RGB/Composite as Connection=%s", config);
       video->setConnection(Video::COMPOSITERGB);
     }
     delete[] config;
index 71764b6971cf4d53346b016fcca8da7385bfb562..82ff84778ea84918aa56ced3b36db6cd4c006e22 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "playervideo.h"
 
-PlayerVideo::PlayerVideo(MessageQueue* messageQueue, UCHAR tIsRecording)
+PlayerVideo::PlayerVideo(MessageQueue* messageQueue, UCHAR tIsRecording, UCHAR isRadio)
 : vfeed(this), afeed(this)
 {
   commandMessageQueue = messageQueue;
@@ -35,6 +35,17 @@ PlayerVideo::PlayerVideo(MessageQueue* messageQueue, UCHAR tIsRecording)
   isRecording = tIsRecording;
   lastRescan = 0;
   threadBuffer = NULL;
+
+  if (isRadio)
+  {
+    blockSize = 20000;
+    startupBlockSize = 60000;
+  }
+  else
+  {
+    blockSize = 100000;
+    startupBlockSize = 250000;
+  }
 }
 
 PlayerVideo::~PlayerVideo()
index c1422ffde0843f7a7849ffe9467d9a3e6c0aa200..ce8bff71a6fa9cc71fefbf6e6dcd635bd487eb59 100644 (file)
@@ -39,7 +39,7 @@
 class PlayerVideo : public Player
 {
   public:
-    PlayerVideo(MessageQueue* messageQueue, UCHAR isRecording);
+    PlayerVideo(MessageQueue* messageQueue, UCHAR isRecording, UCHAR isRadio);
     virtual ~PlayerVideo();
 
     int init();
@@ -76,10 +76,10 @@ class PlayerVideo : public Player
     UCHAR feedMode;
     UCHAR isRecording;
     time_t lastRescan;
+    UINT blockSize;
+    UINT startupBlockSize;
     const static UCHAR MODE_NORMAL = 1;
     const static UCHAR MODE_BACKWARDS = 2;
-    const static UINT blockSize = 100000;
-    const static UINT startupBlockSize = 250000;
     UCHAR* threadBuffer;
 
     UCHAR playing;    // As in not stopped, (playing && paused) can == TRUE
diff --git a/tcp.cc b/tcp.cc
index f71f0e4f13872021e08ac36dc5560b4e2a7dbb0d..f6a4edffe4d420497e0e2bb9faeee9e06cc82073 100644 (file)
--- a/tcp.cc
+++ b/tcp.cc
@@ -242,6 +242,7 @@ int TCP::readData(UCHAR* buffer, int totalBytes)
     }
 
     thisRead = read(sock, &buffer[bytesRead], totalBytes - bytesRead);
+//    printf("read %i\n", thisRead);
     if (!thisRead)
     {
       // if read returns 0 then connection is closed
@@ -261,8 +262,8 @@ int TCP::readData(UCHAR* buffer, int totalBytes)
     {
       if (++readTries == 100)
       {
-        Log::getInstance()->log("TCP", Log::ERR, "Too many reads");
-        return 0;
+//        Log::getInstance()->log("TCP", Log::ERR, "Too many reads");
+//        return 0;
       }
     }
   }
index 4f66b0be8eedb825224db126cbb661f77eca944e..2e1a476bcba443a0f8afffe8242981fb8ef93677 100644 (file)
@@ -198,7 +198,7 @@ int VChannelList::handleCommand(int command)
 
       if (chan == NULL) return 2;
 
-      if (chan->type == VDR::RADIO) return 2;
+   //   if (chan->type == VDR::RADIO) return 2;
 
       VVideoLive* v = new VVideoLive(chanList, chan->type);
       v->setChannel(chan->number);
index dc3bc2813dc556fcfcc768dc31b0d3fca85aa68e..a18aa2577adcad224944cdcf8b44b7271a6198fe 100644 (file)
@@ -22,7 +22,7 @@
 
 VOptions::VOptions()
 {
-  create(500, 250);
+  create(500, 285);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     setScreenPos(120, 140);
@@ -39,92 +39,40 @@ VOptions::VOptions()
 
   int fontHeight = surface->getFontHeight();
 
-  optionBox[0].setSurface(surface);
-  optionBox[0].setSurfaceOffset(330, 45);
-  optionBox[0].setDimensions(150, fontHeight);
-  optionBox[0].addOption("Old");
-  optionBox[0].addOption("New");
-
-  optionBox[1].setSurface(surface);
-  optionBox[1].setSurfaceOffset(330, 75);
-  optionBox[1].setDimensions(150, fontHeight);
-  optionBox[1].addOption("RGB+composite");
-  optionBox[1].addOption("S-Video");
-
-  optionBox[2].setSurface(surface);
-  optionBox[2].setSurfaceOffset(330, 105);
-  optionBox[2].setDimensions(150, fontHeight);
-  optionBox[2].addOption("4:3");
-  optionBox[2].addOption("16:9");
-
-  optionBox[3].setSurface(surface);
-  optionBox[3].setSurfaceOffset(330, 135);
-  optionBox[3].setDimensions(150, fontHeight);
-  optionBox[3].addOption("Chop sides");
-  optionBox[3].addOption("Letterbox");
-
-  optionBox[4].setSurface(surface);
-  optionBox[4].setSurfaceOffset(330, 165);
-  optionBox[4].setDimensions(150, fontHeight);
-  optionBox[4].addOption("On");
-  optionBox[4].addOption("Off");
-  optionBox[4].addOption("Last state");
-
-  optionBox[5].setSurface(surface);
-  optionBox[5].setSurfaceOffset(330, 195);
-  optionBox[5].setDimensions(150, fontHeight);
-  optionBox[5].addOption("All");
-  optionBox[5].addOption("FTA only");
+  UINT i;
+  for (i = 0; i < numOptions; i++)
+  {
+    optionBox[i].setSurface(surface);
+    optionBox[i].setSurfaceOffset(330, 45 + (i * 30));
+    optionBox[i].setDimensions(150, fontHeight);
+    for (UINT j = 0; j < optionData[i].optionCount; j++)
+    {
+      Log::getInstance()->log("Options", Log::DEBUG, "Add option");
+      Log::getInstance()->log("Options", Log::DEBUG, "Add option: %s", optionData[i].options[j]);
+      optionBox[i].addOption(optionData[i].options[j]);
+      Log::getInstance()->log("Options", Log::DEBUG, "Done add option");
+    }
+  }
 
   char* config;
   vdr = VDR::getInstance();
 
-
-  config = vdr->configLoad("General", "Remote type");
-  if (!config || strcasecmp(config, "New"))
-    optionBox[0].setSelected("Old");
-  else
-    optionBox[0].setSelected("New");
-  if (config) delete[] config;
-
-  config = vdr->configLoad("TV", "S-Video");
-  if (!config || strcasecmp(config, "Yes"))
-    optionBox[1].setSelected("RGB+composite");
-  else
-    optionBox[1].setSelected("S-Video");
-  if (config) delete[] config;
-
-  config = vdr->configLoad("TV", "Aspect");
-  if (!config || strcasecmp(config, "16:9"))
-    optionBox[2].setSelected("4:3");
-  else
-    optionBox[2].setSelected("16:9");
-  if (config) delete[] config;
-
-  config = vdr->configLoad("TV", "Widemode");
-  if (!config || strcasecmp(config, "Letterbox"))
-    optionBox[3].setSelected("Chop sides");
-  else
-    optionBox[3].setSelected("Letterbox");
-  if (config) delete[] config;
-
-  config = vdr->configLoad("General", "Power After Boot");
-  if (!config)
-    optionBox[4].setSelected("On");
-  else if (!strcasecmp(config, "Off"))
-    optionBox[4].setSelected("Off");
-  else if (!strcasecmp(config, "Last state"))
-    optionBox[4].setSelected("Last state");
-  else
-    optionBox[4].setSelected("On");
-  if (config) delete[] config;
-
-  config = vdr->configLoad("General", "Channels");
-  if (!config || strcasecmp(config, "FTA only"))
-    optionBox[5].setSelected("All");
-  else
-    optionBox[5].setSelected("FTA only");
-  if (config) delete[] config;
+  for (i = 0; i < numOptions; i++)
+  {
+    optionBox[i].setSelected(optionData[i].options[optionData[i].defaultOption]);
+    config = vdr->configLoad(optionData[i].configSection, optionData[i].configParam);
+    if (config)
+    {
+      for (UINT j = 0; j < optionData[i].optionCount; j++)
+      {
+        if (!strcasecmp(config, optionData[i].options[j]))
+        {
+          optionBox[i].setSelected(optionData[i].options[j]);
+        }
+      }
+      delete[] config;
+    }
+  }
 
   selectedOption = 0;
   optionBox[0].setActive(1);
@@ -141,19 +89,14 @@ void VOptions::draw()
   WSymbol wsy;
   Colour cl;
 
-  drawText("Remote control type", 10, 45, Colour::LIGHTTEXT);
-  drawText("TV connection type", 10, 75, Colour::LIGHTTEXT);
-  drawText("TV aspect ratio", 10, 105, Colour::LIGHTTEXT);
-  drawText("16:9 on 4:3 display mode", 10, 135, Colour::LIGHTTEXT);
-  drawText("Power state after bootup", 10, 165, Colour::LIGHTTEXT);
-  drawText("Display channels", 10, 195, Colour::LIGHTTEXT);
-
-  drawText("Press back to exit, <, > or [ok] to change", 10, 220, Colour::LIGHTTEXT);
+  drawText("Press back to exit, <, > or [ok] to change", 10, 255, Colour::LIGHTTEXT);
 
   wsy.setSurface(surface);
 
   for (UINT i = 0; i < numOptions; i++)
   {
+    drawText(optionData[i].title, 10, 45+i*30, Colour::LIGHTTEXT);
+
     if (i == selectedOption) cl = Colour::SELECTHIGHLIGHT;
     else cl = Colour::BUTTONBACKGROUND;
 
@@ -168,7 +111,6 @@ void VOptions::draw()
     optionBox[i].draw();
     optionBox[i].show();
   }
-
 }
 
 int VOptions::handleCommand(int command)
@@ -235,53 +177,51 @@ int VOptions::handleCommand(int command)
 
 void VOptions::doSave()
 {
-  char* remoteType = optionBox[0].getSelected();
-  vdr->configSave("General", "Remote type", remoteType);
-
-  char* tvconnection = optionBox[1].getSelected();
-  if (!strcmp(tvconnection, "S-Video"))
-    vdr->configSave("TV", "S-Video", "Yes");
-  else
-    vdr->configSave("TV", "S-Video", "No");
-
-  char* aspect = optionBox[2].getSelected();
-  vdr->configSave("TV", "Aspect", aspect);
-
-  char* widemode = optionBox[3].getSelected();
-  vdr->configSave("TV", "Widemode", widemode);
-
-  char* powerState = optionBox[4].getSelected();
-  vdr->configSave("General", "Power After Boot", powerState);
+  char* result[numOptions];
 
-  char* channels = optionBox[5].getSelected();
-  vdr->configSave("General", "Channels", channels);
+  for (UINT i = 0; i < numOptions; i++)
+  {
+    result[i] = optionBox[i].getSelected();
+    vdr->configSave(optionData[i].configSection, optionData[i].configParam, result[i]);
+  }
 
   // Apply changes
+  Video* video = Video::getInstance();
 
-  if (!strcmp(remoteType, "New"))
+  if (!strcmp(result[0], optionData[0].options[1]))
+  {
+    Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote");
     Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
+  }
   else
+  {
+    Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote");
     Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
+  }
 
-  Video* video = Video::getInstance();
-
-  if (!strcmp(tvconnection, "S-Video"))
+  if (!strcmp(result[1], optionData[1].options[1]))
+  {
+    Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
     video->setConnection(Video::SVIDEO);
+  }
   else
+  {
+    Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite");
     video->setConnection(Video::COMPOSITERGB);
+  }
 
-  if (!strcmp(aspect, "16:9"))
+  if (!strcmp(result[2], optionData[2].options[1]))
   {
-    Log::getInstance()->log("Options", Log::DEBUG, "Setting widescreen");
+    Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
     video->setTVsize(Video::ASPECT16X9);
   }
   else
   {
-    Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 screen");
+    Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV");
     video->setTVsize(Video::ASPECT4X3);
   }
 
-  if (!strcmp(widemode, "Letterbox"))
+  if (!strcmp(result[3], optionData[3].options[1]))
   {
     Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
     video->setMode(Video::LETTERBOX);
@@ -291,4 +231,6 @@ void VOptions::doSave()
     Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
     video->setMode(Video::NORMAL);
   }
+
 }
+
index 8237af193aaf6784dd1d1fafe47de571ea39afb5..96d2db721c51419f9dde66a823e411cda7ec3d52 100644 (file)
 #include "woptionbox.h"
 #include "wsymbol.h"
 
+#define NUM_OPTIONS 7
+typedef struct
+{
+  char *title;           // Name of the option
+  char *configSection;   // Which section of the config file
+  char *configParam;     // Parameter name in the config file
+  UINT optionCount;      // How many choices?
+  UINT defaultOption;    // Serial of the default choice (base 0)
+  const char **options;  // Text for the options
+} OPTIONDATA;
+
+const static char* options0[] = {"Old", "New"};
+const static char* options1[] = {"RGB+composite", "S-Video"};
+const static char* options2[] = {"4:3", "16:9"};
+const static char* options3[] = {"Chop sides", "Letterbox"};
+const static char* options4[] = {"On", "Off", "Last state"};
+const static char* options5[] = {"All", "FTA only"};
+const static char* options6[] = {"0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "99"};
+
+const static OPTIONDATA optionData[NUM_OPTIONS] =
+{
+  {"Remote control type",      "General", "Remote type",      2, 0, options0 },
+  {"TV connection type",       "TV",      "Connection",       2, 0, options1 },
+  {"TV aspect ratio",          "TV",      "Aspect",           2, 0, options2 },
+  {"16:9 on 4:3 display mode", "TV",      "Widemode",         2, 0, options3 },
+  {"Power state after bootup", "General", "Power After Boot", 3, 0, options4 },
+  {"Display channels",         "General", "Channels",         2, 0, options5 },
+  {"VDR-Pri 0=OK !See forums!","General", "Live priority",    21, 0, options6 }
+};
+
 class VOptions : public View
 {
   public:
@@ -42,11 +72,10 @@ class VOptions : public View
   private:
     void doSave();
 
-    const static UINT numOptions = 6;
+    const static UINT numOptions = NUM_OPTIONS;
     UINT selectedOption;
     WOptionBox optionBox[numOptions];
     VDR* vdr;
-
 };
 
 #endif
index aab8f089baf83b5001c188cfb9467f45bc37e0a8..05f0fed0c43b7a63c622770f5dd4226deb7e1954 100644 (file)
@@ -32,14 +32,9 @@ VVideoLive::VVideoLive(ChannelList* tchanList, ULONG tstreamType)
   unavailable = 0;
   unavailableView = NULL;
   streamType = tstreamType;
-  if (streamType == VDR::VIDEO)
-  {
-    player = new PlayerVideo(Command::getInstance(), 0);
-  }
-  else
-  {
-    player = new PlayerRadio();
-  }
+  if (streamType == VDR::RADIO) player = new PlayerVideo(Command::getInstance(), 0, 1);
+  else                          player = new PlayerVideo(Command::getInstance(), 0, 0);
+
   player->init();
 
   Video* video = Video::getInstance();
index 113a8536f8e12bd19d26801f6ccf5df97c980172..5622e187666cc0d404089a7204086efcf356925a 100644 (file)
@@ -22,7 +22,7 @@
 
 VVideoRec::VVideoRec(Recording* rec)
 {
-  player = new PlayerVideo(Command::getInstance(), 1);
+  player = new PlayerVideo(Command::getInstance(), 1, 0); // say 0 for radio because buffering will work anyway
   player->init();
   vdr = VDR::getInstance();
 
index cd2cafededcf6a98dda16e424aa6cd8fd682f17f..ca56e273e953f939238f9762472a98de00179abb 100644 (file)
@@ -36,13 +36,17 @@ WOptionBox::~WOptionBox()
   free(options);
 }
 
-void WOptionBox::addOption(char* takeText)
+void WOptionBox::addOption(const char* takeText)
 {
   int length = strlen(takeText);
   char* newOption = new char[length + 1];
   strcpy(newOption, takeText);
 
-  options = (char**)realloc(options, numOptions * sizeof(char*));
+  Log::getInstance()->log("Temp", Log::DEBUG, "About to realloc, num Options=%i, current options = %p, new text = %s", numOptions, options, newOption);
+
+  options = (char**)realloc(options, (numOptions+1) * sizeof(char*));
+  Log::getInstance()->log("Temp", Log::DEBUG, "");
+
   options[numOptions] = newOption;
 
   numOptions++;
@@ -91,7 +95,7 @@ void WOptionBox::cycle()
   }
 }
 
-void WOptionBox::setSelected(char* toSelect)
+void WOptionBox::setSelected(const char* toSelect)
 {
   for(UINT i = 0; i < numOptions; i++)
   {
index c9e8def0997ac75859afb6ceacef435fa0a15e53..b840b137705ee3e3e3a92f4dd069d04b4d97ff99 100644 (file)
@@ -32,8 +32,8 @@ class WOptionBox : public Widget
   public:
     WOptionBox();
     ~WOptionBox();
-    void addOption(char* newOption);
-    void setSelected(char* selectedOption);
+    void addOption(const char* newOption);
+    void setSelected(const char* selectedOption);
     char* getSelected();
     void setActive(UCHAR tactive);
     void left();