Skip to content

Commit

Permalink
Remove the old OpenGL vsync code.
Browse files Browse the repository at this point in the history
This was disabled prior to the 0.24 release and there has been no
feedback suggesting any regressions as a result.
  • Loading branch information
Mark Kendall committed Feb 8, 2011
1 parent 50f2a55 commit 70857ed
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 234 deletions.
6 changes: 0 additions & 6 deletions mythtv/configure
Expand Up @@ -128,7 +128,6 @@ Advanced options (experts only):
--enable-crystalhd enable Broadcom CrystalHD hardware decoder support
--disable-opengl-video disable OpenGL based video display
--disable-quartz-video disable Mac OS X CoreVideo based video display
--disable-opengl-vsync disable OpenGL vsync method
--disable-directfb disable DirectFB (Linux non-X11 video)
--enable-mac-bundle produce standalone OS X apps (e.g. mythfrontend.app)
Expand Down Expand Up @@ -1334,7 +1333,6 @@ MYTHTV_CONFIG_LIST='
lirc
mheg
opengl_video
opengl_vsync
qtdbus
qtwebkit
quartz_video
Expand Down Expand Up @@ -1739,7 +1737,6 @@ mpegtsraw_demuxer_deps="merge_libavformat_mpegts_c"
mythtranscode_deps="backend frontend"
opengl_deps_any="agl_h GL_gl_h GLES2_gl2_h darwin windows x11"
opengl_video_deps="opengl"
opengl_vsync_deps="opengl"
v4l_deps="backend linux_videodev_h linux_videodev2_h"
vdpau_deps="opengl vdpau_vdpau_h vdpau_vdpau_x11_h"
xrandr_deps="x11"
Expand Down Expand Up @@ -1958,7 +1955,6 @@ enable lirc
enable mheg
enable mythtranscode
enable opengl
enable opengl_vsync
enable opengl_video
enable quartz_video
enable symbol_visibility
Expand Down Expand Up @@ -3097,7 +3093,6 @@ EOF
disable mmx
enable disable_mmx_for_debugging # prevent later call to die
fi
disable opengl_vsync
disable v4l
disable x11
# Workaround compile errors from missing gmtime_r/localtime_r/uint def
Expand Down Expand Up @@ -4480,7 +4475,6 @@ fi
if test x"$target_os" = x"darwin" ; then
echo "Quartz video ${quartz_video-no}"
fi
echo "OpenGL vsync ${opengl_vsync-no}"
echo "DirectFB ${directfb-no}"
if test x"$target_os" = x"mingw32" ; then
echo "Windows (Direct3D) yes"
Expand Down
1 change: 0 additions & 1 deletion mythtv/libs/libmythtv/libmythtv.pro
Expand Up @@ -347,7 +347,6 @@ using_frontend {
SOURCES += util-opengl.cpp
QT += opengl
}
using_opengl_vsync:DEFINES += USING_OPENGL_VSYNC

using_opengl_video:DEFINES += USING_OPENGL_VIDEO
using_opengl_video:HEADERS += openglvideo.h videoout_opengl.h
Expand Down
119 changes: 0 additions & 119 deletions mythtv/libs/libmythtv/vsync.cpp
Expand Up @@ -43,10 +43,6 @@
#include "videoout_vdpau.h"
#endif

#ifdef USING_OPENGL_VSYNC
#include "mythrender_opengl.h"
#endif // USING_OPENGL_VSYNC

#ifdef __linux__
#include <linux/rtc.h>
#endif
Expand Down Expand Up @@ -101,15 +97,6 @@ VideoSync *VideoSync::BestMethod(VideoOutput *video_output,
#endif
#ifndef _WIN32
TESTVIDEOSYNC(DRMVideoSync);
#ifdef USING_OPENGL_VSYNC
/*
if (gCoreContext->GetNumSetting("UseOpenGLVSync", 1) &&
(getenv("NO_OPENGL_VSYNC") == NULL))
{
TESTVIDEOSYNC(OpenGLVideoSync);
}
*/
#endif
#endif // _WIN32
#ifdef __linux__
TESTVIDEOSYNC(RTCVideoSync);
Expand Down Expand Up @@ -332,112 +319,6 @@ int DRMVideoSync::WaitForFrame(int sync_delay)
}
#endif /* !_WIN32 */

#ifndef _WIN32
OpenGLVideoSync::OpenGLVideoSync(VideoOutput *video_output,
int frame_interval, int refresh_interval,
bool interlaced) :
VideoSync(video_output, frame_interval, refresh_interval, interlaced),
m_context(NULL), m_device(NULL)
{
VERBOSE(VB_IMPORTANT, LOC + "OpenGLVideoSync()");
}

