Revert "Remove use of shared ownership for Sample"

This reverts commit 1d452331d1.
In some cases, you can infact do away with shared ownership
on Sample if there are no writes being made to either of them,
but to make sure changes are reflected to the object in cases
where writes do happen, they should work with the same one.
This commit is contained in:
sakertooth
2023-09-01 14:25:46 -04:00
parent b1516ea40e
commit 5ac915971b
10 changed files with 78 additions and 69 deletions

View File

@@ -63,9 +63,10 @@ public:
return "sampleclip";
}
const Sample& sample()
std::shared_ptr<Sample> sample()
{
return m_sample;
// TODO C++20: Deprecated, use std::atomic<std::shared_ptr> instead
return std::atomic_load(&m_sample);
}
TimePos sampleLength() const;
@@ -87,7 +88,7 @@ public slots:
private:
Sample m_sample;
std::shared_ptr<Sample> m_sample = std::make_shared<Sample>();
BoolModel m_recordModel;
bool m_isPlaying;

View File

@@ -44,7 +44,7 @@ class AudioPort;
class LMMS_EXPORT SamplePlayHandle : public PlayHandle
{
public:
SamplePlayHandle(const Sample& sample, bool ownAudioPort = true);
SamplePlayHandle(std::shared_ptr<const Sample> sampleBuffer , bool ownAudioPort = true);
SamplePlayHandle( const QString& sampleFile );
SamplePlayHandle( SampleClip* clip );
~SamplePlayHandle() override;
@@ -82,7 +82,7 @@ public:
private:
Sample m_sample;
std::shared_ptr<const Sample> m_sample;
bool m_doneMayReturnTrue;
f_cnt_t m_frame;