[client] audio: move the memory copy into the pull function

This commit is contained in:
Geoffrey McRae
2022-01-19 10:29:49 +11:00
parent 99536eaf9d
commit 15f76339c8
4 changed files with 18 additions and 11 deletions

View File

@@ -131,10 +131,21 @@ void playbackStopNL(void)
}
}
static int playbackPullFrames(uint8_t ** data, int frames)
static int playbackPullFrames(uint8_t * dst, int frames)
{
if (audio.playback.buffer)
*data = ringbuffer_consume(audio.playback.buffer, &frames);
{
frames = min(frames, ringbuffer_getCount(audio.playback.buffer));
for(int fetched = 0; fetched < frames; )
{
int copy = frames - fetched;
uint8_t * src = ringbuffer_consume(audio.playback.buffer, &copy);
memcpy(dst, src, copy * audio.playback.stride);
dst += copy * audio.playback.stride;
fetched += copy;
}
}
else
frames = 0;