diff -Nru kodi-21.0+git20230505.0301-756a5bd475/BUILDDATE kodi-21.0+git20230507.0301-eebc71466d/BUILDDATE --- kodi-21.0+git20230505.0301-756a5bd475/BUILDDATE 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/BUILDDATE 2013-05-12 08:41:54.000000000 +0000 @@ -1 +1 @@ -20230505 +20230507 diff -Nru kodi-21.0+git20230505.0301-756a5bd475/debian/changelog kodi-21.0+git20230507.0301-eebc71466d/debian/changelog --- kodi-21.0+git20230505.0301-756a5bd475/debian/changelog 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/debian/changelog 2013-05-12 08:41:54.000000000 +0000 @@ -1,4 +1,4 @@ -kodi (6:21.0+git20230505.0301-756a5bd475-0~focal) focal; urgency=medium +kodi (6:21.0+git20230507.0301-eebc71466d-0~focal) focal; urgency=medium [ kodi ] * autogenerated dummy changelog diff -Nru kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.cpp kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.cpp --- kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -24,6 +24,11 @@ #include +GIFDecoder::GIFDecoder() +{ + m_extensions.emplace_back(".gif"); +} + // returns true for gif files, otherwise returns false bool GIFDecoder::CanDecode(const std::string &filename) { @@ -35,23 +40,22 @@ int n = 0; bool result = false; - GifHelper *gifImage = new GifHelper(); - if (gifImage->LoadGif(filename.c_str())) + GifHelper gifImage; + if (gifImage.LoadGif(filename)) { - auto extractedFrames = gifImage->GetFrames(); + auto extractedFrames = gifImage.GetFrames(); n = extractedFrames.size(); if (n > 0) { - unsigned int height = gifImage->GetHeight(); - unsigned int width = gifImage->GetWidth(); - unsigned int pitch = gifImage->GetPitch(); - unsigned int frameSize = pitch * height; + unsigned int height = gifImage.GetHeight(); + unsigned int width = gifImage.GetWidth(); + unsigned int pitch = gifImage.GetPitch(); + for (unsigned int i = 0; i < extractedFrames.size(); i++) { DecodedFrame frame; - frame.rgbaImage.pixels.resize(frameSize); - memcpy(frame.rgbaImage.pixels.data(), extractedFrames[i]->m_pImage, frameSize); + frame.rgbaImage.pixels = extractedFrames[i]->m_pImage; frame.rgbaImage.height = height; frame.rgbaImage.width = width; frame.rgbaImage.bbp = 32; @@ -63,11 +67,6 @@ } result = true; } - delete gifImage; - return result; -} -void GIFDecoder::FillSupportedExtensions() -{ - m_supportedExtensions.emplace_back(".gif"); + return result; } diff -Nru kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.h kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.h --- kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/GIFDecoder.h 2013-05-12 08:41:54.000000000 +0000 @@ -25,11 +25,10 @@ class GIFDecoder : public IDecoder { public: + GIFDecoder(); ~GIFDecoder() override = default; bool CanDecode(const std::string &filename) override; bool LoadFile(const std::string& filename, DecodedFrames& frames) override; const char* GetImageFormatName() override { return "GIF"; } const char* GetDecoderName() override { return "libgif"; } - protected: - void FillSupportedExtensions() override; }; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/GifHelper.cpp kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/GifHelper.cpp --- kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/GifHelper.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/GifHelper.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -43,16 +43,10 @@ return gifFile->Read(gifbyte, len); } -GifHelper::GifHelper() -{ - m_gifFile = new CFile(); -} - GifHelper::~GifHelper() { Close(m_gif); Release(); - delete m_gifFile; } bool GifHelper::Open(GifFileType*& gif, void *dataPtr, InputFunc readFunc) @@ -107,8 +101,7 @@ void GifHelper::Release() { - delete[] m_pTemplate; - m_pTemplate = nullptr; + m_pTemplate.clear(); m_globalPalette.clear(); m_frames.clear(); } @@ -174,10 +167,10 @@ return true; } -bool GifHelper::LoadGifMetaData(const char* file) +bool GifHelper::LoadGifMetaData(const std::string& file) { - m_gifFile->Close(); - if (!m_gifFile->Open(file) || !Open(m_gif, m_gifFile, ReadFromVfs)) + m_gifFile.Close(); + if (!m_gifFile.Open(file) || !Open(m_gif, &m_gifFile, ReadFromVfs)) return false; return LoadGifMetaData(m_gif); @@ -200,10 +193,10 @@ return true; } -bool GifHelper::LoadGif(const char* file) +bool GifHelper::LoadGif(const std::string& file) { m_filename = file; - if (!LoadGifMetaData(m_filename.c_str())) + if (!LoadGifMetaData(m_filename)) return false; try @@ -234,8 +227,7 @@ void GifHelper::InitTemplateAndColormap() { - m_pTemplate = new unsigned char[m_imageSize]; - memset(m_pTemplate, 0, m_imageSize); + m_pTemplate.resize(m_imageSize); if (m_gif->SColorMap) { @@ -294,12 +286,6 @@ if (!m_gif) return -1; - if (!m_pTemplate) - { - fprintf(stderr, "Gif::ExtractFrames(): No frame template available\n"); - return -1; - } - int extracted = 0; for (unsigned int i = 0; i < count; i++) { @@ -343,9 +329,7 @@ continue; } - frame->m_pImage = new unsigned char[m_imageSize]; - frame->m_imageSize = m_imageSize; - memcpy(frame->m_pImage, m_pTemplate, m_imageSize); + frame->m_pImage = m_pTemplate; ConstructFrame(*frame, savedImage.RasterBits); @@ -367,7 +351,8 @@ for (unsigned int dest_y = frame.m_top, src_y = 0; src_y < frame.m_height; ++dest_y, ++src_y) { - unsigned char *to = frame.m_pImage + (dest_y * m_pitch) + (frame.m_left * sizeof(GifColor)); + unsigned char* to = + frame.m_pImage.data() + (dest_y * m_pitch) + (frame.m_left * sizeof(GifColor)); const unsigned char *from = src + (src_y * frame.m_width); for (unsigned int src_x = 0; src_x < frame.m_width; ++src_x) @@ -397,18 +382,18 @@ case DISPOSAL_UNSPECIFIED: /* Leave image in place */ case DISPOSE_DO_NOT: - memcpy(m_pTemplate, frame.m_pImage, m_imageSize); - break; + m_pTemplate = frame.m_pImage; + break; - /* + /* Clear the frame's area to transparency. The disposal names is misleading. Do not restore to the background color because this part of the specification is ignored by all browsers/image viewers. */ case DISPOSE_BACKGROUND: { - ClearFrameAreaToTransparency(m_pTemplate, frame); - break; + ClearFrameAreaToTransparency(m_pTemplate.data(), frame); + break; } /* Restore to previous content */ case DISPOSE_PREVIOUS: @@ -430,7 +415,7 @@ { if (m_frames[i]->m_disposal != DISPOSE_PREVIOUS) { - memcpy(m_pTemplate, m_frames[i]->m_pImage, m_imageSize); + m_pTemplate = m_frames[i]->m_pImage; valid = true; break; } @@ -464,30 +449,3 @@ } } } - -GifFrame::GifFrame(const GifFrame& src) - : m_delay(src.m_delay), - m_top(src.m_top), - m_left(src.m_left), - m_disposal(src.m_disposal), - m_height(src.m_height), - m_width(src.m_width), - m_imageSize(src.m_imageSize) -{ - if (src.m_pImage) - { - m_pImage = new unsigned char[m_imageSize]; - memcpy(m_pImage, src.m_pImage, m_imageSize); - } - - if (src.m_palette.size()) - { - m_palette = src.m_palette; - } -} - -GifFrame::~GifFrame() -{ - delete[] m_pImage; - m_pImage = nullptr; -} diff -Nru kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/GifHelper.h kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/GifHelper.h --- kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/GifHelper.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/GifHelper.h 2013-05-12 08:41:54.000000000 +0000 @@ -61,20 +61,17 @@ public: GifFrame() = default; - virtual ~GifFrame(); + virtual ~GifFrame() = default; - unsigned char* m_pImage = nullptr; + std::vector m_pImage; unsigned int m_delay = 0; private: - GifFrame(const GifFrame& src); - unsigned int m_top = 0; unsigned int m_left = 0; unsigned int m_disposal = 0; unsigned int m_height = 0; unsigned int m_width = 0; - unsigned int m_imageSize = 0; std::vector m_palette; }; @@ -87,11 +84,10 @@ typedef std::shared_ptr FramePtr; public: - GifHelper(); + GifHelper() = default; virtual ~GifHelper(); - - bool LoadGif(const char* file); + bool LoadGif(const std::string& file); std::vector& GetFrames() { return m_frames; } unsigned int GetPitch() const { return m_pitch; } @@ -109,8 +105,8 @@ std::string m_filename; GifFileType* m_gif = nullptr; std::vector m_globalPalette; - unsigned char* m_pTemplate = nullptr; - CFile* m_gifFile; + std::vector m_pTemplate; + CFile m_gifFile; unsigned int m_width; unsigned int m_height; @@ -120,7 +116,7 @@ const char* Reason(int reason); - bool LoadGifMetaData(const char* file); + bool LoadGifMetaData(const std::string& file); bool Slurp(GifFileType* gif); void InitTemplateAndColormap(); bool LoadGifMetaData(GifFileType* gif); diff -Nru kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/IDecoder.h kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/IDecoder.h --- kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/IDecoder.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/IDecoder.h 2013-05-12 08:41:54.000000000 +0000 @@ -37,17 +37,10 @@ virtual const char* GetImageFormatName() = 0; virtual const char* GetDecoderName() = 0; - const std::vector& GetSupportedExtensions() - { - m_supportedExtensions.clear(); - FillSupportedExtensions(); - return m_supportedExtensions; - } + const std::vector& GetSupportedExtensions() const { return m_extensions; } protected: - virtual void FillSupportedExtensions() = 0; - //fill this with extensions in FillSupportedExtensions like ".png" - std::vector m_supportedExtensions; + std::vector m_extensions; }; class RGBAImage diff -Nru kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.cpp kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.cpp --- kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -22,19 +22,27 @@ #include "SimpleFS.h" +#include + #include +JPGDecoder::JPGDecoder() +{ + m_extensions.emplace_back(".jpg"); + m_extensions.emplace_back(".jpeg"); +} + bool JPGDecoder::CanDecode(const std::string &filename) { - CFile *fp = new CFile(); + CFile fp; bool ret = false; unsigned char magic[2]; - if (fp->Open(filename)) + if (fp.Open(filename)) { //JPEG image files begin with FF D8 and end with FF D9. // check for FF D8 big + little endian on start - uint64_t readbytes = fp->Read(magic, 2); + uint64_t readbytes = fp.Read(magic, 2); if (readbytes == 2) { if ((magic[0] == 0xd8 && magic[1] == 0xff) || @@ -46,9 +54,9 @@ { ret = false; //check on FF D9 big + little endian on end - uint64_t fileSize = fp->GetFileSize(); - fp->Seek(fileSize - 2); - readbytes = fp->Read(magic, 2); + uint64_t fileSize = fp.GetFileSize(); + fp.Seek(fileSize - 2); + readbytes = fp.Read(magic, 2); if (readbytes == 2) { if ((magic[0] == 0xd9 && magic[1] == 0xff) || @@ -57,19 +65,17 @@ } } } - delete fp; + return ret; } bool JPGDecoder::LoadFile(const std::string &filename, DecodedFrames &frames) { #define WIDTHBYTES(bits) ((((bits) + 31) / 32) * 4) - CFile *arq = new CFile(); - if (!arq->Open(filename)) - { - delete arq; + + CFile arq; + if (!arq.Open(filename)) return false; - } struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; @@ -79,7 +85,7 @@ cinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&cinfo); - jpeg_stdio_src(&cinfo, arq->getFP()); + jpeg_stdio_src(&cinfo, arq.getFP()); jpeg_read_header(&cinfo, TRUE); jpeg_start_decompress(&cinfo); @@ -90,13 +96,16 @@ frame.rgbaImage.pixels.resize(ImageSize); - unsigned char *scanlinebuff = new unsigned char[3 * cinfo.image_width]; + std::vector scanlinebuff; + scanlinebuff.resize(3 * cinfo.image_width); + unsigned char* dst = (unsigned char*)frame.rgbaImage.pixels.data(); while (cinfo.output_scanline < cinfo.output_height) { - jpeg_read_scanlines(&cinfo,&scanlinebuff,1); + unsigned char* src2 = scanlinebuff.data(); + + jpeg_read_scanlines(&cinfo, &src2, 1); - unsigned char *src2 = scanlinebuff; unsigned char *dst2 = dst; for (unsigned int x = 0; x < cinfo.image_width; x++, src2 += 3) { @@ -107,7 +116,6 @@ } dst += cinfo.image_width * 4; } - delete [] scanlinebuff; jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); @@ -119,12 +127,5 @@ frames.frameList.push_back(frame); - delete arq; return true; } - -void JPGDecoder::FillSupportedExtensions() -{ - m_supportedExtensions.emplace_back(".jpg"); - m_supportedExtensions.emplace_back(".jpeg"); -} diff -Nru kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.h kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.h --- kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/JPGDecoder.h 2013-05-12 08:41:54.000000000 +0000 @@ -25,11 +25,10 @@ class JPGDecoder : public IDecoder { public: + JPGDecoder(); ~JPGDecoder() override = default; bool CanDecode(const std::string &filename) override; bool LoadFile(const std::string& filename, DecodedFrames& frames) override; const char* GetImageFormatName() override { return "JPG"; } const char* GetDecoderName() override { return "libjpeg"; } - protected: - void FillSupportedExtensions() override; }; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp --- kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -28,6 +28,11 @@ # define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) #endif +PNGDecoder::PNGDecoder() +{ + m_extensions.emplace_back(".png"); +} + /* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp() * returns zero if the image is a PNG and nonzero if it isn't a PNG. * @@ -216,8 +221,3 @@ return true; } - -void PNGDecoder::FillSupportedExtensions() -{ - m_supportedExtensions.emplace_back(".png"); -} diff -Nru kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.h kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.h --- kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/decoder/PNGDecoder.h 2013-05-12 08:41:54.000000000 +0000 @@ -25,11 +25,10 @@ class PNGDecoder : public IDecoder { public: + PNGDecoder(); ~PNGDecoder() override = default; bool CanDecode(const std::string &filename) override; bool LoadFile(const std::string& filename, DecodedFrames& frames) override; const char* GetImageFormatName() override { return "PNG"; } const char* GetDecoderName() override { return "libpng"; } - protected: - void FillSupportedExtensions() override; }; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/DecoderManager.cpp kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/DecoderManager.cpp --- kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/DecoderManager.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/DecoderManager.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -41,7 +41,7 @@ for (const auto& decoder : m_decoders) { - const std::vector extensions = decoder->GetSupportedExtensions(); + const std::vector& extensions = decoder->GetSupportedExtensions(); for (const auto& extension : extensions) { if (std::string::npos != filename.rfind(extension, filename.length() - extension.length())) diff -Nru kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/TexturePacker.cpp kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/TexturePacker.cpp --- kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/TexturePacker.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/TexturePacker.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -44,6 +44,8 @@ #define strncasecmp _strnicmp #endif +#include + #include #include @@ -51,8 +53,6 @@ #define DIR_SEPARATOR '/' -static DecoderManager decoderManager; - const char *GetFormatString(unsigned int format) { switch (format) @@ -74,9 +74,28 @@ } } -void CreateSkeletonHeaderImpl(CXBTFWriter& xbtfWriter, - const std::string& fullPath, - const std::string& relativePath) +class TexturePacker +{ +public: + TexturePacker() = default; + ~TexturePacker() = default; + + int createBundle(const std::string& InputDir, + const std::string& OutputFile, + unsigned int flags, + bool dupecheck); + + DecoderManager decoderManager; + +private: + void CreateSkeletonHeader(CXBTFWriter& xbtfWriter, + const std::string& fullPath, + const std::string& relativePath = ""); +}; + +void TexturePacker::CreateSkeletonHeader(CXBTFWriter& xbtfWriter, + const std::string& fullPath, + const std::string& relativePath) { struct dirent* dp; struct stat stat_p; @@ -103,7 +122,8 @@ tmpPath += "/"; } - CreateSkeletonHeaderImpl(xbtfWriter, fullPath + DIR_SEPARATOR + dp->d_name, tmpPath + dp->d_name); + CreateSkeletonHeader(xbtfWriter, fullPath + DIR_SEPARATOR + dp->d_name, + tmpPath + dp->d_name); } else if (decoderManager.IsSupportedGraphicsFile(dp->d_name)) { @@ -133,12 +153,6 @@ } } -void CreateSkeletonHeader(CXBTFWriter& xbtfWriter, const std::string& fullPath) -{ - std::string temp; - CreateSkeletonHeaderImpl(xbtfWriter, fullPath, temp); -} - CXBTFFrame appendContent(CXBTFWriter &writer, int width, int height, unsigned char *data, unsigned int size, unsigned int format, bool hasAlpha, unsigned int flags) { CXBTFFrame frame; @@ -148,31 +162,33 @@ { // grab a temporary buffer for unpacking into packedSize = size + size / 16 + 64 + 3; // see simple.c in lzo - unsigned char *packed = new unsigned char[packedSize]; - unsigned char *working = new unsigned char[LZO1X_999_MEM_COMPRESS]; - if (packed && working) + + std::vector packed; + packed.resize(packedSize); + + std::vector working; + working.resize(LZO1X_999_MEM_COMPRESS); + + if (lzo1x_999_compress(data, size, packed.data(), &packedSize, working.data()) != LZO_E_OK || + packedSize > size) { - if (lzo1x_999_compress(data, size, packed, &packedSize, working) != LZO_E_OK || packedSize > size) - { - // compression failed, or compressed size is bigger than uncompressed, so store as uncompressed + // compression failed, or compressed size is bigger than uncompressed, so store as uncompressed + packedSize = size; + writer.AppendContent(data, size); + } + else + { // success + lzo_uint optimSize = size; + if (lzo1x_optimize(packed.data(), packedSize, data, &optimSize, NULL) != LZO_E_OK || + optimSize != size) + { //optimisation failed packedSize = size; writer.AppendContent(data, size); } else { // success - lzo_uint optimSize = size; - if (lzo1x_optimize(packed, packedSize, data, &optimSize, NULL) != LZO_E_OK || optimSize != size) - { //optimisation failed - packedSize = size; - writer.AppendContent(data, size); - } - else - { // success - writer.AppendContent(packed, packedSize); - } + writer.AppendContent(packed.data(), packedSize); } - delete[] working; - delete[] packed; } } else @@ -199,7 +215,7 @@ return false; } -CXBTFFrame createXBTFFrame(RGBAImage &image, CXBTFWriter& writer, double maxMSE, unsigned int flags) +CXBTFFrame createXBTFFrame(RGBAImage& image, CXBTFWriter& writer, unsigned int flags) { int width, height; @@ -253,7 +269,10 @@ return false; } -int createBundle(const std::string& InputDir, const std::string& OutputFile, double maxMSE, unsigned int flags, bool dupecheck) +int TexturePacker::createBundle(const std::string& InputDir, + const std::string& OutputFile, + unsigned int flags, + bool dupecheck) { CXBTFWriter writer(OutputFile); if (!writer.Create()) @@ -320,7 +339,7 @@ for (unsigned int j = 0; j < frames.frameList.size(); j++) { printf(" frame %4i (delay:%4i) ", j, frames.frameList[j].delay); - CXBTFFrame frame = createXBTFFrame(frames.frameList[j].rgbaImage, writer, maxMSE, flags); + CXBTFFrame frame = createXBTFFrame(frames.frameList[j].rgbaImage, writer, flags); frame.SetDuration(frames.frameList[j].delay); file.GetFrames().push_back(frame); printf("%s%c (%d,%d @ %" PRIu64 " bytes)\n", GetFormatString(frame.GetFormat()), frame.HasAlpha() ? ' ' : '*', @@ -368,6 +387,8 @@ std::string InputDir; std::string OutputFilename = "Textures.xbt"; + TexturePacker texturePacker; + for (unsigned int i = 1; i < args.size(); ++i) { if (!platform_stricmp(args[i], "-help") || !platform_stricmp(args[i], "-h") || !platform_stricmp(args[i], "-?")) @@ -386,7 +407,7 @@ } else if (!strcmp(args[i], "-verbose")) { - decoderManager.verbose = true; + texturePacker.decoderManager.verbose = true; } else if (!platform_stricmp(args[i], "-output") || !platform_stricmp(args[i], "-o")) { @@ -413,6 +434,5 @@ if (pos != InputDir.length() - 1) InputDir += DIR_SEPARATOR; - double maxMSE = 1.5; // HQ only please - createBundle(InputDir, OutputFilename, maxMSE, flags, dupecheck); + texturePacker.createBundle(InputDir, OutputFilename, flags, dupecheck); } diff -Nru kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/XBTFWriter.cpp kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/XBTFWriter.cpp --- kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/XBTFWriter.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/XBTFWriter.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -37,11 +37,7 @@ #define WRITE_U32(i, file) { uint32_t _n = Endian_SwapLE32(i); fwrite(&_n, 4, 1, file); } #define WRITE_U64(i, file) { uint64_t _n = i; _n = Endian_SwapLE64(i); fwrite(&_n, 8, 1, file); } -CXBTFWriter::CXBTFWriter(const std::string& outputFile) - : m_outputFile(outputFile), - m_file(nullptr), - m_data(nullptr), - m_size(0) +CXBTFWriter::CXBTFWriter(const std::string& outputFile) : m_outputFile(outputFile), m_file(nullptr) { } CXBTFWriter::~CXBTFWriter() @@ -60,10 +56,10 @@ bool CXBTFWriter::Close() { - if (m_file == nullptr || m_data == nullptr) + if (m_file == nullptr) return false; - fwrite(m_data, 1, m_size, m_file); + fwrite(m_data.data(), 1, m_data.size(), m_file); Cleanup(); @@ -72,9 +68,6 @@ void CXBTFWriter::Cleanup() { - free(m_data); - m_data = nullptr; - m_size = 0; if (m_file) { fclose(m_file); @@ -84,18 +77,7 @@ bool CXBTFWriter::AppendContent(unsigned char const* data, size_t length) { - unsigned char *new_data = (unsigned char *)realloc(m_data, m_size + length); - - if (new_data == nullptr) - { // OOM - cleanup and fail - Cleanup(); - return false; - } - - m_data = new_data; - - memcpy(m_data + m_size, data, length); - m_size += length; + m_data.insert(m_data.end(), data, data + length); return true; } diff -Nru kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/XBTFWriter.h kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/XBTFWriter.h --- kodi-21.0+git20230505.0301-756a5bd475/tools/depends/native/TexturePacker/src/XBTFWriter.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/tools/depends/native/TexturePacker/src/XBTFWriter.h 2013-05-12 08:41:54.000000000 +0000 @@ -42,7 +42,6 @@ std::string m_outputFile; FILE* m_file; - unsigned char *m_data; - size_t m_size; + std::vector m_data; }; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/VERSION kodi-21.0+git20230507.0301-eebc71466d/VERSION --- kodi-21.0+git20230505.0301-756a5bd475/VERSION 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/VERSION 2013-05-12 08:41:54.000000000 +0000 @@ -1 +1 @@ -756a5bd475 +eebc71466d diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/cores/VideoPlayer/VideoReferenceClock.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/cores/VideoPlayer/VideoReferenceClock.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/cores/VideoPlayer/VideoReferenceClock.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/cores/VideoPlayer/VideoReferenceClock.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -50,14 +50,12 @@ Create(); } -void CVideoReferenceClock::CBUpdateClock(int NrVBlanks, uint64_t time, void *clock) +void CVideoReferenceClock::UpdateClock(int NrVBlanks, uint64_t time) { - { - CVideoReferenceClock *refClock = static_cast(clock); - std::unique_lock lock(refClock->m_CritSection); - refClock->m_VblankTime = time; - refClock->UpdateClock(NrVBlanks, true); - } + std::unique_lock lock(m_CritSection); + + m_VblankTime = time; + UpdateClockInternal(NrVBlanks, true); } void CVideoReferenceClock::Process() @@ -71,7 +69,7 @@ if (m_pVideoSync) { - SetupSuccess = m_pVideoSync->Setup(CBUpdateClock); + SetupSuccess = m_pVideoSync->Setup(); UpdateRefreshrate(); } @@ -121,7 +119,7 @@ } //this is called from the vblank run function and from CVideoReferenceClock::Wait in case of a late update -void CVideoReferenceClock::UpdateClock(int NrVBlanks, bool CheckMissed) +void CVideoReferenceClock::UpdateClockInternal(int NrVBlanks, bool CheckMissed) { if (CheckMissed) //set to true from the vblank run function, set to false from Wait and GetTime { @@ -176,7 +174,7 @@ while(Now >= NextVblank) //keep looping until the next vblank is in the future { - UpdateClock(1, false); //update clock when next vblank should have happened already + UpdateClockInternal(1, false); //update clock when next vblank should have happened already NextVblank = TimeOfNextVblank(); //get time when the next vblank should happen } diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/cores/VideoPlayer/VideoReferenceClock.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/cores/VideoPlayer/VideoReferenceClock.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/cores/VideoPlayer/VideoReferenceClock.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/cores/VideoPlayer/VideoReferenceClock.h 2013-05-12 08:41:54.000000000 +0000 @@ -28,14 +28,15 @@ double GetRefreshRate(double* interval = nullptr); bool GetClockInfo(int& MissedVblanks, double& ClockSpeed, double& RefreshRate) const; + void UpdateClock(int NrVBlanks, uint64_t time); + private: void Process() override; void Start(); void UpdateRefreshrate(); - void UpdateClock(int NrVBlanks, bool CheckMissed); + void UpdateClockInternal(int NrVBlanks, bool CheckMissed); double UpdateInterval() const; int64_t TimeOfNextVblank() const; - static void CBUpdateClock(int NrVBlanks, uint64_t time, void *clock); int64_t m_CurrTime; //the current time of the clock when using vblank as clock source int64_t m_LastIntTime; //last interpolated clock value, to make sure the clock doesn't go backwards diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/guilib/GUIBaseContainer.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/guilib/GUIBaseContainer.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/guilib/GUIBaseContainer.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/guilib/GUIBaseContainer.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -237,7 +237,7 @@ CGUIListItemLayoutPtr layout = std::make_unique(*m_layout, this); item->SetLayout(std::move(layout)); } - if (item->GetFocusedLayout()) + if (item->GetFocusedLayout() && item->GetFocusedLayout()->IsAnimating(ANIM_TYPE_UNFOCUS)) item->GetFocusedLayout()->Process(item.get(), m_parentID, currentTime, dirtyregions); if (item->GetLayout()) item->GetLayout()->Process(item.get(), m_parentID, currentTime, dirtyregions); diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/platform/win32/threads/ThreadImplWin.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/platform/win32/threads/ThreadImplWin.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/platform/win32/threads/ThreadImplWin.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/platform/win32/threads/ThreadImplWin.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -60,29 +60,34 @@ void CThreadImplWin::SetThreadInfo(const std::string& name) { - const unsigned int MS_VC_EXCEPTION = 0x406d1388; - -#pragma pack(push,8) - struct THREADNAME_INFO + // Modern way to name threads first (Windows 10 1607 and above) + if (!CWIN32Util::SetThreadName(static_cast(m_handle), name)) { - DWORD dwType; // must be 0x1000 - LPCSTR szName; // pointer to name (in same addr space) - DWORD dwThreadID; // thread ID (-1 caller thread) - DWORD dwFlags; // reserved for future use, most be zero - } info; + // Fallback on legacy method - specially configured exception + const unsigned int MS_VC_EXCEPTION = 0x406d1388; + +#pragma pack(push, 8) + struct THREADNAME_INFO + { + DWORD dwType; // must be 0x1000 + LPCSTR szName; // pointer to name (in same addr space) + DWORD dwThreadID; // thread ID (-1 = caller thread) + DWORD dwFlags; // reserved for future use, must be zero + } info; #pragma pack(pop) - info.dwType = 0x1000; - info.szName = name.c_str(); - info.dwThreadID = reinterpret_cast(m_handle); - info.dwFlags = 0; + info.dwType = 0x1000; + info.szName = name.c_str(); + info.dwThreadID = GetThreadId(static_cast(m_handle)); + info.dwFlags = 0; - __try - { - RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info); - } - __except(EXCEPTION_EXECUTE_HANDLER) - { + __try + { + RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info); + } + __except (EXCEPTION_EXECUTE_HANDLER) + { + } } CWIN32Util::SetThreadLocalLocale(true); // avoid crashing with setlocale(), see https://connect.microsoft.com/VisualStudio/feedback/details/794122 diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/platform/win32/WIN32Util.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/platform/win32/WIN32Util.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/platform/win32/WIN32Util.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/platform/win32/WIN32Util.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -1672,3 +1672,50 @@ return std::wstring(); #endif } + +using SETTHREADDESCRIPTION = HRESULT(WINAPI*)(HANDLE hThread, PCWSTR lpThreadDescription); + +bool CWIN32Util::SetThreadName(const HANDLE handle, const std::string& name) +{ +#if defined(TARGET_WINDOWS_STORE) + //not supported + return false; +#else + static bool initialized = false; + static HINSTANCE hinstLib = NULL; + static SETTHREADDESCRIPTION pSetThreadDescription = nullptr; + + if (!initialized) + { + initialized = true; + + // MS documentation: SetThreadDescription available since Windows 10 1607 + // function located in Kernel32.dll + // except for Windows 10 1607, where it is located in KernelBase.dll + CSysInfo::WindowsVersion winver = CSysInfo::GetWindowsVersion(); + + if (winver < CSysInfo::WindowsVersion::WindowsVersionWin10_1607) + return false; + else if (winver == CSysInfo::WindowsVersion::WindowsVersionWin10_1607) + hinstLib = LoadLibrary(L"KernelBase.dll"); + else if (winver > CSysInfo::WindowsVersion::WindowsVersionWin10_1607) + hinstLib = LoadLibrary(L"Kernel32.dll"); + + if (hinstLib != NULL) + { + pSetThreadDescription = reinterpret_cast( + ::GetProcAddress(hinstLib, "SetThreadDescription")); + } + + if (pSetThreadDescription == nullptr && hinstLib) + FreeLibrary(hinstLib); + } + + if (pSetThreadDescription != nullptr && + SUCCEEDED(pSetThreadDescription(handle, KODI::PLATFORM::WINDOWS::ToW(name).c_str()))) + return true; + else + return false; + +#endif +} diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/platform/win32/WIN32Util.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/platform/win32/WIN32Util.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/platform/win32/WIN32Util.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/platform/win32/WIN32Util.h 2013-05-12 08:41:54.000000000 +0000 @@ -84,4 +84,11 @@ static VideoDriverInfo GetVideoDriverInfo(const UINT vendorId, const std::wstring& driverDesc); static std::wstring GetDisplayFriendlyName(const std::wstring& GdiDeviceName); + /*! + * \brief Set the thread name using SetThreadDescription when available + * \param handle handle of the thread + * \param name name of the thread + * \return true if the name was successfully set, false otherwise (API not supported or API failure) + */ + static bool SetThreadName(const HANDLE handle, const std::string& name); }; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/utils/SystemInfo.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/utils/SystemInfo.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/utils/SystemInfo.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/utils/SystemInfo.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -682,17 +682,25 @@ osNameVer.append("Server 2012 R2"); break; case WindowsVersionWin10: + case WindowsVersionWin10_1607: case WindowsVersionWin10_1709: case WindowsVersionWin10_1803: case WindowsVersionWin10_1809: case WindowsVersionWin10_1903: case WindowsVersionWin10_1909: case WindowsVersionWin10_2004: + case WindowsVersionWin10_20H2: + case WindowsVersionWin10_21H1: + case WindowsVersionWin10_21H2: + case WindowsVersionWin10_22H2: + case WindowsVersionWin10_Future: osNameVer.append("10"); appendWindows10NameVersion(osNameVer); break; - case WindowsVersionWin11: + case WindowsVersionWin11_21H2: + case WindowsVersionWin11_22H2: + case WindowsVersionWin11_Future: osNameVer.append("11"); appendWindows10NameVersion(osNameVer); break; @@ -855,8 +863,10 @@ { if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 3) m_WinVer = WindowsVersionWin8_1; - else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber < 16299) + else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber < 14393) m_WinVer = WindowsVersionWin10; + else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber == 14393) + m_WinVer = WindowsVersionWin10_1607; else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber == 16299) m_WinVer = WindowsVersionWin10_1709; else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber == 17134) @@ -869,9 +879,21 @@ m_WinVer = WindowsVersionWin10_1909; else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber == 19041) m_WinVer = WindowsVersionWin10_2004; - else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber >= 22000) - m_WinVer = WindowsVersionWin11; - else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber > 19041) + else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber == 19042) + m_WinVer = WindowsVersionWin10_20H2; + else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber == 19043) + m_WinVer = WindowsVersionWin10_21H1; + else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber == 19044) + m_WinVer = WindowsVersionWin10_21H2; + else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber == 19045) + m_WinVer = WindowsVersionWin10_22H2; + else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber == 22000) + m_WinVer = WindowsVersionWin11_21H2; + else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber == 22621) + m_WinVer = WindowsVersionWin11_22H2; + else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber > 22621) + m_WinVer = WindowsVersionWin11_Future; + else if (osvi.dwMajorVersion == 10 && osvi.dwMinorVersion == 0 && osvi.dwBuildNumber > 19045) m_WinVer = WindowsVersionWin10_Future; /* Insert checks for new Windows versions here */ else if ( (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion > 3) || osvi.dwMajorVersion > 10) diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/utils/SystemInfo.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/utils/SystemInfo.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/utils/SystemInfo.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/utils/SystemInfo.h 2013-05-12 08:41:54.000000000 +0000 @@ -71,19 +71,28 @@ public: enum WindowsVersion { + // clang-format off WindowsVersionUnknown = -1, // Undetected, unsupported Windows version or OS in not Windows - WindowsVersionWin8_1, // Windows 8.1, Windows Server 2012 R2 + WindowsVersionWin8_1, // Windows 8.1, Windows Server 2012 R2 WindowsVersionWin10, // Windows 10 + WindowsVersionWin10_1607, // Windows 10 1607 WindowsVersionWin10_1709, // Windows 10 1709 (FCU) WindowsVersionWin10_1803, // Windows 10 1803 WindowsVersionWin10_1809, // Windows 10 1809 WindowsVersionWin10_1903, // Windows 10 1903 WindowsVersionWin10_1909, // Windows 10 1909 WindowsVersionWin10_2004, // Windows 10 2004 + WindowsVersionWin10_20H2, // Windows 10 20H2 + WindowsVersionWin10_21H1, // Windows 10 21H1 + WindowsVersionWin10_21H2, // Windows 10 21H2 + WindowsVersionWin10_22H2, // Windows 10 22H2 WindowsVersionWin10_Future, // Windows 10 future build - WindowsVersionWin11, // Windows 11 + WindowsVersionWin11_21H2, // Windows 11 21H2 - Sun Valley + WindowsVersionWin11_22H2, // Windows 11 22H2 - Sun Valley 2 + WindowsVersionWin11_Future, // Windows 11 future build /* Insert new Windows versions here, when they'll be known */ WindowsVersionFuture = 100 // Future Windows version, not known to code + // clang-format on }; enum WindowsDeviceFamily { diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/android/VideoSyncAndroid.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/android/VideoSyncAndroid.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/android/VideoSyncAndroid.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/android/VideoSyncAndroid.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -19,14 +19,12 @@ #include "platform/android/activity/XBMCApp.h" - -bool CVideoSyncAndroid::Setup(PUPDATECLOCK func) +bool CVideoSyncAndroid::Setup() { CLog::Log(LOGDEBUG, "CVideoSyncAndroid::{} setting up", __FUNCTION__); //init the vblank timestamp m_LastVBlankTime = CurrentHostCounter(); - UpdateClock = func; m_abortEvent.Reset(); CXBMCApp::Get().InitFrameCallback(this); @@ -74,5 +72,5 @@ m_LastVBlankTime = frameTimeNanos; //update the vblank timestamp, update the clock and send a signal that we got a vblank - UpdateClock(NrVBlanks, frameTimeNanos, m_refClock); + m_refClock->UpdateClock(NrVBlanks, frameTimeNanos); } diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/android/VideoSyncAndroid.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/android/VideoSyncAndroid.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/android/VideoSyncAndroid.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/android/VideoSyncAndroid.h 2013-05-12 08:41:54.000000000 +0000 @@ -14,10 +14,10 @@ class CVideoSyncAndroid : public CVideoSync, IDispResource { public: - CVideoSyncAndroid(void *clock) : CVideoSync(clock), m_LastVBlankTime(0) {} + CVideoSyncAndroid(CVideoReferenceClock* clock) : CVideoSync(clock), m_LastVBlankTime(0) {} // CVideoSync interface - bool Setup(PUPDATECLOCK func) override; + bool Setup() override; void Run(CEvent& stop) override; void Cleanup() override; float GetFps() override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/android/WinSystemAndroidGLESContext.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -168,7 +168,7 @@ return m_pGLContext.GetEGLConfig(); } -std::unique_ptr CWinSystemAndroidGLESContext::GetVideoSync(void *clock) +std::unique_ptr CWinSystemAndroidGLESContext::GetVideoSync(CVideoReferenceClock* clock) { std::unique_ptr pVSync(new CVideoSyncAndroid(clock)); return pVSync; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/android/WinSystemAndroidGLESContext.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/android/WinSystemAndroidGLESContext.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/android/WinSystemAndroidGLESContext.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/android/WinSystemAndroidGLESContext.h 2013-05-12 08:41:54.000000000 +0000 @@ -35,7 +35,7 @@ bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop) override; bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) override; - std::unique_ptr GetVideoSync(void* clock) override; + std::unique_ptr GetVideoSync(CVideoReferenceClock* clock) override; float GetFrameLatencyAdjustment() override; bool IsHDRDisplay() override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/gbm/VideoSyncGbm.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/gbm/VideoSyncGbm.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/gbm/VideoSyncGbm.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/gbm/VideoSyncGbm.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -9,6 +9,7 @@ #include "VideoSyncGbm.h" #include "ServiceBroker.h" +#include "cores/VideoPlayer/VideoReferenceClock.h" #include "threads/Thread.h" #include "utils/TimeUtils.h" #include "utils/log.h" @@ -24,16 +25,15 @@ #include -CVideoSyncGbm::CVideoSyncGbm(void* clock) +CVideoSyncGbm::CVideoSyncGbm(CVideoReferenceClock* clock) : CVideoSync(clock), m_winSystem(CServiceBroker::GetWinSystem()) { if (!m_winSystem) throw std::runtime_error("window system not available"); } -bool CVideoSyncGbm::Setup(PUPDATECLOCK func) +bool CVideoSyncGbm::Setup() { - UpdateClock = func; m_abort = false; m_winSystem->Register(this); CLog::Log(LOGDEBUG, "CVideoSyncGbm::{} setting up", __FUNCTION__); @@ -101,7 +101,7 @@ if (sequence == m_sequence) continue; - UpdateClock(sequence - m_sequence, m_offset + ns, m_refClock); + m_refClock->UpdateClock(sequence - m_sequence, m_offset + ns); m_sequence = sequence; } } diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/gbm/VideoSyncGbm.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/gbm/VideoSyncGbm.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/gbm/VideoSyncGbm.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/gbm/VideoSyncGbm.h 2013-05-12 08:41:54.000000000 +0000 @@ -18,12 +18,12 @@ class CVideoSyncGbm : public CVideoSync, IDispResource { public: - explicit CVideoSyncGbm(void* clock); + explicit CVideoSyncGbm(CVideoReferenceClock* clock); CVideoSyncGbm() = delete; ~CVideoSyncGbm() override = default; // CVideoSync overrides - bool Setup(PUPDATECLOCK func) override; + bool Setup() override; void Run(CEvent& stopEvent) override; void Cleanup() override; float GetFps() override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/gbm/WinSystemGbm.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/gbm/WinSystemGbm.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/gbm/WinSystemGbm.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/gbm/WinSystemGbm.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -13,6 +13,7 @@ #include "ServiceBroker.h" #include "VideoSyncGbm.h" #include "cores/VideoPlayer/Buffers/VideoBufferDRMPRIME.h" +#include "cores/VideoPlayer/VideoReferenceClock.h" #include "drm/DRMAtomic.h" #include "drm/DRMLegacy.h" #include "drm/OffScreenModeSetting.h" @@ -338,7 +339,7 @@ resource->OnLostDisplay(); } -std::unique_ptr CWinSystemGbm::GetVideoSync(void* clock) +std::unique_ptr CWinSystemGbm::GetVideoSync(CVideoReferenceClock* clock) { return std::make_unique(clock); } diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/gbm/WinSystemGbm.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/gbm/WinSystemGbm.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/gbm/WinSystemGbm.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/gbm/WinSystemGbm.h 2013-05-12 08:41:54.000000000 +0000 @@ -79,7 +79,7 @@ protected: void OnLostDevice(); - std::unique_ptr GetVideoSync(void* clock) override; + std::unique_ptr GetVideoSync(CVideoReferenceClock* clock) override; std::shared_ptr m_DRM; std::unique_ptr m_GBM; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/ios/VideoSyncIos.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/ios/VideoSyncIos.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/ios/VideoSyncIos.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/ios/VideoSyncIos.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -15,13 +15,12 @@ #include "windowing/GraphicContext.h" #include "windowing/ios/WinSystemIOS.h" -bool CVideoSyncIos::Setup(PUPDATECLOCK func) +bool CVideoSyncIos::Setup() { CLog::Log(LOGDEBUG, "CVideoSyncIos::{} setting up OSX", __FUNCTION__); //init the vblank timestamp m_LastVBlankTime = CurrentHostCounter(); - UpdateClock = func; m_abortEvent.Reset(); bool setupOk = InitDisplayLink(); @@ -73,7 +72,7 @@ m_LastVBlankTime = nowtime; //update the vblank timestamp, update the clock and send a signal that we got a vblank - UpdateClock(NrVBlanks, nowtime, m_refClock); + m_refClock->UpdateClock(NrVBlanks, nowtime); } bool CVideoSyncIos::InitDisplayLink() diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/ios/VideoSyncIos.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/ios/VideoSyncIos.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/ios/VideoSyncIos.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/ios/VideoSyncIos.h 2013-05-12 08:41:54.000000000 +0000 @@ -16,11 +16,13 @@ class CVideoSyncIos : public CVideoSync, IDispResource { public: - CVideoSyncIos(void *clock, CWinSystemIOS &winSystem) : - CVideoSync(clock), m_winSystem(winSystem) {} + CVideoSyncIos(CVideoReferenceClock* clock, CWinSystemIOS& winSystem) + : CVideoSync(clock), m_winSystem(winSystem) + { + } // CVideoSync interface - bool Setup(PUPDATECLOCK func) override; + bool Setup() override; void Run(CEvent& stopEvent) override; void Cleanup() override; float GetFps() override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/ios/WinSystemIOS.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/ios/WinSystemIOS.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/ios/WinSystemIOS.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/ios/WinSystemIOS.h 2013-05-12 08:41:54.000000000 +0000 @@ -60,7 +60,7 @@ void Register(IDispResource *resource) override; void Unregister(IDispResource *resource) override; - std::unique_ptr GetVideoSync(void* clock) override; + std::unique_ptr GetVideoSync(CVideoReferenceClock* clock) override; std::vector GetConnectedOutputs() override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/ios/WinSystemIOS.mm kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/ios/WinSystemIOS.mm --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/ios/WinSystemIOS.mm 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/ios/WinSystemIOS.mm 2013-05-12 08:41:54.000000000 +0000 @@ -489,7 +489,7 @@ CDisplaySettings::GetInstance().SetMonitor(CONST_TOUCHSCREEN); } -std::unique_ptr CWinSystemIOS::GetVideoSync(void *clock) +std::unique_ptr CWinSystemIOS::GetVideoSync(CVideoReferenceClock* clock) { std::unique_ptr pVSync(new CVideoSyncIos(clock, *this)); return pVSync; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/osx/SDL/WinSystemOSXSDL.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/osx/SDL/WinSystemOSXSDL.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/osx/SDL/WinSystemOSXSDL.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/osx/SDL/WinSystemOSXSDL.h 2013-05-12 08:41:54.000000000 +0000 @@ -57,7 +57,7 @@ void Register(IDispResource *resource) override; void Unregister(IDispResource *resource) override; - std::unique_ptr GetVideoSync(void* clock) override; + std::unique_ptr GetVideoSync(CVideoReferenceClock* clock) override; std::vector GetConnectedOutputs() override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/osx/SDL/WinSystemOSXSDL.mm kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/osx/SDL/WinSystemOSXSDL.mm --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/osx/SDL/WinSystemOSXSDL.mm 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/osx/SDL/WinSystemOSXSDL.mm 2013-05-12 08:41:54.000000000 +0000 @@ -1820,7 +1820,7 @@ return utf8_text; } -std::unique_ptr CWinSystemOSX::GetVideoSync(void *clock) +std::unique_ptr CWinSystemOSX::GetVideoSync(CVideoReferenceClock* clock) { std::unique_ptr pVSync(new CVideoSyncOsx(clock)); return pVSync; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/osx/VideoSyncOsx.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/osx/VideoSyncOsx.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/osx/VideoSyncOsx.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/osx/VideoSyncOsx.h 2013-05-12 08:41:54.000000000 +0000 @@ -15,13 +15,13 @@ class CVideoSyncOsx : public CVideoSync, IDispResource { public: - CVideoSyncOsx(void* clock) + CVideoSyncOsx(CVideoReferenceClock* clock) : CVideoSync(clock), m_LastVBlankTime(0), m_displayLost(false), m_displayReset(false) { } // CVideoSync interface - bool Setup(PUPDATECLOCK func) override; + bool Setup() override; void Run(CEvent& stopEvent) override; void Cleanup() override; float GetFps() override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/osx/VideoSyncOsx.mm kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/osx/VideoSyncOsx.mm --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/osx/VideoSyncOsx.mm 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/osx/VideoSyncOsx.mm 2013-05-12 08:41:54.000000000 +0000 @@ -9,6 +9,7 @@ #include "VideoSyncOsx.h" #include "ServiceBroker.h" +#include "cores/VideoPlayer/VideoReferenceClock.h" #include "utils/MathUtils.h" #include "utils/TimeUtils.h" #include "utils/log.h" @@ -23,13 +24,12 @@ using namespace std::chrono_literals; -bool CVideoSyncOsx::Setup(PUPDATECLOCK func) +bool CVideoSyncOsx::Setup() { CLog::Log(LOGDEBUG, "CVideoSyncOsx::{} setting up OSX", __FUNCTION__); //init the vblank timestamp m_LastVBlankTime = 0; - UpdateClock = func; m_displayLost = false; m_displayReset = false; m_lostEvent.Reset(); @@ -105,7 +105,7 @@ NrVBlanks = MathUtils::round_int(VBlankTime * static_cast(m_fps)); //update the vblank timestamp, update the clock and send a signal that we got a vblank - UpdateClock(NrVBlanks, Now, m_refClock); + m_refClock->UpdateClock(NrVBlanks, Now); } //save the timestamp of this vblank so we can calculate how many happened next time diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/osx/WinSystemOSX.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/osx/WinSystemOSX.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/osx/WinSystemOSX.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/osx/WinSystemOSX.h 2013-05-12 08:41:54.000000000 +0000 @@ -76,7 +76,7 @@ void Register(IDispResource* resource) override; void Unregister(IDispResource* resource) override; - std::unique_ptr GetVideoSync(void* clock) override; + std::unique_ptr GetVideoSync(CVideoReferenceClock* clock) override; void WindowChangedScreen(); diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/osx/WinSystemOSX.mm kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/osx/WinSystemOSX.mm --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/osx/WinSystemOSX.mm 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/osx/WinSystemOSX.mm 2013-05-12 08:41:54.000000000 +0000 @@ -1194,7 +1194,7 @@ forParameter:NSOpenGLContextParameterSwapInterval]; } -std::unique_ptr CWinSystemOSX::GetVideoSync(void* clock) +std::unique_ptr CWinSystemOSX::GetVideoSync(CVideoReferenceClock* clock) { return std::make_unique(clock); } diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/tvos/VideoSyncTVos.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/tvos/VideoSyncTVos.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/tvos/VideoSyncTVos.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/tvos/VideoSyncTVos.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -15,13 +15,12 @@ #include "windowing/GraphicContext.h" #import "windowing/tvos/WinSystemTVOS.h" -bool CVideoSyncTVos::Setup(PUPDATECLOCK func) +bool CVideoSyncTVos::Setup() { CLog::Log(LOGDEBUG, "CVideoSyncTVos::{} setting up TVOS", __FUNCTION__); //init the vblank timestamp m_LastVBlankTime = CurrentHostCounter(); - UpdateClock = func; m_abortEvent.Reset(); bool setupOk = InitDisplayLink(); @@ -72,7 +71,7 @@ m_LastVBlankTime = nowtime; //update the vblank timestamp, update the clock and send a signal that we got a vblank - UpdateClock(NrVBlanks, nowtime, m_refClock); + m_refClock->UpdateClock(NrVBlanks, nowtime); } bool CVideoSyncTVos::InitDisplayLink() diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/tvos/VideoSyncTVos.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/tvos/VideoSyncTVos.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/tvos/VideoSyncTVos.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/tvos/VideoSyncTVos.h 2013-05-12 08:41:54.000000000 +0000 @@ -16,12 +16,13 @@ class CVideoSyncTVos : public CVideoSync, IDispResource { public: - CVideoSyncTVos(void* clock, CWinSystemTVOS& winSystem) : CVideoSync(clock), m_winSystem(winSystem) + CVideoSyncTVos(CVideoReferenceClock* clock, CWinSystemTVOS& winSystem) + : CVideoSync(clock), m_winSystem(winSystem) { } // CVideoSync interface - bool Setup(PUPDATECLOCK func) override; + bool Setup() override; void Run(CEvent& stopEvent) override; void Cleanup() override; float GetFps() override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/tvos/WinSystemTVOS.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/tvos/WinSystemTVOS.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/tvos/WinSystemTVOS.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/tvos/WinSystemTVOS.h 2013-05-12 08:41:54.000000000 +0000 @@ -72,7 +72,7 @@ void Register(IDispResource* resource) override; void Unregister(IDispResource* resource) override; - //virtual std::unique_ptr GetVideoSync(void* clock) override; + //virtual std::unique_ptr GetVideoSync(CVideoReferenceClock* clock) override; std::vector GetConnectedOutputs() override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/VideoSync.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/VideoSync.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/VideoSync.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/VideoSync.h 2013-05-12 08:41:54.000000000 +0000 @@ -11,21 +11,19 @@ #include "threads/Event.h" class CVideoReferenceClock; -typedef void (*PUPDATECLOCK)(int NrVBlanks, uint64_t time, void *clock); class CVideoSync { public: - explicit CVideoSync(void* clock) { m_refClock = clock; } + explicit CVideoSync(CVideoReferenceClock* clock) { m_refClock = clock; } virtual ~CVideoSync() = default; - virtual bool Setup(PUPDATECLOCK func) = 0; + virtual bool Setup() = 0; virtual void Run(CEvent& stop) = 0; virtual void Cleanup() = 0; virtual float GetFps() = 0; virtual void RefreshChanged() {} protected: - PUPDATECLOCK UpdateClock; float m_fps; - void *m_refClock; + CVideoReferenceClock* m_refClock; }; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/wayland/VideoSyncWpPresentation.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/wayland/VideoSyncWpPresentation.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/wayland/VideoSyncWpPresentation.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/wayland/VideoSyncWpPresentation.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -8,6 +8,7 @@ #include "VideoSyncWpPresentation.h" +#include "cores/VideoPlayer/VideoReferenceClock.h" #include "settings/AdvancedSettings.h" #include "utils/TimeUtils.h" #include "utils/log.h" @@ -19,14 +20,14 @@ using namespace KODI::WINDOWING::WAYLAND; using namespace std::placeholders; -CVideoSyncWpPresentation::CVideoSyncWpPresentation(void* clock, CWinSystemWayland& winSystem) -: CVideoSync(clock), m_winSystem(winSystem) +CVideoSyncWpPresentation::CVideoSyncWpPresentation(CVideoReferenceClock* clock, + CWinSystemWayland& winSystem) + : CVideoSync(clock), m_winSystem(winSystem) { } -bool CVideoSyncWpPresentation::Setup(PUPDATECLOCK func) +bool CVideoSyncWpPresentation::Setup() { - UpdateClock = func; m_stopEvent.Reset(); m_fps = m_winSystem.GetSyncOutputRefreshRate(); @@ -79,5 +80,5 @@ // FIXME use timespec instead of currenthostcounter()? Possibly difficult // due to different clock base - UpdateClock(mscDiff, CurrentHostCounter(), m_refClock); + m_refClock->UpdateClock(mscDiff, CurrentHostCounter()); } diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/wayland/VideoSyncWpPresentation.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/wayland/VideoSyncWpPresentation.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/wayland/VideoSyncWpPresentation.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/wayland/VideoSyncWpPresentation.h 2013-05-12 08:41:54.000000000 +0000 @@ -25,10 +25,10 @@ class CVideoSyncWpPresentation : public CVideoSync { public: - explicit CVideoSyncWpPresentation(void* clock, CWinSystemWayland& winSystem); + explicit CVideoSyncWpPresentation(CVideoReferenceClock* clock, CWinSystemWayland& winSystem); float GetFps() override; - bool Setup(PUPDATECLOCK func) override; + bool Setup() override; void Run(CEvent& stop) override; void Cleanup() override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/wayland/WinSystemWayland.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/wayland/WinSystemWayland.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/wayland/WinSystemWayland.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/wayland/WinSystemWayland.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -24,6 +24,7 @@ #include "application/Application.h" #include "cores/RetroPlayer/process/wayland/RPProcessInfoWayland.h" #include "cores/VideoPlayer/Process/wayland/ProcessInfoWayland.h" +#include "cores/VideoPlayer/VideoReferenceClock.h" #include "guilib/DispResource.h" #include "guilib/LocalizeStrings.h" #include "input/InputManager.h" @@ -1471,7 +1472,7 @@ return m_presentationFeedbackHandlers.Register(handler); } -std::unique_ptr CWinSystemWayland::GetVideoSync(void* clock) +std::unique_ptr CWinSystemWayland::GetVideoSync(CVideoReferenceClock* clock) { if (m_surface && m_presentation) { diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/wayland/WinSystemWayland.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/wayland/WinSystemWayland.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/wayland/WinSystemWayland.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/wayland/WinSystemWayland.h 2013-05-12 08:41:54.000000000 +0000 @@ -84,7 +84,7 @@ float GetSyncOutputRefreshRate(); float GetDisplayLatency() override; float GetFrameLatencyAdjustment() override; - std::unique_ptr GetVideoSync(void* clock) override; + std::unique_ptr GetVideoSync(CVideoReferenceClock* clock) override; void Register(IDispResource* resource) override; void Unregister(IDispResource* resource) override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/win10/WinSystemWin10.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/win10/WinSystemWin10.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/win10/WinSystemWin10.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/win10/WinSystemWin10.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -606,7 +606,7 @@ OnDisplayBack(); } -std::unique_ptr CWinSystemWin10::GetVideoSync(void *clock) +std::unique_ptr CWinSystemWin10::GetVideoSync(CVideoReferenceClock* clock) { std::unique_ptr pVSync(new CVideoSyncD3D(clock)); return pVSync; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/win10/WinSystemWin10.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/win10/WinSystemWin10.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/win10/WinSystemWin10.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/win10/WinSystemWin10.h 2013-05-12 08:41:54.000000000 +0000 @@ -84,7 +84,7 @@ bool HasSystemSdrPeakLuminance() override; // videosync - std::unique_ptr GetVideoSync(void *clock) override; + std::unique_ptr GetVideoSync(CVideoReferenceClock* clock) override; bool WindowedMode() const { return m_state != WINDOW_STATE_FULLSCREEN; } bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/windows/VideoSyncD3D.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/windows/VideoSyncD3D.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/windows/VideoSyncD3D.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/windows/VideoSyncD3D.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -10,6 +10,7 @@ #include "Utils/MathUtils.h" #include "Utils/TimeUtils.h" +#include "cores/VideoPlayer/VideoReferenceClock.h" #include "rendering/dx/DeviceResources.h" #include "rendering/dx/RenderContext.h" #include "utils/StringUtils.h" @@ -40,7 +41,7 @@ m_displayReset = true; } -bool CVideoSyncD3D::Setup(PUPDATECLOCK func) +bool CVideoSyncD3D::Setup() { CLog::Log(LOGDEBUG, "CVideoSyncD3D: Setting up Direct3d"); std::unique_lock lock(CServiceBroker::GetWinSystem()->GetGfxContext()); @@ -48,7 +49,6 @@ m_displayLost = false; m_displayReset = false; m_lostEvent.Reset(); - UpdateClock = func; // we need a high priority thread to get accurate timing if (!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL)) @@ -82,7 +82,7 @@ NrVBlanks = MathUtils::round_int(VBlankTime * m_fps); // update the vblank timestamp, update the clock and send a signal that we got a vblank - UpdateClock(NrVBlanks, Now, m_refClock); + m_refClock->UpdateClock(NrVBlanks, Now); // save the timestamp of this vblank so we can calculate how many vblanks happened next time LastVBlankTime = Now; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/windows/VideoSyncD3D.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/windows/VideoSyncD3D.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/windows/VideoSyncD3D.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/windows/VideoSyncD3D.h 2013-05-12 08:41:54.000000000 +0000 @@ -15,11 +15,11 @@ class CVideoSyncD3D : public CVideoSync, IDispResource { public: - CVideoSyncD3D(void* clock) + CVideoSyncD3D(CVideoReferenceClock* clock) : CVideoSync(clock), m_displayLost(false), m_displayReset(false), m_lastUpdateTime(0) { } - bool Setup(PUPDATECLOCK func) override; + bool Setup() override; void Run(CEvent& stopEvent) override; void Cleanup() override; float GetFps() override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/windows/WinSystemWin32.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/windows/WinSystemWin32.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/windows/WinSystemWin32.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/windows/WinSystemWin32.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -1239,7 +1239,7 @@ } } -std::unique_ptr CWinSystemWin32::GetVideoSync(void *clock) +std::unique_ptr CWinSystemWin32::GetVideoSync(CVideoReferenceClock* clock) { std::unique_ptr pVSync(new CVideoSyncD3D(clock)); return pVSync; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/windows/WinSystemWin32.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/windows/WinSystemWin32.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/windows/WinSystemWin32.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/windows/WinSystemWin32.h 2013-05-12 08:41:54.000000000 +0000 @@ -98,7 +98,7 @@ bool HasSystemSdrPeakLuminance() override; // videosync - std::unique_ptr GetVideoSync(void *clock) override; + std::unique_ptr GetVideoSync(CVideoReferenceClock* clock) override; bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/WinSystem.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/WinSystem.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/WinSystem.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/WinSystem.h 2013-05-12 08:41:54.000000000 +0000 @@ -38,6 +38,7 @@ class CGraphicContext; class CRenderSystemBase; class IRenderLoop; +class CVideoReferenceClock; struct VideoPicture; @@ -105,7 +106,7 @@ virtual bool Show(bool raise = true) { return false; } // videosync - virtual std::unique_ptr GetVideoSync(void *clock) { return nullptr; } + virtual std::unique_ptr GetVideoSync(CVideoReferenceClock* clock) { return nullptr; } // notifications virtual void OnMove(int x, int y) {} diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/OptionalsReg.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/OptionalsReg.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/OptionalsReg.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/OptionalsReg.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -8,6 +8,8 @@ #include "OptionalsReg.h" +#include "cores/VideoPlayer/VideoReferenceClock.h" + //----------------------------------------------------------------------------- // VAAPI //----------------------------------------------------------------------------- @@ -159,8 +161,7 @@ return new CGLContextGLX(dpy); } - -CVideoSync* GLXVideoSyncCreate(void* clock, CWinSystemX11GLContext& winSystem) +CVideoSync* GLXVideoSyncCreate(CVideoReferenceClock* clock, CWinSystemX11GLContext& winSystem) { return new CVideoSyncGLX(clock, winSystem); } @@ -192,7 +193,7 @@ return nullptr; } -CVideoSync* GLXVideoSyncCreate(void* clock, CWinSystemX11GLContext& winSystem) +CVideoSync* GLXVideoSyncCreate(CVideoReferenceClock* clock, CWinSystemX11GLContext& winSystem) { return nullptr; } diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/OptionalsReg.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/OptionalsReg.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/OptionalsReg.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/OptionalsReg.h 2013-05-12 08:41:54.000000000 +0000 @@ -43,6 +43,7 @@ class CVideoSync; class CGLContext; +class CVideoReferenceClock; namespace KODI { @@ -56,7 +57,7 @@ XID GLXGetWindow(void* context); void* GLXGetContext(void* context); CGLContext* GLXContextCreate(Display *dpy); -CVideoSync* GLXVideoSyncCreate(void *clock, CWinSystemX11GLContext& winSystem); +CVideoSync* GLXVideoSyncCreate(CVideoReferenceClock* clock, CWinSystemX11GLContext& winSystem); } } } diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/VideoSyncGLX.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/VideoSyncGLX.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/VideoSyncGLX.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/VideoSyncGLX.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -8,6 +8,7 @@ #include "VideoSyncGLX.h" +#include "cores/VideoPlayer/VideoReferenceClock.h" #include "utils/TimeUtils.h" #include "utils/XTimeUtils.h" #include "utils/log.h" @@ -39,7 +40,7 @@ m_displayReset = true; } -bool CVideoSyncGLX::Setup(PUPDATECLOCK func) +bool CVideoSyncGLX::Setup() { std::unique_lock lock(m_winSystem.GetGfxContext()); @@ -48,7 +49,6 @@ m_vInfo = NULL; m_Window = 0; m_Context = NULL; - UpdateClock = func; int singleBufferAttributes[] = { GLX_RGBA, @@ -197,7 +197,7 @@ if (VblankCount > PrevVblankCount) { - UpdateClock((int)(VblankCount - PrevVblankCount), Now, m_refClock); + m_refClock->UpdateClock((int)(VblankCount - PrevVblankCount), Now); IsReset = false; } else diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/VideoSyncGLX.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/VideoSyncGLX.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/VideoSyncGLX.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/VideoSyncGLX.h 2013-05-12 08:41:54.000000000 +0000 @@ -32,11 +32,11 @@ class CVideoSyncGLX : public CVideoSync, IDispResource { public: - explicit CVideoSyncGLX(void* clock, CWinSystemX11GLContext& winSystem) + explicit CVideoSyncGLX(CVideoReferenceClock* clock, CWinSystemX11GLContext& winSystem) : CVideoSync(clock), m_winSystem(winSystem) { } - bool Setup(PUPDATECLOCK func) override; + bool Setup() override; void Run(CEvent& stopEvent) override; void Cleanup() override; float GetFps() override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/VideoSyncOML.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/VideoSyncOML.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/VideoSyncOML.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/VideoSyncOML.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -8,6 +8,7 @@ #include "VideoSyncOML.h" +#include "cores/VideoPlayer/VideoReferenceClock.h" #include "utils/TimeUtils.h" #include "utils/log.h" #include "windowing/GraphicContext.h" @@ -17,12 +18,10 @@ using namespace KODI::WINDOWING::X11; -bool CVideoSyncOML::Setup(PUPDATECLOCK func) +bool CVideoSyncOML::Setup() { CLog::Log(LOGDEBUG, "CVideoSyncOML::{} - setting up OML", __FUNCTION__); - UpdateClock = func; - m_abort = false; static_cast(&m_winSystem)->Register(this); @@ -60,7 +59,7 @@ } uint64_t now = CurrentHostCounter(); - UpdateClock(newMsc - msc, now, m_refClock); + m_refClock->UpdateClock(newMsc - msc, now); msc = newMsc; } } diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/VideoSyncOML.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/VideoSyncOML.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/VideoSyncOML.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/VideoSyncOML.h 2013-05-12 08:41:54.000000000 +0000 @@ -26,11 +26,11 @@ class CVideoSyncOML : public CVideoSync, IDispResource { public: - explicit CVideoSyncOML(void* clock, CWinSystemX11GLContext& winSystem) + explicit CVideoSyncOML(CVideoReferenceClock* clock, CWinSystemX11GLContext& winSystem) : CVideoSync(clock), m_winSystem(winSystem) { } - bool Setup(PUPDATECLOCK func) override; + bool Setup() override; void Run(CEvent& stopEvent) override; void Cleanup() override; float GetFps() override; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/WinSystemX11GLContext.cpp kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/WinSystemX11GLContext.cpp --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/WinSystemX11GLContext.cpp 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/WinSystemX11GLContext.cpp 2013-05-12 08:41:54.000000000 +0000 @@ -18,6 +18,7 @@ #include "cores/RetroPlayer/rendering/VideoRenderers/RPRendererOpenGL.h" #include "cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h" #include "cores/VideoPlayer/Process/X11/ProcessInfoX11.h" +#include "cores/VideoPlayer/VideoReferenceClock.h" #include "cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h" #include "cores/VideoPlayer/VideoRenderers/RenderFactory.h" #include "guilib/DispResource.h" @@ -313,7 +314,7 @@ return success; } -std::unique_ptr CWinSystemX11GLContext::GetVideoSync(void *clock) +std::unique_ptr CWinSystemX11GLContext::GetVideoSync(CVideoReferenceClock* clock) { std::unique_ptr pVSync; diff -Nru kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/WinSystemX11GLContext.h kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/WinSystemX11GLContext.h --- kodi-21.0+git20230505.0301-756a5bd475/xbmc/windowing/X11/WinSystemX11GLContext.h 2013-05-12 08:41:54.000000000 +0000 +++ kodi-21.0+git20230507.0301-eebc71466d/xbmc/windowing/X11/WinSystemX11GLContext.h 2013-05-12 08:41:54.000000000 +0000 @@ -15,6 +15,7 @@ #include class CGLContext; +class CVideoReferenceClock; namespace KODI { @@ -46,7 +47,7 @@ bool IsExtSupported(const char* extension) const override; // videosync - std::unique_ptr GetVideoSync(void *clock) override; + std::unique_ptr GetVideoSync(CVideoReferenceClock* clock) override; float GetFrameLatencyAdjustment() override; uint64_t GetVblankTiming(uint64_t &msc, uint64_t &interval);