diff options
| author | jhorv <38920027+jhorv@users.noreply.github.com> | 2024-04-21 06:57:35 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-21 12:57:35 +0200 |
| commit | 216026c096d844f8bf09ee0e185dec4111c64095 (patch) | |
| tree | 222eb5476aacb79f9d67abd799ee1657c2d63e7c /src/Ryujinx.Audio.Backends.SoundIo | |
| parent | 7070cf6ae502b5c11551fceb164bc9f158ba980b (diff) | |
Use pooled memory and avoid memory copies (#6691)
* perf: use ByteMemoryPool
* feat: KPageTableBase/KPageTable new methods to read and write `ReadOnlySequence<byte>`
* new: add IWritableBlock.Write(ulong, ReadOnlySequence<byte>) with default impl
* perf: use GetReadOnlySequence() instead of GetSpan()
* perf: make `Parcel` IDisposable, use `ByteMemoryPool` for internal allocation, and make Parcel consumers dispose of it
* remove comment about copySize
* remove unnecessary Clear()
Diffstat (limited to 'src/Ryujinx.Audio.Backends.SoundIo')
| -rw-r--r-- | src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs b/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs index f60982e3..4011a121 100644 --- a/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs +++ b/src/Ryujinx.Audio.Backends.SoundIo/SoundIoHardwareDeviceSession.cs @@ -1,8 +1,10 @@ using Ryujinx.Audio.Backends.Common; using Ryujinx.Audio.Backends.SoundIo.Native; using Ryujinx.Audio.Common; +using Ryujinx.Common.Memory; using Ryujinx.Memory; using System; +using System.Buffers; using System.Collections.Concurrent; using System.Runtime.CompilerServices; using System.Threading; @@ -37,7 +39,7 @@ namespace Ryujinx.Audio.Backends.SoundIo _outputStream = _driver.OpenStream(RequestedSampleFormat, RequestedSampleRate, RequestedChannelCount); _outputStream.WriteCallback += Update; _outputStream.Volume = requestedVolume; - // TODO: Setup other callbacks (errors, ect). + // TODO: Setup other callbacks (errors, etc.) _outputStream.Open(); } @@ -120,7 +122,9 @@ namespace Ryujinx.Audio.Backends.SoundIo int channelCount = areas.Length; - byte[] samples = new byte[frameCount * bytesPerFrame]; + using IMemoryOwner<byte> samplesOwner = ByteMemoryPool.Rent(frameCount * bytesPerFrame); + + Span<byte> samples = samplesOwner.Memory.Span; _ringBuffer.Read(samples, 0, samples.Length); |
