mirror of
				https://github.com/RetroDECK/ES-DE.git
				synced 2025-04-10 19:15:13 +00:00 
			
		
		
		
	Changed to unique_ptr for the threading in VideoFFmpegComponent and TextureDataManager.
This commit is contained in:
		
							parent
							
								
									398e47e2cc
								
							
						
					
					
						commit
						f3f86c6e20
					
				|  | @ -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.
 | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
|  | @ -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() | ||||
|  |  | |||
|  | @ -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; | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Leon Styhre
						Leon Styhre