From 4397049c6ae40c739d4c1d0d1eb262ba212fb0e4 Mon Sep 17 00:00:00 2001 From: greggameplayer <33609333+greggameplayer@users.noreply.github.com> Date: Fri, 15 Jun 2018 17:24:02 +0200 Subject: [PATCH 1/3] Implement ListAudioOutsAuto & OpenAudioOutAuto --- .../OsHle/Services/Aud/IAudioOutManager.cs | 118 ++++++++++++++---- 1 file changed, 91 insertions(+), 27 deletions(-) diff --git a/Ryujinx.HLE/OsHle/Services/Aud/IAudioOutManager.cs b/Ryujinx.HLE/OsHle/Services/Aud/IAudioOutManager.cs index a6b30835a1..5ca399f678 100644 --- a/Ryujinx.HLE/OsHle/Services/Aud/IAudioOutManager.cs +++ b/Ryujinx.HLE/OsHle/Services/Aud/IAudioOutManager.cs @@ -20,32 +20,16 @@ namespace Ryujinx.HLE.OsHle.Services.Aud { m_Commands = new Dictionary() { - { 0, ListAudioOuts }, - { 1, OpenAudioOut } + { 0, ListAudioOuts }, + { 1, OpenAudioOut }, + { 2, ListAudioOutsAuto }, + { 3, OpenAudioOutAuto } }; } public long ListAudioOuts(ServiceCtx Context) - { - long Position = Context.Request.ReceiveBuff[0].Position; - long Size = Context.Request.ReceiveBuff[0].Size; - - int NameCount = 0; - - byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DefaultAudioOutput + "\0"); - - if ((ulong)DeviceNameBuffer.Length <= (ulong)Size) - { - Context.Memory.WriteBytes(Position, DeviceNameBuffer); - - NameCount++; - } - else - { - Context.Ns.Log.PrintError(LogClass.ServiceAudio, $"Output buffer size {Size} too small!"); - } - - Context.ResponseData.Write(NameCount); + { + ListAudioOutsMethod(Context, Context.Request.ReceiveBuff[0].Position, Context.Request.ReceiveBuff[0].Size); return 0; } @@ -53,12 +37,13 @@ namespace Ryujinx.HLE.OsHle.Services.Aud public long OpenAudioOut(ServiceCtx Context) { IAalOutput AudioOut = Context.Ns.AudioOut; - + string DeviceName = AMemoryHelper.ReadAsciiString( Context.Memory, Context.Request.SendBuff[0].Position, - Context.Request.SendBuff[0].Size); - + Context.Request.SendBuff[0].Size + ); + if (DeviceName == string.Empty) { DeviceName = DefaultAudioOutput; @@ -76,7 +61,8 @@ namespace Ryujinx.HLE.OsHle.Services.Aud else { Context.Ns.Log.PrintError(LogClass.ServiceAudio, $"Output buffer size {Size} too small!"); - } + } + int SampleRate = Context.RequestData.ReadInt32(); int Channels = Context.RequestData.ReadInt32(); @@ -111,5 +97,83 @@ namespace Ryujinx.HLE.OsHle.Services.Aud return 0; } + + public long ListAudioOutsAuto(ServiceCtx Context) + { + ListAudioOutsMethod(Context, Context.Request.GetBufferType0x22().Position, Context.Request.GetBufferType0x22().Size); + + return 0; + } + + public long OpenAudioOutAuto(ServiceCtx Context) + { + IAalOutput AudioOut = Context.Ns.AudioOut; + + string DeviceName = AMemoryHelper.ReadAsciiString( + Context.Memory, + Context.Request.GetBufferType0x21().Position, + Context.Request.GetBufferType0x21().Size + ); + + if (DeviceName == string.Empty) + { + DeviceName = DefaultAudioOutput; + } + + long Position = Context.Request.GetBufferType0x22().Position; + long Size = Context.Request.GetBufferType0x22().Size; + + byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DeviceName + "\0"); + + if ((ulong)DeviceNameBuffer.Length <= (ulong)Size) + { + Context.Memory.WriteBytes(Position, DeviceNameBuffer); + } + else + { + Context.Ns.Log.PrintError(LogClass.ServiceAudio, $"Output buffer size {Size} too small!"); + } + + int AudioParams1 = Context.RequestData.ReadInt32(); + int AudioParams2 = Context.RequestData.ReadInt32(); + int AudioParams3 = Context.RequestData.ReadInt32(); + int AudioParams4 = Context.RequestData.ReadInt32(); + + KEvent ReleaseEvent = new KEvent(); + + ReleaseCallback Callback = () => + { + ReleaseEvent.WaitEvent.Set(); + }; + + //TODO: add makeobject (object currently unknown) + + Context.ResponseData.Write(AudioParams1); + Context.ResponseData.Write(AudioParams2); + + return 0; + } + + public long ListAudioOutsMethod(ServiceCtx Context, long Position, long Size) + { + int NameCount = 0; + + byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DefaultAudioOutput + "\0"); + + if ((ulong)DeviceNameBuffer.Length <= (ulong)Size) + { + Context.Memory.WriteBytes(Position, DeviceNameBuffer); + + NameCount++; + } + else + { + Context.Ns.Log.PrintError(LogClass.ServiceAudio, $"Output buffer size {Size} too small!"); + } + + Context.ResponseData.Write(NameCount); + + return 0; + } } -} \ No newline at end of file +} From e40db09bed7fa670c66c15fef1e7a29a82234afc Mon Sep 17 00:00:00 2001 From: greggameplayer <33609333+greggameplayer@users.noreply.github.com> Date: Fri, 15 Jun 2018 17:41:07 +0200 Subject: [PATCH 2/3] add a new Method for OpenAudioOut & OpenAudioOutAuto --- .../OsHle/Services/Aud/IAudioOutManager.cs | 136 +++++++----------- 1 file changed, 50 insertions(+), 86 deletions(-) diff --git a/Ryujinx.HLE/OsHle/Services/Aud/IAudioOutManager.cs b/Ryujinx.HLE/OsHle/Services/Aud/IAudioOutManager.cs index 5ca399f678..cb1cf63be7 100644 --- a/Ryujinx.HLE/OsHle/Services/Aud/IAudioOutManager.cs +++ b/Ryujinx.HLE/OsHle/Services/Aud/IAudioOutManager.cs @@ -35,13 +35,58 @@ namespace Ryujinx.HLE.OsHle.Services.Aud } public long OpenAudioOut(ServiceCtx Context) + { + OpenAudioOutMethod(Context, Context.Request.SendBuff[0].Position, Context.Request.SendBuff[0].Size, + Context.Request.ReceiveBuff[0].Position, Context.Request.ReceiveBuff[0].Size); + + return 0; + } + + public long ListAudioOutsAuto(ServiceCtx Context) + { + ListAudioOutsMethod(Context, Context.Request.GetBufferType0x22().Position, Context.Request.GetBufferType0x22().Size); + + return 0; + } + + public long OpenAudioOutAuto(ServiceCtx Context) + { + OpenAudioOutMethod(Context, Context.Request.GetBufferType0x21().Position, Context.Request.GetBufferType0x21().Size, + Context.Request.GetBufferType0x22().Position, Context.Request.GetBufferType0x22().Size); + + return 0; + } + + public long ListAudioOutsMethod(ServiceCtx Context, long Position, long Size) + { + int NameCount = 0; + + byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DefaultAudioOutput + "\0"); + + if ((ulong)DeviceNameBuffer.Length <= (ulong)Size) + { + Context.Memory.WriteBytes(Position, DeviceNameBuffer); + + NameCount++; + } + else + { + Context.Ns.Log.PrintError(LogClass.ServiceAudio, $"Output buffer size {Size} too small!"); + } + + Context.ResponseData.Write(NameCount); + + return 0; + } + + public long OpenAudioOutMethod(ServiceCtx Context, long SendPosition, long SendSize, long ReceivePosition, long ReceiveSize) { IAalOutput AudioOut = Context.Ns.AudioOut; string DeviceName = AMemoryHelper.ReadAsciiString( Context.Memory, - Context.Request.SendBuff[0].Position, - Context.Request.SendBuff[0].Size + SendPosition, + SendSize ); if (DeviceName == string.Empty) @@ -49,18 +94,15 @@ namespace Ryujinx.HLE.OsHle.Services.Aud DeviceName = DefaultAudioOutput; } - long Position = Context.Request.ReceiveBuff[0].Position; - long Size = Context.Request.ReceiveBuff[0].Size; - byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DeviceName + "\0"); - if ((ulong)DeviceNameBuffer.Length <= (ulong)Size) + if ((ulong)DeviceNameBuffer.Length <= (ulong)ReceiveSize) { - Context.Memory.WriteBytes(Position, DeviceNameBuffer); + Context.Memory.WriteBytes(ReceivePosition, DeviceNameBuffer); } else { - Context.Ns.Log.PrintError(LogClass.ServiceAudio, $"Output buffer size {Size} too small!"); + Context.Ns.Log.PrintError(LogClass.ServiceAudio, $"Output buffer size {ReceiveSize} too small!"); } @@ -97,83 +139,5 @@ namespace Ryujinx.HLE.OsHle.Services.Aud return 0; } - - public long ListAudioOutsAuto(ServiceCtx Context) - { - ListAudioOutsMethod(Context, Context.Request.GetBufferType0x22().Position, Context.Request.GetBufferType0x22().Size); - - return 0; - } - - public long OpenAudioOutAuto(ServiceCtx Context) - { - IAalOutput AudioOut = Context.Ns.AudioOut; - - string DeviceName = AMemoryHelper.ReadAsciiString( - Context.Memory, - Context.Request.GetBufferType0x21().Position, - Context.Request.GetBufferType0x21().Size - ); - - if (DeviceName == string.Empty) - { - DeviceName = DefaultAudioOutput; - } - - long Position = Context.Request.GetBufferType0x22().Position; - long Size = Context.Request.GetBufferType0x22().Size; - - byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DeviceName + "\0"); - - if ((ulong)DeviceNameBuffer.Length <= (ulong)Size) - { - Context.Memory.WriteBytes(Position, DeviceNameBuffer); - } - else - { - Context.Ns.Log.PrintError(LogClass.ServiceAudio, $"Output buffer size {Size} too small!"); - } - - int AudioParams1 = Context.RequestData.ReadInt32(); - int AudioParams2 = Context.RequestData.ReadInt32(); - int AudioParams3 = Context.RequestData.ReadInt32(); - int AudioParams4 = Context.RequestData.ReadInt32(); - - KEvent ReleaseEvent = new KEvent(); - - ReleaseCallback Callback = () => - { - ReleaseEvent.WaitEvent.Set(); - }; - - //TODO: add makeobject (object currently unknown) - - Context.ResponseData.Write(AudioParams1); - Context.ResponseData.Write(AudioParams2); - - return 0; - } - - public long ListAudioOutsMethod(ServiceCtx Context, long Position, long Size) - { - int NameCount = 0; - - byte[] DeviceNameBuffer = Encoding.ASCII.GetBytes(DefaultAudioOutput + "\0"); - - if ((ulong)DeviceNameBuffer.Length <= (ulong)Size) - { - Context.Memory.WriteBytes(Position, DeviceNameBuffer); - - NameCount++; - } - else - { - Context.Ns.Log.PrintError(LogClass.ServiceAudio, $"Output buffer size {Size} too small!"); - } - - Context.ResponseData.Write(NameCount); - - return 0; - } } } From 5a3449f5d933a4d8f9c214ca910e830b563fae8d Mon Sep 17 00:00:00 2001 From: greggameplayer <33609333+greggameplayer@users.noreply.github.com> Date: Fri, 15 Jun 2018 17:54:18 +0200 Subject: [PATCH 3/3] delete mixed tabs & spaces & use void for methods --- .../OsHle/Services/Aud/IAudioOutManager.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Ryujinx.HLE/OsHle/Services/Aud/IAudioOutManager.cs b/Ryujinx.HLE/OsHle/Services/Aud/IAudioOutManager.cs index cb1cf63be7..18aedb32cc 100644 --- a/Ryujinx.HLE/OsHle/Services/Aud/IAudioOutManager.cs +++ b/Ryujinx.HLE/OsHle/Services/Aud/IAudioOutManager.cs @@ -23,7 +23,7 @@ namespace Ryujinx.HLE.OsHle.Services.Aud { 0, ListAudioOuts }, { 1, OpenAudioOut }, { 2, ListAudioOutsAuto }, - { 3, OpenAudioOutAuto } + { 3, OpenAudioOutAuto } }; } @@ -57,7 +57,7 @@ namespace Ryujinx.HLE.OsHle.Services.Aud return 0; } - public long ListAudioOutsMethod(ServiceCtx Context, long Position, long Size) + public void ListAudioOutsMethod(ServiceCtx Context, long Position, long Size) { int NameCount = 0; @@ -75,19 +75,17 @@ namespace Ryujinx.HLE.OsHle.Services.Aud } Context.ResponseData.Write(NameCount); - - return 0; } - public long OpenAudioOutMethod(ServiceCtx Context, long SendPosition, long SendSize, long ReceivePosition, long ReceiveSize) + public void OpenAudioOutMethod(ServiceCtx Context, long SendPosition, long SendSize, long ReceivePosition, long ReceiveSize) { IAalOutput AudioOut = Context.Ns.AudioOut; string DeviceName = AMemoryHelper.ReadAsciiString( Context.Memory, SendPosition, - SendSize - ); + SendSize + ); if (DeviceName == string.Empty) { @@ -103,8 +101,7 @@ namespace Ryujinx.HLE.OsHle.Services.Aud else { Context.Ns.Log.PrintError(LogClass.ServiceAudio, $"Output buffer size {ReceiveSize} too small!"); - } - + } int SampleRate = Context.RequestData.ReadInt32(); int Channels = Context.RequestData.ReadInt32(); @@ -136,8 +133,6 @@ namespace Ryujinx.HLE.OsHle.Services.Aud Context.ResponseData.Write(Channels); Context.ResponseData.Write((int)Format); Context.ResponseData.Write((int)PlaybackState.Stopped); - - return 0; } } }