Steam Deck version fixes

This commit is contained in:
2026-06-04 22:01:45 +01:00
parent 2300e2931e
commit ef365185bf
96 changed files with 198 additions and 73 deletions

View File

@@ -7,15 +7,24 @@ namespace Parsons.SteamDeck
{
private ConcurrentQueue<float> _sampleQueue = new ConcurrentQueue<float>();
// 4096 samples provides a perfect ~90ms safety buffer
private const int MaxBufferSamples = 4096;
public void AddSample(float sample)
{
// Queue the sample from the emulator core
_sampleQueue.Enqueue(sample);
// THE FIX: If the CPU outpaces the soundcard, drop the OLDEST sample!
// This guarantees we never fall behind and the audio stays perfectly synced.
if (_sampleQueue.Count > MaxBufferSamples)
{
_sampleQueue.TryDequeue(out _);
}
}
// Grab absolutely everything we generated this frame
public float[] GetQueuedSamples()
{
// Pull all pending samples out of the queue to send to the sound card
int count = _sampleQueue.Count;
float[] buffer = new float[count];
for (int i = 0; i < count; i++)