Refactoring result codes (#731)

* refactoring result codes

- Add a main enum who can handle some orphalin result codes and the default `ResultCode.Success` one.
- Add sub-enum by services when it's needed.
- Remove some empty line.
- Recast all service calls to ResultCode.
- Remove some unneeded static declaration.
- Delete unused `NvHelper` class.

* NvResult is back

* Fix
This commit is contained in:
Ac_K 2019-07-14 21:04:38 +02:00 committed by gdkchan
parent 4926f6523d
commit 4ad3936afd
147 changed files with 1413 additions and 1477 deletions

View file

@ -1,10 +0,0 @@
namespace Ryujinx.HLE.HOS.Services.Aud
{
static class AudErr
{
public const int DeviceNotFound = 1;
public const int UnsupportedRevision = 2;
public const int UnsupportedSampleRate = 3;
public const int OpusInvalidInput = 6;
}
}

View file

@ -22,41 +22,41 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
[Command(0)]
// GetAudioOutState() -> u32 state
public long GetAudioOutState(ServiceCtx context)
public ResultCode GetAudioOutState(ServiceCtx context)
{
context.ResponseData.Write((int)_audioOut.GetState(_track));
return 0;
return ResultCode.Success;
}
[Command(1)]
// StartAudioOut()
public long StartAudioOut(ServiceCtx context)
public ResultCode StartAudioOut(ServiceCtx context)
{
_audioOut.Start(_track);
return 0;
return ResultCode.Success;
}
[Command(2)]
// StopAudioOut()
public long StopAudioOut(ServiceCtx context)
public ResultCode StopAudioOut(ServiceCtx context)
{
_audioOut.Stop(_track);
return 0;
return ResultCode.Success;
}
[Command(3)]
// AppendAudioOutBuffer(u64 tag, buffer<nn::audio::AudioOutBuffer, 5>)
public long AppendAudioOutBuffer(ServiceCtx context)
public ResultCode AppendAudioOutBuffer(ServiceCtx context)
{
return AppendAudioOutBufferImpl(context, context.Request.SendBuff[0].Position);
}
[Command(4)]
// RegisterBufferEvent() -> handle<copy>
public long RegisterBufferEvent(ServiceCtx context)
public ResultCode RegisterBufferEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_releaseEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
@ -65,12 +65,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
return 0;
return ResultCode.Success;
}
[Command(5)]
// GetReleasedAudioOutBuffer() -> (u32 count, buffer<nn::audio::AudioOutBuffer, 6>)
public long GetReleasedAudioOutBuffer(ServiceCtx context)
public ResultCode GetReleasedAudioOutBuffer(ServiceCtx context)
{
long position = context.Request.ReceiveBuff[0].Position;
long size = context.Request.ReceiveBuff[0].Size;
@ -80,7 +80,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
[Command(6)]
// ContainsAudioOutBuffer(u64 tag) -> b8
public long ContainsAudioOutBuffer(ServiceCtx context)
public ResultCode ContainsAudioOutBuffer(ServiceCtx context)
{
long tag = context.RequestData.ReadInt64();
@ -91,14 +91,14 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
[Command(7)] // 3.0.0+
// AppendAudioOutBufferAuto(u64 tag, buffer<nn::audio::AudioOutBuffer, 0x21>)
public long AppendAudioOutBufferAuto(ServiceCtx context)
public ResultCode AppendAudioOutBufferAuto(ServiceCtx context)
{
(long position, long size) = context.Request.GetBufferType0x21();
return AppendAudioOutBufferImpl(context, position);
}
public long AppendAudioOutBufferImpl(ServiceCtx context, long position)
public ResultCode AppendAudioOutBufferImpl(ServiceCtx context, long position)
{
long tag = context.RequestData.ReadInt64();
@ -112,19 +112,19 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
_audioOut.AppendBuffer(_track, tag, buffer);
return 0;
return ResultCode.Success;
}
[Command(8)] // 3.0.0+
// GetReleasedAudioOutBufferAuto() -> (u32 count, buffer<nn::audio::AudioOutBuffer, 0x22>)
public long GetReleasedAudioOutBufferAuto(ServiceCtx context)
public ResultCode GetReleasedAudioOutBufferAuto(ServiceCtx context)
{
(long position, long size) = context.Request.GetBufferType0x22();
return GetReleasedAudioOutBufferImpl(context, position, size);
}
public long GetReleasedAudioOutBufferImpl(ServiceCtx context, long position, long size)
public ResultCode GetReleasedAudioOutBufferImpl(ServiceCtx context, long position, long size)
{
uint count = (uint)((ulong)size >> 3);
@ -144,7 +144,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
context.ResponseData.Write(releasedBuffers.Length);
return 0;
return ResultCode.Success;
}
public void Dispose()

View file

@ -5,4 +5,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public const int HostSampleRate = 48000;
public const int HostChannelsCount = 2;
}
}
}

