In my libsndfile wrapper currently im using this. To read my stream (Must be a stream im loading from resource) But is this the best way i can fill the pointer with the requested data?
public static void ReadStream(Stream input,IntPtr output,int size)
{
byte[] data = new byte[BufferSize];
int i = BufferSize;
int ptr_offset = 0;
while (i == BufferSize || ptr_offset==size)
{
i = input.Read(data, 0, BufferSize);
if (i + ptr_offset > size)
i = size - ptr_offset;
MarshalExt.Copy_MU(data, 0, output, ptr_offset, (uint)i);
ptr_offset += i;
}
}