Skip to content

Commit

Permalink
Use kMaxEngineFrames or kMaxEngineSamples when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
abique committed Sep 20, 2023
1 parent 8438dbe commit 693f0e5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/engine/effects/engineeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ EngineEffect::EngineEffect(EffectManifestPointer pManifest,
// At this point the SoundDevice is not set up so we use the kInitalSampleRate.
const mixxx::EngineParameters engineParameters(
kInitalSampleRate,
MAX_BUFFER_LEN / mixxx::kEngineChannelCount);
kMaxEngineFrames);
m_pProcessor->initialize(activeInputChannels, registeredOutputChannels, engineParameters);
m_effectRampsFromDry = pManifest->effectRampsFromDry();
}
Expand All @@ -62,7 +62,7 @@ void EngineEffect::initalizeInputChannel(ChannelHandle inputChannel) {
// At this point the SoundDevice is not set up so we use the kInitalSampleRate.
const mixxx::EngineParameters engineParameters(
kInitalSampleRate,
MAX_BUFFER_LEN / mixxx::kEngineChannelCount);
kMaxEngineFrames);
m_pProcessor->initializeInputChannel(inputChannel, engineParameters);
}

Expand Down
6 changes: 4 additions & 2 deletions src/engine/effects/engineeffectchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ EngineEffectChain::EngineEffectChain(const QString& group,
m_enableState(EffectEnableState::Enabled),
m_mixMode(EffectChainMixMode::DrySlashWet),
m_dMix(0),
m_buffer1(MAX_BUFFER_LEN),
m_buffer2(MAX_BUFFER_LEN) {
m_buffer1(kMaxEngineSamples),
m_buffer2(kMaxEngineSamples) {
// Try to prevent memory allocation.
m_effects.reserve(256);

Expand Down Expand Up @@ -179,6 +179,8 @@ bool EngineEffectChain::process(const ChannelHandle& inputHandle,
const mixxx::audio::SampleRate sampleRate,
const GroupFeatureState& groupFeatures,
bool fadeout) {
DEBUG_ASSERT(numSamples <= kMaxEngineFrames);

// Compute the effective enable state from the channel input routing switch and
// the chain's enable state. When either of these are turned on/off, send the
// effects the intermediate enabling/disabling signal.
Expand Down
2 changes: 1 addition & 1 deletion src/soundio/sounddevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void SoundDevice::setSampleRate(mixxx::audio::SampleRate sampleRate) {
}

void SoundDevice::setConfigFramesPerBuffer(unsigned int framesPerBuffer) {
if (framesPerBuffer * 2 > MAX_BUFFER_LEN) {
if (framesPerBuffer > kMaxEngineFrames) {
// framesPerBuffer * 2 because a frame will generally end up
// being 2 samples and MAX_BUFFER_LEN is a number of samples
// this isn't checked elsewhere, so...
Expand Down

0 comments on commit 693f0e5

Please sign in to comment.