2 Copyright 2012 Marten Richter, 2020 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
21 #include "surfacevector.h"
23 #include "vdrresponsepacket.h"
27 #include "osdvector.h"
29 // The next section is activated, if the magick++ PictureReader is provided, it should be available for many POSIX platforms
30 #ifdef PICTURE_DECODER_MAGICK
31 #define MAGICKCORE_QUANTUM_DEPTH 16
32 #define MAGICKCORE_HDRI_ENABLE 0
35 using namespace Magick;
37 static const char* TAG = "OsdVector";
39 class MagickDecoder: public OsdVector::PictureDecoder
42 MagickDecoder(OsdVector::PictureReader* treader): OsdVector::PictureDecoder(treader) {pictInfValid = false;};
44 unsigned char* decodePicture(LoadIndex index, unsigned char* buffer, unsigned int length, bool freemem);
46 bool getDecodedPicture( struct OsdVector::PictureInfo& pict_inf);
48 void freeReference(void* ref);
51 OsdVector::PictureInfo pictInf;
55 unsigned char* MagickDecoder::decodePicture(LoadIndex index, unsigned char* buffer, unsigned int length, bool freemem)
57 if (pictInfValid) return buffer; // does support only one image at a Time;
60 Blob* imageblob = new Blob();
65 LogNT::getInstance()->debug("MagickDecoder", "decodePicture");
67 if (freemem) myblob.updateNoCopy(buffer, length, Blob::MallocAllocator);
68 else myblob.update(buffer, length);
70 magicimage.read(myblob);
72 magicimage.write(imageblob, "RGBA");
75 catch ( Exception& error_ )
77 LogNT::getInstance()->debug("MagickDecoder", "Libmagick: {}", error_.what());
79 LogNT::getInstance()->debug("MagickDecoder", "Libmagick: error mark2");
80 unsigned char* newbuffer = (unsigned char*) malloc(length);
81 memcpy(newbuffer, myblob.data(), length);
85 pictInf.reference = (void*) imageblob;
86 pictInf.width = magicimage.columns();
87 pictInf.height = magicimage.rows();
88 pictInf.image = imageblob->data();
89 pictInf.decoder = this;
90 pictInf.type = OsdVector::PictureInfo::RGBAMemBlock;
91 pictInf.lindex = index;
96 // I can handle everything, so the return value is always true
99 void MagickDecoder::freeReference(void* ref)
101 Blob* todelete = (Blob*) ref;
105 bool MagickDecoder::getDecodedPicture(struct OsdVector::PictureInfo& pict_inf)
107 if (!pictInfValid) return false;
110 pictInfValid = false;
117 OsdVector::OsdVector()
119 setlocale(LC_CTYPE, "C.UTF-8");
120 #ifdef PICTURE_DECODER_MAGICK
121 reader.addDecoder(new MagickDecoder(&reader));
125 bool OsdVector::screenShot(const char* fileName)
127 //Do nothing, if no libmagick is there
128 #ifdef PICTURE_DECODER_MAGICK
130 getRealScreenSize(width, height);
131 size_t length = width * height * 4;
132 void* mem = malloc(length);
138 if (!screenShotInternal(mem, width, height, true))
140 LogNT::getInstance()->debug(TAG, "Screenshot failed!");
145 myblob.updateNoCopy(mem, length, Blob::MallocAllocator);
146 Image image(myblob, Geometry(width, height), 8, "RGBA");
147 image.write(fileName);
149 catch ( Exception& error_ )
151 LogNT::getInstance()->debug("MagickEncoder", "Libmagick: {}", error_.what());
160 Surface* OsdVector::createNewSurface()
162 return new SurfaceVector(this);
165 void OsdVector::Blank()
167 // do nothing? remove this one?
170 int OsdVector::restore()
172 // First clear the contents of all registered surfaces
173 surfaces_mutex.lock();
175 //Now go through all surfaces and clear them
176 for (auto& surface : surfaces)
178 surface.commands.clear();
179 surface.commands.reserve(2048);
182 //also clear all handles, they are now invalid, no need to release them
186 drawstyleHandles.clear();
187 drawstyleHandlesRefCounts.clear();
188 drawstyleHandles_lastit_valid = drawstyleHandlesRefCounts_lastit_valid = false;
192 loadindex_ref.clear();
193 tvmedias_load.clear();
194 tvmedias_load_inv.clear();
195 tvmedias_loaded.clear();
197 surfaces_mutex.unlock();
201 void OsdVector::drawSurfaces()
203 surfaces_mutex.lock();
204 std::list<SurfaceInfo*> todraw; //First figure out if a surfaces is below another surface
205 std::list<SurfaceInfo>::iterator itty1 = surfaces.begin();
207 while (itty1 != surfaces.end())
209 std::list<SurfaceInfo>::iterator itty2 = itty1;
213 while (itty2 != surfaces.end())
215 SurfaceInfo& ref1 = *itty1;
216 SurfaceInfo& ref2 = *itty2;
218 if (ref1.x >= ref2.x && ref1.y >= ref2.y
219 && (ref1.x + ref1.w) <= (ref2.x + ref2.w)
220 && (ref1.y + ref1.h) <= (ref2.y + ref2.h) )
229 if (!hidden) // we are not hidden, perfect
231 todraw.push_back(&(*itty1));
238 getScreenSize(swidth, sheight);
239 //Now go through all surfaces and draw them
240 std::list<SurfaceInfo*>::iterator curdraw = todraw.begin();
242 while (curdraw != todraw.end())
244 drawSetTrans(*(*curdraw));
245 std::vector<SVGCommand>::iterator commands = (*(*curdraw)).commands.begin();
246 std::vector<SVGCommand>::iterator end = (*(*curdraw)).commands.end();
248 while (commands != end)
250 // update any images loaded in the mean time
251 if ((*commands).instr == DrawImageLoading)
253 LoadIndex loadindex = (*commands).target.loadindex;
255 if (tvmedias_loaded.find(loadindex) != tvmedias_loaded.end())
257 (*commands).instr = DrawImage;
258 (*commands).target.image = tvmedias_loaded[loadindex];;
259 incImageRef((*commands).target.image);
260 removeLoadIndexRef(loadindex);
265 // Now check if the command is on screen!
266 if (!(*commands).Outside(0, 0, swidth, sheight))
268 executeDrawCommand(*commands);
277 surfaces_mutex.unlock();
280 void OsdVector::updateOrAddSurface(const SurfaceVector* surf, float x, float y, float height, float width, std::vector<SVGCommand>& commands)
282 std::lock_guard<std::mutex> lg(surfaces_mutex);
286 LogNT::getInstance()->trace(TAG, "updateOrAddSurface, surfaces.length {}", surfaces.size());
290 // First determine it is already in our system
291 for(si = surfaces.begin(); si != surfaces.end(); si++)
293 if (si->surface == surf)
295 // If the surface given (surf) is already in our surfaces vector, reset our SurfaceInfo->commands vector
296 decrementAllRefCounts(si->commands);
297 si->commands.clear();
302 // if not found, make a new SurfaceInfo
303 if (si == surfaces.end())
306 new_sc.surface = surf;
311 si = surfaces.insert(si, new_sc);
314 // update any images loaded in the mean time
316 for (SVGCommand& command : commands)
318 if (command.instr == DrawImageLoading)
320 LoadIndex loadindex = command.target.loadindex;
322 if (tvmedias_loaded.find(loadindex) != tvmedias_loaded.end())
324 command.instr = DrawImage;
325 command.target.image = tvmedias_loaded[loadindex];
326 incImageRef(command.target.image);
327 removeLoadIndexRef(loadindex);
332 si->commands = commands; // Copy surf->commands to our SurfaceInfo->commands
333 incrementAllRefCounts(si->commands);
335 cleanupOrphanedRefs();
338 LogNT::getInstance()->trace(TAG, "After UOAS:");
342 // OSDOVG-ROD-EXPERIMENT
343 LogNT::getInstance()->trace(TAG, "EXPERIMENT - call doRender");
347 void OsdVector::removeSurface(const SurfaceVector* surf)
349 std::lock_guard<std::mutex> lg(surfaces_mutex); // FIXME - Can block here on shutdown if a timer is fired just as the wrong time
350 LogNT::getInstance()->trace("OsdVector-348", "EXPERIMENT - removeSurface");
351 for (auto i = surfaces.begin(); i != surfaces.end(); i++)
353 if (i->surface == surf)
355 decrementAllRefCounts(i->commands);
363 void OsdVector::decrementAllRefCounts(std::vector<SVGCommand>& commands)
365 for (SVGCommand& command : commands)
367 VectorHandle handle = command.getHandle();
368 if (handle != 0) // command might not have a handle
369 decrementDrawStyleHandleRefCount(handle);
371 ImageIndex ii = command.getImageIndex();
372 if (ii) removeImageRef(ii);
374 LoadIndex li = command.getLoadIndex();
375 if (li) removeLoadIndexRef(li);
379 void OsdVector::incrementAllRefCounts(std::vector<SVGCommand>& commands)
381 for (SVGCommand& command : commands)
383 VectorHandle handle = command.getHandle();
384 if (handle != 0) // command might not have a handle
385 incrementDrawStyleHandleRefCount(handle);
387 ImageIndex ii = command.getImageIndex();
388 if (ii) incImageRef(ii);
390 LoadIndex li = command.getLoadIndex();
391 if (li) incLoadIndexRef(li);
395 void OsdVector::incImageRef(ImageIndex index)
397 if (images_ref.find(index) == images_ref.end())
399 images_ref[index] = 1;
407 void OsdVector::removeImageRef(const ImageIndex ref)
412 int OsdVector::getLoadIndexRef(LoadIndex index)
414 surfaces_mutex.lock();
416 if (loadindex_ref.find(index) == loadindex_ref.end())
422 return loadindex_ref[index];
425 surfaces_mutex.unlock();
428 void OsdVector::incLoadIndexRef(LoadIndex index)
430 if (loadindex_ref.find(index) == loadindex_ref.end())
432 loadindex_ref[index] = 1;
436 loadindex_ref[index]++;
440 void OsdVector::removeLoadIndexRef(const LoadIndex ref)
442 loadindex_ref[ref]--;
444 if (loadindex_ref[ref] == 0)
446 //now check, if it is already loaded
447 std::map<LoadIndex, ImageIndex>::iterator itty = tvmedias_loaded.find(ref);
449 if ( itty != tvmedias_loaded.end())
451 removeImageRef((*itty).second); // remove lock
454 tvmedias_loaded.erase(ref);
455 // LogNT::getInstance()->debug(TAG, "TVMedia removeLoadIndexRef {} {:#x}",tvmedias_load.size(),ref);
456 tvmedias_load.erase(tvmedias_load_inv[ref]);
457 tvmedias_load_inv.erase(ref);
459 reader.invalidateLoadIndex(ref);
463 void OsdVector::cleanupOrphanedRefs()
465 // Do some garbage collection
467 std::map<void*, ImageIndex>::iterator mitty = monobitmaps.begin();
469 while (mitty != monobitmaps.end())
471 std::map<ImageIndex, int>::iterator curitty = images_ref.find((*mitty).second);
472 int count = (*curitty).second;
476 ImageIndex ref = (*curitty).first;
477 monobitmaps.erase(mitty++);
478 images_ref.erase(curitty++);
479 destroyImageRef(ref);
484 /*map<string,ImageIndex>::iterator jitty=jpegs.begin();
485 while (jitty!=jpegs.end()) {
486 map<ImageIndex,int>::iterator curitty=images_ref.find((*jitty).second);
487 int count=(*curitty).second;
489 ImageIndex ref=(*curitty).first;
490 jpegs.erase(jitty++);
491 images_ref.erase(curitty++);
492 destroyImageRef(ref);
496 std::map<TVMediaInfo, ImageIndex>::iterator titty = tvmedias.begin();
498 while (titty != tvmedias.end())
500 std::map<ImageIndex, int>::iterator curitty = images_ref.find((*titty).second);
501 int count = (*curitty).second;
505 ImageIndex ref = (*curitty).first;
506 tvmedias.erase(titty++);
507 images_ref.erase(curitty);
508 destroyImageRef(ref);
514 std::map<TVMediaInfo, LoadIndex>::iterator litty = tvmedias_load.begin();
516 while (litty != tvmedias_load.end())
518 std::map<LoadIndex, int>::iterator curitty = loadindex_ref.find((*litty).second);
519 int count = (*curitty).second;
523 tvmedias_load_inv.erase((*litty).second);
524 tvmedias_loaded.erase((*litty).second);
525 tvmedias_load.erase(litty++);
530 std::list<ImageIndex>::iterator pitty = palettepics.begin();
532 while (pitty != palettepics.end())
534 std::map<ImageIndex, int>::iterator curitty = images_ref.find((*pitty));
535 int count = (*curitty).second;
539 ImageIndex ref = (*curitty).first;
540 palettepics.erase(pitty++);
541 images_ref.erase(curitty++);
542 destroyImageRef(ref);
547 std::map<ImageIndex, int>::iterator citty = images_ref.begin();
549 while (citty != images_ref.end())
551 int count = (*citty).second;
555 ImageIndex ref = (*citty).first;
556 images_ref.erase(citty++);
557 destroyImageRef(ref);
563 std::map<DrawStyle, VectorHandle>::iterator sitty = drawstyleHandles.begin();
565 while (sitty != drawstyleHandles.end())
567 std::map<VectorHandle, int>::iterator curitty = drawstyleHandlesRefCounts.find((*sitty).second);
568 int count = (*curitty).second;
572 VectorHandle ref = (*curitty).first;
573 drawstyleHandles.erase(sitty++);
574 drawstyleHandlesRefCounts.erase(curitty++);
575 drawstyleHandles_lastit_valid = drawstyleHandlesRefCounts_lastit_valid = false;
576 destroyDrawStyleHandle(ref);
584 int OsdVector::getImageRef(ImageIndex index)
586 surfaces_mutex.lock();
588 if (images_ref.find(index) == images_ref.end())
594 return images_ref[index];
597 surfaces_mutex.unlock();
600 void OsdVector::incrementDrawStyleHandleRefCount(VectorHandle index)
602 if (!drawstyleHandlesRefCounts_lastit_valid || (drawstyleHandlesRefCounts_lastit->first != index))
604 drawstyleHandlesRefCounts_lastit = drawstyleHandlesRefCounts.find(index);
605 if (drawstyleHandlesRefCounts_lastit == drawstyleHandlesRefCounts.end())
607 drawstyleHandlesRefCounts_lastit = drawstyleHandlesRefCounts.insert(std::pair<VectorHandle, int>(index, 0)).first;
611 drawstyleHandlesRefCounts_lastit->second++;
612 drawstyleHandlesRefCounts_lastit_valid = true;
615 void OsdVector::decrementDrawStyleHandleRefCount(VectorHandle index)
617 if (!drawstyleHandlesRefCounts_lastit_valid || (drawstyleHandlesRefCounts_lastit->first != index))
619 drawstyleHandlesRefCounts_lastit_valid = false;
620 drawstyleHandlesRefCounts_lastit = drawstyleHandlesRefCounts.find(index);
623 if (drawstyleHandlesRefCounts_lastit != drawstyleHandlesRefCounts.end())
625 drawstyleHandlesRefCounts_lastit_valid = true;
626 drawstyleHandlesRefCounts_lastit->second--;
630 VectorHandle OsdVector::getDrawStyleHandle(const DrawStyle& c)
632 surfaces_mutex.lock();
633 VectorHandle style_handle = 0;
639 if (!drawstyleHandles_lastit_valid || (drawstyleHandles_lastit->first != c))
641 drawstyleHandles_lastit_valid = false;
642 drawstyleHandles_lastit = drawstyleHandles.find(c);
645 if (drawstyleHandles_lastit == drawstyleHandles.end())
647 surfaces_mutex.unlock();
648 style_handle = createDrawStyleHandle(c);
649 surfaces_mutex.lock();
650 drawstyleHandles_lastit = drawstyleHandles.insert(std::pair<DrawStyle, VectorHandle>(c, style_handle)).first;
654 style_handle = drawstyleHandles_lastit->second;
656 //Now check if the handle is valid
657 if (!drawstyleHandlesRefCounts_lastit_valid || (*drawstyleHandlesRefCounts_lastit).first != style_handle)
659 drawstyleHandlesRefCounts_lastit_valid = false;
660 drawstyleHandlesRefCounts_lastit = drawstyleHandlesRefCounts.find(style_handle);
663 if (drawstyleHandlesRefCounts_lastit == drawstyleHandlesRefCounts.end())
665 //invalid handle recreate
666 surfaces_mutex.unlock();
667 style_handle = createDrawStyleHandle(c);
668 surfaces_mutex.lock();
669 drawstyleHandles_lastit->second = style_handle;
671 else drawstyleHandlesRefCounts_lastit_valid = true;
674 drawstyleHandles_lastit_valid = true;
675 incrementDrawStyleHandleRefCount(style_handle);
676 surfaces_mutex.unlock();
681 void OsdVector::dumpStyles()
685 std::map<DrawStyle, VectorHandle>::iterator i;
686 for(i = drawstyleHandles.begin(); i != drawstyleHandles.end(); i++)
688 const DrawStyle* test = &(i->first);
689 LogNT::getInstance()->debug(TAG, "DumpStyles: {} {}", (void*)test , i->second);
692 std::map<VectorHandle, int>::iterator i2;
693 for (i2 = drawstyleHandlesRefCounts.begin(); i2 != drawstyleHandlesRefCounts.end(); i2++)
695 LogNT::getInstance()->debug(TAG, "DumpStylesRef: {} {}", i2->first, i2->second);
700 LoadIndex OsdVector::getTVMediaRef(TVMediaInfo& tvmedia, ImageIndex& image)
702 ImageIndex image_handle = 0;
703 LoadIndex loadindex = 0;
704 surfaces_mutex.lock();
706 if (tvmedias.find(tvmedia) == tvmedias.end())
708 loadindex = loadTVMedia(tvmedia);
712 image_handle = tvmedias[tvmedia];
714 if (images_ref.find(image_handle) == images_ref.end())
716 //invalid handle recreate
717 loadindex = loadTVMedia(tvmedia);
722 incImageRef(image_handle);
726 /*tvmedias[tvmedia]=createTVMedia(tvmedia,width,height);
727 incImageRef(image_handle);*/
728 image = image_handle;
729 surfaces_mutex.unlock();
733 LoadIndex OsdVector::loadTVMedia(TVMediaInfo& tvmedia)
737 if (tvmedias_load.find(tvmedia) == tvmedias_load.end())
739 switch (tvmedia.getType())
742 index = VDR::getInstance()->loadTVMediaRecThumb(tvmedia);
747 index = ((long long) tvmedia.getPrimaryID()) << 32LL;
748 reader.addStaticImage(tvmedia.getPrimaryID());
752 index = VDR::getInstance()->loadTVMediaEventThumb(tvmedia);
756 index = VDR::getInstance()->loadChannelLogo(tvmedia);
760 index = VDR::getInstance()->loadTVMedia(tvmedia);
764 if (tvmedia.getType() != 4 && tvmedia.getStaticFallback() > -1)
766 reader.informFallback(index, tvmedia.getStaticFallback());
769 tvmedias_load[tvmedia] = index;
770 tvmedias_load_inv[index] = tvmedia;
774 index = tvmedias_load[tvmedia];
777 incLoadIndexRef(index);
782 void OsdVector::informPicture(LoadIndex index, ImageIndex imageIndex)
784 //Beware for thread safety
785 ImageIndex image_index = 0;
787 LogNT::getInstance()->debug(TAG, "TVMedia Picture for request id {:#x} arrived {:#x}", index, imageIndex);
788 surfaces_mutex.lock();
789 TVMediaInfo tvmedia = tvmedias_load_inv[index];
793 std::map<LoadIndex, int>::iterator itty = loadindex_ref.find(index);
794 image_index = tvmedias[tvmedia] = imageIndex;
795 tvmedias_loaded[index] = image_index;
797 if (itty == loadindex_ref.end() || (*itty).second == 0)
799 // we do not want the picture anymore . Really...
800 // fill images_ref in to not irritate the garbage collector
801 if (images_ref.find(image_index) == images_ref.end())
803 images_ref[image_index] = 0;
808 incImageRef(image_index); // hold one index until all loadings refs are gone;
812 surfaces_mutex.unlock();
816 ImageIndex OsdVector::getJpegRef(const char* fileName, int *width,int *height)
818 ImageIndex image_handle=0;
819 if (jpegs.find(fileName)==jpegs.end())
821 image_handle=jpegs[fileName]=createJpeg(fileName,width,height);
823 image_handle=jpegs[fileName];
826 if (images_ref.find(image_handle)==images_ref.end()) {
827 //invalid handle recreate
828 image_handle=jpegs[fileName]=createJpeg(fileName,width,height);
831 incImageRef(image_handle);
836 ImageIndex OsdVector::getMonoBitmapRef(void* base, int width, int height)
838 ImageIndex image_handle;
839 surfaces_mutex.lock();
841 if (monobitmaps.find(base) == monobitmaps.end())
843 surfaces_mutex.unlock();
844 image_handle = createMonoBitmap(base, width, height);
845 surfaces_mutex.lock();
846 monobitmaps[base] = image_handle;
850 image_handle = monobitmaps[base];
852 if (images_ref.find(image_handle) == images_ref.end())
854 //invalid handle recreate
855 surfaces_mutex.unlock();
856 image_handle = createMonoBitmap(base, width, height);
857 surfaces_mutex.lock();
858 monobitmaps[base] = image_handle;
862 incImageRef(image_handle);
863 surfaces_mutex.unlock();
867 ImageIndex OsdVector::getImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data)
869 ImageIndex image_handle;
870 image_handle = createImagePalette(width, height, image_data, palette_data);
871 surfaces_mutex.lock();
872 palettepics.push_back(image_handle);
873 incImageRef(image_handle);
874 surfaces_mutex.unlock();
878 /// PictureReader Class
880 OsdVector::PictureReader::~PictureReader()
882 decoders_lock.lock();
884 while (decoders.size())
886 PictureDecoder* dec = decoders.front();
887 decoders.pop_front();
891 decoders_lock.unlock();
894 void OsdVector::PictureReader::init()
899 void OsdVector::PictureReader::shutdown()
904 void OsdVector::PictureReader::addDecoder(PictureDecoder* decoder)
906 decoders_lock.lock();
908 decoders.push_front(decoder);
909 decoders_lock.unlock();
912 void OsdVector::PictureReader::removeDecoder(PictureDecoder* decoder)
914 decoders_lock.lock();
915 std::list<PictureDecoder*>::iterator itty = decoders.begin();
917 while (itty != decoders.end())
919 if ((*itty) == decoder)
921 decoders.erase(itty);
928 LogNT::getInstance()->debug(TAG, "removeDecoder");
931 decoders_lock.unlock();
934 void OsdVector::PictureReader::threadMethod()
936 OsdVector* osdvector = dynamic_cast<OsdVector*>(Osd::getInstance());
937 LogNT::getInstance()->debug(TAG, "TVMedia Start Picture Reader");
941 if (!threadIsActive())
943 LogNT::getInstance()->debug(TAG, "TVMedia End Picture Reader");
953 decoders_lock.lock();
954 std::list<PictureDecoder*>::iterator itty = decoders.begin();
956 while (itty != decoders.end())
958 if ((*itty)->getDecodedPicture(pictinf))
961 osdvector->createPicture(pictinf);
967 if (processReceivedPictures())
972 decoders_lock.unlock();
975 //LogNT::getInstance()->debug(TAG, "TVMedia Sleep Picture Reader");
977 struct timespec target_time;
978 getClockRealTime(&target_time);
980 target_time.tv_nsec += 1000000LL * 10;
982 if (target_time.tv_nsec > 999999999)
984 target_time.tv_nsec -= 1000000000L;
985 target_time.tv_sec += 1;
989 threadWaitForSignalTimed(&target_time);
991 //LogNT::getInstance()->debug(TAG, "TVMedia Sleep end Picture Reader");
995 void OsdVector::PictureReader::invalidateLoadIndex(LoadIndex index)
997 pict_lock_incoming.lock();
998 invalid_loadindex.insert(index);
999 pict_lock_incoming.unlock();
1002 void OsdVector::PictureReader::informFallback(LoadIndex index, int fallback)
1004 pict_lock_incoming.lock();
1005 inform_fallback[index] = fallback;
1006 pict_lock_incoming.unlock();
1009 void OsdVector::PictureReader::receivePicture(VDR_ResponsePacket* vresp)
1011 pict_lock_incoming.lock();
1012 pict_incoming.push(vresp);
1013 pict_lock_incoming.unlock();
1018 void OsdVector::PictureReader::addStaticImage(unsigned int id)
1020 pict_lock_incoming.lock();
1021 pict_incoming_static.push(id);
1022 invalid_loadindex.erase(((long long) id) << 32LL);
1023 pict_lock_incoming.unlock();
1029 #pragma warning(disable : 4703)
1032 bool OsdVector::PictureReader::processReceivedPictures()
1034 bool decoded = false;
1036 pict_lock_incoming.lock();
1038 if (pict_incoming.size())
1040 VDR_ResponsePacket* vresp = pict_incoming.front();
1041 pict_incoming.pop();
1042 std::set<LoadIndex>::iterator setpos = invalid_loadindex.find(vresp->getStreamID());
1044 if (setpos != invalid_loadindex.end())
1047 invalid_loadindex.erase(setpos);
1050 pict_lock_incoming.unlock();
1052 if (!valid) // we do not want it anymore skip it;
1058 // LogNT::getInstance()->debug(TAG, "TVMedia Pictures arrived VDR {:#x} {} {}",
1059 // vresp->getStreamID(),vresp->getUserDataLength(),vresp->getFlag());
1060 bool decode = false;
1065 if (vresp->getFlag() != 2)
1067 userdata = vresp->getUserData();
1068 length = vresp->getUserDataLength();
1075 pict_lock_incoming.lock();
1077 if (inform_fallback.find(vresp->getStreamID()) != inform_fallback.end())
1079 fallback = inform_fallback[vresp->getStreamID()];
1082 pict_lock_incoming.unlock();
1084 if (fallback >= 0 && ((OsdVector*)Osd::getInstance())->getStaticImageData(fallback, &userdata, &length))
1093 std::list<PictureDecoder*>::iterator itty = decoders.begin();
1095 while (itty != decoders.end())
1097 userdata = (*itty)->decodePicture(vresp->getStreamID(), userdata, length, freed);
1108 if (!decoded && userdata && freed)
1114 pict_lock_incoming.lock();
1115 inform_fallback.erase(vresp->getStreamID());
1116 pict_lock_incoming.unlock();
1117 //else osd->informPicture(vresp->getStreamID(), 0);
1120 else if (pict_incoming_static.size())
1122 unsigned int static_id = pict_incoming_static.front();
1123 pict_incoming_static.pop();
1124 std::set<LoadIndex>::iterator setpos = invalid_loadindex.find(((long long) static_id) << 32LL);
1126 if (setpos != invalid_loadindex.end())
1129 invalid_loadindex.erase(setpos);
1132 pict_lock_incoming.unlock();
1134 if (!valid) // we do not want it anymore skip it;
1142 if (((OsdVector*)Osd::getInstance())->getStaticImageData(static_id, &userdata, &length))
1144 std::list<PictureDecoder*>::iterator itty = decoders.begin();
1146 while (itty != decoders.end())
1148 if (!(*itty)->decodePicture(((long long) static_id) << 32LL, userdata, length, false))
1160 pict_lock_incoming.unlock();
1163 if (pict_incoming.size() || pict_incoming_static.size()) return true;