Skip to content

Commit

Permalink
Merge pull request #468 from FernetMenta/mainline
Browse files Browse the repository at this point in the history
fix crash on linux systems when refresh rate is changed
  • Loading branch information
elupus committed Nov 16, 2011
2 parents 8a0a87c + 12e90fb commit 01a556e
Show file tree
Hide file tree
Showing 14 changed files with 542 additions and 157 deletions.
5 changes: 5 additions & 0 deletions xbmc/ApplicationMessenger.cpp
Expand Up @@ -43,6 +43,7 @@
#include "windowing/WindowingFactory.h"
#include "GUIInfoManager.h"
#include "utils/Splash.h"
#include "cores/VideoRenderers/RenderManager.h"

#include "powermanagement/PowerManager.h"

Expand Down Expand Up @@ -232,6 +233,10 @@ void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg)
case POWERSTATE_MINIMIZE:
Minimize();
break;

case TMSG_RENDERER_FLUSH:
g_renderManager.Flush();
break;
}
}
break;
Expand Down
1 change: 1 addition & 0 deletions xbmc/ApplicationMessenger.h
Expand Up @@ -76,6 +76,7 @@ class CGUIWindow;
#define TMSG_MINIMIZE 309
#define TMSG_TOGGLEFULLSCREEN 310
#define TMSG_SETLANGUAGE 311
#define TMSG_RENDERER_FLUSH 312

#define TMSG_HTTPAPI 400

Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/VideoRenderers/BaseRenderer.h
Expand Up @@ -64,6 +64,7 @@ class CBaseRenderer
float GetAspectRatio() const;

virtual bool AddVideoPicture(DVDVideoPicture* picture) { return false; }
virtual void Flush() {};

virtual unsigned int GetProcessorSize() { return 0; }

Expand Down
16 changes: 16 additions & 0 deletions xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
Expand Up @@ -554,6 +554,20 @@ void CLinuxRendererGL::Reset()
}
}

void CLinuxRendererGL::Flush()
{
if (!m_bValidated)
return;

glFinish();

for (int i = 0 ; i < m_NumYV12Buffers ; i++)
(this->*m_textureDelete)(i);

glFinish();
m_bValidated = false;
}

void CLinuxRendererGL::Update(bool bPauseDrawing)
{
if (!m_bConfigured) return;
Expand Down Expand Up @@ -1035,6 +1049,8 @@ void CLinuxRendererGL::UnInit()
CLog::Log(LOGDEBUG, "LinuxRendererGL: Cleaning up GL resources");
CSingleLock lock(g_graphicsContext);

glFinish();

if (m_rgbPbo)
{
glDeleteBuffersARB(1, &m_rgbPbo);
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/VideoRenderers/LinuxRendererGL.h
Expand Up @@ -140,6 +140,7 @@ class CLinuxRendererGL : public CBaseRenderer
virtual unsigned int PreInit();
virtual void UnInit();
virtual void Reset(); /* resets renderer after seek for example */
virtual void Flush();

#ifdef HAVE_LIBVDPAU
virtual void AddProcessor(CVDPAU* vdpau);
Expand Down
29 changes: 29 additions & 0 deletions xbmc/cores/VideoRenderers/RenderManager.cpp
Expand Up @@ -337,6 +337,35 @@ void CXBMCRenderManager::UnInit()
m_pRenderer->UnInit();
}

bool CXBMCRenderManager::Flush()
{
if (!m_pRenderer)
return true;

if (g_application.IsCurrentThread())
{
CLog::Log(LOGDEBUG, "%s - flushing renderer", __FUNCTION__);

CRetakeLock<CExclusiveLock> lock(m_sharedSection);
m_pRenderer->Flush();
m_flushEvent.Set();
}
else
{
ThreadMessage msg = {TMSG_RENDERER_FLUSH};
m_flushEvent.Reset();
g_application.getApplicationMessenger().SendMessage(msg, false);
if (!m_flushEvent.WaitMSec(1000))
{
CLog::Log(LOGERROR, "%s - timed out waiting for renderer to flush", __FUNCTION__);
return false;
}
else
return true;
}
return true;
}

void CXBMCRenderManager::SetupScreenshot()
{
CSharedLock lock(m_sharedSection);
Expand Down
2 changes: 2 additions & 0 deletions xbmc/cores/VideoRenderers/RenderManager.h
Expand Up @@ -76,6 +76,7 @@ class CXBMCRenderManager
void FlipPage(volatile bool& bStop, double timestamp = 0.0, int source = -1, EFIELDSYNC sync = FS_NONE);
unsigned int PreInit();
void UnInit();
bool Flush();

void AddOverlay(CDVDOverlay* o, double pts)
{
Expand Down Expand Up @@ -227,6 +228,7 @@ class CXBMCRenderManager
EPRESENTSTEP m_presentstep;
int m_presentsource;
CEvent m_presentevent;
CEvent m_flushEvent;


OVERLAY::CRenderer m_overlays;
Expand Down
2 changes: 2 additions & 0 deletions xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
Expand Up @@ -181,6 +181,8 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
m_pCodecContext->codec_id = hints.codec;
m_pCodecContext->width = hints.width;
m_pCodecContext->height = hints.height;
m_pCodecContext->coded_width = hints.width;
m_pCodecContext->coded_height = hints.height;
if(vdp->Open(m_pCodecContext, pCodec->pix_fmts ? pCodec->pix_fmts[0] : PIX_FMT_NONE))
{
m_pHardware = vdp;
Expand Down

0 comments on commit 01a556e

Please sign in to comment.