Commit 9a897f5a authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Backport relevant part for libretro here - simplify WriteSample

https://github.com/flyinghead/flycast/commit/73a969b1a4b2861d43ef1948896366d55e30a9cb
parent 60e8b1b7
......@@ -7,19 +7,17 @@
extern retro_audio_sample_batch_t audio_batch_cb;
SoundFrame RingBuffer[SAMPLE_COUNT];
void WriteSample(s16 r, s16 l)
{
static const u32 RingBufferByteSize = sizeof(RingBuffer);
static volatile u32 WritePtr; //last written sample
static volatile u32 ReadPtr; //next sample to read
const u32 ptr = (WritePtr+1) % SAMPLE_COUNT;
RingBuffer[ptr].r=r;
RingBuffer[ptr].l=l;
WritePtr=ptr;
static SoundFrame Buffer[SAMPLE_COUNT];
static u32 writePtr; // next sample index
Buffer[writePtr].r = r;
Buffer[writePtr].l = l;
if (WritePtr==(SAMPLE_COUNT-1))
if (++writePtr == SAMPLE_COUNT)
{
if ( dc_is_running() && (!settings.rend.ThreadedRendering || settings.aica.LimitFPS) )
audio_batch_cb((const int16_t*)RingBuffer, SAMPLE_COUNT);
audio_batch_cb((const int16_t*)Buffer, SAMPLE_COUNT);
writePtr = 0;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment