More audio improvements
This commit is contained in:
parent
1c02303c13
commit
7092ad7cc9
5 changed files with 51 additions and 35 deletions
|
@ -24,7 +24,6 @@ namespace Ryujinx.Audio.OpenAL
|
||||||
|
|
||||||
private ConcurrentDictionary<long, int> Buffers;
|
private ConcurrentDictionary<long, int> Buffers;
|
||||||
|
|
||||||
private HashSet<long> QueuedTagsHash;
|
|
||||||
private Queue<long> QueuedTagsQueue;
|
private Queue<long> QueuedTagsQueue;
|
||||||
|
|
||||||
private bool Disposed;
|
private bool Disposed;
|
||||||
|
@ -40,7 +39,6 @@ namespace Ryujinx.Audio.OpenAL
|
||||||
|
|
||||||
Buffers = new ConcurrentDictionary<long, int>();
|
Buffers = new ConcurrentDictionary<long, int>();
|
||||||
|
|
||||||
QueuedTagsHash = new HashSet<long>();
|
|
||||||
QueuedTagsQueue = new Queue<long>();
|
QueuedTagsQueue = new Queue<long>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +58,6 @@ namespace Ryujinx.Audio.OpenAL
|
||||||
return Id;
|
return Id;
|
||||||
});
|
});
|
||||||
|
|
||||||
QueuedTagsHash.Add(Tag);
|
|
||||||
QueuedTagsQueue.Enqueue(Tag);
|
QueuedTagsQueue.Enqueue(Tag);
|
||||||
|
|
||||||
return Id;
|
return Id;
|
||||||
|
@ -68,15 +65,13 @@ namespace Ryujinx.Audio.OpenAL
|
||||||
|
|
||||||
public long[] GetReleasedBuffers()
|
public long[] GetReleasedBuffers()
|
||||||
{
|
{
|
||||||
SyncQueuedTags();
|
ClearReleased();
|
||||||
|
|
||||||
ClearQueue();
|
|
||||||
|
|
||||||
List<long> Tags = new List<long>();
|
List<long> Tags = new List<long>();
|
||||||
|
|
||||||
foreach (long Tag in Buffers.Keys)
|
foreach (long Tag in Buffers.Keys)
|
||||||
{
|
{
|
||||||
if (!QueuedTagsHash.Contains(Tag))
|
if (!ContainsBuffer(Tag))
|
||||||
{
|
{
|
||||||
Tags.Add(Tag);
|
Tags.Add(Tag);
|
||||||
}
|
}
|
||||||
|
@ -85,15 +80,10 @@ namespace Ryujinx.Audio.OpenAL
|
||||||
return Tags.ToArray();
|
return Tags.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ContainsBuffer(long Tag)
|
public void ClearReleased()
|
||||||
{
|
{
|
||||||
SyncQueuedTags();
|
SyncQueuedTags();
|
||||||
|
|
||||||
return QueuedTagsHash.Contains(Tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ClearQueue()
|
|
||||||
{
|
|
||||||
AL.GetSource(SourceId, ALGetSourcei.BuffersProcessed, out int ReleasedCount);
|
AL.GetSource(SourceId, ALGetSourcei.BuffersProcessed, out int ReleasedCount);
|
||||||
|
|
||||||
if (ReleasedCount > 0)
|
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()
|
private void SyncQueuedTags()
|
||||||
{
|
{
|
||||||
AL.GetSource(SourceId, ALGetSourcei.BuffersQueued, out int QueuedCount);
|
AL.GetSource(SourceId, ALGetSourcei.BuffersQueued, out int QueuedCount);
|
||||||
|
@ -111,7 +116,7 @@ namespace Ryujinx.Audio.OpenAL
|
||||||
|
|
||||||
while (QueuedTagsQueue.Count > QueuedCount)
|
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);
|
AL.BufferData(BufferId, Td.Format, Buffer, Buffer.Length, Td.SampleRate);
|
||||||
|
|
||||||
Td.ClearQueue();
|
|
||||||
|
|
||||||
AL.SourceQueueBuffer(Td.SourceId, BufferId);
|
AL.SourceQueueBuffer(Td.SourceId, BufferId);
|
||||||
|
|
||||||
StartPlaybackIfNeeded(Td);
|
StartPlaybackIfNeeded(Td);
|
||||||
|
@ -251,7 +254,7 @@ namespace Ryujinx.Audio.OpenAL
|
||||||
|
|
||||||
if (State != ALSourceState.Playing && Td.State == PlaybackState.Playing)
|
if (State != ALSourceState.Playing && Td.State == PlaybackState.Playing)
|
||||||
{
|
{
|
||||||
Td.ClearQueue();
|
Td.ClearReleased();
|
||||||
|
|
||||||
AL.SourcePlay(Td.SourceId);
|
AL.SourcePlay(Td.SourceId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,14 +87,22 @@ namespace Ryujinx.Core.OsHle.IpcServices.Aud
|
||||||
public long GetReleasedAudioOutBuffer(ServiceCtx Context)
|
public long GetReleasedAudioOutBuffer(ServiceCtx Context)
|
||||||
{
|
{
|
||||||
long Position = Context.Request.ReceiveBuff[0].Position;
|
long Position = Context.Request.ReceiveBuff[0].Position;
|
||||||
|
long Size = Context.Request.ReceiveBuff[0].Size;
|
||||||
|
|
||||||
|
int Count = (int)(Size >> 3);
|
||||||
|
|
||||||
long[] ReleasedBuffers = AudioOut.GetReleasedBuffers(Track);
|
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);
|
Context.ResponseData.Write(ReleasedBuffers.Length);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Core.Settings
|
namespace Ryujinx.Core.Settings
|
||||||
{
|
{
|
||||||
public class SetSys
|
public class SystemSettings
|
||||||
{
|
{
|
||||||
public ColorSet ThemeColor;
|
public ColorSet ThemeColor;
|
||||||
}
|
}
|
|
@ -11,13 +11,18 @@ namespace Ryujinx.Core
|
||||||
public class Switch : IDisposable
|
public class Switch : IDisposable
|
||||||
{
|
{
|
||||||
internal IAalOutput AudioOut { get; private set; }
|
internal IAalOutput AudioOut { get; private set; }
|
||||||
|
|
||||||
internal NsGpu Gpu { get; private set; }
|
internal NsGpu Gpu { get; private set; }
|
||||||
|
|
||||||
internal Horizon Os { get; private set; }
|
internal Horizon Os { get; private set; }
|
||||||
internal VirtualFs VFs { 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 Hid Hid { get; private set; }
|
||||||
public SetSys Settings { get; private set; }
|
|
||||||
public PerformanceStatistics Statistics { get; private set; }
|
|
||||||
|
|
||||||
public event EventHandler Finish;
|
public event EventHandler Finish;
|
||||||
|
|
||||||
|
@ -37,18 +42,18 @@ namespace Ryujinx.Core
|
||||||
|
|
||||||
Gpu = new NsGpu(Renderer);
|
Gpu = new NsGpu(Renderer);
|
||||||
|
|
||||||
VFs = new VirtualFs();
|
Os = new Horizon(this);
|
||||||
|
|
||||||
Hid = new Hid();
|
VFs = new VirtualFileSystem();
|
||||||
|
|
||||||
|
Settings = new SystemSettings();
|
||||||
|
|
||||||
Statistics = new PerformanceStatistics();
|
Statistics = new PerformanceStatistics();
|
||||||
|
|
||||||
Os = new Horizon(this);
|
Hid = new Hid();
|
||||||
|
|
||||||
Os.HidSharedMem.MemoryMapped += Hid.ShMemMap;
|
Os.HidSharedMem.MemoryMapped += Hid.ShMemMap;
|
||||||
Os.HidSharedMem.MemoryUnmapped += Hid.ShMemUnmap;
|
Os.HidSharedMem.MemoryUnmapped += Hid.ShMemUnmap;
|
||||||
|
|
||||||
Settings = new SetSys();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadCart(string ExeFsDir, string RomFsFile = null)
|
public void LoadCart(string ExeFsDir, string RomFsFile = null)
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System.IO;
|
||||||
|
|
||||||
namespace Ryujinx.Core
|
namespace Ryujinx.Core
|
||||||
{
|
{
|
||||||
class VirtualFs : IDisposable
|
class VirtualFileSystem : IDisposable
|
||||||
{
|
{
|
||||||
private const string BasePath = "RyuFs";
|
private const string BasePath = "RyuFs";
|
||||||
private const string NandPath = "nand";
|
private const string NandPath = "nand";
|
Loading…
Add table
Add a link
Reference in a new issue