(FormatCatalog.FindFormats): new generic method.

This commit is contained in:
morkt
2016-12-17 18:51:33 +04:00
parent 7c989a0150
commit f3e3446c9a
4 changed files with 69 additions and 77 deletions

View File

@@ -171,27 +171,23 @@ namespace GameRes
public static SoundInput Read (IBinaryStream file)
{
uint signature = file.Signature;
for (;;)
foreach (var impl in FormatCatalog.Instance.FindFormats<AudioFormat> (file.Name, file.Signature))
{
var range = FormatCatalog.Instance.LookupSignature<AudioFormat> (signature);
foreach (var impl in range)
try
{
try
{
file.Position = 0;
SoundInput sound = impl.TryOpen (file);
if (null != sound)
return sound;
}
catch (System.Exception X)
{
FormatCatalog.Instance.LastError = X;
}
file.Position = 0;
SoundInput sound = impl.TryOpen (file);
if (null != sound)
return sound;
}
catch (OperationCanceledException)
{
throw;
}
catch (System.Exception X)
{
FormatCatalog.Instance.LastError = X;
}
if (0 == signature)
break;
signature = 0;
}
return null;
}