From 58c7a6f4e8903bc5462acaea11ae8d87030345e0 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Fri, 13 Apr 2007 00:44:46 +0000 Subject: [PATCH] Failed attempt to get threaded video to work. Originally committed to SVN as r1065. --- aegisub/gl_wrap.cpp | 5 +++++ aegisub/gl_wrap.h | 3 +++ aegisub/subtitles_provider_libass.cpp | 2 +- aegisub/video_context.cpp | 9 ++++++--- aegisub/video_display.cpp | 3 ++- libass/libass.vcproj | 1 + 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/aegisub/gl_wrap.cpp b/aegisub/gl_wrap.cpp index 1f97bb2f7..cfb8bd10d 100644 --- a/aegisub/gl_wrap.cpp +++ b/aegisub/gl_wrap.cpp @@ -461,3 +461,8 @@ GLuint OpenGLWrapper::CreateYV12Shader(float tw,float th,float tws) { // Return shader return program; } + + +///////// +// Mutex +wxMutex OpenGLWrapper::glMutex; diff --git a/aegisub/gl_wrap.h b/aegisub/gl_wrap.h index 121fc8b40..b7a3f0b68 100644 --- a/aegisub/gl_wrap.h +++ b/aegisub/gl_wrap.h @@ -45,12 +45,15 @@ private: float r2,g2,b2,a2; int lw; + static void Initialize(); static GLuint CreateStandardVertexShader(); static GLuint CreateYV12PixelShader(); static GLuint CreateShaderProgram(GLuint vertex,GLuint pixel); public: + static wxMutex glMutex; + void SetLineColour(wxColour col,float alpha=1.0f,int width=1); void SetFillColour(wxColour col,float alpha=1.0f); void SetModeLine(); diff --git a/aegisub/subtitles_provider_libass.cpp b/aegisub/subtitles_provider_libass.cpp index 3bc3af9b3..0270fb43f 100644 --- a/aegisub/subtitles_provider_libass.cpp +++ b/aegisub/subtitles_provider_libass.cpp @@ -111,7 +111,7 @@ LibassSubtitlesProvider::LibassSubtitlesProvider() { ass_renderer = ass_renderer_init(ass_library); if (!ass_renderer) throw _T("ass_renderer_init failed"); ass_set_font_scale(ass_renderer, 1.); - ass_set_fonts(ass_renderer, "c:\\windows\\fonts\\verdana.ttf", "Sans"); + ass_set_fonts(ass_renderer, NULL, "Sans"); } diff --git a/aegisub/video_context.cpp b/aegisub/video_context.cpp index f1251b388..ad9edc8d9 100644 --- a/aegisub/video_context.cpp +++ b/aegisub/video_context.cpp @@ -395,7 +395,7 @@ void VideoContext::JumpToFrame(int n) { if (isPlaying && n != playNextFrame) return; // Threaded - if (threaded && false) { // Doesn't work, so it's disabled + if (threaded) { // Doesn't work, so it's disabled wxMutexLocker lock(vidMutex); threadNextFrame = n; if (!threadLocked) { @@ -853,8 +853,11 @@ wxThread::ExitCode VideoContextThread::Entry() { // Loop while there is work to do while (true) { // Get frame and set frame number - parent->GetFrameAsTexture(frame); - parent->frame_n = frame; + { + wxMutexLocker glLock(OpenGLWrapper::glMutex); + parent->GetFrameAsTexture(frame); + parent->frame_n = frame; + } // Display parent->UpdateDisplays(false); diff --git a/aegisub/video_display.cpp b/aegisub/video_display.cpp index ce85dc5fe..6054a53f8 100644 --- a/aegisub/video_display.cpp +++ b/aegisub/video_display.cpp @@ -144,6 +144,7 @@ void VideoDisplay::Render() { if (!context->IsLoaded()) return; // Set GL context + wxMutexLocker glLock(OpenGLWrapper::glMutex); SetCurrent(*context->GetGLContext(this)); // Get sizes @@ -256,7 +257,7 @@ void VideoDisplay::Render() { visual->DrawOverlay(); // Swap buffers - //glFinish(); + glFinish(); //if (glGetError()) throw _T("Error finishing gl operation."); SwapBuffers(); } diff --git a/libass/libass.vcproj b/libass/libass.vcproj index 6af9343e1..8f9d74c5f 100644 --- a/libass/libass.vcproj +++ b/libass/libass.vcproj @@ -49,6 +49,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="true" DebugInformationFormat="4" + CompileAs="1" DisableSpecificWarnings="4996;4244;4267;4005" ForcedIncludeFiles="msvc.h" />