diff --git a/Ryujinx.HLE/OsHle/Services/Aud/IAudioRenderer.cs b/Ryujinx.HLE/OsHle/Services/Aud/IAudioRenderer.cs index ccaec8b837..36e2f9a4a2 100644 --- a/Ryujinx.HLE/OsHle/Services/Aud/IAudioRenderer.cs +++ b/Ryujinx.HLE/OsHle/Services/Aud/IAudioRenderer.cs @@ -30,29 +30,19 @@ namespace Ryujinx.HLE.OsHle.Services.Aud }; UpdateEvent = new KEvent(); + this.WorkerParams = WorkerParams; } public long RequestUpdateAudioRenderer(ServiceCtx Context) { - //(buffer) -> (buffer, buffer) - long OutputPosition = Context.Request.GetBufferType0x22().Position; long InputPosition = Context.Request.GetBufferType0x21().Position; AudioRendererConfig InputRequest = AMemoryHelper.Read(Context.Memory, InputPosition); - int MemoryPoolCount = WorkerParams.EffectCount + (WorkerParams.VoiceCount * 4); - int MemoryPoolOffset = Marshal.SizeOf(InputRequest) + InputRequest.BehaviourSize; - MemoryPoolInfo[] PoolInfo = new MemoryPoolInfo[MemoryPoolCount]; - - for (int Index = 0; Index < MemoryPoolCount; Index++) - { - PoolInfo[Index] = AMemoryHelper.Read(Context.Memory, InputPosition + MemoryPoolOffset + Index * 0x20); - } - GCHandle Handle = GCHandle.Alloc(WorkerParams, GCHandleType.Pinned); AudioRendererResponse OutputResponse = (AudioRendererResponse)Marshal.PtrToStructure(Handle.AddrOfPinnedObject(), typeof(AudioRendererResponse)); @@ -69,44 +59,35 @@ namespace Ryujinx.HLE.OsHle.Services.Aud OutputResponse.TotalSize = Marshal.SizeOf(OutputResponse) + OutputResponse.ErrorInfoSize + OutputResponse.MemoryPoolsSize + OutputResponse.VoicesSize + OutputResponse.EffectsSize + OutputResponse.SinksSize + OutputResponse.PerformanceManagerSize; - Context.Ns.Log.PrintInfo(LogClass.ServiceAudio, $"TotalSize: {OutputResponse.TotalSize}"); - Context.Ns.Log.PrintInfo(LogClass.ServiceAudio, $"MemoryPoolsSize: {OutputResponse.MemoryPoolsSize}"); - Context.Ns.Log.PrintInfo(LogClass.ServiceAudio, $"VoicesSize: {OutputResponse.VoicesSize}"); - Context.Ns.Log.PrintInfo(LogClass.ServiceAudio, $"EffectsSize: {OutputResponse.EffectsSize}"); - Context.Ns.Log.PrintInfo(LogClass.ServiceAudio, $"SinksSize: {OutputResponse.SinksSize}"); - Context.Ns.Log.PrintInfo(LogClass.ServiceAudio, $"MemoryPoolCount: {MemoryPoolCount}"); + Context.Memory.WriteInt32(OutputPosition + 0x4, OutputResponse.ErrorInfoSize); + Context.Memory.WriteInt32(OutputPosition + 0x8, OutputResponse.MemoryPoolsSize); + Context.Memory.WriteInt32(OutputPosition + 0xc, OutputResponse.VoicesSize); + Context.Memory.WriteInt32(OutputPosition + 0x14, OutputResponse.EffectsSize); + Context.Memory.WriteInt32(OutputPosition + 0x1c, OutputResponse.SinksSize); + Context.Memory.WriteInt32(OutputPosition + 0x20, OutputResponse.PerformanceManagerSize); + Context.Memory.WriteInt32(OutputPosition + 0x3c, OutputResponse.TotalSize - 4); - MemoryPoolEntry[] PoolEntry = new MemoryPoolEntry[MemoryPoolCount]; - - for (int Index = 0; Index < PoolEntry.Length; Index++) + for (int Offset = 0x40; Offset < 0x40 + OutputResponse.MemoryPoolsSize; Offset += 0x10, MemoryPoolOffset += 0x20) { - if (PoolInfo[Index].PoolState == (int)MemoryPoolStates.MPS_RequestAttach) - PoolEntry[Index].State = (int)MemoryPoolStates.MPS_RequestAttach; - else if (PoolInfo[Index].PoolState == (int)MemoryPoolStates.MPS_RequestDetatch) - PoolEntry[Index].State = (int)MemoryPoolStates.MPS_Detatched; + int PoolState = Context.Memory.ReadInt32(InputPosition + MemoryPoolOffset + 0xC); + + if (PoolState == 4) + { + Context.Memory.WriteInt32(OutputPosition + Offset, 5); + } + else if (PoolState == 2) + { + Context.Memory.WriteInt32(OutputPosition + Offset, 3); + } else - PoolEntry[Index].State = PoolInfo[Index].PoolState; - } - - //0x40 bytes header - Context.Memory.WriteInt32(OutputPosition + 0x4, OutputResponse.ErrorInfoSize); //Behavior Out State Size? (note: this is the last section) - Context.Memory.WriteInt32(OutputPosition + 0x8, OutputResponse.MemoryPoolsSize); //Memory Pool Out State Size? - Context.Memory.WriteInt32(OutputPosition + 0xc, OutputResponse.VoicesSize); //Voice Out State Size? - Context.Memory.WriteInt32(OutputPosition + 0x14, OutputResponse.EffectsSize); //Effect Out State Size? - Context.Memory.WriteInt32(OutputPosition + 0x1c, OutputResponse.SinksSize); //Sink Out State Size? - Context.Memory.WriteInt32(OutputPosition + 0x20, OutputResponse.PerformanceManagerSize); //Performance Out State Size? - Context.Memory.WriteInt32(OutputPosition + 0x3c, OutputResponse.TotalSize); //Total Size (including 0x40 bytes header) - - for (int Offset = 0x40; Offset < 0x40 + OutputResponse.MemoryPoolsSize; Offset += 0x10) - { - Context.Memory.WriteInt32(OutputPosition + Offset, 5); + { + Context.Memory.WriteInt32(OutputPosition + Offset, PoolState); + } } //TODO: We shouldn't be signaling this here. UpdateEvent.WaitEvent.Set(); - Context.Ns.Log.PrintStub(LogClass.ServiceAudio, "Stubbed."); - return 0; } diff --git a/Ryujinx.HLE/OsHle/Services/Aud/MemoryPoolEntry.cs b/Ryujinx.HLE/OsHle/Services/Aud/MemoryPoolEntry.cs deleted file mode 100644 index 05b91cac72..0000000000 --- a/Ryujinx.HLE/OsHle/Services/Aud/MemoryPoolEntry.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Ryujinx.HLE.OsHle.Services.Aud -{ - struct MemoryPoolEntry - { - public int State; - public int Unk4; - public int Unk8; - public int UnkC; - } -} diff --git a/Ryujinx.HLE/OsHle/Services/Aud/MemoryPoolInfo.cs b/Ryujinx.HLE/OsHle/Services/Aud/MemoryPoolInfo.cs deleted file mode 100644 index 2d808439e6..0000000000 --- a/Ryujinx.HLE/OsHle/Services/Aud/MemoryPoolInfo.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Ryujinx.HLE.OsHle.Services.Aud -{ - struct MemoryPoolInfo - { - public long PoolAddress; - public long PoolSize; - public int PoolState; - public int Unknown0; - public int Unknown1; - public int Unknown2; - } -} diff --git a/Ryujinx.HLE/OsHle/Services/Aud/MemoryPoolStates.cs b/Ryujinx.HLE/OsHle/Services/Aud/MemoryPoolStates.cs deleted file mode 100644 index 4b7ca2b983..0000000000 --- a/Ryujinx.HLE/OsHle/Services/Aud/MemoryPoolStates.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Ryujinx.HLE.OsHle.Services.Aud -{ - enum MemoryPoolStates : int - { - MPS_Invalid = 0x0, - MPS_Unknown = 0x1, - MPS_RequestDetatch = 0x2, - MPS_Detatched = 0x3, - MPS_RequestAttach = 0x4, - MPS_Attached = 0x5, - MPS_Released = 0x6 - } -}