OpenGLVideoSync::~OpenGLVideoSync()
{
VERBOSE(VB_IMPORTANT, LOC + "~OpenGLVideoSync()");
#ifdef USING_OPENGL_VSYNC
if (m_context)
delete m_context;
if (m_device)
delete m_device;
#endif
}

/** \fn OpenGLVideoSync::TryInit(void)
* \brief Try to create an OpenGL surface so we can use glXWaitVideoSyncSGI:
* \return true if this method can be employed, false if it cannot.
*/
bool OpenGLVideoSync::TryInit(void)
{
#ifdef USING_OPENGL_VSYNC
m_device = new QPixmap(16,16);
QGLFormat fmt;
fmt.setDepth(false);
m_context = MythRenderOpenGL::Create(fmt, m_device);
if (m_context && m_context->create())
{
m_context->Init();
if (m_context->HasGLXWaitVideoSyncSGI())
return true;

VERBOSE(VB_IMPORTANT, LOC +
"OpenGLVideoSync: GLX_SGI_video_sync extension not "
"supported by driver.");
}

VERBOSE(VB_PLAYBACK, LOC + "OpenGLVideoSync: "
"Failed to Initialize OpenGL V-Sync");

#endif /* USING_OPENGL_VSYNC */
return false;
}

void OpenGLVideoSync::Start(void)
{
#ifdef USING_OPENGL_VSYNC
if (!m_context)
return;

if (!(m_video_output && m_video_output->IsEmbedding()))
{
unsigned int count = m_context->GetVideoSyncCount();
m_context->WaitForVideoSync(2, (count+1)%2, &count);
}
// Initialize next trigger
VideoSync::Start();
#endif /* USING_OPENGL_VSYNC */
}

int OpenGLVideoSync::WaitForFrame(int sync_delay)
{
(void) sync_delay;
#ifdef USING_OPENGL_VSYNC
const QString msg1("First A/V Sync"), msg2("Second A/V Sync");
m_nexttrigger += sync_delay;

if (m_video_output && m_video_output->IsEmbedding())
{
m_delay = CalcDelay();
if (m_delay > 0)
usleep(m_delay);
return 0;
}

if (!m_context)
return 0;

unsigned int frameNum = m_context->GetVideoSyncCount();

// Always sync to the next retrace execpt when we are very late.
if ((m_delay = CalcDelay()) > -(m_refresh_interval/2))
{
m_context->WaitForVideoSync(2, (frameNum+1)%2 ,&frameNum);
m_delay = CalcDelay();
}

// Wait for any remaining retrace intervals in one pass.
if (m_delay > 0)
{
uint n = (m_delay + m_refresh_interval - 1) / m_refresh_interval;
m_context->WaitForVideoSync((n+1), (frameNum+n)%(n+1), &frameNum);
m_delay = CalcDelay();
}

return m_delay;
#endif /* USING_OPENGL_VSYNC */
}
#endif /* !_WIN32 */

#ifdef __linux__
#define RTCRATE 1024
RTCVideoSync::RTCVideoSync(VideoOutput *vo, int fi, int ri, bool intr) :
Expand Down
41 changes: 0 additions & 41 deletions mythtv/libs/libmythtv/vsync.h
Expand Up @@ -23,7 +23,6 @@
#include <time.h>

class VideoOutput;
class MythRenderOpenGL;

extern bool tryingVideoSync;

Expand Down Expand Up @@ -133,46 +132,6 @@ class DRMVideoSync : public VideoSync
};
#endif // !_WIN32

#ifndef _WIN32
/** \brief Video synchronization class employing SGI_video_sync
* OpenGL extension.
*
* Uses glXWaitVideoSyncSGI() to wait for retrace. Phase-maintaining,
* meaning WaitForFrame should always return approximately the same time
* after a vertical retrace.
*
* This works with version 50 or later of the nVidia vendor drivers.
*
* Special care must be taken with this video sync method due
* to a bad interaction between some pthread implementations
* and OpenGL. OpenGL DIRECT contexts cannot be shared between
* processes. And some pthread implementations, notably a common
* one on Linux, treat each thread as a seperate process.
* Hence Start(void), Stop(void) and WaitForFrame(void) must all be called
* from the same thread.
*
* \sa http://osgcvs.no-ip.com/osgarchiver/archives/June2002/0022.html
* \sa http://www.ac3.edu.au/SGI_Developer/books/OpenGLonSGI/sgi_html/ch10.html#id37188
* \sa http://www.inb.mu-luebeck.de/~boehme/xvideo_sync.html
*/
class OpenGLVideoSync : public VideoSync
{
public:
OpenGLVideoSync(VideoOutput*,
int frame_interval, int refresh_interval, bool interlaced);
~OpenGLVideoSync();

QString getName(void) const { return QString("SGI OpenGL"); }
bool TryInit(void);
void Start(void);
int WaitForFrame(int sync_delay);

private:
MythRenderOpenGL *m_context;
QPixmap *m_device;
};
#endif // !_WIN32

