IHardwareDevice.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // Copyright (c) 2019-2021 Ryujinx
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. //
  17. using System;
  18. using System.Diagnostics;
  19. namespace Ryujinx.Audio.Integration
  20. {
  21. /// <summary>
  22. /// Represent an hardware device used in <see cref="Renderer.Dsp.Command.DeviceSinkCommand"/>
  23. /// </summary>
  24. public interface IHardwareDevice : IDisposable
  25. {
  26. /// <summary>
  27. /// Sets the volume level for this device.
  28. /// </summary>
  29. /// <param name="volume">The volume level to set.</param>
  30. void SetVolume(float volume);
  31. /// <summary>
  32. /// Gets the volume level for this device.
  33. /// </summary>
  34. /// <returns>The volume level of this device.</returns>
  35. float GetVolume();
  36. /// <summary>
  37. /// Get the supported sample rate of this device.
  38. /// </summary>
  39. /// <returns>The supported sample rate of this device.</returns>
  40. uint GetSampleRate();
  41. /// <summary>
  42. /// Get the channel count supported by this device.
  43. /// </summary>
  44. /// <returns>The channel count supported by this device.</returns>
  45. uint GetChannelCount();
  46. /// <summary>
  47. /// Appends new PCM16 samples to the device.
  48. /// </summary>
  49. /// <param name="data">The new PCM16 samples.</param>
  50. /// <param name="channelCount">The number of channels.</param>
  51. void AppendBuffer(ReadOnlySpan<short> data, uint channelCount);
  52. /// <summary>
  53. /// Check if the audio renderer needs to perform downmixing.
  54. /// </summary>
  55. /// <returns>True if downmixing is needed.</returns>
  56. public bool NeedDownmixing()
  57. {
  58. uint channelCount = GetChannelCount();
  59. Debug.Assert(channelCount > 0 && channelCount <= Constants.ChannelCountMax);
  60. return channelCount != Constants.ChannelCountMax;
  61. }
  62. }
  63. }