diff --git a/Ryujinx.Audio/OpenAL/OpenALAudioOut.cs b/Ryujinx.Audio/OpenAL/OpenALAudioOut.cs index 3ddf001d02..b82b653153 100644 --- a/Ryujinx.Audio/OpenAL/OpenALAudioOut.cs +++ b/Ryujinx.Audio/OpenAL/OpenALAudioOut.cs @@ -24,8 +24,7 @@ namespace Ryujinx.Audio.OpenAL private ConcurrentDictionary Buffers; - private HashSet QueuedTagsHash; - private Queue QueuedTagsQueue; + private Queue QueuedTagsQueue; private bool Disposed; @@ -40,7 +39,6 @@ namespace Ryujinx.Audio.OpenAL Buffers = new ConcurrentDictionary(); - QueuedTagsHash = new HashSet(); QueuedTagsQueue = new Queue(); } @@ -60,7 +58,6 @@ namespace Ryujinx.Audio.OpenAL return Id; }); - QueuedTagsHash.Add(Tag); QueuedTagsQueue.Enqueue(Tag); return Id; @@ -68,15 +65,13 @@ namespace Ryujinx.Audio.OpenAL public long[] GetReleasedBuffers() { - SyncQueuedTags(); - - ClearQueue(); + ClearReleased(); List Tags = new List(); foreach (long Tag in Buffers.Keys) { - if (!QueuedTagsHash.Contains(Tag)) + if (!ContainsBuffer(Tag)) { Tags.Add(Tag); } @@ -85,15 +80,10 @@ namespace Ryujinx.Audio.OpenAL return Tags.ToArray(); } - public bool ContainsBuffer(long Tag) + public void ClearReleased() { SyncQueuedTags(); - return QueuedTagsHash.Contains(Tag); - } - - public void ClearQueue() - { AL.GetSource(SourceId, ALGetSourcei.BuffersProcessed, out int ReleasedCount); if (ReleasedCount > 0) @@ -102,6 +92,21 @@ namespace Ryujinx.Audio.OpenAL } } + public bool ContainsBuffer(long Tag) + { + SyncQueuedTags(); + + foreach (long QueuedTag in QueuedTagsQueue) + { + if (QueuedTag == Tag) + { + return true; + } + } + + return false; + } + private void SyncQueuedTags() { AL.GetSource(SourceId, ALGetSourcei.BuffersQueued, out int QueuedCount); @@ -111,7 +116,7 @@ namespace Ryujinx.Audio.OpenAL while (QueuedTagsQueue.Count > QueuedCount) { - QueuedTagsHash.Remove(QueuedTagsQueue.Dequeue()); + QueuedTagsQueue.Dequeue(); } } @@ -205,8 +210,6 @@ namespace Ryujinx.Audio.OpenAL AL.BufferData(BufferId, Td.Format, Buffer, Buffer.Length, Td.SampleRate); - Td.ClearQueue(); - AL.SourceQueueBuffer(Td.SourceId, BufferId); StartPlaybackIfNeeded(Td); @@ -246,16 +249,16 @@ namespace Ryujinx.Audio.OpenAL private void StartPlaybackIfNeeded(Track Td) { AL.GetSource(Td.SourceId, ALGetSourcei.SourceState, out int StateInt); - + ALSourceState State = (ALSourceState)StateInt; if (State != ALSourceState.Playing && Td.State == PlaybackState.Playing) { - Td.ClearQueue(); + Td.ClearReleased(); AL.SourcePlay(Td.SourceId); } - } + } public void Stop(int Track) { diff --git a/Ryujinx.Core/OsHle/Services/Aud/IAudioOut.cs b/Ryujinx.Core/OsHle/Services/Aud/IAudioOut.cs index ef95f7f008..39d712cd32 100644 --- a/Ryujinx.Core/OsHle/Services/Aud/IAudioOut.cs +++ b/Ryujinx.Core/OsHle/Services/Aud/IAudioOut.cs @@ -87,14 +87,22 @@ namespace Ryujinx.Core.OsHle.IpcServices.Aud public long GetReleasedAudioOutBuffer(ServiceCtx Context) { long Position = Context.Request.ReceiveBuff[0].Position; + long Size = Context.Request.ReceiveBuff[0].Size; + + int Count = (int)(Size >> 3); long[] ReleasedBuffers = AudioOut.GetReleasedBuffers(Track); - foreach (long Tag in ReleasedBuffers) + for (int Index = 0; Index < Count; Index++) { - Context.Memory.WriteInt64(Position, Tag); + long Tag = 0; - Position += 8; + if (Index < ReleasedBuffers.Length) + { + Tag = ReleasedBuffers[Index]; + } + + Context.Memory.WriteInt64(Position + Index * 8, Tag); } Context.ResponseData.Write(ReleasedBuffers.Length); diff --git a/Ryujinx.Core/Settings/SetSys.cs b/Ryujinx.Core/Settings/SystemSettings.cs similarity index 72% rename from Ryujinx.Core/Settings/SetSys.cs rename to Ryujinx.Core/Settings/SystemSettings.cs index d8b6eb6ef5..0f56ef3ae3 100644 --- a/Ryujinx.Core/Settings/SetSys.cs +++ b/Ryujinx.Core/Settings/SystemSettings.cs @@ -1,6 +1,6 @@ namespace Ryujinx.Core.Settings { - public class SetSys + public class SystemSettings { public ColorSet ThemeColor; } diff --git a/Ryujinx.Core/Switch.cs b/Ryujinx.Core/Switch.cs index 8ccde42328..92d78f4536 100644 --- a/Ryujinx.Core/Switch.cs +++ b/Ryujinx.Core/Switch.cs @@ -11,14 +11,19 @@ namespace Ryujinx.Core public class Switch : IDisposable { internal IAalOutput AudioOut { get; private set; } - internal NsGpu Gpu { get; private set; } - internal Horizon Os { get; private set; } - internal VirtualFs VFs { get; private set; } - public Hid Hid { get; private set; } - public SetSys Settings { get; private set; } + internal NsGpu Gpu { get; private set; } + + internal Horizon Os { get; private set; } + + internal VirtualFileSystem VFs { get; private set; } + + public SystemSettings Settings { get; private set; } + public PerformanceStatistics Statistics { get; private set; } + public Hid Hid { get; private set; } + public event EventHandler Finish; public Switch(IGalRenderer Renderer, IAalOutput AudioOut) @@ -37,18 +42,18 @@ namespace Ryujinx.Core Gpu = new NsGpu(Renderer); - VFs = new VirtualFs(); + Os = new Horizon(this); - Hid = new Hid(); + VFs = new VirtualFileSystem(); + + Settings = new SystemSettings(); Statistics = new PerformanceStatistics(); - Os = new Horizon(this); + Hid = new Hid(); Os.HidSharedMem.MemoryMapped += Hid.ShMemMap; Os.HidSharedMem.MemoryUnmapped += Hid.ShMemUnmap; - - Settings = new SetSys(); } public void LoadCart(string ExeFsDir, string RomFsFile = null) diff --git a/Ryujinx.Core/VirtualFs.cs b/Ryujinx.Core/VirtualFileSystem.cs similarity index 98% rename from Ryujinx.Core/VirtualFs.cs rename to Ryujinx.Core/VirtualFileSystem.cs index c0858e0ee6..1c717b2ca7 100644 --- a/Ryujinx.Core/VirtualFs.cs +++ b/Ryujinx.Core/VirtualFileSystem.cs @@ -3,7 +3,7 @@ using System.IO; namespace Ryujinx.Core { - class VirtualFs : IDisposable + class VirtualFileSystem : IDisposable { private const string BasePath = "RyuFs"; private const string NandPath = "nand";