IAalOutput.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. namespace Ryujinx.Audio
  3. {
  4. public interface IAalOutput : IDisposable
  5. {
  6. bool SupportsChannelCount(int channels);
  7. private int SelectHardwareChannelCount(int targetChannelCount)
  8. {
  9. if (SupportsChannelCount(targetChannelCount))
  10. {
  11. return targetChannelCount;
  12. }
  13. switch (targetChannelCount)
  14. {
  15. case 6:
  16. return SelectHardwareChannelCount(2);
  17. case 2:
  18. return SelectHardwareChannelCount(1);
  19. case 1:
  20. throw new ArgumentException("No valid channel configuration found!");
  21. default:
  22. throw new ArgumentException($"Invalid targetChannelCount {targetChannelCount}");
  23. }
  24. }
  25. int OpenTrack(int sampleRate, int channels, ReleaseCallback callback)
  26. {
  27. return OpenHardwareTrack(sampleRate, SelectHardwareChannelCount(channels), channels, callback);
  28. }
  29. int OpenHardwareTrack(int sampleRate, int hardwareChannels, int virtualChannels, ReleaseCallback callback);
  30. void CloseTrack(int trackId);
  31. bool ContainsBuffer(int trackId, long bufferTag);
  32. long[] GetReleasedBuffers(int trackId, int maxCount);
  33. void AppendBuffer<T>(int trackId, long bufferTag, T[] buffer) where T : struct;
  34. void Start(int trackId);
  35. void Stop(int trackId);
  36. float GetVolume();
  37. void SetVolume(float volume);
  38. PlaybackState GetState(int trackId);
  39. }
  40. }