]> git.vomp.tv Git - vompclient.git/commitdiff
Bug fix: Prevent vector handle ref counts going negative
authorChris Tallon <chris@vomp.tv>
Wed, 24 Nov 2021 16:42:03 +0000 (16:42 +0000)
committerChris Tallon <chris@vomp.tv>
Wed, 24 Nov 2021 16:42:03 +0000 (16:42 +0000)
Disable function OsdVector::getImageRef
Rename LoadIndex LoadingIndex
Rename images_ref vhi_refcounts
Reorganise osdvector.h to identify things private to that class

imageomx.cc
imageomx.h
imageomx2.cc
imageomx2.h
osdvector.cc
osdvector.h
osdwinvector.cc
surfacevector.cc

index 23a5784132bd3ebbda029e17121eaadfec987dab..6be066e03616150d1ad712daa7e96ebab1f1fa7c 100644 (file)
@@ -258,7 +258,7 @@ int ImageOMX::AllocateCodecsOMX(unsigned char * buffer, unsigned int length)
 
 
 
-unsigned char* ImageOMX::decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length, bool freemem)
+unsigned char* ImageOMX::decodePicture(LoadingIndex index, unsigned char * buffer, unsigned int length, bool freemem)
 {
        if (pictInfValid) return buffer; // does support only one image at a Time;
 //     LogNT::getInstance()->debug(TAG,
@@ -297,7 +297,7 @@ unsigned char* ImageOMX::decodePicture(LoadIndex index, unsigned char * buffer,
 }
 
 
-bool ImageOMX::intDecodePicture(LoadIndex index, unsigned char* /* buffer */, unsigned int length, EGLPictureCreator* pictcreat, VideoOMX *video)
+bool ImageOMX::intDecodePicture(LoadingIndex index, unsigned char* /* buffer */, unsigned int length, EGLPictureCreator* pictcreat, VideoOMX *video)
 {
        static OMX_CALLBACKTYPE callbacks= {&VideoOMX::EventHandler_OMX,&EmptyBufferDone_OMX,&FillBufferDone_OMX};
 
index e2df77f288f7cb916cd407e0326a8781b5abfa00..ce722aab5509f5bdbb0e9f16e497ba00af81f62b 100644 (file)
@@ -47,7 +47,7 @@ class ImageOMX : public OsdVector::PictureDecoder
     void init();
     void shutdown();
 
-    unsigned char* decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length, bool freemem);
+    unsigned char* decodePicture(LoadingIndex index, unsigned char * buffer, unsigned int length, bool freemem);
     bool getDecodedPicture(struct OsdVector::PictureInfo& pict_inf);
     void freeReference(void * ref);
 
@@ -57,7 +57,7 @@ class ImageOMX : public OsdVector::PictureDecoder
     static OMX_ERRORTYPE FillBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp, OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* bulibaver);
 
 
-    bool intDecodePicture(LoadIndex index, unsigned char * buffer, unsigned int length, EGLPictureCreator* egl_pict, VideoOMX *video);
+    bool intDecodePicture(LoadingIndex index, unsigned char * buffer, unsigned int length, EGLPictureCreator* egl_pict, VideoOMX *video);
 
     void ReturnEmptyOMXBuffer(OMX_BUFFERHEADERTYPE* bulibaver);
     void ReturnFillOMXBuffer(OMX_BUFFERHEADERTYPE* buffer);
index 7eaffdb800d6e84f3b69483ca292f4a3938d6cdf..2601bdfd0b8b04376a52362c0f161fe9b72895dc 100644 (file)
@@ -73,7 +73,7 @@ void ImageOMX2::reinit()
   init();
 }
 
