Ticket #2383: mythtv-0.20-vsync.patch
File mythtv-0.20-vsync.patch, 4.6 KB (added by , 18 years ago) |
---|
-
libs/libmythtv/vsync.cpp
35 35 #include "util-x11.h" // for OpenGL VSync 36 36 37 37 #ifdef USING_OPENGL_VSYNC 38 #define GLX_GLXEXT_PROTOTYPES39 38 #define XMD_H 1 39 #define GLX_GLXEXT_PROTOTYPES 40 40 #include <GL/glx.h> 41 41 #include <GL/gl.h> 42 42 #undef GLX_ARB_get_proc_address … … 437 437 UpdateNexttrigger(); 438 438 } 439 439 440 #ifdef USING_OPENGL_VSYNC 441 class OpenGLVideoSyncPrivate 442 { 443 public: 444 OpenGLVideoSyncPrivate() 445 { 446 m_glXGetVideoSyncSGI = (PFNGLXGETVIDEOSYNCSGIPROC) glXGetProcAddress("glXGetVideoSyncSGI"); 447 m_glXWaitVideoSyncSGI = (PFNGLXWAITVIDEOSYNCSGIPROC) glXGetProcAddress("glXWaitVideoSyncSGI"); 448 } 449 450 bool funcsLoaded() 451 { 452 return m_glXGetVideoSyncSGI && m_glXWaitVideoSyncSGI; 453 } 454 455 public: 456 int glXGetVideoSyncSGI(unsigned int *count) 457 { 458 return m_glXGetVideoSyncSGI(count); 459 } 460 461 int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) 462 { 463 return m_glXWaitVideoSyncSGI(divisor, remainder, count); 464 } 465 466 __GLXextFuncPtr glXGetProcAddress(const char * const procName) 467 { 468 __GLXextFuncPtr ret = glXGetProcAddressARB((const GLubyte *) procName); 469 if (!ret) 470 { 471 VERBOSE(VB_PLAYBACK, 472 QString("Error: glXGetProcAddressARB unable to find %1") 473 .arg(procName)); 474 } 475 return ret; 476 } 477 478 private: 479 PFNGLXGETVIDEOSYNCSGIPROC m_glXGetVideoSyncSGI; 480 PFNGLXWAITVIDEOSYNCSGIPROC m_glXWaitVideoSyncSGI; 481 }; 482 #endif // USING_OPENGL_VSYNC 483 440 484 OpenGLVideoSync::OpenGLVideoSync(VideoOutput *video_output, 441 485 int frame_interval, int refresh_interval, 442 486 bool interlaced) 443 487 : VideoSync(video_output, frame_interval, refresh_interval, interlaced), 444 m_drawable(0), m_context(0) 488 m_drawable(0), m_context(0), m_imp(0) 445 489 { 490 #ifdef USING_OPENGL_VSYNC 491 m_imp = new OpenGLVideoSyncPrivate; 492 #endif // USING_OPENGL_VSYNC 446 493 } 447 494 448 495 OpenGLVideoSync::~OpenGLVideoSync() … … 457 504 if (m_drawable) 458 505 X11S(XDestroyWindow(vo->XJ_disp, m_drawable)); 459 506 } 507 delete m_imp; 460 508 #endif /* USING_OPENGL_VSYNC */ 461 509 } 462 510 … … 503 551 return false; 504 552 } 505 553 554 if (!m_imp->funcsLoaded()) 555 { 556 VERBOSE(VB_PLAYBACK, QString("GL sync functions not found")); 557 return false; 558 } 559 506 560 int attribList[] = {GLX_RGBA, 507 561 GLX_RED_SIZE, 1, 508 562 GLX_GREEN_SIZE, 1, … … 552 606 if (ret != False) 553 607 { 554 608 unsigned int count; 555 X11S(ret = glXGetVideoSyncSGI(&count));609 X11S(ret = m_imp->glXGetVideoSyncSGI(&count)); 556 610 if (ret == 0) 557 611 { 558 612 VERBOSE(VB_PLAYBACK, "Using OpenGLVideoSync"); … … 631 685 632 686 // Wait for a refresh so we start out synched 633 687 unsigned int count; 634 err = glXGetVideoSyncSGI(&count);688 err = m_imp->glXGetVideoSyncSGI(&count); 635 689 checkGLSyncError("OpenGLVideoSync::Start(): Frame Number Query", err); 636 err = glXWaitVideoSyncSGI(2, (count+1)%2 ,&count);690 err = m_imp->glXWaitVideoSyncSGI(2, (count+1)%2 ,&count); 637 691 checkGLSyncError("OpenGLVideoSync::Start(): A/V Sync", err); 638 692 639 693 // Initialize next trigger … … 649 703 OffsetTimeval(m_nexttrigger, sync_delay); 650 704 651 705 unsigned int frameNum = 0; 652 int err = glXGetVideoSyncSGI(&frameNum);706 int err = m_imp->glXGetVideoSyncSGI(&frameNum); 653 707 checkGLSyncError("Frame Number Query", err); 654 708 655 709 // Always sync to the next retrace execpt when we are very late. 656 710 if ((m_delay = CalcDelay()) > -(m_refresh_interval/2)) 657 711 { 658 err = glXWaitVideoSyncSGI(2, (frameNum+1)%2 ,&frameNum);712 err = m_imp->glXWaitVideoSyncSGI(2, (frameNum+1)%2 ,&frameNum); 659 713 checkGLSyncError(msg1, err); 660 714 m_delay = CalcDelay(); 661 715 } … … 664 718 if (m_delay > 0) 665 719 { 666 720 uint n = m_delay / m_refresh_interval + 1; 667 err = glXWaitVideoSyncSGI((n+1), (frameNum+n)%(n+1), &frameNum);721 err = m_imp->glXWaitVideoSyncSGI((n+1), (frameNum+n)%(n+1), &frameNum); 668 722 checkGLSyncError(msg2, err); 669 723 m_delay = CalcDelay(); 670 724 } -
libs/libmythtv/vsync.h
214 214 private: 215 215 GLXDrawable m_drawable; 216 216 GLXContext m_context; 217 class OpenGLVideoSyncPrivate *m_imp; 217 218 }; 218 219 219 220 #ifdef __linux__