mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Fixed two memory leaks in VideoVlcComponent.
This commit is contained in:
parent
e96f8b9c0a
commit
28c66225c9
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "components/HelpComponent.h"
|
||||
#include "components/ImageComponent.h"
|
||||
#include "components/VideoVlcComponent.h"
|
||||
#include "resources/Font.h"
|
||||
#include "Sound.h"
|
||||
#include "InputManager.h"
|
||||
|
@ -131,6 +132,7 @@ void Window::deinit()
|
|||
|
||||
InputManager::getInstance()->deinit();
|
||||
ResourceManager::getInstance()->unloadAll();
|
||||
VideoVlcComponent::deinit();
|
||||
Renderer::deinit();
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ VideoVlcComponent::VideoVlcComponent(
|
|||
Window* window)
|
||||
: VideoComponent(window),
|
||||
mMediaPlayer(nullptr),
|
||||
mMedia(nullptr),
|
||||
mContext({}),
|
||||
mHasSetAudioVolume(false)
|
||||
{
|
||||
|
@ -50,6 +51,14 @@ VideoVlcComponent::~VideoVlcComponent()
|
|||
mTexture.reset();
|
||||
}
|
||||
|
||||
void VideoVlcComponent::deinit()
|
||||
{
|
||||
if (mVLC) {
|
||||
libvlc_release(mVLC);
|
||||
mVLC = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void VideoVlcComponent::setResize(float width, float height)
|
||||
{
|
||||
// This resize function is used when stretching videos to full screen in the video screensaver.
|
||||
|
@ -358,6 +367,9 @@ void VideoVlcComponent::startVideo()
|
|||
}
|
||||
}
|
||||
libvlc_media_tracks_release(tracks, track_count);
|
||||
libvlc_media_parse_stop(mMedia);
|
||||
libvlc_event_detach(libvlc_media_event_manager(mMedia),
|
||||
libvlc_MediaParsedChanged, VlcMediaParseCallback, 0);
|
||||
|
||||
// Make sure we found a valid video track.
|
||||
if ((mVideoWidth > 0) && (mVideoHeight > 0)) {
|
||||
|
@ -466,6 +478,7 @@ void VideoVlcComponent::stopVideo()
|
|||
libvlc_media_player_release(mMediaPlayer);
|
||||
libvlc_media_release(mMedia);
|
||||
mMediaPlayer = nullptr;
|
||||
mMedia = nullptr;
|
||||
freeContext();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ public:
|
|||
VideoVlcComponent(Window* window);
|
||||
virtual ~VideoVlcComponent();
|
||||
|
||||
static void deinit();
|
||||
|
||||
// Resize the video to fit this size. If one axis is zero, scale that axis to maintain
|
||||
// aspect ratio. If both are non-zero, potentially break the aspect ratio. If both are
|
||||
// zero, no resizing. This can be set before or after a video is loaded.
|
||||
|
|
Loading…
Reference in a new issue