Providing streaming AudFormat data.
AudFormat.GetPCMInputStream now returns data that is streamed, rather than a MemoryStream.
This commit is contained in:
committed by
Paul Chote
parent
85c948fd8d
commit
9413d9595c
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user