mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-21 15:56:58 +02:00
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:
+10
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user