diff --git a/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs b/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs index 86e5566a..c941cf4f 100644 --- a/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs +++ b/Ryujinx.HLE/HOS/Services/Audio/AudioOutManager/IAudioOut.cs @@ -1,6 +1,7 @@ using Ryujinx.Audio; using Ryujinx.Cpu; using Ryujinx.HLE.HOS.Ipc; +using Ryujinx.HLE.HOS.Kernel; using Ryujinx.HLE.HOS.Kernel.Common; using Ryujinx.HLE.HOS.Kernel.Threading; using System; @@ -10,18 +11,20 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOutManager { class IAudioOut : IpcService, IDisposable { - private readonly IAalOutput _audioOut; - private readonly KEvent _releaseEvent; - private int _releaseEventHandle; - private readonly int _track; - private readonly int _clientHandle; + private readonly KernelContext _kernelContext; + private readonly IAalOutput _audioOut; + private readonly KEvent _releaseEvent; + private int _releaseEventHandle; + private readonly int _track; + private readonly int _clientHandle; - public IAudioOut(IAalOutput audioOut, KEvent releaseEvent, int track, int clientHandle) + public IAudioOut(KernelContext kernelContext, IAalOutput audioOut, KEvent releaseEvent, int track, int clientHandle) { - _audioOut = audioOut; - _releaseEvent = releaseEvent; - _track = track; - _clientHandle = clientHandle; + _kernelContext = kernelContext; + _audioOut = audioOut; + _releaseEvent = releaseEvent; + _track = track; + _clientHandle = clientHandle; } [Command(0)] @@ -217,6 +220,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio.AudioOutManager { if (disposing) { + _kernelContext.Syscall.CloseHandle(_clientHandle); _audioOut.CloseTrack(_track); } } diff --git a/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManager.cs b/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManager.cs index 908bf14e..6204a7be 100644 --- a/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManager.cs +++ b/Ryujinx.HLE/HOS/Services/Audio/IAudioOutManager.cs @@ -134,7 +134,7 @@ namespace Ryujinx.HLE.HOS.Services.Audio int track = audioOut.OpenTrack(sampleRate, channels, callback); - MakeObject(context, new IAudioOut(audioOut, releaseEvent, track, context.Request.HandleDesc.ToCopy[0])); + MakeObject(context, new IAudioOut(context.Device.System.KernelContext, audioOut, releaseEvent, track, context.Request.HandleDesc.ToCopy[0])); context.ResponseData.Write(sampleRate); context.ResponseData.Write(channels); diff --git a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs index 52fe3ea1..8b1deb97 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs @@ -329,6 +329,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv context.ResponseData.Write((uint)NvResult.Success); + // Close transfer memory immediately as we don't use it. + context.Device.System.KernelContext.Syscall.CloseHandle(transferMemHandle); + return ResultCode.Success; } @@ -384,9 +387,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv if (errorCode == NvResult.Success) { - KSharedMemory sharedMemory = context.Process.HandleTable.GetObject(sharedMemoryHandle); - - errorCode = ConvertInternalErrorCode(deviceFile.MapSharedMemory(sharedMemory, argument)); + errorCode = ConvertInternalErrorCode(deviceFile.MapSharedMemory(sharedMemoryHandle, argument)); } } diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs index 34ff4ccb..f143f6d1 100644 --- a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs +++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvDeviceFile.cs @@ -28,8 +28,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices return NvInternalResult.NotImplemented; } - public virtual NvInternalResult MapSharedMemory(KSharedMemory sharedMemory, uint argument) + public virtual NvInternalResult MapSharedMemory(int sharedMemoryHandle, uint argument) { + // Close shared memory immediately as we don't use it. + Context.Device.System.KernelContext.Syscall.CloseHandle(sharedMemoryHandle); + return NvInternalResult.NotImplemented; }