Skip to content

Commit

Permalink
Merge branch 'stable-1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-w committed Oct 30, 2017
2 parents 9fb74d9 + 60e9b2f commit 68c85c8
Show file tree
Hide file tree
Showing 23 changed files with 201 additions and 332 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/3rdparty/rpmalloc/rpmalloc"]
path = src/3rdparty/rpmalloc/rpmalloc
url = https://github.com/rampantpixels/rpmalloc.git
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ matrix:
- env: QT5=True TARGET_OS=win32
- env: QT5=True TARGET_OS=win64
- os: osx
osx_image: xcode8.2
env: QT5=True
install: ${TRAVIS_BUILD_DIR}/.travis/install.sh
script: ${TRAVIS_BUILD_DIR}/.travis/script.sh
Expand Down
1 change: 1 addition & 0 deletions include/AutomatableModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#ifndef AUTOMATABLE_MODEL_H
#define AUTOMATABLE_MODEL_H

#include <QtCore/QMap>
#include <QtCore/QMutex>

#include "JournallingObject.h"
Expand Down
1 change: 1 addition & 0 deletions include/AutomationEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public slots:
void getSelectedValues(timeMap & selected_values );

void drawLine( int x0, float y0, int x1, float y1 );
void removePoints( int x0, int x1 );

protected slots:
void play();
Expand Down
108 changes: 11 additions & 97 deletions include/MemoryManager.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* MemoryManager.h - A lightweight, generic memory manager for LMMS
* 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>
*
Expand All @@ -26,81 +27,22 @@
#ifndef MEMORY_MANAGER_H
#define MEMORY_MANAGER_H

#include <QtCore/QVector>
#include <QtCore/QMutex>
#include <QtCore/QHash>
#include "MemoryHelper.h"
#include "export.h"

class QReadWriteLock;

const int MM_CHUNK_SIZE = 64; // granularity of managed memory
const int MM_INITIAL_CHUNKS = 1024 * 1024; // how many chunks to allocate at startup - TODO: make configurable
const int MM_INCREMENT_CHUNKS = 16 * 1024; // min. amount of chunks to increment at a time

struct MemoryPool
{
void * m_pool;
char * m_free;
size_t m_chunks;
QMutex m_mutex;

MemoryPool() :
m_pool( NULL ),
m_free( NULL ),
m_chunks( 0 )
{}

MemoryPool( size_t chunks ) :
m_chunks( chunks )
{
m_free = reinterpret_cast<char*>( MemoryHelper::alignedMalloc( chunks ) );
memset( m_free, 1, chunks );
}

MemoryPool( const MemoryPool & mp ) :
m_pool( mp.m_pool ),
m_free( mp.m_free ),
m_chunks( mp.m_chunks ),
m_mutex()
{}

MemoryPool & operator = ( const MemoryPool & mp )
{
m_pool = mp.m_pool;
m_free = mp.m_free;
m_chunks = mp.m_chunks;
return *this;
}

void * getChunks( int chunksNeeded );
void releaseChunks( void * ptr, int chunks );
};
#include <cstddef>
#include <vector>

struct PtrInfo
{
int chunks;
MemoryPool * memPool;
};

typedef QVector<MemoryPool> MemoryPoolVector;
typedef QHash<void*, PtrInfo> PointerInfoMap;
#include "export.h"

class EXPORT MemoryManager
{
public:
static bool init();
struct ThreadGuard
{
ThreadGuard();
~ThreadGuard();
};

static void * alloc( size_t size );
static void free( void * ptr );
static int extend( int chunks ); // returns index of created pool (for use by alloc)
static void cleanup();

private:
static MemoryPoolVector s_memoryPools;
static QReadWriteLock s_poolMutex;

static PointerInfoMap s_pointerInfo;
static QMutex s_pointerMutex;
};

template<typename T>
Expand Down Expand Up @@ -147,32 +89,4 @@ static void operator delete[] ( void * ptr ) \
// and just for symmetry...
#define MM_FREE( ptr ) MemoryManager::free( ptr )



// for debugging purposes

#define MM_OPERATORS_DEBUG \
public: \
static void * operator new ( size_t size ) \
{ \
qDebug( "MM_OPERATORS_DEBUG: new called for %d bytes", size ); \
return MemoryManager::alloc( size ); \
} \
static void * operator new[] ( size_t size ) \
{ \
qDebug( "MM_OPERATORS_DEBUG: new[] called for %d bytes", size ); \
return MemoryManager::alloc( size ); \
} \
static void operator delete ( void * ptr ) \
{ \
qDebug( "MM_OPERATORS_DEBUG: delete called for %p", ptr ); \
MemoryManager::free( ptr ); \
} \
static void operator delete[] ( void * ptr ) \
{ \
qDebug( "MM_OPERATORS_DEBUG: delete[] called for %p", ptr ); \
MemoryManager::free( ptr ); \
}


#endif
12 changes: 10 additions & 2 deletions include/Note.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,19 @@ class EXPORT Note : public SerializingObject
void quantizeLength( const int qGrid );
void quantizePos( const int qGrid );

