HardwareDevice.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // Copyright (c) 2019-2020 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.Renderer.Integration
  20. {
  21. /// <summary>
  22. /// Represent an hardware device used in <see cref="Dsp.Command.DeviceSinkCommand"/>
  23. /// </summary>
  24. public interface HardwareDevice : IDisposable
  25. {
  26. /// <summary>
  27. /// Get the supported sample rate of this device.
  28. /// </summary>
  29. /// <returns>The supported sample rate of this device.</returns>
  30. uint GetSampleRate();
  31. /// <summary>
  32. /// Get the channel count supported by this device.
  33. /// </summary>
  34. /// <returns>The channel count supported by this device.</returns>
  35. uint GetChannelCount();
  36. /// <summary>
  37. /// Appends new PCM16 samples to the device.
  38. /// </summary>
  39. /// <param name="data">The new PCM16 samples.</param>
  40. /// <param name="channelCount">The number of channels.</param>
  41. void AppendBuffer(ReadOnlySpan<short> data, uint channelCount);
  42. /// <summary>
  43. /// Check if the audio renderer needs to perform downmixing.
  44. /// </summary>
  45. /// <returns>True if downmixing is needed.</returns>
  46. public bool NeedDownmixing()
  47. {
  48. uint channelCount = GetChannelCount();
  49. Debug.Assert(channelCount > 0 && channelCount <= RendererConstants.ChannelCountMax);
  50. return channelCount != RendererConstants.ChannelCountMax;
  51. }
  52. }
  53. }