Remove MemoryManager (#7128)

Removes `MemoryManager` and the use of rpmalloc in favor of the `new` and `delete` operators found in C++.

---------

Co-authored-by: Veratil <veratil@gmail.com>
This commit is contained in:
TechnoPorg
2024-02-25 11:49:56 -07:00
committed by GitHub
parent 03d067b105
commit c991a85eef
47 changed files with 42 additions and 359 deletions

3
.gitmodules vendored
View File

@@ -1,9 +1,6 @@
[submodule "src/3rdparty/qt5-x11embed"]
path = src/3rdparty/qt5-x11embed
url = https://github.com/Lukas-W/qt5-x11embed.git
[submodule "src/3rdparty/rpmalloc/rpmalloc"]
path = src/3rdparty/rpmalloc/rpmalloc
url = https://github.com/mjansson/rpmalloc.git
[submodule "plugins/ZynAddSubFx/zynaddsubfx"]
path = plugins/ZynAddSubFx/zynaddsubfx
url = https://github.com/lmms/zynaddsubfx.git

View File

@@ -29,7 +29,6 @@
#include <QString>
#include <QMutex>
#include "MemoryManager.h"
#include "PlayHandle.h"
namespace lmms
@@ -41,7 +40,6 @@ class BoolModel;
class AudioPort : public ThreadableJob
{
MM_OPERATORS
public:
AudioPort( const QString & _name, bool _has_effect_chain = true,
FloatModel * volumeModel = nullptr, FloatModel * panningModel = nullptr,

View File

@@ -33,7 +33,6 @@
#include "Model.h"
#include "TimePos.h"
#include "ValueBuffer.h"
#include "MemoryManager.h"
#include "ModelVisitor.h"
@@ -77,7 +76,6 @@ class ControllerConnection;
class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject
{
Q_OBJECT
MM_OPERATORS
public:
using AutoModelVector = std::vector<AutomatableModel*>;

View File

@@ -40,7 +40,6 @@
#include "lmms_basics.h"
#include "lmms_constants.h"
#include "interpolation.h"
#include "MemoryManager.h"
namespace lmms
{
@@ -50,7 +49,6 @@ template<ch_cnt_t CHANNELS=DEFAULT_CHANNELS> class BasicFilters;
template<ch_cnt_t CHANNELS>
class LinkwitzRiley
{
MM_OPERATORS
public:
LinkwitzRiley( float sampleRate )
{
@@ -145,7 +143,6 @@ using StereoLinkwitzRiley = LinkwitzRiley<2>;
template<ch_cnt_t CHANNELS>
class BiQuad
{
MM_OPERATORS
public:
BiQuad()
{
@@ -188,7 +185,6 @@ using StereoBiQuad = BiQuad<2>;
template<ch_cnt_t CHANNELS>
class OnePole
{
MM_OPERATORS
public:
OnePole()
{
@@ -222,7 +218,6 @@ using StereoOnePole = OnePole<2>;
template<ch_cnt_t CHANNELS>
class BasicFilters
{
MM_OPERATORS
public:
enum class FilterType
{

View File

@@ -50,7 +50,6 @@ class TrackView;
class LMMS_EXPORT Clip : public Model, public JournallingObject
{
Q_OBJECT
MM_OPERATORS
mapPropertyFromModel(bool,isMuted,setMuted,m_mutedModel);
mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel);
public:

View File

@@ -28,9 +28,9 @@
#include <map>
#include <QDomDocument>
#include <vector>
#include "lmms_export.h"
#include "MemoryManager.h"
class QTextStream;
@@ -42,7 +42,6 @@ class ProjectVersion;
class LMMS_EXPORT DataFile : public QDomDocument
{
MM_OPERATORS
using UpgradeMethod = void(DataFile::*)();
@@ -149,7 +148,6 @@ private:
QDomElement m_head;
Type m_type;
unsigned int m_fileVersion;
} ;

View File

@@ -29,7 +29,6 @@
#include "lmms_basics.h"
#include "lmms_math.h"
#include "interpolation.h"
#include "MemoryManager.h"
namespace lmms
{
@@ -74,20 +73,20 @@ public:
m_delay( 0 ),
m_fraction( 0.0 )
{
m_buffer = MM_ALLOC<frame>(maxDelay );
m_buffer = new frame[maxDelay];
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
virtual ~CombFeedback()
{
MM_FREE( m_buffer );
delete[] m_buffer;
}
inline void setMaxDelay( int maxDelay )
{
if( maxDelay > m_size )
{
MM_FREE( m_buffer );
m_buffer = MM_ALLOC<frame>( maxDelay );
delete[] m_buffer;
m_buffer = new frame[maxDelay];
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
m_size = maxDelay;
@@ -145,20 +144,20 @@ class CombFeedfwd
m_delay( 0 ),
m_fraction( 0.0 )
{
m_buffer = MM_ALLOC<frame>( maxDelay );
m_buffer = new frame[maxDelay];
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
virtual ~CombFeedfwd()
{
MM_FREE( m_buffer );
delete[] m_buffer;
}
inline void setMaxDelay( int maxDelay )
{
if( maxDelay > m_size )
{
MM_FREE( m_buffer );
m_buffer = MM_ALLOC<frame>( maxDelay );
delete[] m_buffer;
m_buffer = new frame[maxDelay];
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
m_size = maxDelay;
@@ -216,20 +215,20 @@ class CombFeedbackDualtap
m_delay( 0 ),
m_fraction( 0.0 )
{
m_buffer = MM_ALLOC<frame>( maxDelay );
m_buffer = new frame[maxDelay];
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
virtual ~CombFeedbackDualtap()
{
MM_FREE( m_buffer );
delete[] m_buffer;
}
inline void setMaxDelay( int maxDelay )
{
if( maxDelay > m_size )
{
MM_FREE( m_buffer );
m_buffer = MM_ALLOC<frame>( maxDelay );
delete[] m_buffer;
m_buffer = new frame[maxDelay];
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
m_size = maxDelay;
@@ -297,20 +296,20 @@ public:
m_delay( 0 ),
m_fraction( 0.0 )
{
m_buffer = MM_ALLOC<frame>( maxDelay );
m_buffer = new frame[maxDelay];
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
virtual ~AllpassDelay()
{
MM_FREE( m_buffer );
delete[] m_buffer;
}
inline void setMaxDelay( int maxDelay )
{
if( maxDelay > m_size )
{
MM_FREE( m_buffer );
m_buffer = MM_ALLOC<frame>( maxDelay );
delete[] m_buffer;
m_buffer = new frame[maxDelay];
memset( m_buffer, 0, sizeof( frame ) * maxDelay );
}
m_size = maxDelay;

View File

@@ -27,7 +27,6 @@
#define LMMS_DETUNING_HELPER_H
#include "InlineAutomation.h"
#include "MemoryManager.h"
namespace lmms
{
@@ -35,7 +34,6 @@ namespace lmms
class DetuningHelper : public InlineAutomation
{
Q_OBJECT
MM_OPERATORS
public:
DetuningHelper() :
InlineAutomation()

View File

@@ -31,7 +31,6 @@
#include "AudioEngine.h"
#include "AutomatableModel.h"
#include "TempoSyncKnobModel.h"
#include "MemoryManager.h"
namespace lmms
{
@@ -49,7 +48,6 @@ class EffectView;
class LMMS_EXPORT Effect : public Plugin
{
MM_OPERATORS
Q_OBJECT
public:
Effect( const Plugin::Descriptor * _desc,

View File

@@ -31,7 +31,6 @@
#include "Flags.h"
#include "lmms_export.h"
#include "lmms_basics.h"
#include "MemoryManager.h"
#include "Plugin.h"
#include "TimePos.h"
@@ -47,7 +46,6 @@ class Track;
class LMMS_EXPORT Instrument : public Plugin
{
MM_OPERATORS
public:
enum class Flag
{

View File

@@ -60,7 +60,6 @@ class MidiCCRackView;
class LMMS_EXPORT InstrumentTrack : public Track, public MidiEventProcessor
{
Q_OBJECT
MM_OPERATORS
mapPropertyFromModel(int,getVolume,setVolume,m_volumeModel);
public:
InstrumentTrack( TrackContainer* tc );

View File

@@ -1,111 +0,0 @@
/*
* MemoryManager.h
*
* Copyright (c) 2017 Lukas W <lukaswhl/at/gmail.com>
* Copyright (c) 2014 Vesa Kivimäki
* Copyright (c) 2007-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef LMMS_MEMORY_MANAGER_H
#define LMMS_MEMORY_MANAGER_H
#include <cstddef>
#include <vector>
#include "lmms_export.h"
namespace lmms
{
class LMMS_EXPORT MemoryManager
{
public:
struct ThreadGuard
{
ThreadGuard();
~ThreadGuard();
};
static void * alloc( size_t size );
static void free( void * ptr );
};
template<typename T>
struct MmAllocator
{
using value_type = T;
template<class U> struct rebind {
using other = MmAllocator<U>;
};
T* allocate( std::size_t n )
{
return reinterpret_cast<T*>( MemoryManager::alloc( sizeof(T) * n ) );
}
void deallocate( T* p, std::size_t )
{
MemoryManager::free( p );
}
using vector = std::vector<T, MmAllocator<T>>;
};
#define MM_OPERATORS \
public: \
static void * operator new ( size_t size ) \
{ \
return MemoryManager::alloc( size ); \
} \
static void * operator new[] ( size_t size ) \
{ \
return MemoryManager::alloc( size ); \
} \
static void operator delete ( void * ptr ) \
{ \
MemoryManager::free( ptr ); \
} \
static void operator delete[] ( void * ptr ) \
{ \
MemoryManager::free( ptr ); \
}
// for use in cases where overriding new/delete isn't a possibility
template<typename T>
T* MM_ALLOC(size_t count)
{
return reinterpret_cast<T*>(
MemoryManager::alloc(sizeof(T) * count));
}
// and just for symmetry...
template<typename T>
void MM_FREE(T* ptr)
{
MemoryManager::free(ptr);
}
} // namespace lmms
#endif // LMMS_MEMORY_MANAGER_H

View File

@@ -26,7 +26,6 @@
#define LMMS_MIDI_EVENT_PROCESSOR_H
#include "MidiEvent.h"
#include "MemoryManager.h"
#include "TimePos.h"
namespace lmms
@@ -35,7 +34,6 @@ namespace lmms
// all classes being able to process MIDI-events should inherit from this
class MidiEventProcessor
{
MM_OPERATORS
public:
MidiEventProcessor() = default;

View File

@@ -32,7 +32,6 @@
#include "Note.h"
#include "PlayHandle.h"
#include "Track.h"
#include "MemoryManager.h"
class QReadWriteLock;
@@ -47,7 +46,6 @@ using ConstNotePlayHandleList = QList<const NotePlayHandle*>;
class LMMS_EXPORT NotePlayHandle : public PlayHandle, public Note
{
MM_OPERATORS
public:
void * m_pluginData;
std::unique_ptr<BasicFilters<>> m_filter;
@@ -273,7 +271,6 @@ public:
private:
class BaseDetuning
{
MM_OPERATORS
public:
BaseDetuning( DetuningHelper* detuning );
@@ -341,7 +338,6 @@ const int NPH_CACHE_INCREMENT = 16;
class NotePlayHandleManager
{
MM_OPERATORS
public:
static void init();
static NotePlayHandle * acquire( InstrumentTrack* instrumentTrack,

View File

@@ -30,7 +30,6 @@
#include "JournallingObject.h"
#include "Model.h"
#include "MemoryManager.h"
class QWidget;
@@ -71,7 +70,6 @@ class PluginView;
*/
class LMMS_EXPORT Plugin : public Model, public JournallingObject
{
MM_OPERATORS
Q_OBJECT
public:
enum class Type

View File

@@ -29,7 +29,7 @@
#include <cmath>
#include <QObject>
#include "lmms_basics.h"
#include "MemoryManager.h"
#include "lmms_export.h"
namespace lmms
@@ -41,7 +41,6 @@ namespace lmms
class LMMS_EXPORT RingBuffer : public QObject
{
Q_OBJECT
MM_OPERATORS
public:
/** \brief Constructs a ringbuffer of specified size, will not care about samplerate changes
* \param size The size of the buffer in frames. The actual size will be size + period size

View File

@@ -67,7 +67,6 @@ char const *const FILENAME_FILTER = "[\\0000-\x1f\"*/:<>?\\\\|\x7f]";
class LMMS_EXPORT Track : public Model, public JournallingObject
{
Q_OBJECT
MM_OPERATORS
mapPropertyFromModel(bool,isMuted,setMuted,m_mutedModel);
mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel);
public:

View File

@@ -28,7 +28,6 @@
#include <vector>
#include "MemoryManager.h"
#include "lmms_export.h"
namespace lmms
@@ -37,7 +36,6 @@ namespace lmms
class LMMS_EXPORT ValueBuffer : public std::vector<float>
{
MM_OPERATORS
public:
ValueBuffer() = default;
ValueBuffer(int length);

View File

@@ -31,7 +31,6 @@
#include "Instrument.h"
#include "InstrumentView.h"
#include "Graph.h"
#include "MemoryManager.h"
namespace lmms
{
@@ -48,7 +47,6 @@ class PixmapButton;
class BSynth
{
MM_OPERATORS
public:
BSynth( float * sample, NotePlayHandle * _nph,
bool _interpolation, float factor,

View File

@@ -62,7 +62,7 @@ BitcrushEffect::BitcrushEffect( Model * parent, const Descriptor::SubPluginFeatu
m_sampleRate( Engine::audioEngine()->processingSampleRate() ),
m_filter( m_sampleRate )
{
m_buffer = MM_ALLOC<sampleFrame>( Engine::audioEngine()->framesPerPeriod() * OS_RATE );
m_buffer = new sampleFrame[Engine::audioEngine()->framesPerPeriod() * OS_RATE];
m_filter.setLowpass( m_sampleRate * ( CUTOFF_RATIO * OS_RATIO ) );
m_needsUpdate = true;
@@ -77,7 +77,7 @@ BitcrushEffect::BitcrushEffect( Model * parent, const Descriptor::SubPluginFeatu
BitcrushEffect::~BitcrushEffect()
{
MM_FREE( m_buffer );
delete[] m_buffer;
}

View File

@@ -64,16 +64,16 @@ CrossoverEQEffect::CrossoverEQEffect( Model* parent, const Descriptor::SubPlugin
m_hp4( m_sampleRate ),
m_needsUpdate( true )
{
m_tmp1 = MM_ALLOC<sampleFrame>( Engine::audioEngine()->framesPerPeriod() );
m_tmp2 = MM_ALLOC<sampleFrame>( Engine::audioEngine()->framesPerPeriod() );
m_work = MM_ALLOC<sampleFrame>( Engine::audioEngine()->framesPerPeriod() );
m_tmp2 = new sampleFrame[Engine::audioEngine()->framesPerPeriod()];
m_tmp1 = new sampleFrame[Engine::audioEngine()->framesPerPeriod()];
m_work = new sampleFrame[Engine::audioEngine()->framesPerPeriod()];
}
CrossoverEQEffect::~CrossoverEQEffect()
{
MM_FREE( m_tmp1 );
MM_FREE( m_tmp2 );
MM_FREE( m_work );
delete[] m_tmp1;
delete[] m_tmp2;
delete[] m_work;
}
void CrossoverEQEffect::sampleRateChanged()

View File

@@ -26,7 +26,6 @@
#include "Gb_Apu.h"
#include "Multi_Buffer.h"
#include "MemoryManager.h"
namespace lmms
{
@@ -34,7 +33,6 @@ namespace lmms
class GbApuWrapper : private Gb_Apu
{
MM_OPERATORS
public:
GbApuWrapper() = default;
~GbApuWrapper() = default;

View File

@@ -38,7 +38,6 @@
#include "Knob.h"
#include "LcdSpinBox.h"
#include "LedCheckBox.h"
#include "MemoryManager.h"
#include "gig.h"
@@ -236,7 +235,6 @@ public:
class GigInstrument : public Instrument
{
Q_OBJECT
MM_OPERATORS
mapPropertyFromModel( int, getBank, setBank, m_bankNum );
mapPropertyFromModel( int, getPatch, setPatch, m_patchNum );

View File

@@ -31,7 +31,6 @@
#include "lmms_math.h"
#include "interpolation.h"
#include "MemoryManager.h"
namespace lmms
{
@@ -40,7 +39,6 @@ namespace lmms
template<class FX = DspEffectLibrary::StereoBypass>
class KickerOsc
{
MM_OPERATORS
public:
KickerOsc( const FX & fx, const float start, const float end, const float noise, const float offset,
const float slope, const float env, const float diststart, const float distend, const float length ) :

View File

@@ -36,7 +36,6 @@
#include "LadspaControl.h"
#include "LadspaSubPluginFeatures.h"
#include "AutomationClip.h"
#include "MemoryManager.h"
#include "ValueBuffer.h"
#include "Song.h"
@@ -326,7 +325,7 @@ void LadspaEffect::pluginInstantiation()
manager->isPortInput( m_key, port ) )
{
p->rate = BufferRate::ChannelIn;
p->buffer = MM_ALLOC<LADSPA_Data>( Engine::audioEngine()->framesPerPeriod() );
p->buffer = new LADSPA_Data[Engine::audioEngine()->framesPerPeriod()];
inbuf[ inputch ] = p->buffer;
inputch++;
}
@@ -341,24 +340,24 @@ void LadspaEffect::pluginInstantiation()
}
else
{
p->buffer = MM_ALLOC<LADSPA_Data>( Engine::audioEngine()->framesPerPeriod() );
p->buffer = new LADSPA_Data[Engine::audioEngine()->framesPerPeriod()];
m_inPlaceBroken = true;
}
}
else if( manager->isPortInput( m_key, port ) )
{
p->rate = BufferRate::AudioRateInput;
p->buffer = MM_ALLOC<LADSPA_Data>( Engine::audioEngine()->framesPerPeriod() );
p->buffer = new LADSPA_Data[Engine::audioEngine()->framesPerPeriod()];
}
else
{
p->rate = BufferRate::AudioRateOutput;
p->buffer = MM_ALLOC<LADSPA_Data>( Engine::audioEngine()->framesPerPeriod() );
p->buffer = new LADSPA_Data[Engine::audioEngine()->framesPerPeriod()];
}
}
else
{
p->buffer = MM_ALLOC<LADSPA_Data>( 1 );
p->buffer = new LADSPA_Data[1];
if( manager->isPortInput( m_key, port ) )
{
@@ -557,7 +556,7 @@ void LadspaEffect::pluginDestruction()
port_desc_t * pp = m_ports.at( proc ).at( port );
if( m_inPlaceBroken || pp->rate != BufferRate::ChannelOut )
{
if( pp->buffer) MM_FREE( pp->buffer );
if( pp->buffer) delete[] pp->buffer;
}
delete pp;
}

View File

@@ -173,7 +173,6 @@ class ComboBox;
class MonstroSynth
{
MM_OPERATORS
public:
MonstroSynth( MonstroInstrument * _i, NotePlayHandle * _nph );
virtual ~MonstroSynth() = default;

View File

@@ -58,7 +58,7 @@ MultitapEchoEffect::MultitapEchoEffect( Model* parent, const Descriptor::SubPlug
m_sampleRate( Engine::audioEngine()->processingSampleRate() ),
m_sampleRatio( 1.0f / m_sampleRate )
{
m_work = MM_ALLOC<sampleFrame>( Engine::audioEngine()->framesPerPeriod() );
m_work = new sampleFrame[Engine::audioEngine()->framesPerPeriod()];
m_buffer.reset();
m_stages = static_cast<int>( m_controls.m_stages.value() );
updateFilters( 0, 19 );
@@ -67,7 +67,7 @@ MultitapEchoEffect::MultitapEchoEffect( Model* parent, const Descriptor::SubPlug
MultitapEchoEffect::~MultitapEchoEffect()
{
MM_FREE( m_work );
delete[] m_work;
}

View File

@@ -31,7 +31,6 @@
#include "InstrumentView.h"
#include "AutomatableModel.h"
#include "PixmapButton.h"
#include "MemoryManager.h"
#define makeknob( name, x, y, hint, unit, oname ) \
@@ -92,7 +91,6 @@ class NesInstrumentView;
class NesObject
{
MM_OPERATORS
public:
NesObject( NesInstrument * nes, const sample_rate_t samplerate, NotePlayHandle * nph );
virtual ~NesObject() = default;

View File

@@ -84,7 +84,6 @@ const float CENT = 1.0f / 1200.0f;
class OscillatorObject : public Model
{
Q_OBJECT
MM_OPERATORS
private:
int m_numOscillators;
IntModel m_waveShape;
@@ -159,7 +158,6 @@ private:
struct oscPtr
{
MM_OPERATORS
Oscillator * oscLeft;
Oscillator * oscRight;
float phaseOffsetLeft[NUM_OSCILLATORS];
@@ -196,7 +194,6 @@ private:
struct OscillatorKnobs
{
MM_OPERATORS
OscillatorKnobs(
Knob * h,
Knob * v,

View File

@@ -31,7 +31,6 @@
#include "Sample.h"
#include "SampleBuffer.h"
#include "AutomatableModel.h"
#include "MemoryManager.h"
namespace lmms
{
@@ -87,7 +86,6 @@ public slots:
private:
struct handle_data
{
MM_OPERATORS
Sample::PlaybackState* state;
bool tuned;
std::shared_ptr<Sample> sample;

View File

@@ -34,7 +34,6 @@
#include "Instrument.h"
#include "InstrumentView.h"
#include "LcdSpinBox.h"
#include "MemoryManager.h"
class QLabel;

View File

@@ -31,7 +31,6 @@
#include "AutomatableModel.h"
#include "Instrument.h"
#include "InstrumentView.h"
#include "MemoryManager.h"
namespace lmms
{
@@ -78,7 +77,6 @@ class SfxrInstrumentView;
class SfxrSynth
{
MM_OPERATORS
public:
SfxrSynth( const SfxrInstrument * s );
virtual ~SfxrSynth() = default;

View File

@@ -48,7 +48,6 @@ class PixmapButton;
class VoiceObject : public Model
{
Q_OBJECT
MM_OPERATORS
public:
enum class WaveForm {
Square = 0,

View File

@@ -57,7 +57,6 @@ const int NUM_OF_OSCILLATORS = 3;
class OscillatorObject : public Model
{
MM_OPERATORS
Q_OBJECT
public:
OscillatorObject( Model * _parent, int _idx );
@@ -139,7 +138,6 @@ private:
struct oscPtr
{
MM_OPERATORS
Oscillator * oscLeft;
Oscillator * oscRight;
} ;
@@ -170,7 +168,6 @@ private:
struct OscillatorKnobs
{
MM_OPERATORS
OscillatorKnobs( Knob * v,
Knob * p,
Knob * c,

View File

@@ -33,7 +33,6 @@
#include "InstrumentTrack.h"
#include "NotePlayHandle.h"
#include "VibratingString.h"
#include "MemoryManager.h"
#include "base64.h"
#include "CaptionMenu.h"
#include "volume.h"
@@ -67,7 +66,6 @@ Plugin::Descriptor PLUGIN_EXPORT vibedstrings_plugin_descriptor =
class Vibed::StringContainer
{
MM_OPERATORS
public:
StringContainer(float pitch, sample_rate_t sampleRate, int bufferLength) :
m_pitch(pitch), m_sampleRate(sampleRate), m_bufferLength(bufferLength) {}

View File

@@ -32,7 +32,6 @@
#include "AutomatableModel.h"
#include "TempoSyncKnob.h"
#include <samplerate.h>
#include "MemoryManager.h"
namespace lmms
{
@@ -88,7 +87,6 @@ class WatsynView;
class WatsynObject
{
MM_OPERATORS
public:
WatsynObject( float * _A1wave, float * _A2wave,
float * _B1wave, float * _B2wave,

View File

@@ -30,7 +30,6 @@
#include <limits>
#include "AutomatableModel.h"
#include "Graph.h"
#include "MemoryManager.h"
namespace lmms
{
@@ -102,7 +101,6 @@ public:
class ExprSynth
{
MM_OPERATORS
public:
ExprSynth(const WaveSample* gW1, const WaveSample* gW2, const WaveSample* gW3, ExprFront* exprO1, ExprFront* exprO2, NotePlayHandle* nph,
const sample_rate_t sample_rate, const FloatModel* pan1, const FloatModel* pan2, float rel_trans);

View File

@@ -4,7 +4,6 @@ IF(LMMS_BUILD_LINUX AND WANT_VST)
ENDIF()
ADD_SUBDIRECTORY(hiir)
ADD_SUBDIRECTORY(rpmalloc)
ADD_SUBDIRECTORY(weakjack)
if(MINGW)

View File

@@ -1,49 +0,0 @@
add_library(rpmalloc STATIC
rpmalloc/rpmalloc/rpmalloc.c
rpmalloc/rpmalloc/rpmalloc.h
)
target_include_directories(rpmalloc PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/rpmalloc/rpmalloc
)
set_property(TARGET rpmalloc PROPERTY C_STANDARD 11)
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(rpmalloc
PRIVATE -Wno-unused-variable
)
endif()
if (NOT LMMS_BUILD_WIN32)
target_compile_definitions(rpmalloc
PRIVATE -D_GNU_SOURCE
)
endif()
if(MINGW)
target_compile_definitions(rpmalloc
PRIVATE -D_WIN32_WINNT=0x600
)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
# rpmalloc uses GCC builtin "__builtin_umull_overflow" with ENABLE_VALIDATE_ARGS,
# which is only available starting with GCC 5
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 5)
set(ENABLE_VALIDATE_ARGS OFF)
else ()
set(ENABLE_VALIDATE_ARGS ON)
endif()
target_compile_definitions(rpmalloc
PRIVATE -DENABLE_ASSERTS=1 -DENABLE_VALIDATE_ARGS=${ENABLE_VALIDATE_ARGS}
)
endif()
option(LMMS_ENABLE_MALLOC_STATS "Enables statistics for rpmalloc" OFF)
if (LMMS_ENABLE_MALLOC_STATS)
target_compile_definitions(rpmalloc
PRIVATE -DENABLE_STATISTICS=1
)
endif()

View File

@@ -186,7 +186,6 @@ SET(LMMS_REQUIRED_LIBS ${LMMS_REQUIRED_LIBS}
${SUIL_LIBRARIES}
${LILV_LIBRARIES}
${FFTW3F_LIBRARIES}
rpmalloc
SampleRate::samplerate
SndFile::sndfile
${EXTRA_LIBRARIES}

View File

@@ -30,7 +30,6 @@
#include "denormals.h"
#include "AudioEngine.h"
#include "MemoryManager.h"
#include "ThreadableJob.h"
#if __SSE__
@@ -167,7 +166,6 @@ void AudioEngineWorkerThread::startAndWaitForJobs()
void AudioEngineWorkerThread::run()
{
MemoryManager::ThreadGuard mmThreadGuard; Q_UNUSED(mmThreadGuard);
disable_denormals();
QMutex m;

View File

@@ -28,7 +28,6 @@
#include <cstring>
#include "MemoryManager.h"
namespace lmms
{
@@ -43,7 +42,7 @@ void BufferManager::init( fpp_t fpp )
sampleFrame * BufferManager::acquire()
{
return MM_ALLOC<sampleFrame>( s_framesPerPeriod );
return new sampleFrame[s_framesPerPeriod];
}
void BufferManager::clear( sampleFrame *ab, const f_cnt_t frames, const f_cnt_t offset )
@@ -62,7 +61,7 @@ void BufferManager::clear( surroundSampleFrame * ab, const f_cnt_t frames,
void BufferManager::release( sampleFrame * buf )
{
MM_FREE( buf );
delete[] buf;
}
} // namespace lmms

View File

@@ -39,7 +39,6 @@ set(LMMS_SRCS
core/LinkedModelGroups.cpp
core/LocklessAllocator.cpp
core/MemoryHelper.cpp
core/MemoryManager.cpp
core/MeterModel.cpp
core/MicroTimer.cpp
core/Microtuner.cpp

View File

@@ -1,84 +0,0 @@
/*
* MemoryManager.cpp
*
* Copyright (c) 2017 Lukas W <lukaswhl/at/gmail.com>
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#include "MemoryManager.h"
#include <QtGlobal>
#include "rpmalloc.h"
namespace lmms
{
/// Global static object handling rpmalloc intializing and finalizing
struct MemoryManagerGlobalGuard {
MemoryManagerGlobalGuard() {
rpmalloc_initialize();
}
~MemoryManagerGlobalGuard() {
rpmalloc_finalize();
}
} static mm_global_guard;
namespace {
static thread_local size_t thread_guard_depth;
}
MemoryManager::ThreadGuard::ThreadGuard()
{
if (thread_guard_depth++ == 0) {
rpmalloc_thread_initialize();
}
}
MemoryManager::ThreadGuard::~ThreadGuard()
{
if (--thread_guard_depth == 0) {
rpmalloc_thread_finalize(true);
}
}
static thread_local MemoryManager::ThreadGuard local_mm_thread_guard{};
void* MemoryManager::alloc(size_t size)
{
// Reference local thread guard to ensure it is initialized.
// Compilers may optimize the instance away otherwise.
Q_UNUSED(&local_mm_thread_guard);
Q_ASSERT_X(rpmalloc_is_thread_initialized(), "MemoryManager::alloc", "Thread not initialized");
return rpmalloc(size);
}
void MemoryManager::free(void * ptr)
{
Q_UNUSED(&local_mm_thread_guard);
Q_ASSERT_X(rpmalloc_is_thread_initialized(), "MemoryManager::free", "Thread not initialized");
return rpfree(ptr);
}
} // namespace lmms

View File

@@ -610,9 +610,9 @@ int NotePlayHandleManager::s_size;
void NotePlayHandleManager::init()
{
s_available = MM_ALLOC<NotePlayHandle*>( INITIAL_NPH_CACHE );
s_available = new NotePlayHandle*[INITIAL_NPH_CACHE];
auto n = MM_ALLOC<NotePlayHandle>(INITIAL_NPH_CACHE);
auto n = static_cast<NotePlayHandle *>(std::malloc(sizeof(NotePlayHandle) * INITIAL_NPH_CACHE));
for( int i=0; i < INITIAL_NPH_CACHE; ++i )
{
@@ -655,11 +655,11 @@ void NotePlayHandleManager::release( NotePlayHandle * nph )
void NotePlayHandleManager::extend( int c )
{
s_size += c;
auto tmp = MM_ALLOC<NotePlayHandle*>(s_size);
MM_FREE( s_available );
auto tmp = new NotePlayHandle*[s_size];
delete[] s_available;
s_available = tmp;
auto n = MM_ALLOC<NotePlayHandle>(c);
auto n = static_cast<NotePlayHandle *>(std::malloc(sizeof(NotePlayHandle) * c));
for( int i=0; i < c; ++i )
{
@@ -670,7 +670,7 @@ void NotePlayHandleManager::extend( int c )
void NotePlayHandleManager::free()
{
MM_FREE(s_available);
delete[] s_available;
}

View File

@@ -159,7 +159,6 @@ void ProjectRenderer::startProcessing()
void ProjectRenderer::run()
{
MemoryManager::ThreadGuard mmThreadGuard; Q_UNUSED(mmThreadGuard);
#if 0
#if defined(LMMS_BUILD_LINUX) || defined(LMMS_BUILD_FREEBSD)
#ifdef LMMS_HAVE_SCHED_H