First OS Agnostic Commit
This commit is contained in:
28
Parsons.Steamdeck/RaylibAudioPlayer.cs
Normal file
28
Parsons.Steamdeck/RaylibAudioPlayer.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Core.Interfaces;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace Parsons.SteamDeck
|
||||
{
|
||||
public class RaylibAudioPlayer : IAudioDevice
|
||||
{
|
||||
private ConcurrentQueue<float> _sampleQueue = new ConcurrentQueue<float>();
|
||||
|
||||
public void AddSample(float sample)
|
||||
{
|
||||
// Queue the sample from the emulator core
|
||||
_sampleQueue.Enqueue(sample);
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
_sampleQueue.TryDequeue(out buffer[i]);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user