Code cleaning
authorChris Tallon <chris@vomp.tv>
Sun, 1 Jun 2008 18:53:57 +0000 (18:53 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 1 Jun 2008 18:53:57 +0000 (18:53 +0000)
boxstack.cc
timers.h
vaudioselector.cc
vchannellist.cc
vconnect.cc
vdr.cc
vdr.h
vradiorec.cc
vvideorec.cc
wprogressbar.cc

index 2d33758e5d1fab30bf00d3df73efb633f1e4d1aa..e4c620f466b0d6d94eae85cf9a074d10f9e9e435 100644 (file)
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
 
-
-/*
-
-#ifndef WIN32
-  pthread_mutex_lock(&boxLock);
-#else
-  WaitForSingleObject(boxLock, INFINITE);
-#endif
-
-
-#ifndef WIN32
-  pthread_mutex_unlock(&boxLock);
-#else
-  ReleaseMutex(boxLock);
-#endif
-
-
-
-
-*/
-
-
-
-
 #include "boxstack.h"
 
 #include "command.h"
index d554aa8d99c5cf17dcef59c4ca4ceb39e8ac648d..34ab67361971607e8d1fcafa71f5a7af291f2650 100755 (executable)
--- a/timers.h
+++ b/timers.h
 
 FYI
 
-Timers ... deprecated. Maybe.
-
-This whole thing will be replaced with a timed-message idea. It will be possible
-to send yourself (or whoever) a message with a delay, or delivery time. The message
-will be handed to Command as usual, but command will do the right thing. The messages
-will be delivered to the recipient _with the gui mutex locked_, meaning updates can
-be done there and then in the message handler.
-
-Good points:
-* Cuts down on code lines
-* Most (all?) timercall()s eventually send a message to command in order to
-  do something within The Big Mutex. This makes it easier and simpler code wise
-* Gets rid of Timers.
-* Hopefully gets rid of most postMessageFromOuterSpace calls
-
-Bad points:
-* Timers become gui only features. Solve this with a MessageReceiver interface and
-  have command deliver messages straight to the recipients rather than through BoxStack.
-* Timer delivery accuracy becomes dependant on everything that uses The Big Mutex.
-  It will become more important to not block The Big Mutex.
-* Cancelling timers... hmm
-
-If you have any comments about the new design, like, "It's just as flawed as the old one",
-then I'd appreciate hearing it before I start writing it all :)
+Fixed:
+
+The main problem was that timers only seemed to launch messages which went into The Big Mutex.
+This has been fixed a different way by implementing locking in BoxStack - meaning timercalls
+can now draw and update their displays without locking The Big Mutex. Problem solved. I think
+the whole program might move more towards classes keeping more mutexes and rely less on The
+Big Mutex.
+
+
+
+>      Timers ... deprecated. Maybe.
+
+>      This whole thing will be replaced with a timed-message idea. It will be possible
+>      to send yourself (or whoever) a message with a delay, or delivery time. The message
+>      will be handed to Command as usual, but command will do the right thing. The messages
+>      will be delivered to the recipient _with the gui mutex locked_, meaning updates can
+>      be done there and then in the message handler.
+
+>      Good points:
+>      * Cuts down on code lines
+>      * Most (all?) timercall()s eventually send a message to command in order to
+>        do something within The Big Mutex. This makes it easier and simpler code wise
+>      * Gets rid of Timers.
+>      * Hopefully gets rid of most postMessageFromOuterSpace calls
+
+>      Bad points:
+>      * Timers become gui only features. Solve this with a MessageReceiver interface and
+>        have command deliver messages straight to the recipients rather than through BoxStack.
+>      * Timer delivery accuracy becomes dependant on everything that uses The Big Mutex.
+>        It will become more important to not block The Big Mutex.
+>      * Cancelling timers... hmm
+
+>      If you have any comments about the new design, like, "It's just as flawed as the old one",
+>      then I'd appreciate hearing it before I start writing it all :)
 
 
 */
index 97306ff6d263ea6e0cfbaa0e7cbbe9f12b7ce691..3315d73f8497c0e24ab352c08cb779e0f91636be 100644 (file)
@@ -249,7 +249,10 @@ VAudioSelector::~VAudioSelector()
   int audioChannelListSize = acl.size();
   for(int i = 0; i < audioChannelListSize; i++)
   {
-    delete acl[i]; // FIXME memory leak - nobody is deleting audio channel name?
+    // FIXME memory leak - nobody is deleting audio channel name? // try:
+    delete[] acl[i]->name;
+    Log::getInstance()->log("VAudioSelector", Log::DEBUG, "Deleted char[] on close");
+    delete acl[i];
   }
   acl.clear();
 
index d0d0aa438737f02a7743c8b1cdcb35d6fcd3958b..a663fcca485d86f0cacc990a53cb4163a492d635 100644 (file)
@@ -219,22 +219,10 @@ int VChannelList::handleCommand(int command)
       if (chanList) chan = (Channel*)sl.getCurrentOptionData();
       if (chan == NULL) return 2;
  
-//      if (chan->type == VDR::VIDEO)
-//      {
-        VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
-        boxstack->add(v);
-        v->go();
-/*
-      }
-      else
-      {
-        VVideoLive* v = new VVideoLive(chanList, chan->type, this);
-        v->draw();
-        boxstack->add(v);
-        boxstack->update(v);
-        v->channelChange(VVideoLive::NUMBER, chan->number);
-      }
-*/
+      VVideoLiveTV* v = new VVideoLiveTV(chanList, chan->number, this);
+      boxstack->add(v);
+      v->go();
+
       return 2;
     }
     case Remote::BACK:
