Delete threaded video mode, as it never worked in the first place and is fundamentally flawed.

Originally committed to SVN as r3632.
This commit is contained in:
Thomas Goyne 2009-10-06 16:12:23 +00:00
parent 9217476357
commit bead7360c4
2 changed files with 24 additions and 196 deletions

View file

@ -91,13 +91,9 @@ BEGIN_EVENT_TABLE(VideoContext, wxEvtHandler)
EVT_TIMER(VIDEO_PLAY_TIMER,VideoContext::OnPlayTimer) EVT_TIMER(VIDEO_PLAY_TIMER,VideoContext::OnPlayTimer)
END_EVENT_TABLE() END_EVENT_TABLE()
/// DOCME /// DOCME
VideoContext *VideoContext::instance = NULL; VideoContext *VideoContext::instance = NULL;
/// @brief Constructor /// @brief Constructor
/// ///
VideoContext::VideoContext() { VideoContext::VideoContext() {
@ -123,16 +119,8 @@ VideoContext::VideoContext() {
isPlaying = false; isPlaying = false;
nextFrame = -1; nextFrame = -1;
keepAudioSync = true; keepAudioSync = true;
// Threads
//threaded = Options.AsBool(_T("Threaded Video"));
threaded = false;
threadLocked = false;
threadNextFrame = -1;
} }
/// @brief Destructor /// @brief Destructor
/// ///
VideoContext::~VideoContext () { VideoContext::~VideoContext () {
@ -142,8 +130,6 @@ VideoContext::~VideoContext () {
glContext = NULL; glContext = NULL;
} }
/// @brief Get Instance /// @brief Get Instance
/// @return /// @return
/// ///
@ -154,8 +140,6 @@ VideoContext *VideoContext::Get() {
return instance; return instance;
} }
/// @brief Clear /// @brief Clear
/// ///
void VideoContext::Clear() { void VideoContext::Clear() {
@ -164,8 +148,6 @@ void VideoContext::Clear() {
instance = NULL; instance = NULL;
} }
/// @brief Reset /// @brief Reset
/// ///
void VideoContext::Reset() { void VideoContext::Reset() {
@ -215,8 +197,6 @@ void VideoContext::Reset() {
subsProvider = NULL; subsProvider = NULL;
} }
/// @brief Reload video /// @brief Reload video
/// ///
void VideoContext::Reload() { void VideoContext::Reload() {
@ -229,8 +209,6 @@ void VideoContext::Reload() {
} }
} }
/// @brief Unload texture /// @brief Unload texture
/// ///
void VideoContext::UnloadTexture() { void VideoContext::UnloadTexture() {
@ -242,15 +220,12 @@ void VideoContext::UnloadTexture() {
lastFrame = -1; lastFrame = -1;
} }
/// @brief Sets video filename /// @brief Sets video filename
/// @param filename /// @param filename
/// ///
void VideoContext::SetVideo(const wxString &filename) { void VideoContext::SetVideo(const wxString &filename) {
// Unload video // Unload video
Reset(); Reset();
threaded = Options.AsBool(_T("Threaded Video"));
// Load video // Load video
if (!filename.IsEmpty()) { if (!filename.IsEmpty()) {
@ -325,8 +300,6 @@ void VideoContext::SetVideo(const wxString &filename) {
loaded = provider != NULL; loaded = provider != NULL;
} }
/// @brief Add new display /// @brief Add new display
/// @param display /// @param display
/// @return /// @return
@ -338,8 +311,6 @@ void VideoContext::AddDisplay(VideoDisplay *display) {
displayList.push_back(display); displayList.push_back(display);
} }
/// @brief Remove display /// @brief Remove display
/// @param display /// @param display
/// ///
@ -347,8 +318,6 @@ void VideoContext::RemoveDisplay(VideoDisplay *display) {
displayList.remove(display); displayList.remove(display);
} }
/// @brief Update displays /// @brief Update displays
/// @param full /// @param full
/// ///
@ -395,8 +364,6 @@ void VideoContext::Refresh (bool video, bool subtitles) {
JumpToFrame(frame_n); JumpToFrame(frame_n);
} }
/// @brief Jumps to a frame and update display /// @brief Jumps to a frame and update display
/// @param n /// @param n
/// @return /// @return
@ -408,45 +375,30 @@ void VideoContext::JumpToFrame(int n) {
// Prevent intervention during playback // Prevent intervention during playback
if (isPlaying && n != playNextFrame) return; if (isPlaying && n != playNextFrame) return;
// Threaded try {
if (threaded && false) { // Doesn't work, so it's disabled // Set frame number
wxMutexLocker lock(vidMutex); frame_n = n;
threadNextFrame = n;
if (!threadLocked) { // Display
threadLocked = true; UpdateDisplays(false);
thread = new VideoContextThread(this);
thread->Create(); // Update grid
thread->Run(); if (!isPlaying && Options.AsBool(_T("Highlight subs in frame"))) grid->Refresh(false);
}
} }
catch (const wxChar *err) {
// Not threaded wxLogError(
else { _T("Failed seeking video. The video will be closed because of this.\n")
try { _T("If you get this error regardless of which video file you use, and also if you use dummy video, Aegisub might not work with your graphics card's OpenGL driver.\n")
// Set frame number _T("Error message reported: %s"),
frame_n = n; err);
Reset();
// Display }
UpdateDisplays(false); catch (...) {
wxLogError(
// Update grid _T("Failed seeking video. The video will be closed because of this.\n")
if (!isPlaying && Options.AsBool(_T("Highlight subs in frame"))) grid->Refresh(false); _T("If you get this error regardless of which video file you use, and also if you use dummy video, Aegisub might not work with your graphics card's OpenGL driver.\n")
} _T("No further error message given."));
catch (const wxChar *err) { Reset();
wxLogError(
_T("Failed seeking video. The video will be closed because of this.\n")
_T("If you get this error regardless of which video file you use, and also if you use dummy video, Aegisub might not work with your graphics card's OpenGL driver.\n")
_T("Error message reported: %s"),
err);
Reset();
}
catch (...) {
wxLogError(
_T("Failed seeking video. The video will be closed because of this.\n")
_T("If you get this error regardless of which video file you use, and also if you use dummy video, Aegisub might not work with your graphics card's OpenGL driver.\n")
_T("No further error message given."));
Reset();
}
} }
} }
@ -543,8 +495,6 @@ void VideoContext::SaveSnapshot(bool raw) {
GetFrame(frame_n,raw).GetImage().SaveFile(path,wxBITMAP_TYPE_PNG); GetFrame(frame_n,raw).GetImage().SaveFile(path,wxBITMAP_TYPE_PNG);
} }
/// @brief Get dimensions of script /// @brief Get dimensions of script
/// @param sw /// @param sw
/// @param sh /// @param sh
@ -553,8 +503,6 @@ void VideoContext::GetScriptSize(int &sw,int &sh) {
grid->ass->GetResolution(sw,sh); grid->ass->GetResolution(sw,sh);
} }
/// @brief Play /// @brief Play
/// @return /// @return
/// ///
@ -581,8 +529,6 @@ void VideoContext::Play() {
playback.Start(10); playback.Start(10);
} }
/// @brief Play line /// @brief Play line
/// @return /// @return
/// ///
@ -611,8 +557,6 @@ void VideoContext::PlayLine() {
playback.Start(10); playback.Start(10);
} }
/// @brief Stop /// @brief Stop
/// ///
void VideoContext::Stop() { void VideoContext::Stop() {
@ -623,8 +567,6 @@ void VideoContext::Stop() {
} }
} }
/// @brief Play timer /// @brief Play timer
/// @param event /// @param event
/// @return /// @return
@ -679,8 +621,6 @@ void VideoContext::OnPlayTimer(wxTimerEvent &event) {
} }
} }
/// @brief Get name of temp work file /// @brief Get name of temp work file
/// @return /// @return
/// ///
@ -693,8 +633,6 @@ wxString VideoContext::GetTempWorkFile () {
return tempfile; return tempfile;
} }
/// @brief Get keyframes /// @brief Get keyframes
/// @return /// @return
/// ///
@ -703,8 +641,6 @@ wxArrayInt VideoContext::GetKeyFrames() {
return KeyFrames; return KeyFrames;
} }
/// @brief Set keyframes /// @brief Set keyframes
/// @param frames /// @param frames
/// ///
@ -712,8 +648,6 @@ void VideoContext::SetKeyFrames(wxArrayInt frames) {
KeyFrames = frames; KeyFrames = frames;
} }
/// @brief Set keyframe override /// @brief Set keyframe override
/// @param frames /// @param frames
/// ///
@ -722,8 +656,6 @@ void VideoContext::SetOverKeyFrames(wxArrayInt frames) {
overKeyFramesLoaded = true; overKeyFramesLoaded = true;
} }
/// @brief Close keyframes /// @brief Close keyframes
/// ///
void VideoContext::CloseOverKeyFrames() { void VideoContext::CloseOverKeyFrames() {
@ -731,8 +663,6 @@ void VideoContext::CloseOverKeyFrames() {
overKeyFramesLoaded = false; overKeyFramesLoaded = false;
} }
/// @brief Check if override keyframes are loaded /// @brief Check if override keyframes are loaded
/// @return /// @return
/// ///
@ -740,8 +670,6 @@ bool VideoContext::OverKeyFramesLoaded() {
return overKeyFramesLoaded; return overKeyFramesLoaded;
} }
/// @brief Check if keyframes are loaded /// @brief Check if keyframes are loaded
/// @return /// @return
/// ///
@ -749,8 +677,6 @@ bool VideoContext::KeyFramesLoaded() {
return overKeyFramesLoaded || keyFramesLoaded; return overKeyFramesLoaded || keyFramesLoaded;
} }
/// @brief Calculate aspect ratio /// @brief Calculate aspect ratio
/// @param type /// @param type
/// @return /// @return
@ -763,8 +689,6 @@ double VideoContext::GetARFromType(int type) {
return 1.0; //error return 1.0; //error
} }
/// @brief Sets aspect ratio /// @brief Sets aspect ratio
/// @param _type /// @param _type
/// @param value /// @param value
@ -780,55 +704,3 @@ void VideoContext::SetAspectRatio(int _type, double value) {
arValue = value; arValue = value;
UpdateDisplays(true); UpdateDisplays(true);
} }
/// @brief Thread constructor
/// @param par
///
VideoContextThread::VideoContextThread(VideoContext *par)
: wxThread(wxTHREAD_DETACHED)
{
parent = par;
}
/// @brief 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
{
wxMutexLocker glLock(OpenGLWrapper::glMutex);
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;
}
}
}

