DummyHardwareDeviceSessionOutput.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Ryujinx.Audio.Backends.Common;
  2. using Ryujinx.Audio.Common;
  3. using Ryujinx.Audio.Integration;
  4. using Ryujinx.Memory;
  5. using System.Threading;
  6. namespace Ryujinx.Audio.Backends.Dummy
  7. {
  8. internal class DummyHardwareDeviceSessionOutput : HardwareDeviceSessionOutputBase
  9. {
  10. private float _volume;
  11. private IHardwareDeviceDriver _manager;
  12. private ulong _playedSampleCount;
  13. public DummyHardwareDeviceSessionOutput(IHardwareDeviceDriver manager, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount, float requestedVolume) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount)
  14. {
  15. _volume = requestedVolume;
  16. _manager = manager;
  17. }
  18. public override void Dispose()
  19. {
  20. // Nothing to do.
  21. }
  22. public override ulong GetPlayedSampleCount()
  23. {
  24. return Interlocked.Read(ref _playedSampleCount);
  25. }
  26. public override float GetVolume()
  27. {
  28. return _volume;
  29. }
  30. public override void PrepareToClose() { }
  31. public override void QueueBuffer(AudioBuffer buffer)
  32. {
  33. Interlocked.Add(ref _playedSampleCount, GetSampleCount(buffer));
  34. _manager.GetUpdateRequiredEvent().Set();
  35. }
  36. public override void SetVolume(float volume)
  37. {
  38. _volume = volume;
  39. }
  40. public override void Start() { }
  41. public override void Stop() { }
  42. public override void UnregisterBuffer(AudioBuffer buffer) { }
  43. public override bool WasBufferFullyConsumed(AudioBuffer buffer)
  44. {
  45. return true;
  46. }
  47. }
  48. }