]> git.vomp.tv Git - vompclient.git/commitdiff
CWFs, brace-inits, clean up PlayerVideoLive and WProgressBar
authorChris Tallon <chris@vomp.tv>
Sat, 14 Mar 2020 18:50:45 +0000 (18:50 +0000)
committerChris Tallon <chris@vomp.tv>
Sat, 14 Mar 2020 18:50:45 +0000 (18:50 +0000)
playervideolive.cc
playervideolive.h
wprogressbar.cc
wprogressbar.h

index d41f99234923b08835db2ceb6aaf6132340b9d6d..38e928f5306a4dd26f16f348fde3d522ee01d65d 100644 (file)
 // ----------------------------------- Called from outside, one offs or info funcs
 
 PlayerVideoLive::PlayerVideoLive(MessageQueue* tmessageQueue, void* tmessageReceiver, OSDReceiver* tosdReceiver, ChannelList* tchanList)
-: vfeed(this), afeed(this), tfeed(this)
+: vfeed(this), afeed(this), tfeed(this),
+  messageQueue(tmessageQueue), messageReceiver(tmessageReceiver), osdReceiver(tosdReceiver), chanList(tchanList)
 {
-  messageQueue = tmessageQueue;
-  messageReceiver = tmessageReceiver;
-  osdReceiver = tosdReceiver;
-  chanList = tchanList;
-  
   audio = Audio::getInstance();
   video = Video::getInstance();
   logger = Log::getInstance();
   vdr = VDR::getInstance();
-  initted = false;
-
-  subtitlesShowing = false;
-  videoStartup = false;
-  pendingAudioPlay = false;
-
-  state = S_STOP;
 
   video->turnVideoOn();
 }
@@ -96,7 +85,6 @@ int PlayerVideoLive::init()
     return 0;
   }
 
-
   video->stop();
   video->blank();
   audio->stop();
