Avoid array resizing in OpenAlAsyncLoadSound.

- Where it is accessible, use the length of the stream to presize the MemoryStream to the correct size.
- Instead of copying out the result via ToArray, grab the underlying buffer via GetBuffer and use that to create the sound source.

This avoids extraneous copying of the array containing the audio.
This commit is contained in:
RoosterDragon
2017-11-22 19:35:38 +00:00
committed by abcdefg30
parent 0899d02377
commit 7760c41bd9
3 changed files with 24 additions and 9 deletions

View File

@@ -170,6 +170,11 @@ namespace OpenRA.Mods.Common.FileFormats
this.dataSize = dataSize;
}
public override long Length
{
get { return outputSize; }
}
protected override bool BufferData(Stream baseStream, Queue<byte> data)
{
if (dataSize <= 0)