private int OnSubtitleReset(int count, IntPtr pOpts, ref int selected_bitmap_index)
{
Log.Debug("OnSubtitleReset");
Log.Debug("selected_bitmap_index " + selected_bitmap_index);
lock (syncLock)
{
bitmapSubtitleCache.Clear();
pageEntries.Clear();
Log.Debug("Number of bitmap options {0}", count);
IntPtr current = pOpts;
for (int i = 0; i < count; i++)
{
Log.Debug("Bitmap index " + i);
SUBTITLESTREAM bOpt = (SUBTITLESTREAM)Marshal.PtrToStructure(current, typeof(SUBTITLESTREAM));
SubtitleOption opt = new SubtitleOption();
opt.bitmapIndex = i;
opt.type = SubtitleType.Bitmap;
opt.language = "" + (char)bOpt.lang0 + (char)bOpt.lang1 + (char)bOpt.lang2;
Log.Debug(opt.ToString());
bitmapSubtitleCache.Add(opt);
current = (IntPtr)(((int)current) + Marshal.SizeOf(bOpt));
}
selected_bitmap_index = -1; // we didnt select a bitmap index
if (currentOption != null && currentOption.isAuto)
{
SubtitleOption prefered = CheckForPreferedLanguage();
if (prefered != null)
{
currentOption.bitmapIndex = prefered.bitmapIndex;
currentOption.entry = prefered.entry;
currentOption.language = prefered.language;
currentOption.type = prefered.type;
Log.Debug("Auto-selection of " + currentOption);
}
else
{
currentOption.language = "None";
currentOption.type = SubtitleType.None;
}
if (subRender != null)
{
subRender.SetSubtitleOption(currentOption);
}
if (currentOption.type == SubtitleType.Bitmap)
{
selected_bitmap_index = currentOption.bitmapIndex;
Log.Debug("Returns selected_bitmap_index == {0} to ISubStream", selected_bitmap_index);
}
}
}
return 0;
}