Ceil the scaled buffer size instead of round

The result has to be large enough to get the original requested size from it.
This commit is contained in:
Chris Robinson
2020-11-23 10:55:13 -08:00
parent d062c16629
commit d08d6b18c4
+3 -1
View File
@@ -27,6 +27,8 @@
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include "alcmain.h"
#include "alexcpt.h"
#include "alu.h"
@@ -553,7 +555,7 @@ void CoreAudioCapture::open(const ALCchar *name)
* conversion ring buffer. Ensure at least 100ms for the total buffer.
*/
double srateScale{double{outputFormat.mSampleRate} / mDevice->Frequency};
auto FrameCount64 = maxu64(static_cast<uint64_t>(mDevice->BufferSize*srateScale + 0.5),
auto FrameCount64 = maxu64(static_cast<uint64_t>(std::ceil(mDevice->BufferSize*srateScale)),
static_cast<UInt32>(outputFormat.mSampleRate)/10);
FrameCount64 += MAX_RESAMPLER_PADDING;
if(FrameCount64 > std::numeric_limits<int32_t>::max())