mirror of https://github.com/odrling/Aegisub
Re-coded threaded video mode, but it fails spetacularly. It's currently disabled in source, but there.
Originally committed to SVN as r1021.
This commit is contained in:
parent
7da5406572
commit
c0b62ff377
|
@ -108,8 +108,12 @@ VideoContext::VideoContext() {
|
||||||
arType = 0;
|
arType = 0;
|
||||||
arValue = 1.0;
|
arValue = 1.0;
|
||||||
isPlaying = false;
|
isPlaying = false;
|
||||||
threaded = Options.AsBool(_T("Threaded Video"));
|
|
||||||
nextFrame = -1;
|
nextFrame = -1;
|
||||||
|
|
||||||
|
// Threads
|
||||||
|
threaded = Options.AsBool(_T("Threaded Video"));
|
||||||
|
threadLocked = false;
|
||||||
|
threadNextFrame = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -373,6 +377,20 @@ void VideoContext::JumpToFrame(int n) {
|
||||||
// Prevent intervention during playback
|
// Prevent intervention during playback
|
||||||
if (isPlaying && n != playNextFrame) return;
|
if (isPlaying && n != playNextFrame) return;
|
||||||
|
|
||||||
|
// Threaded
|
||||||
|
if (threaded && false) { // Doesn't work, so it's disabled
|
||||||
|
wxMutexLocker lock(vidMutex);
|
||||||
|
threadNextFrame = n;
|
||||||
|
if (!threadLocked) {
|
||||||
|
threadLocked = true;
|
||||||
|
thread = new VideoContextThread(this);
|
||||||
|
thread->Create();
|
||||||
|
thread->Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not threaded
|
||||||
|
else {
|
||||||
// Set frame number
|
// Set frame number
|
||||||
frame_n = n;
|
frame_n = n;
|
||||||
GetFrameAsTexture(n);
|
GetFrameAsTexture(n);
|
||||||
|
@ -382,6 +400,7 @@ void VideoContext::JumpToFrame(int n) {
|
||||||
|
|
||||||
// Update grid
|
// Update grid
|
||||||
if (!isPlaying && Options.AsBool(_T("Highlight subs in frame"))) grid->Refresh(false);
|
if (!isPlaying && Options.AsBool(_T("Highlight subs in frame"))) grid->Refresh(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -804,3 +823,48 @@ void VideoContext::SetShader(bool enabled) {
|
||||||
bool VideoContext::HasIndependentSubs() {
|
bool VideoContext::HasIndependentSubs() {
|
||||||
return subsProvider && subsProvider->CanRaster();
|
return subsProvider && subsProvider->CanRaster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////
|
||||||
|
// Thread constructor
|
||||||
|
VideoContextThread::VideoContextThread(VideoContext *par)
|
||||||
|
: wxThread(wxTHREAD_DETACHED)
|
||||||
|
{
|
||||||
|
parent = par;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////
|
||||||
|
// Thread entry point
|
||||||
|
wxThread::ExitCode VideoContextThread::Entry() {
|
||||||
|
// Set up thread
|
||||||
|
int frame = parent->threadNextFrame;
|
||||||
|
int curFrame = parent->frame_n;
|
||||||
|
bool highSubs = Options.AsBool(_T("Highlight subs in frame"));
|
||||||
|
|
||||||
|
// Loop while there is work to do
|
||||||
|
while (true) {
|
||||||
|
// Get frame and set frame number
|
||||||
|
parent->GetFrameAsTexture(frame);
|
||||||
|
parent->frame_n = frame;
|
||||||
|
|
||||||
|
// Display
|
||||||
|
parent->UpdateDisplays(false);
|
||||||
|
|
||||||
|
// Update grid
|
||||||
|
if (!parent->isPlaying && highSubs) parent->grid->Refresh(false);
|
||||||
|
|
||||||
|
// Get lock and check if there is more to do
|
||||||
|
wxMutexLocker lock(parent->vidMutex);
|
||||||
|
curFrame = parent->frame_n;
|
||||||
|
frame = parent->threadNextFrame;
|
||||||
|
|
||||||
|
// Work done, kill thread and release context
|
||||||
|
if (curFrame == frame) {
|
||||||
|
parent->threadLocked = false;
|
||||||
|
parent->threadNextFrame = -1;
|
||||||
|
Delete();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ class AssDialogue;
|
||||||
class VideoProvider;
|
class VideoProvider;
|
||||||
class VideoDisplay;
|
class VideoDisplay;
|
||||||
class SubtitlesProvider;
|
class SubtitlesProvider;
|
||||||
|
class VideoContextThread;
|
||||||
|
|
||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
|
@ -61,6 +62,7 @@ class SubtitlesProvider;
|
||||||
class VideoContext : public wxEvtHandler {
|
class VideoContext : public wxEvtHandler {
|
||||||
friend class AudioProvider;
|
friend class AudioProvider;
|
||||||
friend class VideoDisplayVisual;
|
friend class VideoDisplayVisual;
|
||||||
|
friend class VideoContextThread;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static VideoContext *instance;
|
static VideoContext *instance;
|
||||||
|
@ -92,7 +94,12 @@ private:
|
||||||
int endFrame;
|
int endFrame;
|
||||||
int playNextFrame;
|
int playNextFrame;
|
||||||
int nextFrame;
|
int nextFrame;
|
||||||
|
|
||||||
bool threaded;
|
bool threaded;
|
||||||
|
bool threadLocked;
|
||||||
|
int threadNextFrame;
|
||||||
|
wxMutex vidMutex;
|
||||||
|
wxThread *thread;
|
||||||
|
|
||||||
bool loaded;
|
bool loaded;
|
||||||
bool isInverted;
|
bool isInverted;
|
||||||
|
@ -182,3 +189,15 @@ public:
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//////////
|
||||||
|
// Thread
|
||||||
|
class VideoContextThread : public wxThread {
|
||||||
|
private:
|
||||||
|
VideoContext *parent;
|
||||||
|
|
||||||
|
public:
|
||||||
|
VideoContextThread(VideoContext *parent);
|
||||||
|
wxThread::ExitCode Entry();
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue