diff --git a/.gitmodules b/.gitmodules index c85f7e5d8e0..82f3e464c0f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/include/AudioPort.h b/include/AudioPort.h index d9803d205e8..9e3ce2bd667 100644 --- a/include/AudioPort.h +++ b/include/AudioPort.h @@ -29,7 +29,6 @@ #include #include -#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, diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index 2264a592eda..87adfdc6e7b 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -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; diff --git a/include/BasicFilters.h b/include/BasicFilters.h index b994aecc6ec..4cde320a638 100644 --- a/include/BasicFilters.h +++ b/include/BasicFilters.h @@ -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 class BasicFilters; template class LinkwitzRiley { - MM_OPERATORS public: LinkwitzRiley( float sampleRate ) { @@ -145,7 +143,6 @@ using StereoLinkwitzRiley = LinkwitzRiley<2>; template class BiQuad { - MM_OPERATORS public: BiQuad() { @@ -188,7 +185,6 @@ using StereoBiQuad = BiQuad<2>; template class OnePole { - MM_OPERATORS public: OnePole() { @@ -222,7 +218,6 @@ using StereoOnePole = OnePole<2>; template class BasicFilters { - MM_OPERATORS public: enum class FilterType { diff --git a/include/Clip.h b/include/Clip.h index 0b540ccfbf7..a520ad4e470 100644 --- a/include/Clip.h +++ b/include/Clip.h @@ -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: diff --git a/include/DataFile.h b/include/DataFile.h index 3f170622906..ce5d4edf4c2 100644 --- a/include/DataFile.h +++ b/include/DataFile.h @@ -28,9 +28,9 @@ #include #include +#include #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 @@ class LMMS_EXPORT DataFile : public QDomDocument QDomElement m_head; Type m_type; unsigned int m_fileVersion; - } ; diff --git a/include/Delay.h b/include/Delay.h index daa871baf4c..71fbe1b00b1 100644 --- a/include/Delay.h +++ b/include/Delay.h @@ -29,7 +29,6 @@ #include "lmms_basics.h" #include "lmms_math.h" #include "interpolation.h" -#include "MemoryManager.h" namespace lmms { @@ -74,20 +73,20 @@ class CombFeedback m_delay( 0 ), m_fraction( 0.0 ) { - m_buffer = MM_ALLOC(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( 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( 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( 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( 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( maxDelay ); + delete[] m_buffer; + m_buffer = new frame[maxDelay]; memset( m_buffer, 0, sizeof( frame ) * maxDelay ); } m_size = maxDelay; @@ -297,20 +296,20 @@ class AllpassDelay m_delay( 0 ), m_fraction( 0.0 ) { - m_buffer = MM_ALLOC( 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( maxDelay ); + delete[] m_buffer; + m_buffer = new frame[maxDelay]; memset( m_buffer, 0, sizeof( frame ) * maxDelay ); } m_size = maxDelay; diff --git a/include/DetuningHelper.h b/include/DetuningHelper.h index e5d5f5712d5..da8eb598350 100644 --- a/include/DetuningHelper.h +++ b/include/DetuningHelper.h @@ -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() diff --git a/include/Effect.h b/include/Effect.h index f2fb6e80f49..8b2ff81f0c4 100644 --- a/include/Effect.h +++ b/include/Effect.h @@ -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, diff --git a/include/Instrument.h b/include/Instrument.h index f23e0b401f3..243bdba61f6 100644 --- a/include/Instrument.h +++ b/include/Instrument.h @@ -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 { diff --git a/include/InstrumentTrack.h b/include/InstrumentTrack.h index 5efafe0c72b..3d84df5979a 100644 --- a/include/InstrumentTrack.h +++ b/include/InstrumentTrack.h @@ -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 ); diff --git a/include/MemoryManager.h b/include/MemoryManager.h deleted file mode 100644 index fa2fe8110f4..00000000000 --- a/include/MemoryManager.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * MemoryManager.h - * - * Copyright (c) 2017 Lukas W - * Copyright (c) 2014 Vesa Kivimäki - * Copyright (c) 2007-2014 Tobias Doerffel - * - * 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 -#include - -#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 -struct MmAllocator -{ - using value_type = T; - template struct rebind { - using other = MmAllocator; - }; - - T* allocate( std::size_t n ) - { - return reinterpret_cast( MemoryManager::alloc( sizeof(T) * n ) ); - } - - void deallocate( T* p, std::size_t ) - { - MemoryManager::free( p ); - } - - using vector = std::vector>; -}; - - -#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 -T* MM_ALLOC(size_t count) -{ - return reinterpret_cast( - MemoryManager::alloc(sizeof(T) * count)); -} - -// and just for symmetry... -template -void MM_FREE(T* ptr) -{ - MemoryManager::free(ptr); -} - - -} // namespace lmms - -#endif // LMMS_MEMORY_MANAGER_H diff --git a/include/MidiEventProcessor.h b/include/MidiEventProcessor.h index 1c45b3e3f5b..0fcb9610ead 100644 --- a/include/MidiEventProcessor.h +++ b/include/MidiEventProcessor.h @@ -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; diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index 7105d6672cd..f70268132f8 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -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; class LMMS_EXPORT NotePlayHandle : public PlayHandle, public Note { - MM_OPERATORS public: void * m_pluginData; std::unique_ptr> m_filter; @@ -273,7 +271,6 @@ class LMMS_EXPORT NotePlayHandle : public PlayHandle, public Note 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, diff --git a/include/Plugin.h b/include/Plugin.h index 439dd95ad16..100e9f658eb 100644 --- a/include/Plugin.h +++ b/include/Plugin.h @@ -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 diff --git a/include/RingBuffer.h b/include/RingBuffer.h index 90a607a13a5..98f72647593 100644 --- a/include/RingBuffer.h +++ b/include/RingBuffer.h @@ -29,7 +29,7 @@ #include #include #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 diff --git a/include/Track.h b/include/Track.h index 1c161984f00..b801bb1828b 100644 --- a/include/Track.h +++ b/include/Track.h @@ -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: diff --git a/include/ValueBuffer.h b/include/ValueBuffer.h index 683d17fb1ff..33d93cde02b 100644 --- a/include/ValueBuffer.h +++ b/include/ValueBuffer.h @@ -28,7 +28,6 @@ #include -#include "MemoryManager.h" #include "lmms_export.h" namespace lmms @@ -37,7 +36,6 @@ namespace lmms class LMMS_EXPORT ValueBuffer : public std::vector { - MM_OPERATORS public: ValueBuffer() = default; ValueBuffer(int length); diff --git a/plugins/BitInvader/BitInvader.h b/plugins/BitInvader/BitInvader.h index a08640e998b..6dce9db8315 100644 --- a/plugins/BitInvader/BitInvader.h +++ b/plugins/BitInvader/BitInvader.h @@ -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, diff --git a/plugins/Bitcrush/Bitcrush.cpp b/plugins/Bitcrush/Bitcrush.cpp index 8d29186b5e7..df4a8605dd8 100644 --- a/plugins/Bitcrush/Bitcrush.cpp +++ b/plugins/Bitcrush/Bitcrush.cpp @@ -62,7 +62,7 @@ BitcrushEffect::BitcrushEffect( Model * parent, const Descriptor::SubPluginFeatu m_sampleRate( Engine::audioEngine()->processingSampleRate() ), m_filter( m_sampleRate ) { - m_buffer = MM_ALLOC( 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; } diff --git a/plugins/CrossoverEQ/CrossoverEQ.cpp b/plugins/CrossoverEQ/CrossoverEQ.cpp index c4334677cb4..4dca94a4ccd 100644 --- a/plugins/CrossoverEQ/CrossoverEQ.cpp +++ b/plugins/CrossoverEQ/CrossoverEQ.cpp @@ -64,16 +64,16 @@ CrossoverEQEffect::CrossoverEQEffect( Model* parent, const Descriptor::SubPlugin m_hp4( m_sampleRate ), m_needsUpdate( true ) { - m_tmp1 = MM_ALLOC( Engine::audioEngine()->framesPerPeriod() ); - m_tmp2 = MM_ALLOC( Engine::audioEngine()->framesPerPeriod() ); - m_work = MM_ALLOC( 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() diff --git a/plugins/FreeBoy/GbApuWrapper.h b/plugins/FreeBoy/GbApuWrapper.h index 493a2873153..3b95869d579 100644 --- a/plugins/FreeBoy/GbApuWrapper.h +++ b/plugins/FreeBoy/GbApuWrapper.h @@ -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; diff --git a/plugins/GigPlayer/GigPlayer.h b/plugins/GigPlayer/GigPlayer.h index e5039f109be..986018654a7 100644 --- a/plugins/GigPlayer/GigPlayer.h +++ b/plugins/GigPlayer/GigPlayer.h @@ -38,7 +38,6 @@ #include "Knob.h" #include "LcdSpinBox.h" #include "LedCheckBox.h" -#include "MemoryManager.h" #include "gig.h" @@ -236,7 +235,6 @@ class GigNote class GigInstrument : public Instrument { Q_OBJECT - MM_OPERATORS mapPropertyFromModel( int, getBank, setBank, m_bankNum ); mapPropertyFromModel( int, getPatch, setPatch, m_patchNum ); diff --git a/plugins/Kicker/KickerOsc.h b/plugins/Kicker/KickerOsc.h index 1accb50a44c..69436c5fc9d 100644 --- a/plugins/Kicker/KickerOsc.h +++ b/plugins/Kicker/KickerOsc.h @@ -31,7 +31,6 @@ #include "lmms_math.h" #include "interpolation.h" -#include "MemoryManager.h" namespace lmms { @@ -40,7 +39,6 @@ namespace lmms template 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 ) : diff --git a/plugins/LadspaEffect/LadspaEffect.cpp b/plugins/LadspaEffect/LadspaEffect.cpp index cc754a82962..837bd554c2b 100644 --- a/plugins/LadspaEffect/LadspaEffect.cpp +++ b/plugins/LadspaEffect/LadspaEffect.cpp @@ -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( 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( 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( Engine::audioEngine()->framesPerPeriod() ); + p->buffer = new LADSPA_Data[Engine::audioEngine()->framesPerPeriod()]; } else { p->rate = BufferRate::AudioRateOutput; - p->buffer = MM_ALLOC( Engine::audioEngine()->framesPerPeriod() ); + p->buffer = new LADSPA_Data[Engine::audioEngine()->framesPerPeriod()]; } } else { - p->buffer = MM_ALLOC( 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; } diff --git a/plugins/Monstro/Monstro.h b/plugins/Monstro/Monstro.h index 21efedaf314..919409b2de5 100644 --- a/plugins/Monstro/Monstro.h +++ b/plugins/Monstro/Monstro.h @@ -173,7 +173,6 @@ class ComboBox; class MonstroSynth { - MM_OPERATORS public: MonstroSynth( MonstroInstrument * _i, NotePlayHandle * _nph ); virtual ~MonstroSynth() = default; diff --git a/plugins/MultitapEcho/MultitapEcho.cpp b/plugins/MultitapEcho/MultitapEcho.cpp index 4f5e9fdf8b3..ff3ca828a27 100644 --- a/plugins/MultitapEcho/MultitapEcho.cpp +++ b/plugins/MultitapEcho/MultitapEcho.cpp @@ -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( Engine::audioEngine()->framesPerPeriod() ); + m_work = new sampleFrame[Engine::audioEngine()->framesPerPeriod()]; m_buffer.reset(); m_stages = static_cast( 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; } diff --git a/plugins/Nes/Nes.h b/plugins/Nes/Nes.h index b4102f31d10..a05b3a2f85c 100644 --- a/plugins/Nes/Nes.h +++ b/plugins/Nes/Nes.h @@ -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; diff --git a/plugins/Organic/Organic.h b/plugins/Organic/Organic.h index a46b7882ffa..e50550e5e2d 100644 --- a/plugins/Organic/Organic.h +++ b/plugins/Organic/Organic.h @@ -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 @@ public slots: struct oscPtr { - MM_OPERATORS Oscillator * oscLeft; Oscillator * oscRight; float phaseOffsetLeft[NUM_OSCILLATORS]; @@ -196,7 +194,6 @@ class OrganicInstrumentView : public InstrumentViewFixedSize struct OscillatorKnobs { - MM_OPERATORS OscillatorKnobs( Knob * h, Knob * v, diff --git a/plugins/Patman/Patman.h b/plugins/Patman/Patman.h index 8d2c8c6577b..486524522d4 100644 --- a/plugins/Patman/Patman.h +++ b/plugins/Patman/Patman.h @@ -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; diff --git a/plugins/Sf2Player/Sf2Player.h b/plugins/Sf2Player/Sf2Player.h index 17ddf550037..1af370e05eb 100644 --- a/plugins/Sf2Player/Sf2Player.h +++ b/plugins/Sf2Player/Sf2Player.h @@ -34,7 +34,6 @@ #include "Instrument.h" #include "InstrumentView.h" #include "LcdSpinBox.h" -#include "MemoryManager.h" class QLabel; diff --git a/plugins/Sfxr/Sfxr.h b/plugins/Sfxr/Sfxr.h index edec0ba6f00..8af8984c953 100644 --- a/plugins/Sfxr/Sfxr.h +++ b/plugins/Sfxr/Sfxr.h @@ -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; diff --git a/plugins/Sid/SidInstrument.h b/plugins/Sid/SidInstrument.h index 53efa8942f7..1a133b58b1b 100644 --- a/plugins/Sid/SidInstrument.h +++ b/plugins/Sid/SidInstrument.h @@ -48,7 +48,6 @@ class PixmapButton; class VoiceObject : public Model { Q_OBJECT - MM_OPERATORS public: enum class WaveForm { Square = 0, diff --git a/plugins/TripleOscillator/TripleOscillator.h b/plugins/TripleOscillator/TripleOscillator.h index c0258b5448b..4b6d97835e9 100644 --- a/plugins/TripleOscillator/TripleOscillator.h +++ b/plugins/TripleOscillator/TripleOscillator.h @@ -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 @@ protected slots: struct oscPtr { - MM_OPERATORS Oscillator * oscLeft; Oscillator * oscRight; } ; @@ -170,7 +168,6 @@ class TripleOscillatorView : public InstrumentViewFixedSize struct OscillatorKnobs { - MM_OPERATORS OscillatorKnobs( Knob * v, Knob * p, Knob * c, diff --git a/plugins/Vibed/Vibed.cpp b/plugins/Vibed/Vibed.cpp index ad6a3942af4..ddf9097a527 100644 --- a/plugins/Vibed/Vibed.cpp +++ b/plugins/Vibed/Vibed.cpp @@ -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) {} diff --git a/plugins/Watsyn/Watsyn.h b/plugins/Watsyn/Watsyn.h index 3a736e1621f..d238edbdea6 100644 --- a/plugins/Watsyn/Watsyn.h +++ b/plugins/Watsyn/Watsyn.h @@ -32,7 +32,6 @@ #include "AutomatableModel.h" #include "TempoSyncKnob.h" #include -#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, diff --git a/plugins/Xpressive/ExprSynth.h b/plugins/Xpressive/ExprSynth.h index f338b78fc38..5d664c85e6d 100644 --- a/plugins/Xpressive/ExprSynth.h +++ b/plugins/Xpressive/ExprSynth.h @@ -30,7 +30,6 @@ #include #include "AutomatableModel.h" #include "Graph.h" -#include "MemoryManager.h" namespace lmms { @@ -102,7 +101,6 @@ class WaveSample 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); diff --git a/src/3rdparty/CMakeLists.txt b/src/3rdparty/CMakeLists.txt index a95332a0754..f1578a9703e 100644 --- a/src/3rdparty/CMakeLists.txt +++ b/src/3rdparty/CMakeLists.txt @@ -4,7 +4,6 @@ IF(LMMS_BUILD_LINUX AND WANT_VST) ENDIF() ADD_SUBDIRECTORY(hiir) -ADD_SUBDIRECTORY(rpmalloc) ADD_SUBDIRECTORY(weakjack) if(MINGW) diff --git a/src/3rdparty/rpmalloc/CMakeLists.txt b/src/3rdparty/rpmalloc/CMakeLists.txt deleted file mode 100644 index 047c32678c2..00000000000 --- a/src/3rdparty/rpmalloc/CMakeLists.txt +++ /dev/null @@ -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() diff --git a/src/3rdparty/rpmalloc/rpmalloc b/src/3rdparty/rpmalloc/rpmalloc deleted file mode 160000 index 80daac0d539..00000000000 --- a/src/3rdparty/rpmalloc/rpmalloc +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 80daac0d539ab2a8edfd5ca24b1e0c77a4974bbb diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d55a725dd51..d71b34c5944 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -186,7 +186,6 @@ SET(LMMS_REQUIRED_LIBS ${LMMS_REQUIRED_LIBS} ${SUIL_LIBRARIES} ${LILV_LIBRARIES} ${FFTW3F_LIBRARIES} - rpmalloc SampleRate::samplerate SndFile::sndfile ${EXTRA_LIBRARIES} diff --git a/src/core/AudioEngineWorkerThread.cpp b/src/core/AudioEngineWorkerThread.cpp index 528841c7128..ae459c5e484 100644 --- a/src/core/AudioEngineWorkerThread.cpp +++ b/src/core/AudioEngineWorkerThread.cpp @@ -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; diff --git a/src/core/BufferManager.cpp b/src/core/BufferManager.cpp index ff35e6a194e..2362be85a3d 100644 --- a/src/core/BufferManager.cpp +++ b/src/core/BufferManager.cpp @@ -28,7 +28,6 @@ #include -#include "MemoryManager.h" namespace lmms { @@ -43,7 +42,7 @@ void BufferManager::init( fpp_t fpp ) sampleFrame * BufferManager::acquire() { - return MM_ALLOC( 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 diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 26d458f9e76..1a4871fc72b 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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 diff --git a/src/core/MemoryManager.cpp b/src/core/MemoryManager.cpp deleted file mode 100644 index bd3168f1487..00000000000 --- a/src/core/MemoryManager.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * MemoryManager.cpp - * - * Copyright (c) 2017 Lukas W - * - * 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 -#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 diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 712b64e8917..2c1c2193161 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -610,9 +610,9 @@ int NotePlayHandleManager::s_size; void NotePlayHandleManager::init() { - s_available = MM_ALLOC( INITIAL_NPH_CACHE ); + s_available = new NotePlayHandle*[INITIAL_NPH_CACHE]; - auto n = MM_ALLOC(INITIAL_NPH_CACHE); + auto n = static_cast(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(s_size); - MM_FREE( s_available ); + auto tmp = new NotePlayHandle*[s_size]; + delete[] s_available; s_available = tmp; - auto n = MM_ALLOC(c); + auto n = static_cast(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; } diff --git a/src/core/ProjectRenderer.cpp b/src/core/ProjectRenderer.cpp index 3f101330aeb..3d83515f22e 100644 --- a/src/core/ProjectRenderer.cpp +++ b/src/core/ProjectRenderer.cpp @@ -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