mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-21 21:23:35 -05:00
REVIEWED: Formating, tested sound examples
This commit is contained in:
20
src/raudio.c
20
src/raudio.c
@ -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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user