From 34c9492f97429d51a70331662bd97cf42c9a628b Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Mon, 9 Apr 2007 16:08:57 +0000 Subject: [PATCH] Made csri/vsfilter_textsub use csri_open_file() instead of csri_open_mem() Originally committed to SVN as r1048. --- aegisub/subtitles_provider_csri.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/aegisub/subtitles_provider_csri.cpp b/aegisub/subtitles_provider_csri.cpp index 955c0d839..0cb8175ce 100644 --- a/aegisub/subtitles_provider_csri.cpp +++ b/aegisub/subtitles_provider_csri.cpp @@ -122,21 +122,18 @@ void CSRISubtitlesProvider::LoadSubtitles(AssFile *subs) { if (instance) csri_close(instance); instance = NULL; - // Prepare subtitles - std::vector data; - subs->SaveMemory(data,_T("UTF-8")); - delete subs; - // CSRI variables csri_rend *cur,*renderer=NULL; csri_info *info; // Select renderer + bool canOpenMem = true; for (cur = csri_renderer_default();cur;cur=csri_renderer_next(cur)) { info = csri_renderer_info(cur); wxString name(info->name,wxConvUTF8); if (name == subType) { renderer = cur; + if (name.StartsWith(_T("vsfilter"))) canOpenMem = false; break; } } @@ -147,8 +144,20 @@ void CSRISubtitlesProvider::LoadSubtitles(AssFile *subs) { if (!renderer) throw _T("No CSRI renderer available. Try installing one or switch to another subtitle provider."); } - // Open - instance = csri_open_mem(renderer,&data[0],data.size(),NULL); + // Open from memory + if (canOpenMem) { + std::vector data; + subs->SaveMemory(data,_T("UTF-8")); + delete subs; + instance = csri_open_mem(renderer,&data[0],data.size(),NULL); + } + + // Open from disk + else { + wxString subsFileName = VideoContext::Get()->GetTempWorkFile(); + subs->Save(subsFileName,false,false,_T("UTF-8")); + instance = csri_open_file(renderer,subsFileName.mb_str(wxConvUTF8),NULL); + } }