More audio improvements
This commit is contained in:
parent
1c02303c13
commit
7092ad7cc9
5 changed files with 51 additions and 35 deletions
|
@ -24,8 +24,7 @@ namespace Ryujinx.Audio.OpenAL
|
|||
|
||||
private ConcurrentDictionary<long, int> Buffers;
|
||||
|
||||
private HashSet<long> QueuedTagsHash;
|
||||
private Queue<long> QueuedTagsQueue;
|
||||
private Queue<long> QueuedTagsQueue;
|
||||
|
||||
private bool Disposed;
|
||||
|
||||
|
@ -40,7 +39,6 @@ namespace Ryujinx.Audio.OpenAL
|
|||
|
||||
Buffers = new ConcurrentDictionary<long, int>();
|
||||
|
||||
QueuedTagsHash = new HashSet<long>();
|
||||
QueuedTagsQueue = new Queue<long>();
|
||||
}
|
||||
|
||||
|
@ -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<long> Tags = new List<long>();
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
namespace Ryujinx.Core.Settings
|
||||
{
|
||||
public class SetSys
|
||||
public class SystemSettings
|
||||
{
|
||||
public ColorSet ThemeColor;
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -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";
|
Loading…
Add table
Reference in a new issue