View file

@ -13,4 +13,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public short A1;
public short A2;
}
}
}

View file

@ -66,40 +66,40 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
[Command(0)]
// GetSampleRate() -> u32
public long GetSampleRate(ServiceCtx context)
public ResultCode GetSampleRate(ServiceCtx context)
{
context.ResponseData.Write(_params.SampleRate);
return 0;
return ResultCode.Success;
}
[Command(1)]
// GetSampleCount() -> u32
public long GetSampleCount(ServiceCtx context)
public ResultCode GetSampleCount(ServiceCtx context)
{
context.ResponseData.Write(_params.SampleCount);
return 0;
return ResultCode.Success;
}
[Command(2)]
// GetMixBufferCount() -> u32
public long GetMixBufferCount(ServiceCtx context)
public ResultCode GetMixBufferCount(ServiceCtx context)
{
context.ResponseData.Write(_params.MixCount);
return 0;
return ResultCode.Success;
}
[Command(3)]
// GetState() -> u32
private long GetState(ServiceCtx context)
private ResultCode GetState(ServiceCtx context)
{
context.ResponseData.Write((int)_playState);
Logger.PrintStub(LogClass.ServiceAudio, new { State = Enum.GetName(typeof(PlayState), _playState) });
return 0;
return ResultCode.Success;
}
private void AudioCallback()
@ -131,7 +131,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
[Command(4)]
// RequestUpdateAudioRenderer(buffer<nn::audio::detail::AudioRendererUpdateDataHeader, 5>)
// -> (buffer<nn::audio::detail::AudioRendererUpdateDataHeader, 6>, buffer<nn::audio::detail::AudioRendererUpdateDataHeader, 6>)
public long RequestUpdateAudioRenderer(ServiceCtx context)
public ResultCode RequestUpdateAudioRenderer(ServiceCtx context)
{
long outputPosition = context.Request.ReceiveBuff[0].Position;
long outputSize = context.Request.ReceiveBuff[0].Size;
@ -234,34 +234,34 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
writer.Write(voice.OutStatus);
}
return 0;
return ResultCode.Success;
}
[Command(5)]
// Start()
public long StartAudioRenderer(ServiceCtx context)
public ResultCode StartAudioRenderer(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAudio);
_playState = PlayState.Playing;
return 0;
return ResultCode.Success;
}
[Command(6)]
// Stop()
public long StopAudioRenderer(ServiceCtx context)
public ResultCode StopAudioRenderer(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAudio);
_playState = PlayState.Stopped;
return 0;
return ResultCode.Success;
}
[Command(7)]
// QuerySystemEvent() -> handle<copy, event>
public long QuerySystemEvent(ServiceCtx context)
public ResultCode QuerySystemEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_updateEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
@ -270,7 +270,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
return 0;
return ResultCode.Success;
}
private AdpcmDecoderContext GetAdpcmDecoderContext(long position, long size)

