From 5a878ae9afe73d12bd344c139ee1b485335af3ff Mon Sep 17 00:00:00 2001 From: jhorv <38920027+jhorv@users.noreply.github.com> Date: Sat, 15 Jun 2024 17:00:13 -0400 Subject: [PATCH] replace `ByteMemoryPool` use with `MemoryOwner` and `SpanOwner` (#6911) --- .../SDL2HardwareDeviceSession.cs | 4 ++-- .../SoundIoHardwareDeviceSession.cs | 4 ++-- src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Ryujinx.Audio.Backends.SDL2/SDL2HardwareDeviceSession.cs b/src/Ryujinx.Audio.Backends.SDL2/SDL2HardwareDeviceSession.cs index 62fe5025..4eb75a57 100644 --- a/src/Ryujinx.Audio.Backends.SDL2/SDL2HardwareDeviceSession.cs +++ b/src/Ryujinx.Audio.Backends.SDL2/SDL2HardwareDeviceSession.cs @@ -89,9 +89,9 @@ namespace Ryujinx.Audio.Backends.SDL2 return; } - using IMemoryOwner samplesOwner = ByteMemoryPool.Rent(frameCount * _bytesPerFrame); + using SpanOwner samplesOwner = SpanOwner.Rent(frameCount * _bytesPerFrame); - Span samples = samplesOwner.Memory.Span; + Span samples = samplesOwner.Span; _ringBuffer.Read(samples, 0, samples.Length); diff --git a/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs b/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs index 4011a121..e9cc6a8e 100644 --- a/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs +++ b/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs @@ -122,9 +122,9 @@ namespace Ryujinx.Audio.Backends.SoundIo int channelCount = areas.Length; - using IMemoryOwner samplesOwner = ByteMemoryPool.Rent(frameCount * bytesPerFrame); + using SpanOwner samplesOwner = SpanOwner.Rent(frameCount * bytesPerFrame); - Span samples = samplesOwner.Memory.Span; + Span samples = samplesOwner.Span; _ringBuffer.Read(samples, 0, samples.Length); diff --git a/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs b/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs index b95e5bed..7aefe886 100644 --- a/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs +++ b/src/Ryujinx.Audio/Backends/Common/DynamicRingBuffer.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Audio.Backends.Common private readonly object _lock = new(); - private IMemoryOwner _bufferOwner; + private MemoryOwner _bufferOwner; private Memory _buffer; private int _size; private int _headOffset; @@ -24,7 +24,7 @@ namespace Ryujinx.Audio.Backends.Common public DynamicRingBuffer(int initialCapacity = RingBufferAlignment) { - _bufferOwner = ByteMemoryPool.RentCleared(initialCapacity); + _bufferOwner = MemoryOwner.RentCleared(initialCapacity); _buffer = _bufferOwner.Memory; } @@ -62,7 +62,7 @@ namespace Ryujinx.Audio.Backends.Common private void SetCapacityLocked(int capacity) { - IMemoryOwner newBufferOwner = ByteMemoryPool.RentCleared(capacity); + MemoryOwner newBufferOwner = MemoryOwner.RentCleared(capacity); Memory newBuffer = newBufferOwner.Memory; if (_size > 0)