DummyHardwareDeviceSessionInput.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // Copyright (c) 2019-2021 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 Ryujinx.Audio.Common;
  18. using Ryujinx.Audio.Integration;
  19. using Ryujinx.Memory;
  20. using System;
  21. namespace Ryujinx.Audio.Backends.Dummy
  22. {
  23. class DummyHardwareDeviceSessionInput : IHardwareDeviceSession
  24. {
  25. private float _volume;
  26. private IHardwareDeviceDriver _manager;
  27. private IVirtualMemoryManager _memoryManager;
  28. public DummyHardwareDeviceSessionInput(IHardwareDeviceDriver manager, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount)
  29. {
  30. _volume = 1.0f;
  31. _manager = manager;
  32. _memoryManager = memoryManager;
  33. }
  34. public void Dispose()
  35. {
  36. // Nothing to do.
  37. }
  38. public ulong GetPlayedSampleCount()
  39. {
  40. // Not implemented for input.
  41. throw new NotSupportedException();
  42. }
  43. public float GetVolume()
  44. {
  45. return _volume;
  46. }
  47. public void PrepareToClose() { }
  48. public void QueueBuffer(AudioBuffer buffer)
  49. {
  50. _memoryManager.Fill(buffer.DataPointer, buffer.DataSize, 0);
  51. _manager.GetUpdateRequiredEvent().Set();
  52. }
  53. public bool RegisterBuffer(AudioBuffer buffer)
  54. {
  55. return buffer.DataPointer != 0;
  56. }
  57. public void SetVolume(float volume)
  58. {
  59. _volume = volume;
  60. }
  61. public void Start() { }
  62. public void Stop() { }
  63. public void UnregisterBuffer(AudioBuffer buffer) { }
  64. public bool WasBufferFullyConsumed(AudioBuffer buffer)
  65. {
  66. return true;
  67. }
  68. }
  69. }