Commit 438db05c authored by David Reid's avatar David Reid

Fix a bug in ma_data_source_read_pcm_frames().

The issue here is that MA_AT_END is getting returned when nothing has
been read. The rules are that MA_AT_END should only ever be returned
when nothing is read.
parent 3a3616e0
...@@ -53661,6 +53661,14 @@ MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, voi ...@@ -53661,6 +53661,14 @@ MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, voi
MA_AT_END. To loop back to the start, all we need to do is seek back to the first frame. MA_AT_END. To loop back to the start, all we need to do is seek back to the first frame.
*/ */
if (result == MA_AT_END) { if (result == MA_AT_END) {
/*
The result needs to be reset back to MA_SUCCESS (from MA_AT_END) so that we don't
accidentally return MA_AT_END when data has been read in prior loop iterations. at the
end of this function, the result will be checked for MA_SUCCESS, and if the total
number of frames processed is 0, will be explicitly set to MA_AT_END.
*/
result = MA_SUCCESS;
/* /*
We reached the end. If we're looping, we just loop back to the start of the current We reached the end. If we're looping, we just loop back to the start of the current
data source. If we're not looping we need to check if we have another in the chain, and data source. If we're not looping we need to check if we have another in the chain, and
...@@ -53701,13 +53709,6 @@ MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, voi ...@@ -53701,13 +53709,6 @@ MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, voi
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
break; break;
} }
/*
We need to make sure we clear the MA_AT_END result so we don't accidentally return
it in the event that we coincidentally ended reading at the exact transition point
of two data sources in a chain.
*/
result = MA_SUCCESS;
} }
} }
...@@ -53720,6 +53721,8 @@ MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, voi ...@@ -53720,6 +53721,8 @@ MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, voi
*pFramesRead = totalFramesProcessed; *pFramesRead = totalFramesProcessed;
} }
MA_ASSERT(!(result == MA_AT_END && totalFramesProcessed > 0)); /* We should never be returning MA_AT_END if we read some data. */
if (result == MA_SUCCESS && totalFramesProcessed == 0) { if (result == MA_SUCCESS && totalFramesProcessed == 0) {
result = MA_AT_END; result = MA_AT_END;
} }
...@@ -89509,6 +89512,8 @@ v0.11.3 - TBD ...@@ -89509,6 +89512,8 @@ v0.11.3 - TBD
for debugging in miniaudio. To filter out these messages, just filter against the log level for debugging in miniaudio. To filter out these messages, just filter against the log level
which will be MA_LOG_LEVEL_DEBUG. which will be MA_LOG_LEVEL_DEBUG.
- Fix a bug where ma_device_get_info() and ma_device_get_name() return an error. - Fix a bug where ma_device_get_info() and ma_device_get_name() return an error.
- Fix a bug where ma_data_source_read_pcm_frames() can return MA_AT_END even when some data has
been read. MA_AT_END should only be returned when nothing has been read.
- PulseAudio: Fix some bugs where starting and stopping a device can result in a deadlock. - PulseAudio: Fix some bugs where starting and stopping a device can result in a deadlock.
v0.11.2 - 2021-12-31 v0.11.2 - 2021-12-31
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment