migration to IBinaryStream interface.

This commit is contained in:
morkt
2016-10-15 09:34:46 +04:00
parent 0b96ef8f77
commit 503b734645
16 changed files with 264 additions and 332 deletions

View File

@@ -162,34 +162,21 @@ namespace GameRes
{
public override string Type { get { return "audio"; } }
public abstract SoundInput TryOpen (Stream file);
public abstract SoundInput TryOpen (IBinaryStream file);
public virtual void Write (SoundInput source, Stream output)
{
throw new System.NotImplementedException ("AudioFormat.Write not implemenented");
}
public static SoundInput Read (Stream file)
public static SoundInput Read (IBinaryStream file)
{
var input = new MemoryStream();
file.CopyTo (input);
try
{
var sound = FindFormat (input);
if (null != sound)
input = null; // input stream is owned by sound object now, don't dispose it
return sound;
}
finally
{
if (null != input)
input.Dispose();
}
return FindFormat (file);
}
public static SoundInput FindFormat (Stream file)
public static SoundInput FindFormat (IBinaryStream file)
{
uint signature = FormatCatalog.ReadSignature (file);
uint signature = file.Signature;
for (;;)
{
var range = FormatCatalog.Instance.LookupSignature<AudioFormat> (signature);