From 4679631f5b1bbfe54a292ee04f4a3a67679ab9d3 Mon Sep 17 00:00:00 2001 From: David Reid Date: Thu, 28 May 2026 08:37:16 +1000 Subject: [PATCH] Fix a node graph error. Prior to this commit, the number of frames read was always reported as the whole frame count. This is incorrect for leaf nodes which don't always produce the full frame count (an example being when the end of a sound is reached). --- miniaudio.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/miniaudio.h b/miniaudio.h index 9487fe43..89169f72 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -83596,6 +83596,7 @@ static ma_result ma_node_input_bus_read_pcm_frames(ma_node* pInputNode, ma_node_ ma_node_output_bus* pFirst; ma_uint32 inputChannels; ma_bool32 doesOutputBufferHaveContent = MA_FALSE; + ma_uint32 framesRead = 0; /* This will be called from the audio thread which means we can't be doing any locking. Basically, @@ -83712,6 +83713,11 @@ static ma_result ma_node_input_bus_read_pcm_frames(ma_node* pInputNode, ma_node_ /* Seek. */ ma_node_read_pcm_frames(pOutputBus->pNode, pOutputBus->outputBusIndex, NULL, frameCount, &framesProcessed, globalTime); } + + /* The number of frames read will equal the maximum number of frames that were pulled from the outputs that are attached to this input. */ + if (framesRead < framesProcessed) { + framesRead = framesProcessed; + } } /* If we didn't output anything, output silence. */ @@ -83719,8 +83725,7 @@ static ma_result ma_node_input_bus_read_pcm_frames(ma_node* pInputNode, ma_node_ ma_silence_pcm_frames(pFramesOut, frameCount, ma_format_f32, inputChannels); } - /* In this path we always "process" the entire amount. */ - *pFramesRead = frameCount; + *pFramesRead = framesRead; return result; }