REVIEWED: Formating, tested sound examples

This commit is contained in:
Ray
2026-02-21 09:09:43 +01:00
parent 0c91f230fd
commit 11e3e6e0b9

View File

@ -2378,10 +2378,7 @@ static void OnLog(void *pUserData, ma_uint32 level, const char *pMessage)
static ma_uint32 ReadAudioBufferFramesInInternalFormat(AudioBuffer *audioBuffer, void *framesOut, ma_uint32 frameCount) static ma_uint32 ReadAudioBufferFramesInInternalFormat(AudioBuffer *audioBuffer, void *framesOut, ma_uint32 frameCount)
{ {
// Don't read anything if the sound is not playing // Don't read anything if the sound is not playing
if (!audioBuffer->playing) if (!audioBuffer->playing) return 0;
{
return 0;
}
// Using audio buffer callback // Using audio buffer callback
if (audioBuffer->callback) if (audioBuffer->callback)
@ -2519,15 +2516,8 @@ static ma_uint32 ReadAudioBufferFramesInMixingFormat(AudioBuffer *audioBuffer, f
// When the guess is overestimated, that's when it gets more complicated. In this case, any overflow // When the guess is overestimated, that's when it gets more complicated. In this case, any overflow
// needs to be stored in a buffer for later processing by the next read. // needs to be stored in a buffer for later processing by the next read.
ma_uint32 estimatedInputFrameCount = (ma_uint32)(((float)audioBuffer->converter.resampler.sampleRateIn / audioBuffer->converter.resampler.sampleRateOut) * outputFramesToProcessThisIteration); ma_uint32 estimatedInputFrameCount = (ma_uint32)(((float)audioBuffer->converter.resampler.sampleRateIn / audioBuffer->converter.resampler.sampleRateOut) * outputFramesToProcessThisIteration);
if (estimatedInputFrameCount == 0) if (estimatedInputFrameCount == 0) estimatedInputFrameCount = 1; // Make sure at least one input frame is read.
{ if (estimatedInputFrameCount > inputBufferFrameCap) estimatedInputFrameCount = inputBufferFrameCap;
estimatedInputFrameCount = 1; // Make sure at least one input frame is read.
}
if (estimatedInputFrameCount > inputBufferFrameCap)
{
estimatedInputFrameCount = inputBufferFrameCap;
}
ma_uint32 inputFramesInInternalFormatCount = ReadAudioBufferFramesInInternalFormat(audioBuffer, inputBuffer, estimatedInputFrameCount); ma_uint32 inputFramesInInternalFormatCount = ReadAudioBufferFramesInInternalFormat(audioBuffer, inputBuffer, estimatedInputFrameCount);
@ -2553,9 +2543,7 @@ static ma_uint32 ReadAudioBufferFramesInMixingFormat(AudioBuffer *audioBuffer, f
audioBuffer->converterResidualCount = residualFrameCount; audioBuffer->converterResidualCount = residualFrameCount;
} }
if (inputFramesInInternalFormatCount < estimatedInputFrameCount) { if (inputFramesInInternalFormatCount < estimatedInputFrameCount) break; // Reached the end of the sound
break; // Reached the end of the sound
}
} }
} }