Skip to content

Commit

Permalink
Fixed record temp audio buffer size
Browse files Browse the repository at this point in the history
  • Loading branch information
FangCunWuChang committed Nov 25, 2024
1 parent 443303b commit 799ffb5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/audioCore/misc/RecordTemp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void RecordTemp::setInputSampleRate(double sampleRate) {
void RecordTemp::setInputChannelNum(int channels) {
juce::GenericScopedLock locker(this->lock);
this->audioBuffer.setSize(channels,
this->audioBuffer.getNumSamples(), true, true, true);
std::max(this->audioBuffer.getNumSamples(), AUDIO_BUFFER_MIN), true, true, true);
}

void RecordTemp::recordData(double timeSec,
Expand Down Expand Up @@ -77,15 +77,15 @@ void RecordTemp::clearAudio() {

bool RecordTemp::tryToEnsureAudioBufferSamplesAllocated(uint64_t sampleNum) {
while (this->audioBuffer.getNumSamples() < sampleNum) {
uint16_t num = (uint64_t)(this->audioBuffer.getNumSamples()) * 2;
uint64_t num = (uint64_t)(this->audioBuffer.getNumSamples()) * 2;
if (num > INT_MAX) {
this->audioBuffer.setSize(this->audioBuffer.getNumChannels(),
INT_MAX, false, true, true);
break;
}

this->audioBuffer.setSize(this->audioBuffer.getNumChannels(),
(int)num, false, true, true);
std::max((int)num, AUDIO_BUFFER_MIN), false, true, true);
}

return this->audioBuffer.getNumSamples() >= sampleNum;
Expand Down

0 comments on commit 799ffb5

Please sign in to comment.