BufferedSoundStream.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace Urho.Audio {
  4. public partial class BufferedSoundStream {
  5. public void AddData (byte [] data, int start = 0, int count = -1)
  6. {
  7. if (data == null)
  8. throw new ArgumentNullException (nameof(data));
  9. if (start < 0)
  10. throw new ArgumentException ("start should be positive");
  11. if (count > 0 && start + count > data.Length)
  12. throw new ArgumentException ("start and count would go beyond the array");
  13. unsafe {
  14. fixed (byte *p = &data[start])
  15. BufferedSoundStream_AddData (handle, (IntPtr) p, (uint)(count == -1 ? data.Length-start : count));
  16. }
  17. }
  18. public void AddData (short [] data, int start = 0, int count = -1)
  19. {
  20. if (data == null)
  21. throw new ArgumentNullException (nameof(data));
  22. if (start < 0)
  23. throw new ArgumentException ("start should be positive");
  24. if (count > 0 && start + count > data.Length)
  25. throw new ArgumentException ("start and count would go beyond the array");
  26. unsafe {
  27. fixed (short *p = &data[start])
  28. BufferedSoundStream_AddData (handle, (IntPtr) p, (uint)(2 * (count == -1 ? data.Length-start : count)));
  29. }
  30. }
  31. }
  32. }