index 8ad6f7dbb1983360529e8691448a0fbb08e8ac4d..9666156d9f0761b816b9fe4bc59b1d0f9c425ce2 100644 (file)
@@ -120,8 +120,7 @@ void VConnect::threadMethod()
       selectedServer = -1;
       VServerSelect* vs = new VServerSelect(servers, this);
       vs->draw();
-      boxstack->add(vs);  // FIXME - do this better - perhaps post message to Command
-                          // Otherwise it will be using BoxStack without the Command mutex locked
+      boxstack->add(vs);
       boxstack->update(vs);
 
       threadLock();
diff --git a/vdr.cc b/vdr.cc
index e612c9d3e93f570ffbcf118a103e0de8657f4d1b..57ef49246e24af6ad4773cc1e028938332a223ca 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -689,13 +689,6 @@ ChannelList* VDR::getChannelsList(ULONG type)
   return chanList;
 }
 
-
-int VDR::streamChannel(ULONG number)
-{
-  // FIXME radio
-  return 0;
-}
-
 int VDR::streamChannel(ULONG number, StreamReceiver* tstreamReceiver)
 {
   VDR_RequestPacket vrp;
diff --git a/vdr.h b/vdr.h
index 6c75dc4507ad399bed08bc04004c20adc2289f25..a9eefe003a47f1922191e3be11d863f14ca20288 100644 (file)
--- a/vdr.h
+++ b/vdr.h
@@ -166,7 +166,6 @@ class VDR : public Thread_TYPE, public EventDispatcher
     int           deleteTimer(RecTimer* delTimer);
     ChannelList*  getChannelsList(ULONG type);
     int           streamChannel(ULONG number, StreamReceiver*);
-    int           streamChannel(ULONG number);
     void          getChannelPids(Channel* channel);
     UCHAR*        getBlock(ULLONG position, UINT maxAmount, UINT* amountReceived);
                   //get image blocks separate - we can do this in parallel
index a028d775934e75ea4a41016c026a2058aac52d98..f0d53cf1a1e9046f22dc51ee73b9d0488b306112 100644 (file)
@@ -317,15 +317,7 @@ void VRadioRec::stopPlay()
 {
   Log::getInstance()->log("VRadioRec", Log::DEBUG, "Pre stopPlay");
 
-  // FIXME work out a better soln for this
-  // Fix a problem to do with thread sync here
-  // because the bar gets a timer every 0.2s and it seems to take up to 0.1s,
-  // (or maybe just the wrong thread being selected?) for the main loop to lock and process
-  // the video stop message it is possible for a bar message to stack up after a stop message
-  // when the bar message is finally processed the prog crashes because this is deleted by then
   removeBar();
-  //
-
   player->stop();
   vdr->stopStreaming();
   delete player;
index 909a35fc2b4d1c145e060715fb442debbddfd350..f2ee7c020432879c457b3dc81962151c58067e67 100644 (file)
@@ -531,15 +531,7 @@ void VVideoRec::stopPlay()
 {
   Log::getInstance()->log("VVideoRec", Log::DEBUG, "Pre stopPlay");
 
-  // FIXME work out a better soln for this
-  // Fix a problem to do with thread sync here
-  // because the bar gets a timer every 0.2s and it seems to take up to 0.1s,
-  // (or maybe just the wrong thread being selected?) for the main loop to lock and process
-  // the video stop message it is possible for a bar message to stack up after a stop message
-  // when the bar message is finally processed the prog crashes because this is deleted by then
   removeBar();
-  //
-
   player->stop();
   vdr->stopStreaming();
   delete player;
index d61daa05ab1fce124dd2d6fadeba2d1b38bf075c..b025a8850ecd2cf28db8de0a0053f90c9c384933 100644 (file)
@@ -42,8 +42,6 @@ void WProgressBar::draw()
   if (area.w < 5) return;
   if (area.h < 5) return;
   
-  printf("progress bar: %u\n", percent);
-  
   // Hmm, can't draw two boxes because should not paint on areas
   // not needing it - this class does not know the background colour