Update ma_pcm_rb data source implementation.

The data source implementation of a ma_pcm_rb could possibly return a
frame count of 0 which would in turn result in
ma_data_source_read_pcm_frames() returning MA_AT_END which does not
make sense for a ring buffer since it has no notion of an end.
This commit is contained in:
David Reid
2025-01-11 16:30:15 +10:00
parent 547ef1c9b7
commit fcddfe6204
3 changed files with 11 additions and 3 deletions
+10
View File
@@ -56897,6 +56897,16 @@ static ma_result ma_pcm_rb_data_source__on_read(ma_data_source* pDataSource, voi
totalFramesRead += mappedFrameCount;
}
/*
There is no notion of an "end" in a ring buffer. If we didn't have enough data to fill the requested frame
count we'll need to pad with silence. If we don't do this, totalFramesRead might equal 0 which will result
in the data source layer at a higher level translating this to MA_AT_END which is incorrect for a ring buffer.
*/
if (totalFramesRead < frameCount) {
ma_silence_pcm_frames(ma_offset_pcm_frames_ptr(pFramesOut, totalFramesRead, pRB->format, pRB->channels), (frameCount - totalFramesRead), pRB->format, pRB->channels);
totalFramesRead = frameCount;
}
*pFramesRead = totalFramesRead;
return MA_SUCCESS;
}