Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LMMS Memory Manager #1088

Merged
merged 28 commits into from Nov 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9c25be1
LMMS Memory Manager
diizy Aug 22, 2014
75770b4
Fix 64 bit, increase mm usage
diizy Aug 22, 2014
9972cb3
Fixes
diizy Aug 23, 2014
5e43085
More fixes
diizy Aug 23, 2014
42e67d2
Add dedicated manager for noteplayhandles
diizy Aug 23, 2014
8fb8c68
Changing and fixing some stuff
diizy Aug 24, 2014
3a9e9cc
Use ReadWriteLock for the pools container instead of Mutex
diizy Aug 24, 2014
a821187
Fix arpeggio to work better with the new way to handle note offsets
diizy Aug 24, 2014
3d9a7fb
remove tr.whitespace
diizy Aug 24, 2014
f3ed39a
Fix weird issue with remotevstplugin
diizy Aug 24, 2014
daa5f6c
Use memory management in LADSPA effects
diizy Aug 24, 2014
af60402
Make it possible to use sample-exact controls in LADSPA plugins
diizy Aug 24, 2014
311d33d
Implement BufferManager
diizy Aug 24, 2014
857de8d
Huge structural changes
diizy Aug 26, 2014
1deb80a
Finish audioport rehaul, get vol/pan knobs working again, also some b…
diizy Aug 27, 2014
1864dcf
Fix bugs
diizy Aug 29, 2014
9a3d3cb
Fix windows compiling
diizy Aug 29, 2014
7bc97f5
Fixes
diizy Aug 31, 2014
68b5a21
Initialize BufferManager from within Mixer
tobydox Sep 2, 2014
9fe5516
Remove base64.h again (was re-added accidentally at merge resolution)
diizy Sep 3, 2014
dc4bfdc
Various fixes and precautions
diizy Oct 11, 2014
f25da35
Sanitize all channel outputs when exporting
diizy Oct 15, 2014
50bfed7
Fix Carla in memmgr branch
diizy Oct 15, 2014
8a596b0
Sanitize output of all effects when exporting
diizy Oct 20, 2014
f207613
Some attention on peak controller
diizy Oct 31, 2014
b441bda
Freeverb3: make it work properly on all samplerates
diizy Nov 9, 2014
ba05b75
More peak controller changes:
diizy Nov 10, 2014
815a70a
Sync
diizy Nov 16, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 25 additions & 40 deletions include/AudioPort.h
Expand Up @@ -22,55 +22,43 @@
*
*/

#ifndef _AUDIO_PORT_H
#define _AUDIO_PORT_H
#ifndef AUDIO_PORT_H
#define AUDIO_PORT_H

#include <QtCore/QString>
#include <QtCore/QMutex>
#include <QtCore/QMutexLocker>

#include "Mixer.h"
#include "MemoryManager.h"
#include "PlayHandle.h"

class EffectChain;
class FloatModel;

