From 12632e6b5e821b852ca878fae9ab5f0bb8b83e0f Mon Sep 17 00:00:00 2001 From: Rossmaxx <74815851+Rossmaxx@users.noreply.github.com> Date: Sun, 14 Jul 2024 02:31:31 +0530 Subject: [PATCH] Remove `BufferManager::clear` (#7378) --- include/BufferManager.h | 4 ---- src/core/AudioEngine.cpp | 2 +- src/core/BufferManager.cpp | 4 ---- src/core/Mixer.cpp | 8 +++----- src/core/Oscillator.cpp | 2 +- src/core/PlayHandle.cpp | 2 +- src/core/RemotePlugin.cpp | 6 +++--- src/core/audio/AudioPort.cpp | 2 +- src/gui/widgets/Oscilloscope.cpp | 2 +- 9 files changed, 11 insertions(+), 21 deletions(-) diff --git a/include/BufferManager.h b/include/BufferManager.h index 98f6703db..84602f121 100644 --- a/include/BufferManager.h +++ b/include/BufferManager.h @@ -39,10 +39,6 @@ class LMMS_EXPORT BufferManager public: static void init( fpp_t fpp ); static SampleFrame* acquire(); - // audio-buffer-mgm - static void clear( SampleFrame* ab, const f_cnt_t frames, - const f_cnt_t offset = 0 ); - static void release( SampleFrame* buf ); private: diff --git a/src/core/AudioEngine.cpp b/src/core/AudioEngine.cpp index 157b6fe65..42e7079b0 100644 --- a/src/core/AudioEngine.cpp +++ b/src/core/AudioEngine.cpp @@ -95,7 +95,7 @@ AudioEngine::AudioEngine( bool renderOnly ) : m_inputBufferFrames[i] = 0; m_inputBufferSize[i] = DEFAULT_BUFFER_SIZE * 100; m_inputBuffer[i] = new SampleFrame[ DEFAULT_BUFFER_SIZE * 100 ]; - BufferManager::clear( m_inputBuffer[i], m_inputBufferSize[i] ); + zeroSampleFrames(m_inputBuffer[i], m_inputBufferSize[i]); } // determine FIFO size and number of frames per period diff --git a/src/core/BufferManager.cpp b/src/core/BufferManager.cpp index a7a051e26..47598c633 100644 --- a/src/core/BufferManager.cpp +++ b/src/core/BufferManager.cpp @@ -47,10 +47,6 @@ SampleFrame* BufferManager::acquire() return new SampleFrame[s_framesPerPeriod]; } -void BufferManager::clear( SampleFrame* ab, const f_cnt_t frames, const f_cnt_t offset ) -{ - zeroSampleFrames(ab + offset, frames); -} void BufferManager::release( SampleFrame* buf ) diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index 0b0689eb5..ba02296f8 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -74,7 +74,7 @@ MixerChannel::MixerChannel( int idx, Model * _parent ) : m_queued( false ), m_dependenciesMet(0) { - BufferManager::clear( m_buffer, Engine::audioEngine()->framesPerPeriod() ); + zeroSampleFrames(m_buffer, Engine::audioEngine()->framesPerPeriod()); } @@ -612,8 +612,7 @@ void Mixer::mixToChannel( const SampleFrame* _buf, mix_ch_t _ch ) void Mixer::prepareMasterMix() { - BufferManager::clear( m_mixerChannels[0]->m_buffer, - Engine::audioEngine()->framesPerPeriod() ); + zeroSampleFrames(m_mixerChannels[0]->m_buffer, Engine::audioEngine()->framesPerPeriod()); } @@ -685,8 +684,7 @@ void Mixer::masterMix( SampleFrame* _buf ) // reset channel process state for( int i = 0; i < numChannels(); ++i) { - BufferManager::clear( m_mixerChannels[i]->m_buffer, - Engine::audioEngine()->framesPerPeriod() ); + zeroSampleFrames(m_mixerChannels[i]->m_buffer, Engine::audioEngine()->framesPerPeriod()); m_mixerChannels[i]->reset(); m_mixerChannels[i]->m_queued = false; // also reset hasInput diff --git a/src/core/Oscillator.cpp b/src/core/Oscillator.cpp index d24e82d98..4cbd9ccb4 100644 --- a/src/core/Oscillator.cpp +++ b/src/core/Oscillator.cpp @@ -81,7 +81,7 @@ void Oscillator::update(SampleFrame* ab, const fpp_t frames, const ch_cnt_t chnl { if (m_freq >= Engine::audioEngine()->outputSampleRate() / 2) { - BufferManager::clear(ab, frames); + zeroSampleFrames(ab, frames); return; } // If this oscillator is used to PM or PF modulate another oscillator, take a note. diff --git a/src/core/PlayHandle.cpp b/src/core/PlayHandle.cpp index eb90f6b65..134fcd311 100644 --- a/src/core/PlayHandle.cpp +++ b/src/core/PlayHandle.cpp @@ -55,7 +55,7 @@ void PlayHandle::doProcessing() if( m_usesBuffer ) { m_bufferReleased = false; - BufferManager::clear(m_playHandleBuffer, Engine::audioEngine()->framesPerPeriod()); + zeroSampleFrames(m_playHandleBuffer, Engine::audioEngine()->framesPerPeriod()); play( buffer() ); } else diff --git a/src/core/RemotePlugin.cpp b/src/core/RemotePlugin.cpp index 4cfcc313c..dc26bf2b5 100644 --- a/src/core/RemotePlugin.cpp +++ b/src/core/RemotePlugin.cpp @@ -333,7 +333,7 @@ bool RemotePlugin::process( const SampleFrame* _in_buf, SampleFrame* _out_buf ) { if( _out_buf != nullptr ) { - BufferManager::clear( _out_buf, frames ); + zeroSampleFrames(_out_buf, frames); } return false; } @@ -352,7 +352,7 @@ bool RemotePlugin::process( const SampleFrame* _in_buf, SampleFrame* _out_buf ) } if( _out_buf != nullptr ) { - BufferManager::clear( _out_buf, frames ); + zeroSampleFrames(_out_buf, frames); } return false; } @@ -426,7 +426,7 @@ bool RemotePlugin::process( const SampleFrame* _in_buf, SampleFrame* _out_buf ) { auto o = (SampleFrame*)(m_audioBuffer.get() + m_inputCount * frames); // clear buffer, if plugin didn't fill up both channels - BufferManager::clear( _out_buf, frames ); + zeroSampleFrames(_out_buf, frames); for (ch_cnt_t ch = 0; ch < std::min(DEFAULT_CHANNELS, outputs); ++ch) diff --git a/src/core/audio/AudioPort.cpp b/src/core/audio/AudioPort.cpp index 7bae3db1c..8efdd2c11 100644 --- a/src/core/audio/AudioPort.cpp +++ b/src/core/audio/AudioPort.cpp @@ -113,7 +113,7 @@ void AudioPort::doProcessing() const fpp_t fpp = Engine::audioEngine()->framesPerPeriod(); // clear the buffer - BufferManager::clear( m_portBuffer, fpp ); + zeroSampleFrames(m_portBuffer, fpp); //qDebug( "Playhandles: %d", m_playHandles.size() ); for( PlayHandle * ph : m_playHandles ) // now we mix all playhandle buffers into the audioport buffer diff --git a/src/gui/widgets/Oscilloscope.cpp b/src/gui/widgets/Oscilloscope.cpp index 8cb840592..3178d7ef2 100644 --- a/src/gui/widgets/Oscilloscope.cpp +++ b/src/gui/widgets/Oscilloscope.cpp @@ -57,7 +57,7 @@ Oscilloscope::Oscilloscope( QWidget * _p ) : const fpp_t frames = Engine::audioEngine()->framesPerPeriod(); m_buffer = new SampleFrame[frames]; - BufferManager::clear( m_buffer, frames ); + zeroSampleFrames(m_buffer, frames); setToolTip(tr("Oscilloscope"));