@@ -729,132 +717,133 @@ void PlayerVideoLive::threadMethod()
         
         if (!checkError())
         {
-               Channel* chan = (*chanList)[i.channelIndex];
-               chan->loadPids();
-               h264=chan->vstreamtype==0x1b;
-               demuxer->seth264(h264);
-               video->seth264mode(chan->vstreamtype==0x1b);
-               demuxer->setVID(chan->vpid);
-               video->seth264mode(chan->vstreamtype==0x1b);
-
-               bool dolby=false;
-               int selected=-1;
-               int prefered=-1;
-               Command* command = Command::getInstance();
-
-               if (chan->numDPids > 0 && audio->maysupportAc3())
-               {
-                       ULONG j = 0;
-                       while (j < chan->numDPids)
-                       {
-                               int newpref = command->getLangPref(false, chan->dpids[j].desc);
-                               if (Audio::getInstance()->streamTypeSupported(chan->dpids[j].type)
-                                               && (prefered < 0 || newpref < prefered))
-                               {
-                                       selected = j;
-                                       dolby=true;
-                                       prefered = newpref;
-                               }
-                               j++;
-                       }
-               }
-
-
-
-               if (chan->numAPids > 0)
-               {
-                       ULONG j = 0;
-                       while (j < chan->numAPids)
-                       {
-                               int newpref = command->getLangPref(false, chan->apids[j].desc);
-                               if (Audio::getInstance()->streamTypeSupported(chan->apids[j].type)
-                                               && (prefered < 0 || newpref < prefered))
-                               {
-                                       selected = j;
-                                       dolby=false;
-                                       prefered = newpref;
-                               }
-                               j++;
-                       }
-               }
-
-
-               if (selected >= 0) {
-                       if (dolby) {
-                               demuxer->setAID(chan->dpids[selected].pid, 1, chan->dpids[selected].type, true);
-                               audio->setStreamType(Audio::MPEG2_PES);
-                               logger->log("PlayerVideoLive", Log::DEBUG, "Demuxer pids: %u %u (ac3) %u",
-                                               chan->vpid, chan->dpids[selected].pid, chan->dpids[selected].type);
-                       } else {
-                               demuxer->setAID(chan->apids[selected].pid, 0, chan->apids[selected].type, true);
-                               audio->setStreamType(Audio::MPEG2_PES);
-                               logger->log("PlayerVideoLive", Log::DEBUG, "Demuxer pids: %u %u %u", chan->vpid, chan->apids[selected].pid,
-                                               chan->apids[selected].type);
-                       }
-
-               } else {
-                       logger->log("PlayerVideoLive", Log::WARN, "Demuxer video pid only: %u", chan->vpid);
-               }
-
-
-               selected = -1;
-               prefered=-1;
-               if (chan->numSPids) {
-                       ULONG j = 0;
-                       while (j < chan->numSPids)
-                       {
-                               int newpref = command->getLangPref(true, chan->spids[j].desc);
-                               if ( (prefered < 0 || newpref < prefered))
-                               {
-                                       selected = j;
-                                       prefered = newpref;
-                               }
-                               j++;
-                       }
-               }
-
-            if (selected >= 0)
-            {
-              demuxer->setSubID(chan->spids[selected].pid);
+          Channel* chan = (*chanList)[i.channelIndex];
+          chan->loadPids();
+          h264 = (chan->vstreamtype == 0x1b);
+          demuxer->seth264(h264);
+          video->seth264mode(h264);
+          demuxer->setVID(chan->vpid);
+          video->seth264mode(h264);
 
-              if (firstStart)
+          bool dolby = false;
+          int selected = -1;
+          int prefered = -1;
+
+          Command* command = Command::getInstance();
+
+          if (chan->numDPids > 0 && audio->maysupportAc3())
+          {
+            ULONG j = 0;
+            while (j < chan->numDPids)
+            {
+              int newpref = command->getLangPref(false, chan->dpids[j].desc);
+              if (Audio::getInstance()->streamTypeSupported(chan->dpids[j].type) && (prefered < 0 || newpref < prefered))
               {
-                firstStart = false;
+                selected = j;
+                dolby=true;
+                prefered = newpref;
+              }
+              j++;
+            }
+          }
 
-                if (command->getSubDefault())
-                  turnSubtitlesOn(true);
-                else
-                  turnSubtitlesOn(false);
+          if (chan->numAPids > 0)
+          {
+            ULONG j = 0;
+            while (j < chan->numAPids)
+            {
+              int newpref = command->getLangPref(false, chan->apids[j].desc);
+              if (Audio::getInstance()->streamTypeSupported(chan->apids[j].type) && (prefered < 0 || newpref < prefered))
+              {
+                selected = j;
+                dolby = false;
+                prefered = newpref;
               }
-              else
+              j++;
+            }
+          }
+
+          if (selected >= 0)
+          {
+            if (dolby)
+            {
+              demuxer->setAID(chan->dpids[selected].pid, 1, chan->dpids[selected].type, true);
+              audio->setStreamType(Audio::MPEG2_PES);
+              logger->log("PlayerVideoLive", Log::DEBUG, "Demuxer pids: %u %u (ac3) %u",
+                          chan->vpid, chan->dpids[selected].pid, chan->dpids[selected].type);
+            }
+            else
+            {
+              demuxer->setAID(chan->apids[selected].pid, 0, chan->apids[selected].type, true);
+              audio->setStreamType(Audio::MPEG2_PES);
+              logger->log("PlayerVideoLive", Log::DEBUG, "Demuxer pids: %u %u %u", chan->vpid, chan->apids[selected].pid,
+              chan->apids[selected].type);
+            }
+          }
+          else
+          {
+            logger->log("PlayerVideoLive", Log::WARN, "Demuxer video pid only: %u", chan->vpid);
+          }
+
+          selected = -1;
+          prefered = -1;
+          if (chan->numSPids)
+          {
+            ULONG j = 0;
+            while (j < chan->numSPids)
+            {
+              int newpref = command->getLangPref(true, chan->spids[j].desc);
+              if ((prefered < 0 || newpref < prefered))
               {
-                if (subsRestore)
-                  turnSubtitlesOn(true);
-                else
-                  turnSubtitlesOn(false);
+                selected = j;
+                prefered = newpref;
               }
+              j++;
+            }
+          }
+
+          if (selected >= 0)
+          {
+            demuxer->setSubID(chan->spids[selected].pid);
+
+            if (firstStart)
+            {
+              firstStart = false;
+
+              if (command->getSubDefault())
+                turnSubtitlesOn(true);
+              else
+                turnSubtitlesOn(false);
             }
+            else
+            {
+              if (subsRestore)
+                turnSubtitlesOn(true);
+              else
+                turnSubtitlesOn(false);
+            }
+          }
 
-               demuxer->setTID(chan->tpid);
-               teletext->ResetDecoder();
-               int streamSuccess = vdr->streamChannel(chan->number, this);
-               if (!checkError() && !streamSuccess)
-               {
-                       Message* m = new Message();
-                       m->from = this;
-                       m->to = messageReceiver;
-                       m->message = Message::PLAYER_EVENT;
-                       m->parameter = PlayerVideoLive::STREAM_END;
-                       messageQueue->postMessage(m);
-               }
+          demuxer->setTID(chan->tpid);
+          teletext->ResetDecoder();
+          int streamSuccess = vdr->streamChannel(chan->number, this);
+          if (!checkError() && !streamSuccess)
+          {
+            Message* m = new Message();
+            m->from = this;
+            m->to = messageReceiver;
+            m->message = Message::PLAYER_EVENT;
+            m->parameter = PlayerVideoLive::STREAM_END;
+            messageQueue->postMessage(m);
+          }
         }
       }
       else if (i.instruction == I_STOP)
       {
-         logger->log("PlayerVideoLive", Log::DEBUG, "Stopping by instruction");
-         switchState(S_STOP);
-         checkError();
-         return;
+        logger->log("PlayerVideoLive", Log::DEBUG, "Stopping by instruction");
+        switchState(S_STOP);
+        checkError();
+        return;
       }
     }
 
