Fix a bug where data buffers never return MA_AT_END.

This commit is contained in:
David Reid
2021-06-13 07:24:40 +10:00
parent 7a9ce3d0d3
commit b3d0858edf
+12 -2
View File
@@ -7421,7 +7421,7 @@ MA_API ma_result ma_resource_manager_data_buffer_uninit(ma_resource_manager_data
MA_API ma_result ma_resource_manager_data_buffer_read_pcm_frames(ma_resource_manager_data_buffer* pDataBuffer, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead) MA_API ma_result ma_resource_manager_data_buffer_read_pcm_frames(ma_resource_manager_data_buffer* pDataBuffer, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead)
{ {
ma_result result; ma_result result = MA_SUCCESS;
ma_uint64 framesRead; ma_uint64 framesRead;
ma_bool32 isLooping; ma_bool32 isLooping;
ma_bool32 isDecodedBufferBusy = MA_FALSE; ma_bool32 isDecodedBufferBusy = MA_FALSE;
@@ -7461,11 +7461,16 @@ MA_API ma_result ma_resource_manager_data_buffer_read_pcm_frames(ma_resource_man
/* Don't try reading more than the available frame count. */ /* Don't try reading more than the available frame count. */
if (frameCount > availableFrames) { if (frameCount > availableFrames) {
frameCount = availableFrames; frameCount = availableFrames;
isDecodedBufferBusy = MA_TRUE; isDecodedBufferBusy = (ma_resource_manager_data_buffer_node_result(pDataBuffer->pNode) == MA_BUSY);
if (!isDecodedBufferBusy && availableFrames == 0) {
result = MA_AT_END;
}
} }
} }
} }
if (result == MA_SUCCESS) {
result = ma_resource_manager_data_buffer_get_looping(pDataBuffer, &isLooping); result = ma_resource_manager_data_buffer_get_looping(pDataBuffer, &isLooping);
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
return result; return result;
@@ -7491,6 +7496,7 @@ MA_API ma_result ma_resource_manager_data_buffer_read_pcm_frames(ma_resource_man
if (pFramesRead != NULL) { if (pFramesRead != NULL) {
*pFramesRead = framesRead; *pFramesRead = framesRead;
} }
}
return result; return result;
} }
@@ -10261,6 +10267,8 @@ MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer,
} }
#endif #endif
//Com_Printf("listenerpos = %f %f %f\n", pListener->position.x, pListener->position.y, pListener->position.z);
/* /*
Multiply the lookat matrix by the spatializer position to transform it to listener Multiply the lookat matrix by the spatializer position to transform it to listener
space. This allows calculations to work based on the sound being relative to the space. This allows calculations to work based on the sound being relative to the
@@ -10281,6 +10289,8 @@ MA_API ma_result ma_spatializer_process_pcm_frames(ma_spatializer* pSpatializer,
} }
#endif #endif
//Com_Printf("relativePos = %f %f %f\n", relativePos.x, relativePos.y, relativePos.z);
/* /*
The direction of the sound needs to also be transformed so that it's relative to the The direction of the sound needs to also be transformed so that it's relative to the
rotation of the listener. rotation of the listener.