-unsigned char* ImageOMX2::decodePicture(LoadIndex index, unsigned char* buffer, unsigned int length, bool freemem) noexcept
+unsigned char* ImageOMX2::decodePicture(LoadingIndex index, unsigned char* buffer, unsigned int length, bool freemem) noexcept
 {
   // This function needs to return NULL if successful, buffer if not.
 
index 8f8fb63305ef77f9e9e76eed599f59f6d4e7c92e..ef85a755caf381ea45ce8d0d84854a9d575c47bd 100644 (file)
@@ -64,7 +64,7 @@ class ImageOMX2 : public OsdVector::PictureDecoder
     void init();
     void shutdown();
 
-    unsigned char* decodePicture(LoadIndex index, unsigned char* buffer, unsigned int length, bool freemem) noexcept;
+    unsigned char* decodePicture(LoadingIndex index, unsigned char* buffer, unsigned int length, bool freemem) noexcept;
     bool getDecodedPicture(struct OsdVector::PictureInfo& pict_inf);
     void freeReference(void*) {};
 
index e34fac5c7bbd1573b1e152a42ad3f935b1ebb23c..e7311ed82b9bfa10fd737122a94b4a0fd496cdd7 100644 (file)
@@ -41,7 +41,7 @@ class MagickDecoder: public OsdVector::PictureDecoder
   public:
     MagickDecoder(OsdVector::PictureReader* treader): OsdVector::PictureDecoder(treader) {pictInfValid = false;};
 
-    unsigned char* decodePicture(LoadIndex index, unsigned char* buffer, unsigned int length, bool freemem);
+    unsigned char* decodePicture(LoadingIndex index, unsigned char* buffer, unsigned int length, bool freemem);
 
     bool getDecodedPicture( struct OsdVector::PictureInfo& pict_inf);
 
@@ -52,7 +52,7 @@ class MagickDecoder: public OsdVector::PictureDecoder
     bool pictInfValid;
 };
 
-unsigned char* MagickDecoder::decodePicture(LoadIndex index, unsigned char* buffer, unsigned int length, bool freemem)
+unsigned char* MagickDecoder::decodePicture(LoadingIndex index, unsigned char* buffer, unsigned int length, bool freemem)
 {
   if (pictInfValid) return buffer; // does support only one image at a Time;
 
@@ -172,7 +172,7 @@ Surface* OsdVector::createNewSurface()
 
 void OsdVector::Blank()
 {
-  // do nothing? remove this one?
+  // FIXME do nothing? remove this one?
 }
 
 int OsdVector::restore()
@@ -188,7 +188,7 @@ int OsdVector::restore()
   }
 
   //also clear all handles, they are now invalid, no need to release them
-  images_ref.clear();
+  vhi_refcounts.clear();
   monobitmaps.clear();
   //jpegs.clear();
   drawstyleHandles.clear();
@@ -258,14 +258,14 @@ void OsdVector::drawSurfaces()
       // update any images loaded in the mean time
       if ((*commands).instr == DrawImageLoading)
       {
-        LoadIndex loadindex = (*commands).target.loadindex;
+        LoadingIndex loadindex = (*commands).target.loadindex;
 
         if (tvmedias_loaded.find(loadindex) != tvmedias_loaded.end())
         {
           (*commands).instr = DrawImage;
           (*commands).target.image = tvmedias_loaded[loadindex];;
           incImageRef((*commands).target.image);
-          removeLoadIndexRef(loadindex);
+          removeLoadingIndexRef(loadindex);
         }
 
       }
@@ -325,14 +325,14 @@ void OsdVector::updateOrAddSurface(const SurfaceVector* surf, float x, float y,
   {
     if (command.instr == DrawImageLoading)
     {
-      LoadIndex loadindex = command.target.loadindex;
+      LoadingIndex loadindex = command.target.loadindex;
 
       if (tvmedias_loaded.find(loadindex) != tvmedias_loaded.end())
       {
         command.instr = DrawImage;
         command.target.image = tvmedias_loaded[loadindex];
         incImageRef(command.target.image);
-        removeLoadIndexRef(loadindex);
+        removeLoadingIndexRef(loadindex);
       }
     }
   }
@@ -379,8 +379,8 @@ void OsdVector::decrementAllRefCounts(std::vector<SVGCommand>& commands)
     VectorHandleImage imageHandle = command.getImageHandle();
     if (imageHandle) removeImageRef(imageHandle);
 
-    LoadIndex li = command.getLoadIndex();
-    if (li) removeLoadIndexRef(li);
+    LoadingIndex li = command.getLoadingIndex();
+    if (li) removeLoadingIndexRef(li);
   }
 }
 
@@ -395,29 +395,29 @@ void OsdVector::incrementAllRefCounts(std::vector<SVGCommand>& commands)
     VectorHandleImage imageHandle = command.getImageHandle();
     if (imageHandle) incImageRef(imageHandle);
 
