Fixed AudFormat and WavFormat implementations of ISoundFormat.LengthInSeconds

- Fixed a rounding issue in `WavReader.WaveLength()`.
- Fixed `AudReader.SoundLength()` not resetting the stream position.
- Fixed crashes caused by disposed streams because `LengthInSeconds` would try and calculate the length on the fly. It is now precalculated and cached (making it consistent across all 5 current `ISoundFormat` implementations).
- Fixed a crash in `AudReader.LoadSound()`'s `out Func<Stream> result` because that func would try and access the disposed stream's `Length` property. That works for `SegmentStream`, but not for `FileStream`.
- Fixed frameCount/soundLength label positioning in the AssetBrowser window to avoid text clipping .
This commit is contained in:
penev92
2021-02-21 15:10:59 +02:00
committed by Matthias Mailänder
parent 8b944e9c82
commit abea3a0f74
6 changed files with 16 additions and 6 deletions

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Cnc.AudioLoaders
public int Channels => channels;
public int SampleBits => sampleBits;
public int SampleRate => sampleRate;
public float LengthInSeconds => AudReader.SoundLength(sourceStream);
public float LengthInSeconds { get; }
public Stream GetPCMInputStream() { return audStreamFactory(); }
public void Dispose() { sourceStream.Dispose(); }
@@ -68,6 +68,8 @@ namespace OpenRA.Mods.Cnc.AudioLoaders
if (!AudReader.LoadSound(stream, out audStreamFactory, out sampleRate, out sampleBits, out channels))
throw new InvalidDataException();
LengthInSeconds = AudReader.SoundLength(sourceStream);
}
}
}