class AudioPort : public ThreadableJob
{
MM_OPERATORS
public:
AudioPort( const QString & _name, bool _has_effect_chain = true );
AudioPort( const QString & _name, bool _has_effect_chain = true,
FloatModel * volumeModel = NULL, FloatModel * panningModel = NULL );
virtual ~AudioPort();

inline sampleFrame * firstBuffer()
inline sampleFrame * buffer()
{
return m_firstBuffer;
return m_portBuffer;
}

inline sampleFrame * secondBuffer()
inline void lockBuffer()
{
return m_secondBuffer;
m_portBufferLock.lock();
}

inline void lockFirstBuffer()
inline void unlockBuffer()
{
m_firstBufferLock.lock();
m_portBufferLock.unlock();
}

inline void lockSecondBuffer()
{
m_secondBufferLock.lock();
}

inline void unlockFirstBuffer()
{
m_firstBufferLock.unlock();
}

inline void unlockSecondBuffer()
{
m_secondBufferLock.unlock();
}

void nextPeriod();


// indicate whether JACK & Co should provide output-buffer at ext. port
inline bool extOutputEnabled() const
Expand Down Expand Up @@ -110,28 +98,20 @@ class AudioPort : public ThreadableJob
bool processEffects();

// ThreadableJob stuff
virtual void doProcessing( sampleFrame * );
virtual void doProcessing();
virtual bool requiresProcessing() const
{
return true;
}


enum bufferUsages
{
NoUsage,
FirstBuffer,
BothBuffers
} ;

void addPlayHandle( PlayHandle * handle );
void removePlayHandle( PlayHandle * handle );

private:
volatile bufferUsages m_bufferUsage;
volatile bool m_bufferUsage;

sampleFrame * m_firstBuffer;
sampleFrame * m_secondBuffer;
QMutex m_firstBufferLock;
QMutex m_secondBufferLock;
sampleFrame * m_portBuffer;
QMutex m_portBufferLock;

bool m_extOutputEnabled;
fx_ch_t m_nextFxChannel;
Expand All @@ -140,6 +120,11 @@ class AudioPort : public ThreadableJob

EffectChain * m_effects;

PlayHandleList m_playHandles;
QMutex m_playHandleLock;

FloatModel * m_volumeModel;
FloatModel * m_panningModel;

friend class Mixer;
friend class MixerWorkerThread;
Expand Down
3 changes: 2 additions & 1 deletion include/AutomatableModel.h
Expand Up @@ -32,7 +32,7 @@
#include "Model.h"
#include "MidiTime.h"
#include "ValueBuffer.h"

#include "MemoryManager.h"

// simple way to map a property of a view to a model
#define mapPropertyFromModelPtr(type,getfunc,setfunc,modelname) \
Expand Down Expand Up @@ -66,6 +66,7 @@ class ControllerConnection;
class EXPORT AutomatableModel : public Model, public JournallingObject
{
Q_OBJECT
MM_OPERATORS
public:
typedef QVector<AutomatableModel *> AutoModelVector;

Expand Down
59 changes: 59 additions & 0 deletions include/BufferManager.h
@@ -0,0 +1,59 @@
/*
* BufferManager.h - A buffer caching/memory management system
*
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* 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 BUFFER_MANAGER_H
#define BUFFER_MANAGER_H

#include "MemoryManager.h"
#include "lmms_basics.h"
#include "engine.h"
#include "Mixer.h"
#include <QtCore/QAtomicInt>
#include <QtCore/QReadWriteLock>


const int BM_INITIAL_BUFFERS = 512;
//const int BM_INCREMENT = 64;

class EXPORT BufferManager
{
public:
static void init( fpp_t framesPerPeriod );
static sampleFrame * acquire();
static void release( sampleFrame * buf );
static void refresh();
// static void extend( int c );

private:
static sampleFrame ** s_available;
static QAtomicInt s_availableIndex;

static sampleFrame ** s_released;
static QAtomicInt s_releasedIndex;
// static QReadWriteLock s_mutex;
static int s_size;
};

#endif
3 changes: 2 additions & 1 deletion include/ConfigManager.h
Expand Up @@ -34,7 +34,7 @@
#include <QtCore/QVector>

#include "export.h"

#include "MemoryManager.h"

class engine;

Expand All @@ -49,6 +49,7 @@ const QString LOCALE_PATH = "locale/";

class EXPORT ConfigManager
{
MM_OPERATORS
public:
static inline ConfigManager * inst()
{
Expand Down
3 changes: 2 additions & 1 deletion include/DataFile.h
Expand Up @@ -32,10 +32,11 @@

#include "export.h"
#include "lmms_basics.h"

#include "MemoryManager.h"

class EXPORT DataFile : public QDomDocument
{
MM_OPERATORS
public:
enum Types
{
Expand Down
7 changes: 4 additions & 3 deletions include/DetuningHelper.h
Expand Up @@ -23,14 +23,15 @@
*
*/

#ifndef _DETUNING_HELPER_H
#define _DETUNING_HELPER_H
#ifndef DETUNING_HELPER_H
#define DETUNING_HELPER_H

#include "InlineAutomation.h"

#include "MemoryManager.h"

class DetuningHelper : public InlineAutomation
{
MM_OPERATORS
public:
DetuningHelper() :
InlineAutomation()
Expand Down
3 changes: 2 additions & 1 deletion include/Effect.h
Expand Up @@ -31,14 +31,15 @@
#include "Mixer.h"
#include "AutomatableModel.h"
#include "TempoSyncKnobModel.h"

#include "MemoryManager.h"

class EffectChain;
class EffectControls;


class EXPORT Effect : public Plugin
{
MM_OPERATORS
public:
Effect( const Plugin::Descriptor * _desc,
Model * _parent,
Expand Down
2 changes: 1 addition & 1 deletion include/FxMixer.h
Expand Up @@ -76,7 +76,7 @@ class FxChannel : public ThreadableJob
void processed();

private:
virtual void doProcessing( sampleFrame * _working_buffer );
virtual void doProcessing();
};


Expand Down
1 change: 1 addition & 0 deletions include/Instrument.h
Expand Up @@ -43,6 +43,7 @@ class track;

class EXPORT Instrument : public Plugin
{
MM_OPERATORS
public:
enum Flag
{
Expand Down
11 changes: 4 additions & 7 deletions include/InstrumentPlayHandle.h
Expand Up @@ -28,16 +28,12 @@
#include "PlayHandle.h"
#include "Instrument.h"
#include "NotePlayHandle.h"
#include "export.h"


class InstrumentPlayHandle : public PlayHandle
class EXPORT InstrumentPlayHandle : public PlayHandle
{
public:
InstrumentPlayHandle( Instrument* instrument ) :
PlayHandle( TypeInstrumentPlayHandle ),
m_instrument( instrument )
{
}
InstrumentPlayHandle( Instrument * instrument, InstrumentTrack* instrumentTrack );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobydox, should this be class EXPORT InstrumentPlayHandle ? It's the only way I could get compilation for Win32/64 to succeed but I'm just taking guesses here.


virtual ~InstrumentPlayHandle()
{
Expand Down Expand Up @@ -88,6 +84,7 @@ class InstrumentPlayHandle : public PlayHandle

private:
Instrument* m_instrument;
InstrumentTrack * m_instrumentTrack;

} ;

Expand Down
5 changes: 4 additions & 1 deletion include/InstrumentTrack.h
Expand Up @@ -60,6 +60,7 @@ class trackLabelButton;
class EXPORT InstrumentTrack : public track, public MidiEventProcessor
{
Q_OBJECT
MM_OPERATORS
mapPropertyFromModel(int,getVolume,setVolume,m_volumeModel);
public:
InstrumentTrack( TrackContainer* tc );
Expand Down Expand Up @@ -224,7 +225,6 @@ protected slots:


private:
AudioPort m_audioPort;
MidiPort m_midiPort;

NotePlayHandle* m_notes[NumKeys];
Expand All @@ -243,6 +243,9 @@ protected slots:

FloatModel m_volumeModel;
FloatModel m_panningModel;

AudioPort m_audioPort;

FloatModel m_pitchModel;
IntModel m_pitchRangeModel;
IntModel m_effectChannelModel;
Expand Down
2 changes: 2 additions & 0 deletions include/LadspaControl.h
Expand Up @@ -30,6 +30,7 @@

#include "AutomatableModel.h"
#include "TempoSyncKnobModel.h"
#include "ValueBuffer.h"


typedef struct PortDescription port_desc_t;
Expand All @@ -44,6 +45,7 @@ class EXPORT LadspaControl : public Model, public JournallingObject
~LadspaControl();

LADSPA_Data value();
ValueBuffer * valueBuffer();
void setValue( LADSPA_Data _value );
void setLink( bool _state );

Expand Down