#ifdef __linux__
/** \brief Video synchronization class employing /dev/rtc
*
Expand Down
56 changes: 0 additions & 56 deletions mythtv/libs/libmythui/mythrender_opengl.cpp
Expand Up @@ -5,17 +5,9 @@
#define LOC QString("OpenGL: ")
#define LOC_ERR QString("OpenGL Error: ")

#if defined(Q_WS_X11)
#include <QX11Info>
#include <GL/glx.h>
#endif

#include "mythrender_opengl1.h"
#include "mythrender_opengl2.h"

MYTH_GLXGETVIDEOSYNCSGIPROC MythRenderOpenGL::g_glXGetVideoSyncSGI = NULL;
MYTH_GLXWAITVIDEOSYNCSGIPROC MythRenderOpenGL::g_glXWaitVideoSyncSGI = NULL;

static const GLuint kTextureOffset = 8 * sizeof(GLfloat);

static inline int __glCheck__(const QString &loc, const char* fileName, int n)
Expand Down Expand Up @@ -632,54 +624,6 @@ void MythRenderOpenGL::DrawRect(const QRect &area, bool drawFill,
doneCurrent();
}

bool MythRenderOpenGL::HasGLXWaitVideoSyncSGI(void)
{
static bool initialised = false;
if (!initialised)
{
makeCurrent();
initialised = true;

#if defined(Q_WS_X11)
int screen = DefaultScreen(QX11Info::display());
QString glxExt =
QString(QLatin1String(glXQueryExtensionsString(QX11Info::display(),
screen)));
if (glxExt.contains(QLatin1String("GLX_SGI_video_sync")))
{
g_glXGetVideoSyncSGI = (MYTH_GLXGETVIDEOSYNCSGIPROC)
GetProcAddress("glXGetVideoSyncSGI");
g_glXWaitVideoSyncSGI = (MYTH_GLXWAITVIDEOSYNCSGIPROC)
GetProcAddress("glXWaitVideoSyncSGI");
}
#endif
doneCurrent();
}
return g_glXGetVideoSyncSGI && g_glXWaitVideoSyncSGI;
}

unsigned int MythRenderOpenGL::GetVideoSyncCount(void)
{
unsigned int count = 0;
if (HasGLXWaitVideoSyncSGI())
{
makeCurrent();
g_glXGetVideoSyncSGI(&count);
doneCurrent();
}
return count;
}

void MythRenderOpenGL::WaitForVideoSync(int div, int rem, unsigned int *count)
{
if (HasGLXWaitVideoSyncSGI())
{
makeCurrent();
g_glXWaitVideoSyncSGI(div, rem, count);
doneCurrent();
}
}

void MythRenderOpenGL::Init2DState(void)
{
SetBlend(false);
Expand Down
7 changes: 0 additions & 7 deletions mythtv/libs/libmythui/mythrender_opengl.h
Expand Up @@ -147,10 +147,6 @@ class MPUBLIC MythRenderOpenGL : public QGLContext, public MythRender
int lineWidth, const QColor &lineColor,
int target = 0, int prog = 0);

bool HasGLXWaitVideoSyncSGI(void);
unsigned int GetVideoSyncCount(void);
void WaitForVideoSync(int div, int rem, unsigned int *count);

protected:
virtual void DrawBitmapPriv(uint tex, const QRect *src, const QRect *dst,
uint prog, int alpha,
Expand Down Expand Up @@ -247,9 +243,6 @@ class MPUBLIC MythRenderOpenGL : public QGLContext, public MythRender
MYTH_GLDELETEFENCESAPPLEPROC m_glDeleteFencesAPPLE;
MYTH_GLSETFENCEAPPLEPROC m_glSetFenceAPPLE;
MYTH_GLFINISHFENCEAPPLEPROC m_glFinishFenceAPPLE;
// GLX_SGI_video_sync
static MYTH_GLXGETVIDEOSYNCSGIPROC g_glXGetVideoSyncSGI;
static MYTH_GLXWAITVIDEOSYNCSGIPROC g_glXWaitVideoSyncSGI;
};

#endif
4 changes: 0 additions & 4 deletions mythtv/libs/libmythui/mythrender_opengl_defs.h
Expand Up @@ -143,8 +143,4 @@ typedef void ( * MYTH_GLSETFENCEAPPLEPROC)
(GLuint fence);
typedef void ( * MYTH_GLFINISHFENCEAPPLEPROC)
(GLuint fence);
typedef int ( * MYTH_GLXGETVIDEOSYNCSGIPROC)
(unsigned int *count);
typedef int ( * MYTH_GLXWAITVIDEOSYNCSGIPROC)
(int divisor, int remainder, unsigned int *count);
#endif

0 comments on commit 70857ed

Please sign in to comment.