BufferManager: Use MemoryPool, rename to BufferPool
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* BufferManager.h - A buffer caching/memory management system
|
||||
* BufferPool.h
|
||||
*
|
||||
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
|
||||
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
@@ -23,13 +23,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BUFFER_MANAGER_H
|
||||
#define BUFFER_MANAGER_H
|
||||
#pragma once
|
||||
|
||||
#include "lmms_export.h"
|
||||
#include "lmms_basics.h"
|
||||
|
||||
class LMMS_EXPORT BufferManager
|
||||
/// Legacy interface for buffer re-use. Uses MemoryPool internally now.
|
||||
class LMMS_EXPORT BufferPool
|
||||
{
|
||||
public:
|
||||
static void init( fpp_t framesPerPeriod );
|
||||
@@ -43,5 +43,3 @@ public:
|
||||
#endif
|
||||
static void release( sampleFrame * buf );
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -38,8 +38,6 @@
|
||||
#include <QMenu>
|
||||
#include <QDomElement>
|
||||
|
||||
#include "ConfigManager.h"
|
||||
#include "BufferManager.h"
|
||||
#include "ConfigManager.h"
|
||||
#include "Engine.h"
|
||||
#include "gui_templates.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* BufferManager.cpp - A buffer caching/memory management system
|
||||
* BufferPool.cpp
|
||||
*
|
||||
* Copyright (c) 2017 Lukas W <lukaswhl/at/gmail.com>
|
||||
* Copyright (c) 2018 Lukas W <lukaswhl/at/gmail.com>
|
||||
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
|
||||
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
@@ -24,32 +24,31 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "BufferManager.h"
|
||||
#include "BufferPool.h"
|
||||
|
||||
#include "Engine.h"
|
||||
#include "Mixer.h"
|
||||
#include "Memory.h"
|
||||
#include <cstring>
|
||||
#include "MemoryPool.h"
|
||||
|
||||
static fpp_t framesPerPeriod;
|
||||
static std::unique_ptr<_MemoryPool_Base> pool;
|
||||
const int BM_INITIAL_BUFFERS = 256;
|
||||
|
||||
void BufferManager::init( fpp_t framesPerPeriod )
|
||||
void BufferPool::init( fpp_t framesPerPeriod )
|
||||
{
|
||||
::framesPerPeriod = framesPerPeriod;
|
||||
pool.reset(new _MemoryPool_Base(framesPerPeriod * sizeof(sampleFrame), BM_INITIAL_BUFFERS));
|
||||
}
|
||||
|
||||
|
||||
sampleFrame * BufferManager::acquire()
|
||||
sampleFrame * BufferPool::acquire()
|
||||
{
|
||||
return MM_ALLOC( sampleFrame, ::framesPerPeriod );
|
||||
return reinterpret_cast<sampleFrame*>(pool->allocate());
|
||||
}
|
||||
|
||||
void BufferManager::clear( sampleFrame *ab, const f_cnt_t frames, const f_cnt_t offset )
|
||||
void BufferPool::clear( sampleFrame *ab, const f_cnt_t frames, const f_cnt_t offset )
|
||||
{
|
||||
memset( ab + offset, 0, sizeof( *ab ) * frames );
|
||||
}
|
||||
|
||||
#ifndef LMMS_DISABLE_SURROUND
|
||||
void BufferManager::clear( surroundSampleFrame * ab, const f_cnt_t frames,
|
||||
void BufferPool::clear( surroundSampleFrame * ab, const f_cnt_t frames,
|
||||
const f_cnt_t offset )
|
||||
{
|
||||
memset( ab + offset, 0, sizeof( *ab ) * frames );
|
||||
@@ -57,8 +56,7 @@ void BufferManager::clear( surroundSampleFrame * ab, const f_cnt_t frames,
|
||||
#endif
|
||||
|
||||
|
||||
void BufferManager::release( sampleFrame * buf )
|
||||
void BufferPool::release( sampleFrame * buf )
|
||||
{
|
||||
MM_FREE( buf );
|
||||
pool->deallocate(buf);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ set(LMMS_SRCS
|
||||
core/BandLimitedWave.cpp
|
||||
core/base64.cpp
|
||||
core/BBTrackContainer.cpp
|
||||
core/BufferManager.cpp
|
||||
core/BufferPool.cpp
|
||||
core/Clipboard.cpp
|
||||
core/ComboBoxModel.cpp
|
||||
core/ConfigManager.cpp
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <QDomElement>
|
||||
|
||||
#include "BufferManager.h"
|
||||
#include "BufferPool.h"
|
||||
#include "FxMixer.h"
|
||||
#include "Mixer.h"
|
||||
#include "MixerWorkerThread.h"
|
||||
@@ -74,7 +74,7 @@ FxChannel::FxChannel( int idx, Model * _parent ) :
|
||||
m_queued( false ),
|
||||
m_dependenciesMet(0)
|
||||
{
|
||||
BufferManager::clear( m_buffer, Engine::mixer()->framesPerPeriod() );
|
||||
BufferPool::clear( m_buffer, Engine::mixer()->framesPerPeriod() );
|
||||
}
|
||||
|
||||
|
||||
@@ -585,7 +585,7 @@ void FxMixer::mixToChannel( const sampleFrame * _buf, fx_ch_t _ch )
|
||||
|
||||
void FxMixer::prepareMasterMix()
|
||||
{
|
||||
BufferManager::clear( m_fxChannels[0]->m_buffer,
|
||||
BufferPool::clear( m_fxChannels[0]->m_buffer,
|
||||
Engine::mixer()->framesPerPeriod() );
|
||||
}
|
||||
|
||||
@@ -658,7 +658,7 @@ void FxMixer::masterMix( sampleFrame * _buf )
|
||||
// reset channel process state
|
||||
for( int i = 0; i < numChannels(); ++i)
|
||||
{
|
||||
BufferManager::clear( m_fxChannels[i]->m_buffer,
|
||||
BufferPool::clear( m_fxChannels[i]->m_buffer,
|
||||
Engine::mixer()->framesPerPeriod() );
|
||||
m_fxChannels[i]->reset();
|
||||
m_fxChannels[i]->m_queued = false;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "ConfigManager.h"
|
||||
#include "SamplePlayHandle.h"
|
||||
#include "Memory.h"
|
||||
#include "BufferPool.h"
|
||||
|
||||
// platform-specific audio-interface-classes
|
||||
#include "AudioAlsa.h"
|
||||
@@ -59,8 +60,6 @@
|
||||
#include "MidiApple.h"
|
||||
#include "MidiDummy.h"
|
||||
|
||||
#include "BufferManager.h"
|
||||
|
||||
typedef LocklessList<PlayHandle *>::Element LocklessListElement;
|
||||
|
||||
|
||||
@@ -98,7 +97,7 @@ Mixer::Mixer( 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] );
|
||||
BufferPool::clear( m_inputBuffer[i], m_inputBufferSize[i] );
|
||||
}
|
||||
|
||||
// determine FIFO size and number of frames per period
|
||||
@@ -133,15 +132,15 @@ Mixer::Mixer( bool renderOnly ) :
|
||||
// allocte the FIFO from the determined size
|
||||
m_fifo = new fifo( fifoSize );
|
||||
|
||||
// now that framesPerPeriod is fixed initialize global BufferManager
|
||||
BufferManager::init( m_framesPerPeriod );
|
||||
// now that framesPerPeriod is fixed initialize global BufferPool
|
||||
BufferPool::init( m_framesPerPeriod );
|
||||
|
||||
AlignedAllocator<surroundSampleFrame> alloc;
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
m_readBuf = alloc.allocate( m_framesPerPeriod );
|
||||
|
||||
BufferManager::clear( m_readBuf, m_framesPerPeriod );
|
||||
BufferPool::clear( m_readBuf, m_framesPerPeriod );
|
||||
m_bufferPool.push_back( m_readBuf );
|
||||
}
|
||||
|
||||
@@ -417,7 +416,7 @@ const surroundSampleFrame * Mixer::renderNextBuffer()
|
||||
m_readBuf = m_bufferPool[m_readBuffer];
|
||||
|
||||
// clear last audio-buffer
|
||||
BufferManager::clear( m_writeBuf, m_framesPerPeriod );
|
||||
BufferPool::clear( m_writeBuf, m_framesPerPeriod );
|
||||
|
||||
// prepare master mix (clear internal buffers etc.)
|
||||
FxMixer * fxMixer = Engine::fxMixer();
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "Oscillator.h"
|
||||
|
||||
#include "BufferManager.h"
|
||||
#include "BufferPool.h"
|
||||
#include "Engine.h"
|
||||
#include "Mixer.h"
|
||||
#include "AutomatableModel.h"
|
||||
@@ -59,7 +59,7 @@ void Oscillator::update( sampleFrame * _ab, const fpp_t _frames,
|
||||
{
|
||||
if( m_freq >= Engine::mixer()->processingSampleRate() / 2 )
|
||||
{
|
||||
BufferManager::clear( _ab, _frames );
|
||||
BufferPool::clear( _ab, _frames );
|
||||
return;
|
||||
}
|
||||
if( m_subOsc != NULL )
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "PlayHandle.h"
|
||||
#include "BufferManager.h"
|
||||
#include "BufferPool.h"
|
||||
#include "Engine.h"
|
||||
#include "Mixer.h"
|
||||
|
||||
@@ -36,7 +36,7 @@ PlayHandle::PlayHandle(const Type type, f_cnt_t offset) :
|
||||
m_type(type),
|
||||
m_offset(offset),
|
||||
m_affinity(QThread::currentThread()),
|
||||
m_playHandleBuffer(BufferManager::acquire()),
|
||||
m_playHandleBuffer(BufferPool::acquire()),
|
||||
m_bufferReleased(true),
|
||||
m_usesBuffer(true)
|
||||
{
|
||||
@@ -45,7 +45,7 @@ PlayHandle::PlayHandle(const Type type, f_cnt_t offset) :
|
||||
|
||||
PlayHandle::~PlayHandle()
|
||||
{
|
||||
BufferManager::release(m_playHandleBuffer);
|
||||
BufferPool::release(m_playHandleBuffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ void PlayHandle::doProcessing()
|
||||
if( m_usesBuffer )
|
||||
{
|
||||
m_bufferReleased = false;
|
||||
BufferManager::clear(m_playHandleBuffer, Engine::mixer()->framesPerPeriod());
|
||||
BufferPool::clear(m_playHandleBuffer, Engine::mixer()->framesPerPeriod());
|
||||
play( buffer() );
|
||||
}
|
||||
else
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <QDebug>
|
||||
#endif
|
||||
|
||||
#include "BufferManager.h"
|
||||
#include "BufferPool.h"
|
||||
#include "RemotePlugin.h"
|
||||
#include "Mixer.h"
|
||||
#include "Engine.h"
|
||||
@@ -287,7 +287,7 @@ bool RemotePlugin::process( const sampleFrame * _in_buf,
|
||||
{
|
||||
if( _out_buf != NULL )
|
||||
{
|
||||
BufferManager::clear( _out_buf, frames );
|
||||
BufferPool::clear( _out_buf, frames );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -306,7 +306,7 @@ bool RemotePlugin::process( const sampleFrame * _in_buf,
|
||||
}
|
||||
if( _out_buf != NULL )
|
||||
{
|
||||
BufferManager::clear( _out_buf, frames );
|
||||
BufferPool::clear( _out_buf, frames );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -380,7 +380,7 @@ bool RemotePlugin::process( const sampleFrame * _in_buf,
|
||||
sampleFrame * o = (sampleFrame *) ( m_shm +
|
||||
m_inputCount*frames );
|
||||
// clear buffer, if plugin didn't fill up both channels
|
||||
BufferManager::clear( _out_buf, frames );
|
||||
BufferPool::clear( _out_buf, frames );
|
||||
|
||||
for( ch_cnt_t ch = 0; ch <
|
||||
qMin<int>( DEFAULT_CHANNELS, outputs ); ++ch )
|
||||
|
||||
@@ -29,14 +29,14 @@
|
||||
#include "Engine.h"
|
||||
#include "Mixer.h"
|
||||
#include "MixHelpers.h"
|
||||
#include "BufferManager.h"
|
||||
#include "BufferPool.h"
|
||||
|
||||
|
||||
AudioPort::AudioPort( const QString & _name, bool _has_effect_chain,
|
||||
FloatModel * volumeModel, FloatModel * panningModel,
|
||||
BoolModel * mutedModel ) :
|
||||
m_bufferUsage( false ),
|
||||
m_portBuffer( BufferManager::acquire() ),
|
||||
m_portBuffer( BufferPool::acquire() ),
|
||||
m_extOutputEnabled( false ),
|
||||
m_nextFxChannel( 0 ),
|
||||
m_name( "unnamed port" ),
|
||||
@@ -56,7 +56,7 @@ AudioPort::~AudioPort()
|
||||
{
|
||||
setExtOutputEnabled( false );
|
||||
Engine::mixer()->removeAudioPort( this );
|
||||
BufferManager::release( m_portBuffer );
|
||||
BufferPool::release( m_portBuffer );
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ void AudioPort::doProcessing()
|
||||
const fpp_t fpp = Engine::mixer()->framesPerPeriod();
|
||||
|
||||
// clear the buffer
|
||||
BufferManager::clear( m_portBuffer, fpp );
|
||||
BufferPool::clear( m_portBuffer, fpp );
|
||||
|
||||
//qDebug( "Playhandles: %d", m_playHandles.size() );
|
||||
for( PlayHandle * ph : m_playHandles ) // now we mix all playhandle buffers into the audioport buffer
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "ToolTip.h"
|
||||
#include "Song.h"
|
||||
|
||||
#include "BufferManager.h"
|
||||
#include "BufferPool.h"
|
||||
|
||||
|
||||
VisualizationWidget::VisualizationWidget( const QPixmap & _bg, QWidget * _p,
|
||||
@@ -55,7 +55,7 @@ VisualizationWidget::VisualizationWidget( const QPixmap & _bg, QWidget * _p,
|
||||
const fpp_t frames = Engine::mixer()->framesPerPeriod();
|
||||
m_buffer = new sampleFrame[frames];
|
||||
|
||||
BufferManager::clear( m_buffer, frames );
|
||||
BufferPool::clear( m_buffer, frames );
|
||||
|
||||
|
||||
ToolTip::add( this, tr( "Oscilloscope" ) );
|
||||
|
||||
Reference in New Issue
Block a user