diff --git a/es-core/src/components/VideoFFmpegComponent.cpp b/es-core/src/components/VideoFFmpegComponent.cpp index cdf68e974..1aa0647fe 100644 --- a/es-core/src/components/VideoFFmpegComponent.cpp +++ b/es-core/src/components/VideoFFmpegComponent.cpp @@ -189,7 +189,8 @@ void VideoFFmpegComponent::update(int deltaTime) mTimeReference = std::chrono::high_resolution_clock::now(); if (!mFrameProcessingThread) - mFrameProcessingThread = new std::thread(&VideoFFmpegComponent::frameProcessing, this); + mFrameProcessingThread = + std::make_unique<std::thread>(&VideoFFmpegComponent::frameProcessing, this); } void VideoFFmpegComponent::frameProcessing() @@ -729,8 +730,7 @@ void VideoFFmpegComponent::stopVideo() if (mFrameProcessingThread) { // Wait for the thread execution to complete. mFrameProcessingThread->join(); - delete mFrameProcessingThread; - mFrameProcessingThread = nullptr; + mFrameProcessingThread.reset(); } // Clear the video and audio frame queues. diff --git a/es-core/src/components/VideoFFmpegComponent.h b/es-core/src/components/VideoFFmpegComponent.h index 60ef302b5..02b3033e5 100644 --- a/es-core/src/components/VideoFFmpegComponent.h +++ b/es-core/src/components/VideoFFmpegComponent.h @@ -74,7 +74,7 @@ private: std::shared_ptr<TextureResource> mTexture; std::vector<float> mVideoRectangleCoords; - std::thread* mFrameProcessingThread; + std::unique_ptr<std::thread> mFrameProcessingThread; std::mutex mPictureMutex; AVFormatContext* mFormatContext; diff --git a/es-core/src/resources/TextureDataManager.cpp b/es-core/src/resources/TextureDataManager.cpp index 8c55d7b9f..3f4e79fcf 100644 --- a/es-core/src/resources/TextureDataManager.cpp +++ b/es-core/src/resources/TextureDataManager.cpp @@ -149,7 +149,7 @@ void TextureDataManager::load(std::shared_ptr<TextureData> tex, bool block) TextureLoader::TextureLoader() : mExit(false) { - mThread = new std::thread(&TextureLoader::threadProc, this); + mThread = std::make_unique<std::thread>(&TextureLoader::threadProc, this); } TextureLoader::~TextureLoader() @@ -162,7 +162,7 @@ TextureLoader::~TextureLoader() mExit = true; mEvent.notify_one(); mThread->join(); - delete mThread; + mThread.reset(); } void TextureLoader::threadProc() diff --git a/es-core/src/resources/TextureDataManager.h b/es-core/src/resources/TextureDataManager.h index 027f33094..84890cc41 100644 --- a/es-core/src/resources/TextureDataManager.h +++ b/es-core/src/resources/TextureDataManager.h @@ -38,7 +38,7 @@ private: std::map<TextureData*, std::list<std::shared_ptr<TextureData>>::const_iterator> mTextureDataLookup; - std::thread* mThread; + std::unique_ptr<std::thread> mThread; std::mutex mMutex; std::condition_variable mEvent; bool mExit;