Made csri/vsfilter_textsub use csri_open_file() instead of csri_open_mem()

Originally committed to SVN as r1048.
This commit is contained in:
Rodrigo Braz Monteiro 2007-04-09 16:08:57 +00:00
parent 1c6bea3220
commit 34c9492f97

View file

@ -122,21 +122,18 @@ void CSRISubtitlesProvider::LoadSubtitles(AssFile *subs) {
if (instance) csri_close(instance);
instance = NULL;
// Prepare subtitles
std::vector<char> 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<char> 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);
}
}