diff options
author | Chris Robinson <[email protected]> | 2020-11-23 10:40:20 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-11-23 10:40:20 -0800 |
commit | 31c7eb5c552482cc782b1599c94532cecf09851a (patch) | |
tree | 1cfac85c468cf7ab84e8a2de6132ec85aa2ca09f /alc/backends | |
parent | 5d82058da7b8419f9d8bebda42826505fb3f1a6b (diff) |
Fix capture buffer size scaling in CoreAudio
Diffstat (limited to 'alc/backends')
-rw-r--r-- | alc/backends/coreaudio.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp index 60103f51..6ec0f3ab 100644 --- a/alc/backends/coreaudio.cpp +++ b/alc/backends/coreaudio.cpp @@ -550,13 +550,13 @@ void CoreAudioCapture::open(const ALCchar *name) throw al::backend_exception{ALC_INVALID_VALUE, "Could not set input format: %u", err}; /* Calculate the minimum AudioUnit output format frame count for the pre- - * conversion ring buffer. + * conversion ring buffer. Ensure at least 100ms for the total buffer. */ - uint64_t FrameCount64{mDevice->UpdateSize}; - FrameCount64 = FrameCount64*static_cast<UInt32>(outputFormat.mSampleRate) + (mDevice->Frequency-1) / - mDevice->Frequency; + double srateScale{double{outputFormat.mSampleRate} / mDevice->Frequency}; + auto FrameCount64 = maxu64(static_cast<uint64_t>(mDevice->BufferSize*srateScale + 0.5), + static_cast<UInt32>(outputFormat.mSampleRate)/10); FrameCount64 += MAX_RESAMPLER_PADDING; - if(FrameCount64 > std::numeric_limits<uint32_t>::max()/2) + if(FrameCount64 > std::numeric_limits<int32_t>::max()) throw al::backend_exception{ALC_INVALID_VALUE, "Calculated frame count is too large: %" PRIu64, FrameCount64}; |