static inline bool lessThan( Note * &lhs, Note * &rhs )
static inline bool lessThan( const Note * lhs, const Note * rhs )
{
// function to compare two notes - must be called explictly when
// using qSort
return (bool) ((int) ( *lhs ).pos() < (int) ( *rhs ).pos());
if( (int)( *lhs ).pos() < (int)( *rhs ).pos() )
{
return true;
}
else if( (int)( *lhs ).pos() > (int)( *rhs ).pos() )
{
return false;
}
return ( (int)( *lhs ).key() > (int)( *rhs ).key() );
}

inline bool selected() const
Expand Down
1 change: 1 addition & 0 deletions include/PluginFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <memory>

#include <QtCore/QFileInfo>
#include <QtCore/QHash>
#include <QtCore/QList>

#include "export.h"
Expand Down
2 changes: 2 additions & 0 deletions plugins/carlabase/carla.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#ifndef CARLA_H
#define CARLA_H

#include <QtCore/QMutex>

#include "CarlaNative.h"

#include "Instrument.h"
Expand Down
2 changes: 2 additions & 0 deletions plugins/monstro/Monstro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,8 @@ QWidget * MonstroView::setupOperatorsView( QWidget * _parent )
makeknob( m_osc3SpoKnob, KNOBCOL4, O3ROW, tr( "Stereo phase offset" ), tr( " deg" ), "osc3Knob" )
makeknob( m_osc3SubKnob, KNOBCOL5, O3ROW, tr( "Sub-osc mix" ), "", "osc3Knob" )

m_osc3VolKnob -> setVolumeKnob( true );

m_osc3Wave1Box = new ComboBox( view );
m_osc3Wave1Box -> setGeometry( 160, O3ROW + 7, 42, 22 );
m_osc3Wave1Box->setFont( pointSize<8>( m_osc3Wave1Box->font() ) );
Expand Down
4 changes: 4 additions & 0 deletions src/3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(CMAKE_C_FLAGS "")
set(CMAKE_CXX_FLAGS "")

ADD_SUBDIRECTORY(rpmalloc)
30 changes: 30 additions & 0 deletions src/3rdparty/rpmalloc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
set(CMAKE_C_FLAGS "-std=c11")

add_library(rpmalloc STATIC
rpmalloc/rpmalloc/rpmalloc.c
rpmalloc/rpmalloc/rpmalloc.h
)

target_include_directories(rpmalloc PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/rpmalloc/rpmalloc
)

if (NOT LMMS_BUILD_WIN32)
target_compile_definitions(rpmalloc
PRIVATE -D_GNU_SOURCE
)
endif()

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(rpmalloc
PRIVATE -DENABLE_ASSERTS=1 -DENABLE_VALIDATE_ARGS=1
)
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()
1 change: 1 addition & 0 deletions src/3rdparty/rpmalloc/rpmalloc
Submodule rpmalloc added at 2e0479
12 changes: 12 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ADD_SUBDIRECTORY(3rdparty)

CONFIGURE_FILE("lmmsconfig.h.in" "${CMAKE_BINARY_DIR}/lmmsconfig.h")
CONFIGURE_FILE("lmmsversion.h.in" "${CMAKE_BINARY_DIR}/lmmsversion.h")

Expand Down Expand Up @@ -147,14 +149,24 @@ SET(LMMS_REQUIRED_LIBS
${SAMPLERATE_LIBRARIES}
${SNDFILE_LIBRARIES}
${EXTRA_LIBRARIES}
rpmalloc
)

# Expose required libs for tests binary
SET(LMMS_REQUIRED_LIBS ${LMMS_REQUIRED_LIBS} PARENT_SCOPE)

TARGET_LINK_LIBRARIES(lmms
${LMMS_REQUIRED_LIBS}
)

FOREACH(LIB ${LMMS_REQUIRED_LIBS})
GET_TARGET_PROPERTY(INCLUDE_DIRS ${LIB} INTERFACE_INCLUDE_DIRECTORIES)
if (INCLUDE_DIRS)
TARGET_INCLUDE_DIRECTORIES(lmmsobjs PRIVATE ${INCLUDE_DIRS})
ENDIF()
ENDFOREACH()


# Required libs for debug msys builds
IF(LMMS_BUILD_MSYS AND CMAKE_BUILD_TYPE STREQUAL "Debug")
TARGET_LINK_LIBRARIES(lmms QtCore4 QtGui4 QtXml4)
Expand Down
15 changes: 12 additions & 3 deletions src/core/InstrumentSoundShaping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,22 @@ f_cnt_t InstrumentSoundShaping::envFrames( const bool _only_vol ) const

f_cnt_t InstrumentSoundShaping::releaseFrames() const
{
if( !m_instrumentTrack->instrument() )
{
return 0;
}

f_cnt_t ret_val = m_instrumentTrack->instrument()->desiredReleaseFrames();

if( m_instrumentTrack->instrument()->flags().testFlag( Instrument::IsSingleStreamed ) )
{
return ret_val;
}

if( m_envLfoParameters[Volume]->isUsed() )
{
return m_envLfoParameters[Volume]->releaseFrames();
}
f_cnt_t ret_val = m_instrumentTrack->instrument()
? m_instrumentTrack->instrument()->desiredReleaseFrames()
: 0;

for( int i = Volume+1; i < NumTargets; ++i )
{
Expand Down
Loading

0 comments on commit 68c85c8

Please sign in to comment.