Skip to content

Commit

Permalink
MythRender: Add a Release method to MythRenderOpenGL.
Browse files Browse the repository at this point in the history
MythRenderOpenGL re-implements the QGLContext makeCurrent and
doneCurrent methods in order to enforce thread safety. We recursively
lock the context and only release it when the final doneCurrent call is
received. When we call show() on the UI painter window, however, Qt
calls makeCurrent several times internally without matching doneCurrent
calls and hence we never actually unlock and release the main OpenGL
context in normal use.

With the imminent move to a single, shared OpenGL context for video and
UI, this will cause a lockup at any point the decoder thread tries to
re-initiate the video output objects (or deinterlacers) when using
OpenGL for both video and the UI.

So we simply force the context to release itself after the call to
show().
  • Loading branch information
Mark Kendall committed May 2, 2011
1 parent 5c5ad6c commit ea24712
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mythtv/libs/libmythui/mythmainwindow.cpp
Expand Up @@ -534,6 +534,8 @@ void MythMainWindow::ShowPainterWindow(void)
{
if (d->paintwin)
d->paintwin->show();
if (d->render)
d->render->Release();
}

void MythMainWindow::HidePainterWindow(void)
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythui/mythrender_base.h
Expand Up @@ -51,6 +51,7 @@ class MythRender
RenderType Type(void) { return m_type; }
bool IsErrored(void) const { return m_errored; }
QSize GetSize(void) const { return m_size; }
virtual void Release(void) { }

protected:
virtual ~MythRender() { }
Expand Down
6 changes: 6 additions & 0 deletions mythtv/libs/libmythui/mythrender_opengl.cpp
Expand Up @@ -100,6 +100,12 @@ void MythRenderOpenGL::doneCurrent()
m_lock->unlock();
}

void MythRenderOpenGL::Release(void)
{
while (m_lock_level > 0)
doneCurrent();
}

void MythRenderOpenGL::MoveResizeWindow(const QRect &rect)
{
QWidget *parent = (QWidget*)this->device();
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythui/mythrender_opengl.h
Expand Up @@ -107,6 +107,7 @@ class MUI_PUBLIC MythRenderOpenGL : public QGLContext, public MythRender

virtual void makeCurrent();
virtual void doneCurrent();
virtual void Release(void);

void Init(void);

Expand Down

0 comments on commit ea24712

Please sign in to comment.