BufferedSoundStream.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. Runtime.ValidateRefCounted(this);
  8. if (data == null)
  9. throw new ArgumentNullException (nameof(data));
  10. if (start < 0)
  11. throw new ArgumentException ("start should be positive");
  12. if (count > 0 && start + count > data.Length)
  13. throw new ArgumentException ("start and count would go beyond the array");
  14. unsafe {
  15. fixed (byte *p = &data[start])
  16. BufferedSoundStream_AddData (handle, (IntPtr) p, (uint)(count == -1 ? data.Length-start : count));
  17. }
  18. }
  19. public void AddData (short [] data, int start = 0, int count = -1)
  20. {
  21. Runtime.ValidateRefCounted(this);
  22. if (data == null)
  23. throw new ArgumentNullException (nameof(data));
  24. if (start < 0)
  25. throw new ArgumentException ("start should be positive");
  26. if (count > 0 && start + count > data.Length)
  27. throw new ArgumentException ("start and count would go beyond the array");
  28. unsafe {
  29. fixed (short *p = &data[start])
  30. BufferedSoundStream_AddData (handle, (IntPtr) p, (uint)(2 * (count == -1 ? data.Length-start : count)));
  31. }
  32. }
  33. }
  34. }