result = pDataSourceBase->vtable->onRead(pDataSourceBase, pFramesOut, frameCount, &framesRead);
} else {
/* Need to clamp to within the range. */
ma_uint64 cursor;
ma_uint64 relativeCursor;
ma_uint64 absoluteCursor;
result = ma_data_source_get_cursor_in_pcm_frames(pDataSourceBase, &cursor);
result = ma_data_source_get_cursor_in_pcm_frames(pDataSourceBase, &relativeCursor);
if (result != MA_SUCCESS) {
/* Failed to retrieve the cursor. Cannot read within a range or loop points. Just read like normal - this may happen for things like noise data sources where it doesn't really matter. */
result = pDataSourceBase->vtable->onRead(pDataSourceBase, pFramesOut, frameCount, &framesRead);
} else {
ma_uint64 rangeBeg;
ma_uint64 rangeEnd;
/* We have the cursor. We need to make sure we don't read beyond our range. */
rangeBeg = pDataSourceBase->rangeBegInFrames;
rangeEnd = pDataSourceBase->rangeEndInFrames;
absoluteCursor = rangeBeg + relativeCursor;
/* If looping, make sure we're within range. */
if (loop) {
if (pDataSourceBase->loopEndInFrames != ~((ma_uint64)0)) {