Add locks around CSRI operations as VSFilter isn't even vaguely threadsafe
Originally committed to SVN as r5810.
This commit is contained in:
parent
29f0786c81
commit
f48bc59694
1 changed files with 12 additions and 16 deletions
|
@ -38,28 +38,29 @@
|
||||||
|
|
||||||
#ifdef WITH_CSRI
|
#ifdef WITH_CSRI
|
||||||
|
|
||||||
#include "ass_file.h"
|
#ifndef AGI_PRE
|
||||||
|
#include <wx/thread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "subtitles_provider_csri.h"
|
#include "subtitles_provider_csri.h"
|
||||||
|
|
||||||
|
#include "ass_file.h"
|
||||||
#include "text_file_writer.h"
|
#include "text_file_writer.h"
|
||||||
#include "video_context.h"
|
#include "video_context.h"
|
||||||
#include "video_frame.h"
|
#include "video_frame.h"
|
||||||
|
|
||||||
/// @brief Constructor
|
static wxMutex csri_mutex;
|
||||||
/// @param type
|
|
||||||
///
|
|
||||||
CSRISubtitlesProvider::CSRISubtitlesProvider(std::string type) : subType(type) {
|
CSRISubtitlesProvider::CSRISubtitlesProvider(std::string type) : subType(type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Destructor
|
|
||||||
///
|
|
||||||
CSRISubtitlesProvider::~CSRISubtitlesProvider() {
|
CSRISubtitlesProvider::~CSRISubtitlesProvider() {
|
||||||
if (!tempfile.empty()) wxRemoveFile(tempfile);
|
if (!tempfile.empty()) wxRemoveFile(tempfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Load subtitles
|
|
||||||
/// @param subs
|
|
||||||
///
|
|
||||||
void CSRISubtitlesProvider::LoadSubtitles(AssFile *subs) {
|
void CSRISubtitlesProvider::LoadSubtitles(AssFile *subs) {
|
||||||
|
wxMutexLocker lock(csri_mutex);
|
||||||
|
|
||||||
// CSRI variables
|
// CSRI variables
|
||||||
csri_rend *cur,*renderer=NULL;
|
csri_rend *cur,*renderer=NULL;
|
||||||
|
|
||||||
|
@ -101,15 +102,12 @@ void CSRISubtitlesProvider::LoadSubtitles(AssFile *subs) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Draw subtitles
|
|
||||||
/// @param dst
|
|
||||||
/// @param time
|
|
||||||
/// @return
|
|
||||||
///
|
|
||||||
void CSRISubtitlesProvider::DrawSubtitles(AegiVideoFrame &dst,double time) {
|
void CSRISubtitlesProvider::DrawSubtitles(AegiVideoFrame &dst,double time) {
|
||||||
// Check if CSRI loaded properly
|
// Check if CSRI loaded properly
|
||||||
if (!instance.get()) return;
|
if (!instance.get()) return;
|
||||||
|
|
||||||
|
wxMutexLocker lock(csri_mutex);
|
||||||
|
|
||||||
// Load data into frame
|
// Load data into frame
|
||||||
csri_frame frame;
|
csri_frame frame;
|
||||||
if (dst.flipped) {
|
if (dst.flipped) {
|
||||||
|
@ -134,8 +132,6 @@ void CSRISubtitlesProvider::DrawSubtitles(AegiVideoFrame &dst,double time) {
|
||||||
csri_render(instance.get(),&frame,time);
|
csri_render(instance.get(),&frame,time);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Get CSRI subtypes
|
|
||||||
///
|
|
||||||
std::vector<std::string> CSRISubtitlesProvider::GetSubTypes() {
|
std::vector<std::string> CSRISubtitlesProvider::GetSubTypes() {
|
||||||
std::vector<std::string> final;
|
std::vector<std::string> final;
|
||||||
for (csri_rend *cur = csri_renderer_default();cur;cur = csri_renderer_next(cur)) {
|
for (csri_rend *cur = csri_renderer_default();cur;cur = csri_renderer_next(cur)) {
|
||||||
|
|
Loading…
Reference in a new issue