Skip to content

Commit fc3dfda

Browse files
authored
Remove unused default volume model in SamplePlayHandle (#8349)
Removes construction of the unused default volume model from `SamplePlayHandle`. Frequent construction of this model was causing performance slowdowns due to the model having to find and create a journaling ID in a for loop inside `ProjectJournal::allocID`, leading to the exhaustion of available IDs very quickly. There were also general improvements made to `SamplePlayHandle` (using NSDMI, removing other unused members, etc).
1 parent 9628cb1 commit fc3dfda

3 files changed

Lines changed: 10 additions & 33 deletions

File tree

include/SamplePlayHandle.h

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#define LMMS_SAMPLE_PLAY_HANDLE_H
2828

2929
#include "Sample.h"
30-
#include "AutomatableModel.h"
3130
#include "PlayHandle.h"
3231

3332
namespace lmms
@@ -73,27 +72,14 @@ class LMMS_EXPORT SamplePlayHandle : public PlayHandle
7372
m_patternTrack = pt;
7473
}
7574

76-
void setVolumeModel( FloatModel * _model )
77-
{
78-
m_volumeModel = _model;
79-
}
80-
81-
8275
private:
83-
Sample* m_sample;
84-
bool m_doneMayReturnTrue;
85-
86-
f_cnt_t m_frame;
8776
Sample::PlaybackState m_state;
88-
89-
const bool m_ownAudioBusHandle;
90-
91-
FloatModel m_defaultVolumeModel;
92-
FloatModel * m_volumeModel;
93-
Track * m_track;
94-
95-
PatternTrack* m_patternTrack;
96-
77+
f_cnt_t m_frame = 0;
78+
Sample* m_sample = nullptr;
79+
Track* m_track = nullptr;
80+
PatternTrack* m_patternTrack = nullptr;
81+
bool m_doneMayReturnTrue = true;
82+
bool m_ownAudioBusHandle = false;
9783
} ;
9884

9985

src/core/SamplePlayHandle.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,17 @@
2626
#include "AudioEngine.h"
2727
#include "AudioBusHandle.h"
2828
#include "Engine.h"
29-
#include "Note.h"
3029
#include "PatternTrack.h"
3130
#include "SampleClip.h"
3231
#include "SampleTrack.h"
3332

3433
namespace lmms
3534
{
3635

37-
38-
SamplePlayHandle::SamplePlayHandle(Sample* sample, bool ownAudioBusHandle) :
39-
PlayHandle(Type::SamplePlayHandle),
40-
m_sample(sample),
41-
m_doneMayReturnTrue(true),
42-
m_frame(0),
43-
m_ownAudioBusHandle(ownAudioBusHandle),
44-
m_defaultVolumeModel(DefaultVolume, MinVolume, MaxVolume, 1),
45-
m_volumeModel(&m_defaultVolumeModel),
46-
m_track(nullptr),
47-
m_patternTrack(nullptr)
36+
SamplePlayHandle::SamplePlayHandle(Sample* sample, bool ownAudioBusHandle)
37+
: PlayHandle(Type::SamplePlayHandle)
38+
, m_sample(sample)
39+
, m_ownAudioBusHandle(ownAudioBusHandle)
4840
{
4941
if (ownAudioBusHandle)
5042
{

src/tracks/SampleTrack.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ bool SampleTrack::play( const TimePos & _start, const f_cnt_t _frames,
152152
else
153153
{
154154
auto smpHandle = new SamplePlayHandle(st);
155-
smpHandle->setVolumeModel( &m_volumeModel );
156155
smpHandle->setPatternTrack(pattern_track);
157156
handle = smpHandle;
158157
}

0 commit comments

Comments
 (0)