1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-24 03:47:18 +02:00

Correctly shutdown client media handlers

This commit is contained in:
Ivan Savenko 2023-11-13 15:24:14 +02:00
parent a6f37b7cd7
commit af0afb251e
3 changed files with 10 additions and 5 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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;