IAalOutput.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. return targetChannelCount switch
  14. {
  15. 6 => SelectHardwareChannelCount(2),
  16. 2 => SelectHardwareChannelCount(1),
  17. 1 => throw new ArgumentException("No valid channel configuration found!"),
  18. _ => throw new ArgumentException($"Invalid targetChannelCount {targetChannelCount}"),
  19. };
  20. }
  21. int OpenTrack(int sampleRate, int channels, ReleaseCallback callback)
  22. {
  23. return OpenHardwareTrack(sampleRate, SelectHardwareChannelCount(channels), channels, callback);
  24. }
  25. int OpenHardwareTrack(int sampleRate, int hardwareChannels, int virtualChannels, ReleaseCallback callback);
  26. void CloseTrack(int trackId);
  27. bool ContainsBuffer(int trackId, long bufferTag);
  28. long[] GetReleasedBuffers(int trackId, int maxCount);
  29. void AppendBuffer<T>(int trackId, long bufferTag, T[] buffer) where T : struct;
  30. void Start(int trackId);
  31. void Stop(int trackId);
  32. uint GetBufferCount(int trackId);
  33. ulong GetPlayedSampleCount(int trackId);
  34. bool FlushBuffers(int trackId);
  35. float GetVolume(int trackId);
  36. void SetVolume(int trackId, float volume);
  37. PlaybackState GetState(int trackId);
  38. }
  39. }