index a7077489fb5653990376ab4050ed4dfdf4586f88..b61943388ff734988fd07ab8eddf1ef1189373a0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright 2004-2005 Chris Tallon
+    Copyright 2004-2020 Chris Tallon
 
     This file is part of VOMP.
 
@@ -98,10 +98,13 @@ class PlayerVideoLive : public PlayerLive, public Callback, public StreamReceive
     void threadMethod();
 
   private:
-    bool subtitlesShowing;
+    VFeed vfeed;
+    AFeed afeed;
+    TFeed tfeed;
     MessageQueue* messageQueue;
     void* messageReceiver;
     OSDReceiver* osdReceiver;
+    ChannelList* chanList;
     Log* logger;
     Audio* audio;
     Video* video;
@@ -109,25 +112,18 @@ class PlayerVideoLive : public PlayerLive, public Callback, public StreamReceive
     DVBSubtitles* subtitles;
     TeletextDecoderVBIEBU *teletext;
     VDR* vdr;
-    VFeed vfeed;
-    AFeed afeed;
-    TFeed tfeed;
-    ChannelList* chanList;
-    bool firstStart{true};
 
     std::queue<PLInstruction> instructions;
     const static UCHAR I_SETCHANNEL = 1;
     const static UCHAR I_STOP = 2;
-    
+
     std::queue<StreamChunk> streamChunks;
-    
-    bool initted;
+
 
     std::thread playerThread;
     std::mutex playerThreadMutex;
     std::condition_variable playerThreadCond;
 
-    UCHAR state;
     const static UCHAR S_STOP = 1;
     const static UCHAR S_VIDEOSTARTUP = 2;
     const static UCHAR S_PREBUFFERING = 3;
@@ -135,8 +131,12 @@ class PlayerVideoLive : public PlayerLive, public Callback, public StreamReceive
     void switchState(UCHAR newState);
     bool checkError();
 
-    bool videoStartup;
-    bool pendingAudioPlay;
+    bool initted{};
+    UCHAR state{S_STOP};
+    bool subtitlesShowing{};
+    bool firstStart{true};
+    bool videoStartup{};
+    bool pendingAudioPlay{};
     bool h264;
     int preBufferCount;
     const static int preBufferAmount = 3;
index a41f21915475cff77556f5b10733b2a5499bf785..9931563291e1628aef47441ee12afeedcb6b3fac 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright 2008 Chris Tallon
+    Copyright 2008-2020 Chris Tallon
 
     This file is part of VOMP.
 
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
 */
 
-#include "wprogressbar.h"
-
 #include "colour.h"
 
-WProgressBar::WProgressBar()
-{
-  percent = 0;
-}
-
-WProgressBar::~WProgressBar()
-{
-}
+#include "wprogressbar.h"
 
 void WProgressBar::setPercent(UINT tpercent)
 {
@@ -50,7 +40,6 @@ void WProgressBar::draw()
   rectangle(0, 0, 2, area.h, DrawStyle::LIGHTTEXT); // left
   rectangle(area.w - 2, 0, 2, area.h, DrawStyle::LIGHTTEXT); // right
   
-  int progressWidth = (int)((area.w - 4) * (float)percent / 100);
+  int progressWidth = (area.w - 4) * percent / 100;
   rectangle(2, 2, progressWidth, area.h - 4, DrawStyle::PROGRESSBAR);
 }
-
index d7addc437bc1574081b8e3d99f499149c5154575..5b28f68a1e3a437b16835ed1444a310ddbbe1463 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright 2008 Chris Tallon
+    Copyright 2008-2020 Chris Tallon
 
     This file is part of VOMP.
 
@@ -14,8 +14,7 @@
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with VOMP; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+    along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
 */
 
 /*
@@ -26,23 +25,17 @@ recording playback bar could be rolled into this class
 #ifndef WPROGRESSBAR_H
 #define WPROGRESSBAR_H
 
-#include <stdio.h>
-#include <string.h>
-
 #include "defines.h"
 #include "boxx.h"
 
 class WProgressBar : public Boxx
 {
   public:
-    WProgressBar();
-    virtual ~WProgressBar();
     void setPercent(UINT percent);
     void draw();
 
   private:
-    UINT percent;
+    UINT percent{};
 };
 
 #endif
-