public SeekableDataInputVirtualFile(SeekableDataInput file, IVirtualFile ioctlFile) : base(file, ioctlFile) { }
protected internal virtual int hlePsmfPlayerSetPsmf(int psmfPlayer, PspString fileAddr, int offset, bool doCallbacks, bool useSizeFromPsmfHeader) { if (psmfPlayerStatus != PSMF_PLAYER_STATUS_INIT) { return(ERROR_PSMFPLAYER_NOT_INITIALIZED); } if (offset != 0) { Console.WriteLine(string.Format("hlePsmfPlayerSetPsmf unimplemented offset=0x{0:X}", offset)); } pmfFilePath = fileAddr.String; // Get the file and read it to a buffer. try { if (log.InfoEnabled) { Console.WriteLine(string.Format("Loading PSMF file '{0}'", pmfFilePath)); } SeekableDataInput psmfFile = Modules.IoFileMgrForUserModule.getFile(pmfFilePath, 0); psmfFile.seek(offset); int Length = (int)psmfFile.Length() - offset; // Some PSMF files have an incorrect size stored into their header. // It seems that the PSP is ignoring this size when using scePsmfPlayerSetPsmf(). // However, the size is probably not ignored when using scePsmfPlayerSetPsmfOffset(). if (useSizeFromPsmfHeader) { // Try to find the Length of the PSMF file by reading the PSMF header sbyte[] header = new sbyte[pspsharp.filesystems.umdiso.ISectorDevice_Fields.sectorLength]; psmfFile.readFully(header); int psmfMagic = read32(null, 0, header, PSMF_MAGIC_OFFSET); if (psmfMagic == PSMF_MAGIC) { // Found the PSMF header, extract the file size from the stream size and offset. Length = endianSwap32(read32(null, 0, header, PSMF_STREAM_SIZE_OFFSET)); Length += endianSwap32(read32(null, 0, header, PSMF_STREAM_OFFSET_OFFSET)); //if (log.DebugEnabled) { Console.WriteLine(string.Format("PSMF Length=0x{0:X}, header: {1}", Length, Utilities.getMemoryDump(header, 0, header.Length))); } } } psmfFile.seek(offset); pmfFileData = new sbyte[Length]; psmfFile.readFully(pmfFileData); psmfFile.Dispose(); Modules.sceMpegModule.analyseMpeg(0, pmfFileData); pmfFileDataRingbufferPosition = Modules.sceMpegModule.PsmfHeader.mpegOffset; } catch (System.OutOfMemoryException e) { Console.WriteLine("hlePsmfPlayerSetPsmf", e); } catch (IOException e) { Console.WriteLine("hlePsmfPlayerSetPsmf", e); } // Switch to STANDBY. psmfPlayerStatus = PSMF_PLAYER_STATUS_STANDBY; // Delay the thread for 100ms Modules.ThreadManForUserModule.hleKernelDelayThread(100000, doCallbacks); return(0); }