mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-20 05:38:52 +01:00
Video instance is now a singleton (checkin error previously). changed where video texture is destroyed to improve performance.
This commit is contained in:
parent
4dd2c97fd6
commit
03b07cf126
@ -50,6 +50,7 @@ GStreamerVideo::GStreamerVideo()
|
||||
, Width(0)
|
||||
, VideoBuffer(NULL)
|
||||
, VideoBufferSize(0)
|
||||
, MaxVideoBufferSize(0)
|
||||
, FrameReady(false)
|
||||
, IsPlaying(false)
|
||||
, PlayCount(0)
|
||||
@ -65,8 +66,12 @@ GStreamerVideo::~GStreamerVideo()
|
||||
delete[] VideoBuffer;
|
||||
VideoBuffer = NULL;
|
||||
VideoBufferSize = 0;
|
||||
MaxVideoBufferSize = 0;
|
||||
}
|
||||
|
||||
SDL_DestroyTexture(Texture);
|
||||
Texture = NULL;
|
||||
|
||||
FreeElements();
|
||||
}
|
||||
|
||||
@ -99,8 +104,14 @@ void GStreamerVideo::ProcessNewBuffer (GstElement *fakesink, GstBuffer *buf, Gst
|
||||
|
||||
if(video->Height && video->Width)
|
||||
{
|
||||
if(video->Texture && video->VideoBufferSize != map.size)
|
||||
{
|
||||
SDL_DestroyTexture(video->Texture);
|
||||
video->Texture = NULL;
|
||||
}
|
||||
|
||||
// keep the largest video buffer allocated to avoid the penalty of reallocating and deallocating
|
||||
if(!video->VideoBuffer || video->VideoBufferSize < map.size)
|
||||
if(!video->VideoBuffer || video->MaxVideoBufferSize < map.size)
|
||||
{
|
||||
if(video->VideoBuffer)
|
||||
{
|
||||
@ -108,9 +119,11 @@ void GStreamerVideo::ProcessNewBuffer (GstElement *fakesink, GstBuffer *buf, Gst
|
||||
}
|
||||
|
||||
video->VideoBuffer = new char[map.size];
|
||||
video->VideoBufferSize = map.size;
|
||||
video->MaxVideoBufferSize = map.size;
|
||||
}
|
||||
|
||||
video->VideoBufferSize = map.size;
|
||||
|
||||
memcpy(video->VideoBuffer, map.data, map.size);
|
||||
gst_buffer_unmap(buf, &map);
|
||||
video->FrameReady = true;
|
||||
@ -165,13 +178,6 @@ bool GStreamerVideo::Stop()
|
||||
// FreeElements();
|
||||
|
||||
IsPlaying = false;
|
||||
|
||||
if(Texture)
|
||||
{
|
||||
SDL_DestroyTexture(Texture);
|
||||
Texture = NULL;
|
||||
}
|
||||
IsPlaying = false;
|
||||
Height = 0;
|
||||
Width = 0;
|
||||
FrameReady = false;
|
||||
|
||||
@ -42,6 +42,7 @@ private:
|
||||
gint Width;
|
||||
char *VideoBuffer;
|
||||
gsize VideoBufferSize;
|
||||
gsize MaxVideoBufferSize;
|
||||
bool FrameReady;
|
||||
bool IsPlaying;
|
||||
static bool Initialized;
|
||||
|
||||
@ -25,7 +25,7 @@ IVideo *VideoFactory::Instance = NULL;
|
||||
IVideo *VideoFactory::CreateVideo()
|
||||
{
|
||||
|
||||
if(Enabled)
|
||||
if(Enabled && !Instance)
|
||||
{
|
||||
Instance = new GStreamerVideo();
|
||||
Instance->Initialize();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user