Remove use of shared ownership for Sample
Sample does not need to be wrapped around a std::shared_ptr. This was to work with the audio thread, but the audio thread can instead have their own Sample separate from the UI's Sample, so changes to the UI's Sample would not leave the audio worker thread using freed data if it had pointed to it.
This commit is contained in:
@@ -63,10 +63,9 @@ public:
|
||||
return "sampleclip";
|
||||
}
|
||||
|
||||
std::shared_ptr<Sample> sample()
|
||||
const Sample& sample()
|
||||
{
|
||||
// TODO C++20: Deprecated, use std::atomic<std::shared_ptr> instead
|
||||
return std::atomic_load(&m_sample);
|
||||
return m_sample;
|
||||
}
|
||||
|
||||
TimePos sampleLength() const;
|
||||
@@ -88,7 +87,7 @@ public slots:
|
||||
|
||||
|
||||
private:
|
||||
std::shared_ptr<Sample> m_sample = std::make_shared<Sample>();
|
||||
Sample m_sample;
|
||||
BoolModel m_recordModel;
|
||||
bool m_isPlaying;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class AudioPort;
|
||||
class LMMS_EXPORT SamplePlayHandle : public PlayHandle
|
||||
{
|
||||
public:
|
||||
SamplePlayHandle(std::shared_ptr<const Sample> sampleBuffer , bool ownAudioPort = true);
|
||||
SamplePlayHandle(const Sample& sample, bool ownAudioPort = true);
|
||||
SamplePlayHandle( const QString& sampleFile );
|
||||
SamplePlayHandle( SampleClip* clip );
|
||||
~SamplePlayHandle() override;
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
std::shared_ptr<const Sample> m_sample;
|
||||
Sample m_sample;
|
||||
bool m_doneMayReturnTrue;
|
||||
|
||||
f_cnt_t m_frame;
|
||||
|
||||
Reference in New Issue
Block a user