From 5b26e4ef94afca8450f07c42393180e3c97f9c00 Mon Sep 17 00:00:00 2001 From: Mary Date: Tue, 18 Aug 2020 21:03:55 +0200 Subject: Misc audio fixes (#1348) Changes: Implement software surround downmixing (fix #796). Fix a crash when no audio renderer were created when stopping emulation. NOTE: This PR also disable support of 5.1 surround on the OpenAL backend as we cannot detect if the hardware directly support it. (the downmixing applied by OpenAL on Windows is terribly slow) --- Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Ryujinx.HLE/HOS') diff --git a/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs b/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs index e6b7cb3d..d75fecf2 100644 --- a/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs +++ b/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs @@ -4,6 +4,7 @@ using Ryujinx.HLE.HOS.Ipc; using Ryujinx.HLE.HOS.Kernel.Common; using Ryujinx.HLE.HOS.Kernel.Threading; using System; +using System.Runtime.InteropServices; namespace Ryujinx.HLE.HOS.Services.Audio.AudioOutManager { @@ -106,9 +107,10 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOutManager context.Memory, position); - byte[] buffer = new byte[data.SampleBufferSize]; + // NOTE: Assume PCM16 all the time, change if new format are found. + short[] buffer = new short[data.SampleBufferSize / sizeof(short)]; - context.Memory.Read((ulong)data.SampleBufferPtr, buffer); + context.Memory.Read((ulong)data.SampleBufferPtr, MemoryMarshal.Cast(buffer)); _audioOut.AppendBuffer(_track, tag, buffer); -- cgit v1.2.3