]> git.vomp.tv Git - vompclient.git/commitdiff
Minor code cleaning re: Messages
authorChris Tallon <chris@vomp.tv>
Tue, 21 Sep 2021 16:46:29 +0000 (17:46 +0100)
committerChris Tallon <chris@vomp.tv>
Tue, 21 Sep 2021 16:46:29 +0000 (17:46 +0100)
boxstack.cc
control.cc
message.h
osdopenvg.cc

index 248b17e4ad62e8b0f5997b7a6a9083da952885ea..c5d6d9c554752895564c914d180d5494b8003cf9 100644 (file)
@@ -546,7 +546,7 @@ void BoxStack::processMessage(Message* m)
     {
       if (boxes[i] == m->to)
       {
-        LogNT::getInstance()->debug(TAG, "sending message from box {} to box {} {}", (void*)m->from, (void*)m->to, m->message);
+        LogNT::getInstance()->debug(TAG, "sending message {} from {} to {}", m->message, (void*)m->from, (void*)m->to);
         boxes[i]->processMessage(m);
         return;
       }
index bfd761f4ebb7d3d8f1c193a69c4446b7ad081389..5bc2888e3d6c6235c61b995378e6a6f35807b9a8 100644 (file)
@@ -438,14 +438,9 @@ void Control::run()
 
 void Control::processMessage(Message* m)
 {
-    // FIXME - a slight modification - how if messagereceivers were to register
-    // themselves as receivers to avoid the calling-a-deleted-object problem
-    // then only deliver/register/unregister would have to be protected
-
   logger->debug(TAG, "processing message {}", m->message);
 
-
-  if ((m->p_to == Message::CONTROL) || (m->to == this)) // Maybe don't check m->to here? Always use predefined?
+  if (m->p_to == Message::CONTROL)
   {
     switch(m->message)
     {
@@ -454,19 +449,14 @@ void Control::processMessage(Message* m)
         irun = false;
         break;
       }
-      // << FIXME OBSELETE
       case Message::STOP_PLAYBACK:
       {
         handleCommand(Input::STOP); // an odd way of doing it, but so simple
         break;
       }
-      // Also connection_lost comes from player - anywhere else?
-      // FIXME OBSELETE >>
-
-
       case Message::VDR_CONNECTED:
       {
-        doJustConnected(static_cast<VConnect*>(m->from)); // FIXME delete from here?
+        doJustConnected(static_cast<VConnect*>(m->from));
         break;
       }
       case Message::SCREENSHOT:
@@ -517,6 +507,8 @@ void Control::processMessage(Message* m)
       }
       case Message::NEW_PICTURE:
       {
+        // FIXME MQSUB
+
         //Log::getInstance()->log("Control", Log::DEBUG, "TVMedia NEW_PICTURE");
         OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
         if (osdv) osdv->informPicture(m->tag, reinterpret_cast<ImageIndex>(m->data));
@@ -628,7 +620,7 @@ void Control::sig1()
 #ifdef DEV
   Message* m = new Message(); // break into master mutex
   m->message = Message::SCREENSHOT;
-  m->to = this;
+  m->p_to = Message::CONTROL;
   postMessage(m);
 #endif
 }
index 9b442f5907517d927da35ef9defa9751e5b953c2..1b13703d8184c417df013c543363bd90a57b791d 100644 (file)
--- a/message.h
+++ b/message.h
 
 #include <stdio.h>
 
-//class Message;
 #include "defines.h"
 
-// Usage of messages is more dubious now that the single master mutex lock
-// protects all gui actions. Reason(s) for usage:
-// 1. View A wants something to be done by View B *after* View A has been deleted
-// 2. A thread wants its object/view deleting *after* the thread has exited
-
-// Put a justification line after call to Message* m = new  Message() line
-// So that the sources can be grepped for proper message usage
-
 class Message
 {
   public:
 
+    // Not using a pre-defined target if one is available is deprecated, and is now essential for CONTROL
+
     enum PreDefinedTarget
     {
       NA = 0,
@@ -50,46 +43,48 @@ class Message
     void* from{};
     PreDefinedTarget p_to{NA}; // If this is set 'to' is ignored
     void* to{};
-    ULONG message{};
+    int message{};
     ULONG parameter{};
     ULONG tag{};     // use this for identifying which object / question is being replied to
     void* data{};    // Use this for anything. Int, pointer, pointer to memory to be freed by the recipient, etc.
 
-    const static ULONG QUESTION_YES = 1;
-    const static ULONG CLOSE_ME = 2;
-    const static ULONG PLAY_SELECTED_RECORDING = 3;
-    const static ULONG DELETE_SELECTED_RECORDING = 4;
-    const static ULONG SCREENSHOT = 5;
-    const static ULONG CHANNEL_CHANGE = 6;
-    const static ULONG RESUME_SELECTED_RECORDING = 7;
-    const static ULONG INPUT_EVENT = 8;
-    const static ULONG STOP_PLAYBACK = 9;
-    const static ULONG SERVER_SELECTED = 10;
-    const static ULONG VDR_CONNECTED = 11;
-    const static ULONG ADD_VIEW = 12;
-    const static ULONG REDRAW_LANG = 14;
-    const static ULONG EPG = 16;
-    const static ULONG CHANGED_OPTIONS = 18;
-    const static ULONG CONNECTION_LOST = 19;
-    const static ULONG MOVE_RECORDING = 20;
-    const static ULONG PLAYER_EVENT = 22;
-    const static ULONG AUDIO_CHANGE_CHANNEL = 23;
-    const static ULONG CHILD_CLOSE = 24;
-    const static ULONG MOUSE_MOVE = 25;
-    const static ULONG MOUSE_LBDOWN = 26;
-    const static ULONG CHANGE_LANGUAGE = 27;
-    const static ULONG LAST_VIEW_CLOSE = 28;
-    const static ULONG CHANGED_REMOTECONTROL = 29;
-    const static ULONG DELETE_SELECTED_TIMER = 30;
-    const static ULONG CHANGED_DEVICEOPTIONS = 31;
-    const static ULONG TELETEXTUPDATE = 32;
-    const static ULONG TELETEXTUPDATEFIRSTLINE = 33;
-    const static ULONG SUBTITLE_CHANGE_CHANNEL = 34;
-    const static ULONG MOUSE_SCROLL = 35;
-    const static ULONG NEW_PICTURE = 36;
-    const static ULONG NEW_PICTURE_STATIC = 37;
-    const static ULONG REDRAW = 38;
-    const static ULONG SHUTDOWN = 39;
+    // Never use the values, only the names
+    const static int INVALID                       = 0;
+    const static int QUESTION_YES                  = 1;
+    const static int CLOSE_ME                      = 2;
+    const static int PLAY_SELECTED_RECORDING       = 3;
+    const static int DELETE_SELECTED_RECORDING     = 4;
+    const static int SCREENSHOT                    = 5;
+    const static int CHANNEL_CHANGE                = 6;
+    const static int RESUME_SELECTED_RECORDING     = 7;
+    const static int INPUT_EVENT                   = 8;
+    const static int STOP_PLAYBACK                 = 9;
+    const static int SERVER_SELECTED               = 10;
+    const static int VDR_CONNECTED                 = 11;
+    const static int ADD_VIEW                      = 12;
+    const static int REDRAW_LANG                   = 14;
+    const static int EPG                           = 16;
+    const static int CHANGED_OPTIONS               = 18;
+    const static int CONNECTION_LOST               = 19;
+    const static int MOVE_RECORDING                = 20;
+    const static int PLAYER_EVENT                  = 22;
+    const static int AUDIO_CHANGE_CHANNEL          = 23;
+    const static int CHILD_CLOSE                   = 24;
+    const static int MOUSE_MOVE                    = 25;
+    const static int MOUSE_LBDOWN                  = 26;
+    const static int CHANGE_LANGUAGE               = 27;
+    const static int LAST_VIEW_CLOSE               = 28;
+    const static int CHANGED_REMOTECONTROL         = 29;
+    const static int DELETE_SELECTED_TIMER         = 30;
+    const static int CHANGED_DEVICEOPTIONS         = 31;
+    const static int TELETEXTUPDATE                = 32;
+    const static int TELETEXTUPDATEFIRSTLINE       = 33;
+    const static int SUBTITLE_CHANGE_CHANNEL       = 34;
+    const static int MOUSE_SCROLL                  = 35;
+    const static int NEW_PICTURE                   = 36;
+    const static int NEW_PICTURE_STATIC            = 37;
+    const static int REDRAW                        = 38;
+    const static int SHUTDOWN                      = 39;
 
 };
 
index 9e60663e8f22514ef4a9b1e424da20c5534f1b19..a53df8395990709ce9113bf4ea86ae39192a2536 100644 (file)
@@ -1448,7 +1448,7 @@ unsigned int OsdOpenVG::handleOpenVGCommand(OpenVGCommand& command)
       if (info->lindex & 0xffffffff) static_image = false;
 
       Message* m = new  Message();
-      // We have a pictures! send a message to ourself, to switch to gui thread
+      // We have a pictures! send a message to ourself, to switch to gui thread    // FIXME MQSUB
       m->from = this;
       m->p_to = Message::CONTROL;
       m->data = reinterpret_cast<void*>(handle);