From 8917ab42c5b54274e8f175460b9e0c75cf7250b9 Mon Sep 17 00:00:00 2001 From: jduncanator Date: Mon, 18 Nov 2019 14:32:15 +1100 Subject: [PATCH] am: Return IStorage not available when queue is empty We should be returning the appropriate error code when the FIFO is empty, rather than just throwing an exception and killing the emulator. --- .../SoftwareKeyboardApplet.cs | 2 +- .../ILibraryAppletAccessor.cs | 22 ++++++++++++------- Ryujinx.HLE/HOS/Services/Am/ResultCode.cs | 1 + 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs index 5d7b1e05c6..947a370037 100644 --- a/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs +++ b/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs @@ -71,7 +71,7 @@ namespace Ryujinx.HLE.HOS.Applets } // If our default text is longer than the allowed length, - // we trunacte it. + // we truncate it. if (_textValue.Length > _keyboardConfig.StringLengthMax) { _textValue = _textValue.Substring(0, (int)_keyboardConfig.StringLengthMax); diff --git a/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs b/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs index 50008783fc..fe64a50c37 100644 --- a/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs +++ b/Ryujinx.HLE/HOS/Services/Am/AppletAE/AllSystemAppletProxiesService/LibraryAppletCreator/ILibraryAppletAccessor.cs @@ -95,13 +95,16 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib // PopOutData() -> object public ResultCode PopOutData(ServiceCtx context) { - byte[] data = _normalSession.Pop(); + if(_normalSession.TryPop(out byte[] data)) + { + MakeObject(context, new IStorage(data)); - MakeObject(context, new IStorage(data)); + _normalOutDataEvent.WritableEvent.Clear(); - _normalOutDataEvent.WritableEvent.Clear(); + return ResultCode.Success; + } - return ResultCode.Success; + return ResultCode.NotAvailble; } [Command(103)] @@ -119,13 +122,16 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Lib // PopInteractiveOutData() -> object public ResultCode PopInteractiveOutData(ServiceCtx context) { - byte[] data = _interactiveSession.Pop(); + if(_interactiveSession.TryPop(out byte[] data)) + { + MakeObject(context, new IStorage(data)); - MakeObject(context, new IStorage(data)); + _interactiveOutDataEvent.WritableEvent.Clear(); - _interactiveOutDataEvent.WritableEvent.Clear(); + return ResultCode.Success; + } - return ResultCode.Success; + return ResultCode.NotAvailble; } [Command(105)] diff --git a/Ryujinx.HLE/HOS/Services/Am/ResultCode.cs b/Ryujinx.HLE/HOS/Services/Am/ResultCode.cs index de83ab3995..2d2b873105 100644 --- a/Ryujinx.HLE/HOS/Services/Am/ResultCode.cs +++ b/Ryujinx.HLE/HOS/Services/Am/ResultCode.cs @@ -7,6 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Am Success = 0, + NotAvailble = (2 << ErrorCodeShift) | ModuleId, NoMessages = (3 << ErrorCodeShift) | ModuleId, ObjectInvalid = (500 << ErrorCodeShift) | ModuleId, OutOfBounds = (503 << ErrorCodeShift) | ModuleId,