mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 16:24:04 +02:00
Fix a bug with data source ranges.
Public issue https://github.com/mackron/miniaudio/discussions/596
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
v0.11.12 - TBD
|
v0.11.12 - TBD
|
||||||
=====================
|
=====================
|
||||||
|
* Fix a bug with data source ranges which resulted in data being read from outside the range.
|
||||||
* Fix a crash due to a race condition in the resource manager.
|
* Fix a crash due to a race condition in the resource manager.
|
||||||
* Fix a crash with some backends when rerouting the playback side of a duplex device.
|
* Fix a crash with some backends when rerouting the playback side of a duplex device.
|
||||||
* Fix some bugs with initialization of POSIX threads.
|
* Fix some bugs with initialization of POSIX threads.
|
||||||
|
|||||||
+9
-9
@@ -4415,11 +4415,6 @@ logLevel (in)
|
|||||||
|
|
||||||
pMessage (in)
|
pMessage (in)
|
||||||
The log message.
|
The log message.
|
||||||
|
|
||||||
|
|
||||||
Remarks
|
|
||||||
-------
|
|
||||||
Do not modify the state of the device from inside the callback.
|
|
||||||
*/
|
*/
|
||||||
typedef void (* ma_log_callback_proc)(void* pUserData, ma_uint32 level, const char* pMessage);
|
typedef void (* ma_log_callback_proc)(void* pUserData, ma_uint32 level, const char* pMessage);
|
||||||
|
|
||||||
@@ -56161,18 +56156,23 @@ static ma_result ma_data_source_read_pcm_frames_within_range(ma_data_source* pDa
|
|||||||
result = pDataSourceBase->vtable->onRead(pDataSourceBase, pFramesOut, frameCount, &framesRead);
|
result = pDataSourceBase->vtable->onRead(pDataSourceBase, pFramesOut, frameCount, &framesRead);
|
||||||
} else {
|
} else {
|
||||||
/* Need to clamp to within the range. */
|
/* 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) {
|
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. */
|
/* 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);
|
result = pDataSourceBase->vtable->onRead(pDataSourceBase, pFramesOut, frameCount, &framesRead);
|
||||||
} else {
|
} else {
|
||||||
|
ma_uint64 rangeBeg;
|
||||||
ma_uint64 rangeEnd;
|
ma_uint64 rangeEnd;
|
||||||
|
|
||||||
/* We have the cursor. We need to make sure we don't read beyond our range. */
|
/* We have the cursor. We need to make sure we don't read beyond our range. */
|
||||||
|
rangeBeg = pDataSourceBase->rangeBegInFrames;
|
||||||
rangeEnd = pDataSourceBase->rangeEndInFrames;
|
rangeEnd = pDataSourceBase->rangeEndInFrames;
|
||||||
|
|
||||||
|
absoluteCursor = rangeBeg + relativeCursor;
|
||||||
|
|
||||||
/* If looping, make sure we're within range. */
|
/* If looping, make sure we're within range. */
|
||||||
if (loop) {
|
if (loop) {
|
||||||
if (pDataSourceBase->loopEndInFrames != ~((ma_uint64)0)) {
|
if (pDataSourceBase->loopEndInFrames != ~((ma_uint64)0)) {
|
||||||
@@ -56180,8 +56180,8 @@ static ma_result ma_data_source_read_pcm_frames_within_range(ma_data_source* pDa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frameCount > (rangeEnd - cursor) && rangeEnd != ~((ma_uint64)0)) {
|
if (frameCount > (rangeEnd - absoluteCursor) && rangeEnd != ~((ma_uint64)0)) {
|
||||||
frameCount = (rangeEnd - cursor);
|
frameCount = (rangeEnd - absoluteCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user