From 227eae0dbe9486653b9a31eafd5975a0d7b1bc2b Mon Sep 17 00:00:00 2001 From: morkt Date: Sun, 14 Jun 2015 04:10:00 +0400 Subject: [PATCH] convert OGV format into Ogg propery. --- ArcFormats/AudioOGV.cs | 35 +++++++++++++++++---------- ArcFormats/Properties/AssemblyInfo.cs | 4 +-- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/ArcFormats/AudioOGV.cs b/ArcFormats/AudioOGV.cs index a60ac36d..68ba03e8 100644 --- a/ArcFormats/AudioOGV.cs +++ b/ArcFormats/AudioOGV.cs @@ -25,6 +25,7 @@ using System.ComponentModel.Composition; using System.IO; +using GameRes.Utility; namespace GameRes.Formats.ShiinaRio { @@ -37,21 +38,29 @@ namespace GameRes.Formats.ShiinaRio public override SoundInput TryOpen (Stream file) { - var input = file as MemoryStream; - if (null == input || !input.CanWrite) + file.Position = 0xc; + var header = new byte[8]; + if (8 != file.Read (header, 0, 8)) + return null; + if (!Binary.AsciiEqual (header, 0, "fmt ")) + return null; + uint offset = LittleEndian.ToUInt32 (header, 4); + file.Seek (offset, SeekOrigin.Current); + if (8 != file.Read (header, 0, 8)) + return null; + if (!Binary.AsciiEqual (header, 0, "data")) + return null; + + var input = new StreamRegion (file, file.Position); + try { - input = new MemoryStream(); - file.CopyTo (input); + return new OggInput (input); + } + catch + { + input.Dispose(); + throw; } - input.Position = 1; - input.WriteByte ((byte)'g'); - input.WriteByte ((byte)'g'); - input.WriteByte ((byte)'S'); - input.Position = 0; - var ogg = new OggInput (input); - if (file != input) - file.Dispose(); - return ogg; } } } diff --git a/ArcFormats/Properties/AssemblyInfo.cs b/ArcFormats/Properties/AssemblyInfo.cs index 3a7208ba..451c7186 100644 --- a/ArcFormats/Properties/AssemblyInfo.cs +++ b/ArcFormats/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion ("1.0.6.62")] -[assembly: AssemblyFileVersion ("1.0.6.62")] +[assembly: AssemblyVersion ("1.0.6.63")] +[assembly: AssemblyFileVersion ("1.0.6.63")]