int ReadDataFromDataStream(IntPtr buffer, int needRead) { OpenALDataStreamSound currentDataStreamSound = (OpenALDataStreamSound)currentSound; if (tempDataStreamReadArray.Length < needRead) { tempDataStreamReadArray = new byte[needRead]; } int readed = currentDataStreamSound.dataReadCallback(tempDataStreamReadArray, 0, needRead); if (readed != 0) { Marshal.Copy(tempDataStreamReadArray, 0, buffer, readed); } if (readed < 16) { readed = Math.Min(needRead, 16); NativeUtility.ZeroMemory(buffer, readed); } return(readed); }