View file

@ -9,4 +9,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
OutStatus.State = MemoryPoolState.Detached;
}
}
}
}

View file

@ -11,4 +11,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public int Unknown14;
public long Unknown18;
}
}
}

View file

@ -9,4 +9,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public int Unknown14;
public long Unknown18;
}
}
}

View file

@ -10,4 +10,4 @@
Attached = 5,
Released = 6
}
}
}

View file

@ -6,4 +6,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
Stopped = 1,
Paused = 2
}
}
}

View file

@ -19,4 +19,4 @@
public int Unknown38;
public int TotalSize;
}
}
}

View file

@ -7,4 +7,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
{
// ???
}
}
}

View file

@ -196,4 +196,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
_bufferReload = true;
}
}
}
}

View file

@ -46,4 +46,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public WaveBuffer WaveBuffer2;
public WaveBuffer WaveBuffer3;
}
}
}

View file

@ -9,4 +9,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public int PlayedWaveBuffersCount;
public int VoiceDropsCount; //?
}
}
}

View file

@ -17,4 +17,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
public long AdpcmLoopContextSize;
public long Unknown30;
}
}
}

View file

@ -19,4 +19,4 @@ namespace Ryujinx.HLE.HOS.Services.Aud
public int Unknown2C;
public int Revision;
}
}
}

View file

@ -22,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(0)]
// ListAudioDeviceName() -> (u32, buffer<bytes, 6>)
public long ListAudioDeviceName(ServiceCtx context)
public ResultCode ListAudioDeviceName(ServiceCtx context)
{
string[] deviceNames = SystemStateMgr.AudioOutputs;
@ -49,12 +49,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud
position += buffer.Length;
}
return 0;
return ResultCode.Success;
}
[Command(1)]
// SetAudioDeviceOutputVolume(u32, buffer<bytes, 5>)
public long SetAudioDeviceOutputVolume(ServiceCtx context)
public ResultCode SetAudioDeviceOutputVolume(ServiceCtx context)
{
float volume = context.RequestData.ReadSingle();
@ -67,12 +67,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintStub(LogClass.ServiceAudio);
return 0;
return ResultCode.Success;
}
[Command(3)]
// GetActiveAudioDeviceName() -> buffer<bytes, 6>
public long GetActiveAudioDeviceName(ServiceCtx context)
public ResultCode GetActiveAudioDeviceName(ServiceCtx context)
{
string name = context.Device.System.State.ActiveAudioOutput;
@ -90,12 +90,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {size} too small!");
}
return 0;
return ResultCode.Success;
}
[Command(4)]
// QueryAudioDeviceSystemEvent() -> handle<copy, event>
public long QueryAudioDeviceSystemEvent(ServiceCtx context)
public ResultCode QueryAudioDeviceSystemEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_systemEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
@ -106,23 +106,23 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintStub(LogClass.ServiceAudio);
return 0;
return ResultCode.Success;
}
[Command(5)]
// GetActiveChannelCount() -> u32
public long GetActiveChannelCount(ServiceCtx context)
public ResultCode GetActiveChannelCount(ServiceCtx context)
{
context.ResponseData.Write(2);
Logger.PrintStub(LogClass.ServiceAudio);
return 0;
return ResultCode.Success;
}
[Command(6)]
// ListAudioDeviceNameAuto() -> (u32, buffer<bytes, 0x22>)
public long ListAudioDeviceNameAuto(ServiceCtx context)
public ResultCode ListAudioDeviceNameAuto(ServiceCtx context)
{
string[] deviceNames = SystemStateMgr.AudioOutputs;
@ -148,12 +148,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud
position += buffer.Length;
}
return 0;
return ResultCode.Success;
}
[Command(7)]
// SetAudioDeviceOutputVolumeAuto(u32, buffer<bytes, 0x21>)
public long SetAudioDeviceOutputVolumeAuto(ServiceCtx context)
public ResultCode SetAudioDeviceOutputVolumeAuto(ServiceCtx context)
{
float volume = context.RequestData.ReadSingle();
@ -165,23 +165,23 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintStub(LogClass.ServiceAudio);
return 0;
return ResultCode.Success;
}
[Command(8)]
// GetAudioDeviceOutputVolumeAuto(buffer<bytes, 0x21>) -> u32
public long GetAudioDeviceOutputVolumeAuto(ServiceCtx context)
public ResultCode GetAudioDeviceOutputVolumeAuto(ServiceCtx context)
{
context.ResponseData.Write(1f);
Logger.PrintStub(LogClass.ServiceAudio);
return 0;
return ResultCode.Success;
}
[Command(10)]
// GetActiveAudioDeviceNameAuto() -> buffer<bytes, 0x22>
public long GetActiveAudioDeviceNameAuto(ServiceCtx context)
public ResultCode GetActiveAudioDeviceNameAuto(ServiceCtx context)
{
string name = context.Device.System.State.ActiveAudioOutput;
@ -198,12 +198,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintError(LogClass.ServiceAudio, $"Output buffer size {size} too small!");
}
return 0;
return ResultCode.Success;
}
[Command(11)]
// QueryAudioDeviceInputEvent() -> handle<copy, event>
public long QueryAudioDeviceInputEvent(ServiceCtx context)
public ResultCode QueryAudioDeviceInputEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_systemEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
@ -214,12 +214,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintStub(LogClass.ServiceAudio);
return 0;
return ResultCode.Success;
}
[Command(12)]
// QueryAudioDeviceOutputEvent() -> handle<copy, event>
public long QueryAudioDeviceOutputEvent(ServiceCtx context)
public ResultCode QueryAudioDeviceOutputEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_systemEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
@ -230,7 +230,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintStub(LogClass.ServiceAudio);
return 0;
return ResultCode.Success;
}
}
}

