Providing streaming AudFormat data.

AudFormat.GetPCMInputStream now returns data that is streamed, rather than a MemoryStream.
This commit is contained in:
RoosterDragon
2017-07-09 20:21:02 +00:00
committed by Paul Chote
parent 85c948fd8d
commit 9413d9595c
7 changed files with 218 additions and 75 deletions

View File

@@ -12,6 +12,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace OpenRA
@@ -117,7 +118,17 @@ namespace OpenRA
public static byte[] ReadAllBytes(this Stream s)
{
using (s)
return s.ReadBytes((int)(s.Length - s.Position));
{
if (s.CanSeek)
return s.ReadBytes((int)(s.Length - s.Position));
var bytes = new List<byte>();
var buffer = new byte[1024];
int count;
while ((count = s.Read(buffer, 0, buffer.Length)) > 0)
bytes.AddRange(buffer.Take(count));
return bytes.ToArray();
}
}
public static void Write(this Stream s, byte[] data)