Browse Source

Correctly shutdown client media handlers

Ivan Savenko 1 year ago
parent
commit
af0afb251e
3 changed files with 10 additions and 5 deletions
  1. 3 0
      client/CMT.cpp
  2. 4 3
      client/CMusicHandler.h
  3. 3 2
      client/CVideoHandler.h

+ 3 - 0
client/CMT.cpp

@@ -473,6 +473,9 @@ static void quitApplication()
 
 			delete CCS->consoleh;
 			delete CCS->curh;
+			delete CCS->videoh;
+			delete CCS->musich;
+			delete CCS->soundh;
 
 			vstd::clear_pointer(CCS);
 		}

+ 4 - 3
client/CMusicHandler.h

@@ -23,8 +23,9 @@ protected:
 	bool initialized;
 	int volume;					// from 0 (mute) to 100
 
-public:
 	CAudioBase(): initialized(false), volume(0) {};
+	~CAudioBase() = default;
+public:
 	virtual void init() = 0;
 	virtual void release() = 0;
 
@@ -32,7 +33,7 @@ public:
 	ui32 getVolume() const { return volume; };
 };
 
-class CSoundHandler: public CAudioBase
+class CSoundHandler final : public CAudioBase
 {
 private:
 	//update volume on configuration change
@@ -124,7 +125,7 @@ public:
 	bool stop(int fade_ms=0);
 };
 
-class CMusicHandler: public CAudioBase
+class CMusicHandler final: public CAudioBase
 {
 private:
 	//update volume on configuration change

+ 3 - 2
client/CVideoHandler.h

@@ -31,6 +31,7 @@ public:
 class IMainVideoPlayer : public IVideoPlayer
 {
 public:
+	virtual ~IMainVideoPlayer() = default;
 	virtual void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true, std::function<void()> restart = nullptr){}
 	virtual bool openAndPlayVideo(const VideoPath & name, int x, int y, bool stopOnKey = false, bool scale = false)
 	{
@@ -39,7 +40,7 @@ public:
 	virtual std::pair<std::unique_ptr<ui8 []>, si64> getAudio(const VideoPath & videoToOpen) { return std::make_pair(nullptr, 0); };
 };
 
-class CEmptyVideoPlayer : public IMainVideoPlayer
+class CEmptyVideoPlayer final : public IMainVideoPlayer
 {
 public:
 	int curFrame() const override {return -1;};
@@ -64,7 +65,7 @@ VCMI_LIB_NAMESPACE_BEGIN
 class CInputStream;
 VCMI_LIB_NAMESPACE_END
 
-class CVideoPlayer : public IMainVideoPlayer
+class CVideoPlayer final : public IMainVideoPlayer
 {
 	int stream;					// stream index in video
 	AVFormatContext *format;