DummyAudioOut.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System.Collections.Concurrent;
  2. using System.Collections.Generic;
  3. namespace Ryujinx.Audio
  4. {
  5. /// <summary>
  6. /// A Dummy audio renderer that does not output any audio
  7. /// </summary>
  8. public class DummyAudioOut : IAalOutput
  9. {
  10. private ConcurrentQueue<long> m_Buffers;
  11. public DummyAudioOut()
  12. {
  13. m_Buffers = new ConcurrentQueue<long>();
  14. }
  15. /// <summary>
  16. /// Dummy audio output is always available, Baka!
  17. /// </summary>
  18. public static bool IsSupported => true;
  19. public PlaybackState GetState(int trackId) => PlaybackState.Stopped;
  20. public int OpenTrack(int sampleRate, int channels, ReleaseCallback callback) => 1;
  21. public void CloseTrack(int trackId) { }
  22. public void Start(int trackId) { }
  23. public void Stop(int trackId) { }
  24. public void AppendBuffer<T>(int trackID, long bufferTag, T[] buffer)
  25. where T : struct
  26. {
  27. m_Buffers.Enqueue(bufferTag);
  28. }
  29. public long[] GetReleasedBuffers(int trackId, int maxCount)
  30. {
  31. List<long> bufferTags = new List<long>();
  32. for (int i = 0; i < maxCount; i++)
  33. {
  34. if (!m_Buffers.TryDequeue(out long tag))
  35. {
  36. break;
  37. }
  38. bufferTags.Add(tag);
  39. }
  40. return bufferTags.ToArray();
  41. }
  42. public bool ContainsBuffer(int trackID, long bufferTag) => false;
  43. public void Dispose()
  44. {
  45. m_Buffers.Clear();
  46. }
  47. }
  48. }