IHardwareDevice.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Diagnostics;
  3. namespace Ryujinx.Audio.Integration
  4. {
  5. /// <summary>
  6. /// Represent an hardware device used in <see cref="Renderer.Dsp.Command.DeviceSinkCommand"/>
  7. /// </summary>
  8. public interface IHardwareDevice : IDisposable
  9. {
  10. /// <summary>
  11. /// Sets the volume level for this device.
  12. /// </summary>
  13. /// <param name="volume">The volume level to set.</param>
  14. void SetVolume(float volume);
  15. /// <summary>
  16. /// Gets the volume level for this device.
  17. /// </summary>
  18. /// <returns>The volume level of this device.</returns>
  19. float GetVolume();
  20. /// <summary>
  21. /// Get the supported sample rate of this device.
  22. /// </summary>
  23. /// <returns>The supported sample rate of this device.</returns>
  24. uint GetSampleRate();
  25. /// <summary>
  26. /// Get the channel count supported by this device.
  27. /// </summary>
  28. /// <returns>The channel count supported by this device.</returns>
  29. uint GetChannelCount();
  30. /// <summary>
  31. /// Appends new PCM16 samples to the device.
  32. /// </summary>
  33. /// <param name="data">The new PCM16 samples.</param>
  34. /// <param name="channelCount">The number of channels.</param>
  35. void AppendBuffer(ReadOnlySpan<short> data, uint channelCount);
  36. /// <summary>
  37. /// Check if the audio renderer needs to perform downmixing.
  38. /// </summary>
  39. /// <returns>True if downmixing is needed.</returns>
  40. public bool NeedDownmixing()
  41. {
  42. uint channelCount = GetChannelCount();
  43. Debug.Assert(channelCount > 0 && channelCount <= Constants.ChannelCountMax);
  44. return channelCount != Constants.ChannelCountMax;
  45. }
  46. }
  47. }