28 lines
795 B
C#
28 lines
795 B
C#
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;
|
|
}
|
|
}
|
|
} |