View file

@ -34,9 +34,6 @@
/// @ingroup video /// @ingroup video
/// ///
/////////// ///////////
// Headers // Headers
#ifndef AGI_PRE #ifndef AGI_PRE
@ -76,9 +73,6 @@ class AssDialogue;
class VideoProvider; class VideoProvider;
class VideoDisplay; class VideoDisplay;
class SubtitlesProvider; class SubtitlesProvider;
class VideoContextThread;
/// DOCME /// DOCME
/// @class VideoContext /// @class VideoContext
@ -88,7 +82,6 @@ class VideoContextThread;
class VideoContext : public wxEvtHandler { class VideoContext : public wxEvtHandler {
friend class AudioProvider; friend class AudioProvider;
friend class VisualTool; friend class VisualTool;
friend class VideoContextThread;
private: private:
/// DOCME /// DOCME
@ -163,23 +156,6 @@ private:
/// DOCME /// DOCME
int nextFrame; int nextFrame;
/// DOCME
bool threaded;
/// DOCME
bool threadLocked;
/// DOCME
int threadNextFrame;
/// DOCME
wxMutex vidMutex;
/// DOCME
wxThread *thread;
/// DOCME /// DOCME
bool loaded; bool loaded;
@ -359,23 +335,3 @@ public:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
/// DOCME
/// @class VideoContextThread
/// @brief DOCME
///
/// DOCME
class VideoContextThread : public wxThread {
private:
/// DOCME
VideoContext *parent;
public:
VideoContextThread(VideoContext *parent);
wxThread::ExitCode Entry();
};