Permalink
Browse files

Merge pull request #468 from FernetMenta/mainline

fix crash on linux systems when refresh rate is changed
  • Loading branch information...
2 parents 8a0a87c + 12e90fb commit 01a556e5f6a2a1c01514b8c02270f35302f7679a @elupus elupus committed Nov 16, 2011
@@ -43,6 +43,7 @@
#include "windowing/WindowingFactory.h"
#include "GUIInfoManager.h"
#include "utils/Splash.h"
+#include "cores/VideoRenderers/RenderManager.h"
#include "powermanagement/PowerManager.h"
@@ -232,6 +233,10 @@ void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg)
case POWERSTATE_MINIMIZE:
Minimize();
break;
+
+ case TMSG_RENDERER_FLUSH:
+ g_renderManager.Flush();
+ break;
}
}
break;
@@ -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
@@ -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; }
@@ -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;
@@ -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);
@@ -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);
@@ -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);
@@ -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)
{
@@ -227,6 +228,7 @@ class CXBMCRenderManager
EPRESENTSTEP m_presentstep;
int m_presentsource;
CEvent m_presentevent;
+ CEvent m_flushEvent;
OVERLAY::CRenderer m_overlays;
@@ -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;
Oops, something went wrong.

0 comments on commit 01a556e

Please sign in to comment.