From 520620d4bac227e9481398b34b294f58f386dc0d Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Mon, 27 Sep 2021 15:48:36 +0100 Subject: [PATCH] OsdVector sends messages to itself now rather than through Control --- control.cc | 16 ---------------- osdopenvg.cc | 7 ++----- osdvector.cc | 25 +++++++++++++++++++++++++ osdvector.h | 5 ++++- osdwinvector.cc | 4 ++-- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/control.cc b/control.cc index c5ea164..5e9ce2f 100644 --- a/control.cc +++ b/control.cc @@ -484,22 +484,6 @@ void Control::dispatchMessage(Message* m) break; } - case Message::NEW_PICTURE: - { - // FIXME MQSUB - - //Log::getInstance()->log("Control", Log::DEBUG, "TVMedia NEW_PICTURE"); - OsdVector* osdv = dynamic_cast(Osd::getInstance()); - if (osdv) osdv->informPicture(m->tag, reinterpret_cast(m->data)); - break; - } - case Message::NEW_PICTURE_STATIC: - { - //Log::getInstance()->log("Control", Log::DEBUG, "TVMedia NEW_PICTURE %x %x",m->tag,m->parameter); - OsdVector* osdv = dynamic_cast(Osd::getInstance()); - if (osdv) osdv->informPicture(static_cast(m->tag) << 32LL, reinterpret_cast(m->data)); - break; - } } } else if (m->p_to == Message::BOXSTACK) diff --git a/osdopenvg.cc b/osdopenvg.cc index a53df83..8717d4e 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -26,7 +26,6 @@ #include "log.h" #include "videoomx.h" #include "surface.h" -#include "message.h" #include "messagequeue.h" #include "teletxt/txtfont.h" @@ -1450,7 +1449,7 @@ unsigned int OsdOpenVG::handleOpenVGCommand(OpenVGCommand& command) Message* m = new Message(); // 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->to = this; m->data = reinterpret_cast(handle); if (!static_image) @@ -1463,7 +1462,6 @@ unsigned int OsdOpenVG::handleOpenVGCommand(OpenVGCommand& command) m->message = Message::NEW_PICTURE_STATIC; m->tag = info->lindex >> 32LL; } - MessageQueue::getInstance()->postMessage(m); // inform control about new picture delete info; @@ -1495,7 +1493,7 @@ unsigned int OsdOpenVG::handleOpenVGCommand(OpenVGCommand& command) Message* m = new Message(); m->from = this; - m->p_to = Message::CONTROL; + m->to = this; m->data = reinterpret_cast(info->handle); if (!static_image) @@ -1508,7 +1506,6 @@ unsigned int OsdOpenVG::handleOpenVGCommand(OpenVGCommand& command) m->message = Message::NEW_PICTURE_STATIC; m->tag = info->lindex >> 32LL; } - MessageQueue::getInstance()->postMessage(m); // inform command about new picture delete info; diff --git a/osdvector.cc b/osdvector.cc index cd86d35..57621a7 100644 --- a/osdvector.cc +++ b/osdvector.cc @@ -120,6 +120,12 @@ OsdVector::OsdVector() #ifdef PICTURE_DECODER_MAGICK reader.addDecoder(new MagickDecoder(&reader)); #endif + MessageQueue::getInstance()->addReceiver(this); +} + +OsdVector::~OsdVector() +{ + MessageQueue::getInstance()->removeReceiver(this); } bool OsdVector::screenShot(const char* fileName) @@ -812,6 +818,25 @@ void OsdVector::informPicture(LoadIndex index, ImageIndex imageIndex) surfaces_mutex.unlock(); } +void OsdVector::processMessage(Message* m) +{ + switch(m->message) + { + case Message::NEW_PICTURE: + { + //LogNT::getInstance()->debug(TAG, "TVMedia NEW_PICTURE"); + informPicture(m->tag, reinterpret_cast(m->data)); + break; + } + case Message::NEW_PICTURE_STATIC: + { + //LogNT::getInstance()->debug(TAG, "TVMedia NEW_PICTURE {:#x} {:#x}", m->tag, m->parameter); + informPicture(static_cast(m->tag) << 32LL, reinterpret_cast(m->data)); + break; + } + } +} + /* ImageIndex OsdVector::getJpegRef(const char* fileName, int *width,int *height) { diff --git a/osdvector.h b/osdvector.h index 34b6223..d9aa510 100644 --- a/osdvector.h +++ b/osdvector.h @@ -29,6 +29,7 @@ #include #include "defines.h" +#include "messagequeue.h" #include "threadsystem.h" #include "osd.h" #include "colour.h" @@ -207,10 +208,11 @@ struct SurfaceInfo float x, y, w, h; }; -class OsdVector : public Osd +class OsdVector : public Osd, public MessageReceiver { public: OsdVector(); + virtual ~OsdVector(); int restore(); @@ -247,6 +249,7 @@ class OsdVector : public Osd // should be only called from control thread void informPicture(LoadIndex index, ImageIndex i_index); + void processMessage(Message* m); int charSet() {return 2;}; //UTF-8 diff --git a/osdwinvector.cc b/osdwinvector.cc index 1f60b9e..46b166b 100644 --- a/osdwinvector.cc +++ b/osdwinvector.cc @@ -1237,10 +1237,10 @@ void OsdWinVector::createPicture(struct PictureInfo& pict_inf) bool static_image = true; if (pict_inf.lindex & 0xffffffff) static_image = false; - Message* m = new Message(); + Message* m = new Message(); // We have a pictures! send a message to ourself, to switch to gui thread m->from = this; - m->p_to = Message::CONTROL; + m->to = this; m->data = pict_inf.reference; if (!static_image) { m->message = Message::NEW_PICTURE; -- 2.39.2