View file

@ -5,8 +5,6 @@ using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.HLE.HOS.Services.Aud.AudioOut;
using System.Text;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Services.Aud
{
[Service("audout:u")]
@ -20,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(0)]
// ListAudioOuts() -> (u32 count, buffer<bytes, 6>)
public long ListAudioOuts(ServiceCtx context)
public ResultCode ListAudioOuts(ServiceCtx context)
{
return ListAudioOutsImpl(
context,
@ -31,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(1)]
// OpenAudioOut(u32 sample_rate, u16 unused, u16 channel_count, nn::applet::AppletResourceUserId, pid, handle<copy, process>, buffer<bytes, 5> name_in)
// -> (u32 sample_rate, u32 channel_count, u32 pcm_format, u32, object<nn::audio::detail::IAudioOut>, buffer<bytes, 6> name_out)
public long OpenAudioOut(ServiceCtx context)
public ResultCode OpenAudioOut(ServiceCtx context)
{
return OpenAudioOutImpl(
context,
@ -43,7 +41,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(2)] // 3.0.0+
// ListAudioOutsAuto() -> (u32 count, buffer<bytes, 0x22>)
public long ListAudioOutsAuto(ServiceCtx context)
public ResultCode ListAudioOutsAuto(ServiceCtx context)
{
(long recvPosition, long recvSize) = context.Request.GetBufferType0x22();
@ -53,7 +51,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(3)] // 3.0.0+
// OpenAudioOutAuto(u32 sample_rate, u16 unused, u16 channel_count, nn::applet::AppletResourceUserId, pid, handle<copy, process>, buffer<bytes, 0x21>)
// -> (u32 sample_rate, u32 channel_count, u32 pcm_format, u32, object<nn::audio::detail::IAudioOut>, buffer<bytes, 0x22> name_out)
public long OpenAudioOutAuto(ServiceCtx context)
public ResultCode OpenAudioOutAuto(ServiceCtx context)
{
(long sendPosition, long sendSize) = context.Request.GetBufferType0x21();
(long recvPosition, long recvSize) = context.Request.GetBufferType0x22();
@ -66,7 +64,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
recvSize);
}
private long ListAudioOutsImpl(ServiceCtx context, long position, long size)
private ResultCode ListAudioOutsImpl(ServiceCtx context, long position, long size)
{
int nameCount = 0;
@ -85,10 +83,10 @@ namespace Ryujinx.HLE.HOS.Services.Aud
context.ResponseData.Write(nameCount);
return 0;
return ResultCode.Success;
}
private long OpenAudioOutImpl(ServiceCtx context, long sendPosition, long sendSize, long receivePosition, long receiveSize)
private ResultCode OpenAudioOutImpl(ServiceCtx context, long sendPosition, long sendSize, long receivePosition, long receiveSize)
{
string deviceName = MemoryHelper.ReadAsciiString(
context.Memory,
@ -104,7 +102,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
{
Logger.PrintWarning(LogClass.Audio, "Invalid device name!");
return MakeError(ErrorModule.Audio, AudErr.DeviceNotFound);
return ResultCode.DeviceNotFound;
}
byte[] deviceNameBuffer = Encoding.ASCII.GetBytes(deviceName + "\0");
@ -130,7 +128,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
{
Logger.PrintWarning(LogClass.Audio, "Invalid sample rate!");
return MakeError(ErrorModule.Audio, AudErr.UnsupportedSampleRate);
return ResultCode.UnsupportedSampleRate;
}
channels = (ushort)channels;
@ -158,7 +156,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
context.ResponseData.Write((int)SampleFormat.PcmInt16);
context.ResponseData.Write((int)PlaybackState.Stopped);
return 0;
return ResultCode.Success;
}
}
}