-    LoadIndex li = command.getLoadIndex();
-    if (li) incLoadIndexRef(li);
+    LoadingIndex li = command.getLoadingIndex();
+    if (li) incLoadingIndexRef(li);
   }
 }
 
 void OsdVector::incImageRef(VectorHandleImage handle)
 {
-  if (images_ref.find(handle) == images_ref.end())
+  if (vhi_refcounts.find(handle) == vhi_refcounts.end())
   {
-    images_ref[handle] = 1;
+    vhi_refcounts[handle] = 1;
   }
   else
   {
-    images_ref[handle]++;
+    vhi_refcounts[handle]++;
   }
 }
 
 void OsdVector::removeImageRef(const VectorHandleImage handle)
 {
-  images_ref[handle]--;
+  vhi_refcounts[handle]--;
 }
 
-int OsdVector::getLoadIndexRef(LoadIndex index)
+int OsdVector::getLoadingIndexRef(LoadingIndex index)
 {
   surfaces_mutex.lock();
 
@@ -433,7 +433,7 @@ int OsdVector::getLoadIndexRef(LoadIndex index)
   surfaces_mutex.unlock();
 }
 
-void OsdVector::incLoadIndexRef(LoadIndex index)
+void OsdVector::incLoadingIndexRef(LoadingIndex index)
 {
   if (loadindex_ref.find(index) == loadindex_ref.end())
   {
@@ -445,18 +445,23 @@ void OsdVector::incLoadIndexRef(LoadIndex index)
   }
 }
 
-void OsdVector::removeLoadIndexRef(const LoadIndex ref)
+void OsdVector::removeLoadingIndexRef(const LoadingIndex ref)
 {
   loadindex_ref[ref]--;
 
   if (loadindex_ref[ref] == 0)
   {
     //now check, if it is already loaded
-    std::map<LoadIndex, VectorHandleImage>::iterator itty = tvmedias_loaded.find(ref);
+    std::map<LoadingIndex, VectorHandleImage>::iterator itty = tvmedias_loaded.find(ref);
 
     if ( itty != tvmedias_loaded.end())
     {
-      removeImageRef((*itty).second); // remove lock
+      // removeImageRef((*itty).second); // remove lock
+      /*
+       * I'm not sure exactly how all this works but removing this line of code prevents
+       * reference counts in vhi_refcounts from going negative. Therefore I suspect the above
+       * line is wrong. Will test for a while.
+       */
     }
 
     tvmedias_loaded.erase(ref);
@@ -464,7 +469,7 @@ void OsdVector::removeLoadIndexRef(const LoadIndex ref)
     tvmedias_load.erase(tvmedias_load_inv[ref]);
     tvmedias_load_inv.erase(ref);
 
-    reader.invalidateLoadIndex(ref);
+    reader.invalidateLoadingIndex(ref);
   }
 }
 
