Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b29ded1d60 | ||
|
9860bfb2cd |
@@ -199,7 +199,7 @@ namespace Ryujinx.Cpu
|
||||
|
||||
break;
|
||||
}
|
||||
catch (OutOfMemoryException)
|
||||
catch (SystemException)
|
||||
{
|
||||
baseMemory?.Dispose();
|
||||
mirrorMemory?.Dispose();
|
||||
|
@@ -31,7 +31,7 @@ namespace Ryujinx.Memory
|
||||
/// </summary>
|
||||
/// <param name="size">Size of the memory block in bytes</param>
|
||||
/// <param name="flags">Flags that controls memory block memory allocation</param>
|
||||
/// <exception cref="OutOfMemoryException">Throw when there's no enough memory to allocate the requested size</exception>
|
||||
/// <exception cref="SystemException">Throw when there's an error while allocating the requested size</exception>
|
||||
/// <exception cref="PlatformNotSupportedException">Throw when the current platform is not supported</exception>
|
||||
public MemoryBlock(ulong size, MemoryAllocationFlags flags = MemoryAllocationFlags.None)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ namespace Ryujinx.Memory
|
||||
/// </summary>
|
||||
/// <param name="size">Size of the memory block in bytes</param>
|
||||
/// <param name="sharedMemory">Shared memory to use as backing storage for this block</param>
|
||||
/// <exception cref="OutOfMemoryException">Throw when there's no enough address space left to map the shared memory</exception>
|
||||
/// <exception cref="SystemException">Throw when there's an error while mapping the shared memory</exception>
|
||||
/// <exception cref="PlatformNotSupportedException">Throw when the current platform is not supported</exception>
|
||||
private MemoryBlock(ulong size, IntPtr sharedMemory)
|
||||
{
|
||||
@@ -82,7 +82,7 @@ namespace Ryujinx.Memory
|
||||
/// </summary>
|
||||
/// <returns>A new memory block that shares storage with this one</returns>
|
||||
/// <exception cref="NotSupportedException">Throw when the current memory block does not support mirroring</exception>
|
||||
/// <exception cref="OutOfMemoryException">Throw when there's no enough address space left to map the shared memory</exception>
|
||||
/// <exception cref="SystemException">Throw when there's an error while mapping the shared memory</exception>
|
||||
/// <exception cref="PlatformNotSupportedException">Throw when the current platform is not supported</exception>
|
||||
public MemoryBlock CreateMirror()
|
||||
{
|
||||
|
@@ -147,12 +147,12 @@ namespace Ryujinx.Memory
|
||||
fd = shm_open((IntPtr)pMemName, 0x2 | 0x200 | 0x800 | 0x400, 384); // O_RDWR | O_CREAT | O_EXCL | O_TRUNC, 0600
|
||||
if (fd == -1)
|
||||
{
|
||||
throw new OutOfMemoryException();
|
||||
throw new SystemException(Marshal.GetLastPInvokeErrorMessage());
|
||||
}
|
||||
|
||||
if (shm_unlink((IntPtr)pMemName) != 0)
|
||||
{
|
||||
throw new OutOfMemoryException();
|
||||
throw new SystemException(Marshal.GetLastPInvokeErrorMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,22 +165,22 @@ namespace Ryujinx.Memory
|
||||
fd = mkstemp((IntPtr)pFileName);
|
||||
if (fd == -1)
|
||||
{
|
||||
throw new OutOfMemoryException();
|
||||
throw new SystemException(Marshal.GetLastPInvokeErrorMessage());
|
||||
}
|
||||
|
||||
if (unlink((IntPtr)pFileName) != 0)
|
||||
{
|
||||
throw new OutOfMemoryException();
|
||||
throw new SystemException(Marshal.GetLastPInvokeErrorMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ftruncate(fd, (IntPtr)size) != 0)
|
||||
{
|
||||
throw new OutOfMemoryException();
|
||||
throw new SystemException(Marshal.GetLastPInvokeErrorMessage());
|
||||
}
|
||||
|
||||
return (IntPtr)fd;
|
||||
return fd;
|
||||
}
|
||||
|
||||
public static void DestroySharedMemory(IntPtr handle)
|
||||
|
@@ -114,7 +114,7 @@ namespace Ryujinx.Memory
|
||||
|
||||
if (handle == IntPtr.Zero)
|
||||
{
|
||||
throw new OutOfMemoryException();
|
||||
throw new SystemException(Marshal.GetLastPInvokeErrorMessage());
|
||||
}
|
||||
|
||||
return handle;
|
||||
@@ -134,7 +134,7 @@ namespace Ryujinx.Memory
|
||||
|
||||
if (ptr == IntPtr.Zero)
|
||||
{
|
||||
throw new OutOfMemoryException();
|
||||
throw new SystemException(Marshal.GetLastPInvokeErrorMessage());
|
||||
}
|
||||
|
||||
return ptr;
|
||||
|
@@ -19,10 +19,7 @@ namespace Ryujinx.SDL2.Common
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new SDL2Driver();
|
||||
}
|
||||
_instance ??= new SDL2Driver();
|
||||
|
||||
return _instance;
|
||||
}
|
||||
@@ -43,7 +40,7 @@ namespace Ryujinx.SDL2.Common
|
||||
|
||||
private readonly object _lock = new();
|
||||
|
||||
private SDL2Driver() {}
|
||||
private SDL2Driver() { }
|
||||
|
||||
private const string SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS = "SDL_JOYSTICK_HIDAPI_COMBINE_JOY_CONS";
|
||||
|
||||
@@ -80,8 +77,15 @@ namespace Ryujinx.SDL2.Common
|
||||
}
|
||||
|
||||
// First ensure that we only enable joystick events (for connected/disconnected).
|
||||
SDL_GameControllerEventState(SDL_DISABLE);
|
||||
SDL_JoystickEventState(SDL_ENABLE);
|
||||
if (SDL_GameControllerEventState(SDL_IGNORE) != SDL_IGNORE)
|
||||
{
|
||||
Logger.Error?.PrintMsg(LogClass.Application, "Couldn't change the state of game controller events.");
|
||||
}
|
||||
|
||||
if (SDL_JoystickEventState(SDL_ENABLE) < 0)
|
||||
{
|
||||
Logger.Error?.PrintMsg(LogClass.Application, $"Failed to enable joystick event polling: {SDL_GetError()}");
|
||||
}
|
||||
|
||||
// Disable all joysticks information, we don't need them no need to flood the event queue for that.
|
||||
SDL_EventState(SDL_EventType.SDL_JOYAXISMOTION, SDL_DISABLE);
|
||||
@@ -153,7 +157,7 @@ namespace Ryujinx.SDL2.Common
|
||||
{
|
||||
const int WaitTimeMs = 10;
|
||||
|
||||
using ManualResetEventSlim waitHandle = new ManualResetEventSlim(false);
|
||||
using ManualResetEventSlim waitHandle = new(false);
|
||||
|
||||
while (_isRunning)
|
||||
{
|
||||
@@ -199,6 +203,7 @@ namespace Ryujinx.SDL2.Common
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
Dispose(true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user