View file

@ -3,8 +3,6 @@ using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Aud.AudioRenderer;
using Ryujinx.HLE.Utilities;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Services.Aud
{
[Service("audren:u")]
@ -24,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(0)]
// OpenAudioRenderer(nn::audio::detail::AudioRendererParameterInternal, u64, nn::applet::AppletResourceUserId, pid, handle<copy>, handle<copy>)
// -> object<nn::audio::detail::IAudioRenderer>
public long OpenAudioRenderer(ServiceCtx context)
public ResultCode OpenAudioRenderer(ServiceCtx context)
{
IAalOutput audioOut = context.Device.AudioOut;
@ -36,12 +34,12 @@ namespace Ryujinx.HLE.HOS.Services.Aud
audioOut,
Params));
return 0;
return ResultCode.Success;
}
[Command(1)]
// GetWorkBufferSize(nn::audio::detail::AudioRendererParameterInternal) -> u64
public long GetAudioRendererWorkBufferSize(ServiceCtx context)
public ResultCode GetAudioRendererWorkBufferSize(ServiceCtx context)
{
AudioRendererParameter Params = GetAudioRendererParameter(context);
@ -111,7 +109,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintDebug(LogClass.ServiceAudio, $"WorkBufferSize is 0x{size:x16}.");
return 0;
return ResultCode.Success;
}
else
{
@ -119,7 +117,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
Logger.PrintWarning(LogClass.ServiceAudio, $"Library Revision 0x{Params.Revision:x8} is not supported!");
return MakeError(ErrorModule.Audio, AudErr.UnsupportedRevision);
return ResultCode.UnsupportedRevision;
}
}
@ -170,18 +168,18 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(2)]
// GetAudioDeviceService(nn::applet::AppletResourceUserId) -> object<nn::audio::detail::IAudioDevice>
public long GetAudioDeviceService(ServiceCtx context)
public ResultCode GetAudioDeviceService(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
MakeObject(context, new IAudioDevice(context.Device.System));
return 0;
return ResultCode.Success;
}
[Command(4)] // 4.0.0+
// GetAudioDeviceServiceWithRevisionInfo(nn::applet::AppletResourceUserId, u32) -> object<nn::audio::detail::IAudioDevice>
private long GetAudioDeviceServiceWithRevisionInfo(ServiceCtx context)
private ResultCode GetAudioDeviceServiceWithRevisionInfo(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
int revisionInfo = context.RequestData.ReadInt32();

View file

@ -1,7 +1,5 @@
using Concentus.Structs;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Services.Aud
{
class IHardwareOpusDecoder : IpcService
@ -23,14 +21,14 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(0)]
// DecodeInterleaved(buffer<unknown, 5>) -> (u32, u32, buffer<unknown, 6>)
public long DecodeInterleaved(ServiceCtx context)
public ResultCode DecodeInterleaved(ServiceCtx context)
{
long inPosition = context.Request.SendBuff[0].Position;
long inSize = context.Request.SendBuff[0].Size;
if (inSize < 8)
{
return MakeError(ErrorModule.Audio, AudErr.OpusInvalidInput);
return ResultCode.OpusInvalidInput;
}
long outPosition = context.Request.ReceiveBuff[0].Position;
@ -45,7 +43,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
if ((uint)processed > (ulong)inSize)
{
return MakeError(ErrorModule.Audio, AudErr.OpusInvalidInput);
return ResultCode.OpusInvalidInput;
}
short[] pcm = new short[outSize / 2];
@ -64,14 +62,14 @@ namespace Ryujinx.HLE.HOS.Services.Aud
context.ResponseData.Write(processed);
context.ResponseData.Write(samples);
return 0;
return ResultCode.Success;
}
[Command(4)]
// DecodeInterleavedWithPerf(buffer<unknown, 5>) -> (u32, u32, u64, buffer<unknown, 0x46>)
public long DecodeInterleavedWithPerf(ServiceCtx context)
public ResultCode DecodeInterleavedWithPerf(ServiceCtx context)
{
long result = DecodeInterleaved(context);
ResultCode result = DecodeInterleaved(context);
// TODO: Figure out what this value is.
// According to switchbrew, it is now used.

View file

@ -7,19 +7,19 @@ namespace Ryujinx.HLE.HOS.Services.Aud
[Command(0)]
// Initialize(bytes<8, 4>, u32, handle<copy>) -> object<nn::codec::detail::IHardwareOpusDecoder>
public long Initialize(ServiceCtx context)
public ResultCode Initialize(ServiceCtx context)
{
int sampleRate = context.RequestData.ReadInt32();
int channelsCount = context.RequestData.ReadInt32();
MakeObject(context, new IHardwareOpusDecoder(sampleRate, channelsCount));
return 0;
return ResultCode.Success;
}
[Command(1)]
// GetWorkBufferSize(bytes<8, 4>) -> u32
public long GetWorkBufferSize(ServiceCtx context)
public ResultCode GetWorkBufferSize(ServiceCtx context)
{
// Note: The sample rate is ignored because it is fixed to 48KHz.
int sampleRate = context.RequestData.ReadInt32();
@ -27,7 +27,7 @@ namespace Ryujinx.HLE.HOS.Services.Aud
context.ResponseData.Write(GetOpusDecoderSize(channelsCount));
return 0;
return ResultCode.Success;
}
private static int GetOpusDecoderSize(int channelsCount)

View file

@ -0,0 +1,15 @@
namespace Ryujinx.HLE.HOS.Services.Aud
{
enum ResultCode
{
ModuleId = 153,
ErrorCodeShift = 9,
Success = 0,
DeviceNotFound = (1 << ErrorCodeShift) | ModuleId,
UnsupportedRevision = (2 << ErrorCodeShift) | ModuleId,
UnsupportedSampleRate = (3 << ErrorCodeShift) | ModuleId,
OpusInvalidInput = (6 << ErrorCodeShift) | ModuleId
}
}