From 2df53abf902c64daf657b8451138a266c2e8f1c9 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Fri, 3 Dec 2021 20:57:04 +0000 Subject: [PATCH] Revert ref-count-negative commit Import comments and dumpImages from 0-6-dev-imagerefs --- osdopenvg.cc | 2 ++ osdvector.cc | 36 +++++++++++++++++++++++++++++++++--- osdvector.h | 2 ++ surfacevector.cc | 3 ++- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/osdopenvg.cc b/osdopenvg.cc index 6c8ddd9..7b6b980 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -512,6 +512,8 @@ void OsdOpenVG::renderLoop() if (ts != 0) { // OSDOVG-ROD-EXPERIMENT + //dumpImages(); + renderThreadCond.wait(ul, [this]{ return renderThreadReq != 0; }); // experiment! always wait, no time limit //renderThreadCond.wait_for(ul, std::chrono::milliseconds(ts), [this]{ return renderThreadReq != 0; }); diff --git a/osdvector.cc b/osdvector.cc index e7311ed..990072c 100644 --- a/osdvector.cc +++ b/osdvector.cc @@ -17,6 +17,8 @@ along with VOMP. If not, see . */ +// FIXME It doesn't seem like the LoadingIndex entries in loadindex_ref ever get deleted + #include "log.h" #include "surfacevector.h" #include "vdr.h" @@ -456,7 +458,10 @@ void OsdVector::removeLoadingIndexRef(const LoadingIndex ref) if ( itty != tvmedias_loaded.end()) { - // removeImageRef((*itty).second); // remove lock + removeImageRef((*itty).second); // remove lock + + /* Update - not this? Re-enabled. */ + /* * 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 @@ -473,6 +478,31 @@ void OsdVector::removeLoadingIndexRef(const LoadingIndex ref) } } +void OsdVector::dumpImages() +{ + // surfaces_mutex.lock(); + + printf("tvmedias.size = %i\n", tvmedias.size()); + + printf("vhi_refcounts\n"); + // std::map vhi_refcounts; + // ImageIndex is a VectorHandle. VectorHandle is an unsigned int + for(auto& a : vhi_refcounts) + { + printf("ImageIndex: %u int: %i\n", a.first, a.second); + } + + printf("loadingindex_ref\n"); + // std::map loadindex_ref; + // LoadingIndex is a unsigned long long + for(auto& a : loadindex_ref) + { + printf("LoadingIndex: %llu (%llu) int: %i\n", a.first, a.first >> 32, a.second); + } + + // surfaces_mutex.unlock(); +} + void OsdVector::cleanupOrphanedRefs() { // Do some garbage collection @@ -986,7 +1016,7 @@ void OsdVector::PictureReader::removeDecoder(PictureDecoder* decoder) itty++; } - LogNT::getInstance()->debug(TAG, "removeDecoder"); + LogNT::getInstance()->debug("PictureReader", "removeDecoder"); decoder->shutdown(); delete decoder; decoders_lock.unlock(); @@ -1117,7 +1147,7 @@ bool OsdVector::PictureReader::processReceivedPictures() return true; } - // LogNT::getInstance()->debug(TAG, "TVMedia Pictures arrived VDR {:#x} {} {}", + // LogNT::getInstance()->debug("PictureReader", "TVMedia Pictures arrived VDR {:#x} {} {}", // vresp->getStreamID(),vresp->getUserDataLength(),vresp->getFlag()); bool decode = false; bool freed = false; diff --git a/osdvector.h b/osdvector.h index b3b20cc..8bf7398 100644 --- a/osdvector.h +++ b/osdvector.h @@ -214,6 +214,8 @@ struct SurfaceInfo class OsdVector : public Osd, public MessageReceiver { public: + void dumpImages(); + OsdVector(); virtual ~OsdVector(); diff --git a/surfacevector.cc b/surfacevector.cc index ca1c6ba..a01bbad 100644 --- a/surfacevector.cc +++ b/surfacevector.cc @@ -262,7 +262,8 @@ void SurfaceVector::drawTVMedia(TVMediaInfo& tvmedia, float x, float y, float w { command_mutex.lock(); VectorHandleImage handle = 0; - LoadingIndex load_index = osd->getTVMediaRef(tvmedia, handle); + LoadingIndex load_index = osd->getTVMediaRef(tvmedia, handle); // This is where you can get a cache hit + if (width != 0 && height != 0) { -- 2.39.5