@@ -476,14 +481,14 @@ void OsdVector::cleanupOrphanedRefs()
 
   while (mitty != monobitmaps.end())
   {
-    std::map<VectorHandleImage, int>::iterator curitty = images_ref.find((*mitty).second);
+    std::map<VectorHandleImage, int>::iterator curitty = vhi_refcounts.find((*mitty).second);
     int count = (*curitty).second;
 
     if (count == 0)
     {
       VectorHandleImage handle = (*curitty).first;
       monobitmaps.erase(mitty++);
-      images_ref.erase(curitty++);
+      vhi_refcounts.erase(curitty++);
       destroyImageRef(handle);
     }
     else ++mitty;
@@ -491,12 +496,12 @@ void OsdVector::cleanupOrphanedRefs()
 
   /*map<string,VectorHandleImage>::iterator jitty=jpegs.begin();
   while (jitty!=jpegs.end()) {
-       map<VectorHandleImage,int>::iterator curitty=images_ref.find((*jitty).second);
+       map<VectorHandleImage,int>::iterator curitty=vhi_refcounts.find((*jitty).second);
        int count=(*curitty).second;
        if (count==0) {
                VectorHandleImage handle=(*curitty).first;
                jpegs.erase(jitty++);
-               images_ref.erase(curitty++);
+               vhi_refcounts.erase(curitty++);
                destroyImageRef(handle);
        } else ++jitty;
   }*/
@@ -505,25 +510,25 @@ void OsdVector::cleanupOrphanedRefs()
 
   while (titty != tvmedias.end())
   {
-    std::map<VectorHandleImage, int>::iterator curitty = images_ref.find((*titty).second);
+    std::map<VectorHandleImage, int>::iterator curitty = vhi_refcounts.find((*titty).second);
     int count = (*curitty).second;
 
     if (count == 0)
     {
       VectorHandleImage handle = (*curitty).first;
       tvmedias.erase(titty++);
-      images_ref.erase(curitty);
+      vhi_refcounts.erase(curitty);
       destroyImageRef(handle);
     }
     else ++titty;
   }
 
 
-  std::map<TVMediaInfo, LoadIndex>::iterator litty = tvmedias_load.begin();
+  std::map<TVMediaInfo, LoadingIndex>::iterator litty = tvmedias_load.begin();
 
   while (litty != tvmedias_load.end())
   {
-    std::map<LoadIndex, int>::iterator curitty = loadindex_ref.find((*litty).second);
+    std::map<LoadingIndex, int>::iterator curitty = loadindex_ref.find((*litty).second);
     int count = (*curitty).second;
 
     if (count == 0)
@@ -539,29 +544,29 @@ void OsdVector::cleanupOrphanedRefs()
 
   while (pitty != palettepics.end())
   {
-    std::map<VectorHandleImage, int>::iterator curitty = images_ref.find((*pitty));
+    std::map<VectorHandleImage, int>::iterator curitty = vhi_refcounts.find((*pitty));
     int count = (*curitty).second;
 
     if (count == 0)
     {
       VectorHandleImage handle = (*curitty).first;
       palettepics.erase(pitty++);
-      images_ref.erase(curitty++);
+      vhi_refcounts.erase(curitty++);
       destroyImageRef(handle);
     }
     else ++pitty;
   }
 
-  std::map<VectorHandleImage, int>::iterator citty = images_ref.begin();
+  std::map<VectorHandleImage, int>::iterator citty = vhi_refcounts.begin();
 
-  while (citty != images_ref.end())
+  while (citty != vhi_refcounts.end())
   {
     int count = (*citty).second;
 
     if (count == 0)
     {
       VectorHandleImage handle = (*citty).first;
-      images_ref.erase(citty++);
+      vhi_refcounts.erase(citty++);
       destroyImageRef(handle);
     }
     else ++citty;
@@ -589,21 +594,21 @@ void OsdVector::cleanupOrphanedRefs()
   }
 }
 
-int OsdVector::getImageRef(VectorHandleImage handle)
-{
-  surfaces_mutex.lock();
-
-  if (images_ref.find(handle) == images_ref.end())
-  {
-    return -1;
-  }
-  else
-  {
-    return images_ref[handle];
-  }
-
-  surfaces_mutex.unlock();
-}
+//int OsdVector::getImageRef(VectorHandleImage handle)
+//{
+//  surfaces_mutex.lock();
+//
+//  if (vhi_refcounts.find(handle) == vhi_refcounts.end())
+//  {
+//    return -1;
+//  }
+//  else
+//  {
+//    return vhi_refcounts[handle];
+//  }
+//
+//  surfaces_mutex.unlock();
+//}
 
 void OsdVector::incrementDrawStyleHandleRefCount(VectorHandle index)
 {
@@ -705,21 +710,21 @@ void OsdVector::dumpStyles()
 }
 #endif
 
-LoadIndex OsdVector::getTVMediaRef(TVMediaInfo& tvmedia, VectorHandleImage& handle)
+LoadingIndex OsdVector::getTVMediaRef(TVMediaInfo& tvmedia, VectorHandleImage& handle)
 {
   VectorHandleImage localHandle = 0;
-  LoadIndex loadindex = 0;
+  LoadingIndex loadindex = 0;
   surfaces_mutex.lock();
 
   if (tvmedias.find(tvmedia) == tvmedias.end())   // if not found, return a loadIndex from loadTVMedia(tvmedia)
   {
     loadindex = loadTVMedia(tvmedia);
   }
-  else   // if found, return a real imageIndex. incImageRef(localHandle). EXCEPT: If it's not found in images_ref (???) in which case do same as above.
+  else   // if found, return a real imageIndex. incImageRef(localHandle). EXCEPT: If it's not found in vhi_refcounts (???) in which case do same as above.
   {
     localHandle = tvmedias[tvmedia];
 
-    if (images_ref.find(localHandle) == images_ref.end())
+    if (vhi_refcounts.find(localHandle) == vhi_refcounts.end())
     {
       //invalid handle recreate
       loadindex = loadTVMedia(tvmedia);
@@ -738,9 +743,9 @@ LoadIndex OsdVector::getTVMediaRef(TVMediaInfo& tvmedia, VectorHandleImage& hand
   return loadindex;
 }
 
-LoadIndex OsdVector::loadTVMedia(TVMediaInfo& tvmedia)          // insert a tvmedia for loading
+LoadingIndex OsdVector::loadTVMedia(TVMediaInfo& tvmedia)          // insert a tvmedia for loading
 {
-  LoadIndex index = 0;
+  LoadingIndex index = 0;
 
   if (tvmedias_load.find(tvmedia) == tvmedias_load.end())        // if not found in tvmedias_load
   {
@@ -782,12 +787,12 @@ LoadIndex OsdVector::loadTVMedia(TVMediaInfo& tvmedia)          // insert a tvme
     index = tvmedias_load[tvmedia];
   }
 
-  incLoadIndexRef(index);
+  incLoadingIndexRef(index);
 
   return index;
 }
 
-void OsdVector::informPicture(LoadIndex index, VectorHandleImage handle)
+void OsdVector::informPicture(LoadingIndex index, VectorHandleImage handle)
 {
   //Beware for thread safety
   VectorHandleImage localHandle = 0;
@@ -798,17 +803,17 @@ void OsdVector::informPicture(LoadIndex index, VectorHandleImage handle)
 
   if (handle)
   {
-    std::map<LoadIndex, int>::iterator itty = loadindex_ref.find(index);
+    std::map<LoadingIndex, int>::iterator itty = loadindex_ref.find(index);
     localHandle = tvmedias[tvmedia] = handle;
     tvmedias_loaded[index] = localHandle;
 
     if (itty == loadindex_ref.end() || (*itty).second == 0)
     {
       // we do not want the picture anymore . Really...
-      // fill images_ref in to not irritate the garbage collector
-      if (images_ref.find(localHandle) == images_ref.end())
+      // fill vhi_refcounts in to not irritate the garbage collector
+      if (vhi_refcounts.find(localHandle) == vhi_refcounts.end())
       {
-        images_ref[localHandle] = 0;
+        vhi_refcounts[localHandle] = 0;
       }
     }
     else
@@ -854,7 +859,7 @@ VectorHandleImage OsdVector::getJpegRef(const char* fileName, int *width,int *he
                image_handle=jpegs[fileName];
                *width=0;
                *height=0;
-               if (images_ref.find(image_handle)==images_ref.end()) {
+               if (vhi_refcounts.find(image_handle)==vhi_refcounts.end()) {
                        //invalid handle recreate
                        image_handle=jpegs[fileName]=createJpeg(fileName,width,height);
                }
@@ -880,7 +885,7 @@ VectorHandleImage OsdVector::getMonoBitmapRef(void* base, int width, int height)
   {
     image_handle = monobitmaps[base];
 
-    if (images_ref.find(image_handle) == images_ref.end())
+    if (vhi_refcounts.find(image_handle) == vhi_refcounts.end())
     {
       //invalid handle recreate
       surfaces_mutex.unlock();
@@ -1035,7 +1040,7 @@ void OsdVector::PictureReader::threadMethod()
   }
 }
 
-void OsdVector::PictureReader::invalidateLoadIndex(LoadIndex index)
+void OsdVector::PictureReader::invalidateLoadingIndex(LoadingIndex index)
 {
   pict_lock_incoming.lock();
   invalid_loadindex.insert(index);
@@ -1047,7 +1052,7 @@ void OsdVector::PictureReader::invalidateLoadIndex(LoadIndex index)
   // Doesn't look like it, but if it does get the 4 lines below
 }
 
-void OsdVector::PictureReader::informFallback(LoadIndex index, int fallback)
+void OsdVector::PictureReader::informFallback(LoadingIndex index, int fallback)
 {
   pict_lock_incoming.lock();
   inform_fallback[index] = fallback;
@@ -1096,7 +1101,7 @@ bool OsdVector::PictureReader::processReceivedPictures()
   {
     VDR_ResponsePacket* vresp = pict_incoming.front();
     pict_incoming.pop();
-    std::set<LoadIndex>::iterator setpos = invalid_loadindex.find(vresp->getStreamID());
+    std::set<LoadingIndex>::iterator setpos = invalid_loadindex.find(vresp->getStreamID());
 
     if (setpos != invalid_loadindex.end())
     {
@@ -1178,7 +1183,7 @@ bool OsdVector::PictureReader::processReceivedPictures()
   {
     unsigned int static_id = pict_incoming_static.front();
     pict_incoming_static.pop();
-    std::set<LoadIndex>::iterator setpos = invalid_loadindex.find(((long long) static_id) << 32LL);
+    std::set<LoadingIndex>::iterator setpos = invalid_loadindex.find(((long long) static_id) << 32LL);
 
     if (setpos != invalid_loadindex.end())
     {
index 4b7ae5fb8b40a5f25a887c4ae2286c668d0598e6..b3b20cc77b7f4f0ed4c5e90197ae277807ae0053 100644 (file)
@@ -71,7 +71,7 @@ enum Corner
 };
 
 typedef VectorHandle VectorHandleImage;
-typedef unsigned long long LoadIndex;
+typedef unsigned long long LoadingIndex;
 
 class SVGCommand
 {
@@ -89,7 +89,7 @@ class SVGCommand
       return nc;
     };
 
-    inline static SVGCommand PaintImageLoading(LoadIndex load_in, float ix, float iy, float iw, float ih, Corner corner = TopLeft)
+    inline static SVGCommand PaintImageLoading(LoadingIndex load_in, float ix, float iy, float iw, float ih, Corner corner = TopLeft)
     {
       SVGCommand nc;
       nc.instr = DrawImageLoading;
@@ -181,7 +181,7 @@ class SVGCommand
       else return target.image;
     };
 
-    LoadIndex getLoadIndex()
+    LoadingIndex getLoadingIndex()
     {
       if (instr != DrawImageLoading) return 0;
       else return target.loadindex;
@@ -197,7 +197,7 @@ class SVGCommand
       wchar_t textchar;
       VectorHandleImage image;
       unsigned int ttchar;
-      LoadIndex loadindex;
+      LoadingIndex loadindex;
     } target;
 };
 
@@ -234,24 +234,24 @@ class OsdVector : public Osd, public MessageReceiver
     virtual float getFontHeight() = 0;
     virtual float getCharWidth(wchar_t c) = 0;
     float* getCharWidthArray() {return byte_char_width;};
-
-    //virtual VectorHandleImage getJpegRef(const char* fileName, int *width,int *height);
-    virtual LoadIndex getTVMediaRef(TVMediaInfo& tvmedia, VectorHandleImage& handle);
-    virtual VectorHandleImage getMonoBitmapRef(void* base, int width, int height);
-    virtual VectorHandleImage getImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data);
-
+    virtual void getScreenSize(int& width, int& height) = 0;
+    virtual void getRealScreenSize(int& width, int& height) = 0;
 
     virtual bool getStaticImageData(unsigned int static_id, UCHAR** userdata, ULONG* length) = 0;
 
+    // Used only by OsdVector and SurfaceVector
     void removeImageRef(const VectorHandleImage ref);
-    void removeLoadIndexRef(const LoadIndex ref);
+    void removeLoadingIndexRef(const LoadingIndex ref);
     VectorHandle getDrawStyleHandle(const DrawStyle& c);
-    virtual void decrementDrawStyleHandleRefCount(VectorHandle ref);
-    virtual void getScreenSize(int& width, int& height) = 0;
-    virtual void getRealScreenSize(int& width, int& height) = 0;
+    void decrementDrawStyleHandleRefCount(VectorHandle ref);
+    LoadingIndex getTVMediaRef(TVMediaInfo& tvmedia, VectorHandleImage& handle);
+    //virtual VectorHandleImage getJpegRef(const char* fileName, int *width,int *height);
+    virtual VectorHandleImage getMonoBitmapRef(void* base, int width, int height);
+    virtual VectorHandleImage getImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data);
+
 
     // should be only called from control thread
-    void informPicture(LoadIndex index, VectorHandleImage handle);
+    void informPicture(LoadingIndex index, VectorHandleImage handle);
     void processMessage(Message* m);
 
 
@@ -270,7 +270,7 @@ class OsdVector : public Osd, public MessageReceiver
       PictType type;
       ULONG width;
       ULONG height;
-      LoadIndex lindex;
+      LoadingIndex lindex;
       union
       {
         const void* image;
@@ -290,7 +290,7 @@ class OsdVector : public Osd, public MessageReceiver
         virtual ~PictureDecoder() {};
 
         // its is always guaranted, that after getDecodedPicture a call to decodePicture follows, if the return value was true;
-        virtual unsigned char* decodePicture(LoadIndex index, unsigned char* buffer, unsigned int length, bool freemem = true) = 0;
+        virtual unsigned char* decodePicture(LoadingIndex index, unsigned char* buffer, unsigned int length, bool freemem = true) = 0;
 
         virtual bool getDecodedPicture(struct PictureInfo& pict_inf) = 0;
         virtual void freeReference(void* ref) = 0;
@@ -316,8 +316,8 @@ class OsdVector : public Osd, public MessageReceiver
         void receivePicture(VDR_ResponsePacket* vresp);
 
         void addStaticImage(unsigned int id);
-        void invalidateLoadIndex(LoadIndex index);
-        void informFallback(LoadIndex index, int fallback);
+        void invalidateLoadingIndex(LoadingIndex index);
+        void informFallback(LoadingIndex index, int fallback);
 
       protected:
 
@@ -333,8 +333,8 @@ class OsdVector : public Osd, public MessageReceiver
         std::queue<VDR_ResponsePacket*> pict_incoming;
         std::queue<unsigned int> pict_incoming_static;
         std::list<PictureDecoder*> decoders;
-        std::map<LoadIndex, int> inform_fallback;
-        std::set<LoadIndex> invalid_loadindex;
+        std::map<LoadingIndex, int> inform_fallback;
+        std::set<LoadingIndex> invalid_loadindex;
 
         bool picture_update;
     };
@@ -346,53 +346,16 @@ class OsdVector : public Osd, public MessageReceiver
 
     PictureReader reader;
 
-    std::map<VectorHandleImage, int> images_ref;
-    std::map<void*, VectorHandleImage> monobitmaps;
-    //map<string,VectorHandleImage> jpegs;
-    std::map<TVMediaInfo, VectorHandleImage> tvmedias;
-    std::list<VectorHandleImage> palettepics;
-    std::map<LoadIndex, int> loadindex_ref;
-    std::map<TVMediaInfo, LoadIndex> tvmedias_load;
-    std::map<LoadIndex, TVMediaInfo> tvmedias_load_inv;
-    std::map<LoadIndex, VectorHandleImage> tvmedias_loaded;
-
-    std::map<DrawStyle, VectorHandle> drawstyleHandles;
-    std::map<DrawStyle, VectorHandle>::iterator drawstyleHandles_lastit;
-    bool drawstyleHandles_lastit_valid{};
-
-    std::map<VectorHandle, int> drawstyleHandlesRefCounts;
-    std::map<VectorHandle, int>::iterator drawstyleHandlesRefCounts_lastit;
-    bool drawstyleHandlesRefCounts_lastit_valid{};
-
-    std::list<SurfaceInfo> surfaces;
-    using SurfacesIterator = std::list<SurfaceInfo>::iterator;
-
-    std::mutex surfaces_mutex;
-
     float byte_char_width[256]{};
 
-    void incImageRef(VectorHandleImage handle);
-    int getImageRef(VectorHandleImage handle);
-    virtual void destroyImageRef(VectorHandleImage handle) = 0;
-    void incLoadIndexRef(LoadIndex index);
-    int getLoadIndexRef(LoadIndex index);
 
+    virtual void destroyImageRef(VectorHandleImage handle) = 0;
     //virtual VectorHandleImage createJpeg(const char* fileName, int *width,int *height)=0;
     virtual VectorHandleImage createMonoBitmap(void* base, int width, int height) = 0;
     virtual VectorHandleImage createImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data) = 0;
     virtual void createPicture(struct PictureInfo& pict_inf) = 0;
-
-    virtual LoadIndex loadTVMedia(TVMediaInfo& tvmedia);
-
     virtual VectorHandle createDrawStyleHandle(const DrawStyle& c) = 0;
-    void incrementDrawStyleHandleRefCount(VectorHandle index);
     virtual void destroyDrawStyleHandle(VectorHandle index) = 0;
-
-
-    void decrementAllRefCounts(std::vector<SVGCommand>& commands);
-    void incrementAllRefCounts(std::vector<SVGCommand>& commands);
-    void cleanupOrphanedRefs();
-
     virtual void drawSetTrans(SurfaceInfo& sc) = 0;
     virtual void executeDrawCommand(SVGCommand& command) = 0;
 
@@ -401,6 +364,51 @@ class OsdVector : public Osd, public MessageReceiver
     #if DEV
     void dumpStyles();
     #endif
+
+  // See what we can make private in OsdVector
+  private:
+
+    // Methods that only seem to be called internally
+    void incImageRef(VectorHandleImage handle);
+    void incLoadingIndexRef(LoadingIndex index);
+    int getLoadingIndexRef(LoadingIndex index);
+    void decrementAllRefCounts(std::vector<SVGCommand>& commands);
+    void incrementAllRefCounts(std::vector<SVGCommand>& commands);
+    void cleanupOrphanedRefs();
+    void incrementDrawStyleHandleRefCount(VectorHandle index);
+    LoadingIndex loadTVMedia(TVMediaInfo& tvmedia);
+
+    // int getImageRef(VectorHandleImage handle); // Not used anywhere
+
+
+
+    // All the below are data structures only touched by this base class OsdVector
+
+    std::map<TVMediaInfo, VectorHandleImage> tvmedias;
+    std::map<void*, VectorHandleImage> monobitmaps;
+    //map<string,VectorHandleImage> jpegs;
+    std::list<VectorHandleImage> palettepics;
+
+    std::map<VectorHandleImage, int> vhi_refcounts;   // This appears to cover all 3 (4) of the above types
+
+    std::map<LoadingIndex, int> loadindex_ref;
+    std::map<TVMediaInfo, LoadingIndex> tvmedias_load;
+    std::map<LoadingIndex, TVMediaInfo> tvmedias_load_inv;
+    std::map<LoadingIndex, VectorHandleImage> tvmedias_loaded;
+
+
+    std::map<DrawStyle, VectorHandle> drawstyleHandles;
+    std::map<DrawStyle, VectorHandle>::iterator drawstyleHandles_lastit;
+    bool drawstyleHandles_lastit_valid{};
+
+    std::map<VectorHandle, int> drawstyleHandlesRefCounts;
+    std::map<VectorHandle, int>::iterator drawstyleHandlesRefCounts_lastit;
+    bool drawstyleHandlesRefCounts_lastit_valid{};
+
+    std::list<SurfaceInfo> surfaces;
+    using SurfacesIterator = std::list<SurfaceInfo>::iterator;
+    std::mutex surfaces_mutex;
+
 };
 
 #endif
index 51504eb9e6076d8f2dc0a62b7d806ff1bdeb23d3..67de968071f31cf4ccad658f2e77fd5d550633e3 100644 (file)
@@ -51,7 +51,7 @@ public:
        WICPictDecoder(OsdVector::PictureReader* treader, OsdWinVector *posd);
        virtual ~WICPictDecoder();
 
-       unsigned char *decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length, bool freemem);
+       unsigned char *decodePicture(LoadingIndex index, unsigned char * buffer, unsigned int length, bool freemem);
 
        bool getDecodedPicture(struct OsdVector::PictureInfo& pict_inf);
 
@@ -80,7 +80,7 @@ WICPictDecoder::~WICPictDecoder()
        wicfactory->Release();
 }
 
-unsigned char * WICPictDecoder::decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length, bool freemem)
+unsigned char * WICPictDecoder::decodePicture(LoadingIndex index, unsigned char * buffer, unsigned int length, bool freemem)
 {
        if (pictInfValid) return buffer; // does support only one image at a Time;
        
index 1da632b46ca62b560f15a16a39ac0a602dde0309..ca1c6bad1e52276c7104052ff9de36e6b02825be 100644 (file)
@@ -45,8 +45,8 @@ SurfaceVector::~SurfaceVector()
     VectorHandleImage handle = command.getImageHandle();
     if (handle) osd->removeImageRef(handle);
 
-    LoadIndex li = command.getLoadIndex();
-    if (li) osd->removeLoadIndexRef(li);
+    LoadingIndex li = command.getLoadingIndex();
+    if (li) osd->removeLoadingIndexRef(li);
   }
 }
 
@@ -262,7 +262,7 @@ void SurfaceVector::drawTVMedia(TVMediaInfo& tvmedia, float x, float y, float  w
 {
   command_mutex.lock();
   VectorHandleImage handle = 0;
-  LoadIndex load_index = osd->getTVMediaRef(tvmedia, handle);
+  LoadingIndex load_index = osd->getTVMediaRef(tvmedia, handle);
 
   if (width != 0 && height != 0)
   {
@@ -404,9 +404,9 @@ int SurfaceVector::removeCommands(float x, float y, float width, float height)
 
       if (handle) osd->removeImageRef(handle);
 
-      LoadIndex li = (*itty).getLoadIndex();
+      LoadingIndex li = (*itty).getLoadingIndex();
 
-      if (li) osd->removeLoadIndexRef(li);
+      if (li) osd->removeLoadingIndexRef(li);
 
       if (!remove)
       {