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

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.AudioLoaders
public int Channels => channels;
public int SampleBits => sampleBits;
public int SampleRate => sampleRate;
public float LengthInSeconds => WavReader.WaveLength(sourceStream);
public float LengthInSeconds { get; }
public Stream GetPCMInputStream() { return wavStreamFactory(); }
public void Dispose() { sourceStream.Dispose(); }
@@ -69,6 +69,8 @@ namespace OpenRA.Mods.Common.AudioLoaders
if (!WavReader.LoadSound(stream, out wavStreamFactory, out channels, out sampleBits, out sampleRate))
throw new InvalidDataException();
LengthInSeconds = WavReader.WaveLength(sourceStream);
}
}
}