protected static VirtualFileStream CreateFileStream(string fileName) { try { return(VirtualFile.Open(fileName)); } catch (FileNotFoundException) { return(null); } catch (Exception e) { Log.Warning("SoundWorld: File stream creation failed: {0}", e.Message); return(null); } }
//static double totalTime; //static double startTime; //static int openings; //static int calls; //static void BeginCounter() //{ // //xx xx; // startTime = RendererWorld.renderTimerManager.GetSystemTime(); // calls++; //} //static void EndCounter() //{ // double t = RendererWorld.renderTimerManager.GetSystemTime() - startTime; // totalTime += t; //} unsafe static bool open(void */*MyOgreVirtualDataStream*/ stream, string fileName, ref int streamSize, ref bool fileNotFound) { //!!!!!right? EngineThreading.CheckMainThread(); //!!!!!посмотреть, что тут грузится. по сути не надо это ведь совсем. ну для шейдеров разве чтоли. тогда будет ли работать с мультипотоке? //openings++; //Log.Info( "OPEN: " + fileName ); streamSize = 0; fileNotFound = false; VirtualFileStream s; try { //watermark //if( fileName == WmImage.GetName() ) // s = WmImage.Open(); //else s = VirtualFile.Open(fileName); } catch (FileNotFoundException) { fileNotFound = true; return(false); } catch { return(false); } streamSize = (int)s.Length; openedStreams.Add((IntPtr)stream, s); lastOpenedOgreStream = (MyOgreVirtualDataStream *)stream; lastOpenedStream = s; return(true); }
/// <summary> /// Loads the block from a file of virtual file system. /// </summary> /// <param name="path">The virtual file path.</param> /// <param name="errorString">The information on an error.</param> /// <param name="fileNotFound"><b>true</b> if file not found.</param> /// <returns><see cref="NeoAxis.TextBlock"/> if the block has been loaded; otherwise, <b>null</b>.</returns> public static TextBlock LoadFromVirtualFile(string path, out string errorString, out bool fileNotFound) { errorString = null; fileNotFound = false; //!!!!имя файла в ошибке снаружи метода try { using (Stream stream = VirtualFile.Open(path)) { using (StreamReader streamReader = new StreamReader(stream)) { string error; TextBlock textBlock = TextBlock.Parse(streamReader.ReadToEnd(), out error); if (textBlock == null) { errorString = $"Unable to load file \'{path}\'. " + error; return(null); } return(textBlock); } } } catch (FileNotFoundException) { errorString = $"Unable to load file \'{path}\'. File not found."; fileNotFound = true; return(null); } catch (Exception e) { errorString = $"Unable to load file \'{path}\'. " + e.Message; return(null); } }
void CreateOggFile() { PreloadNativeLibraries(); DestroyOggFile(); var fileName = FileName.Value?.ResourceName; if (string.IsNullOrEmpty(fileName)) { return; } VirtualFileStream stream = null; try { stream = VirtualFile.Open(fileName); oggFile = new OggFile(); oggFile.Volume = Volume; bool sound3D = ParentContainer.Transform3D != null; // is UIContainer3D; oggFile.Init(stream, new MyVideoDriver(videoBuffer), new MyAudioDriver(), sound3D); } catch (Exception ex) { if (!noLogErrorAtLoading) { Log.Warning(string.Format("UIVideo: CreateOggFile: Error: {0} ({1}).", ex.Message, fileName)); } if (oggFile != null) { oggFile.Dispose(); oggFile = null; } if (stream != null) { stream.Dispose(); } return; } if (oggFile.VideoDriver == null) { oggFile.Dispose(); oggFile = null; } if (oggFile == null) { return; } UpdateOggFileSoundPosition(); oggFile.Pause = Pause; }