Nicer way to deal with the shared audiothumbnailcache
This commit is contained in:
parent
a109d71f09
commit
e9e1c45550
@ -154,15 +154,8 @@ void PaulstretchpluginAudioProcessorEditor::chooseFile()
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<AudioThumbnailCache> g_thumbcache;
|
||||
|
||||
WaveformComponent::WaveformComponent(AudioFormatManager* afm)
|
||||
{
|
||||
if (g_thumbcache == nullptr)
|
||||
{
|
||||
g_thumbcache = std::make_shared<AudioThumbnailCache>(100);
|
||||
}
|
||||
m_thumbcache = g_thumbcache;
|
||||
TimeSelectionChangedCallback = [](Range<double>, int) {};
|
||||
if (m_use_opengl == true)
|
||||
m_ogl.attachTo(*this);
|
||||
@ -438,10 +431,3 @@ int WaveformComponent::getTimeSelectionEdge(int x, int y)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cleanUpGUI()
|
||||
{
|
||||
if (g_thumbcache.unique())
|
||||
{
|
||||
g_thumbcache = nullptr;
|
||||
}
|
||||
}
|
@ -133,6 +133,13 @@ private:
|
||||
bool m_dragging = false;
|
||||
};
|
||||
|
||||
class MyThumbCache : public AudioThumbnailCache
|
||||
{
|
||||
public:
|
||||
MyThumbCache() : AudioThumbnailCache(100) { Logger::writeToLog("Constructed AudioThumbNailCache"); }
|
||||
~MyThumbCache() { Logger::writeToLog("Destructed AudioThumbNailCache"); }
|
||||
};
|
||||
|
||||
class WaveformComponent : public Component, public ChangeListener, public Timer
|
||||
{
|
||||
public:
|
||||
@ -175,7 +182,7 @@ public:
|
||||
Value ShowFileCacheRange;
|
||||
void setRecordingPosition(double pos) { m_rec_pos = pos; }
|
||||
private:
|
||||
std::shared_ptr<AudioThumbnailCache> m_thumbcache;
|
||||
SharedResourcePointer<MyThumbCache> m_thumbcache;
|
||||
|
||||
std::unique_ptr<AudioThumbnail> m_thumb;
|
||||
Range<double> m_view_range{ 0.0,1.0 };
|
||||
@ -222,4 +229,3 @@ private:
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessorEditor)
|
||||
};
|
||||
|
||||
void cleanUpGUI();
|
@ -96,7 +96,6 @@ PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor()
|
||||
{
|
||||
g_activeprocessors.erase(this);
|
||||
m_bufferingthread.stopThread(1000);
|
||||
cleanUpGUI();
|
||||
}
|
||||
|
||||
void PaulstretchpluginAudioProcessor::setPreBufferAmount(int x)
|
||||
|
@ -13,9 +13,8 @@
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
#include "PS_Source/PaulStretchControl.h"
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
*/
|
||||
class MyThumbCache;
|
||||
|
||||
class PaulstretchpluginAudioProcessor : public AudioProcessor
|
||||
{
|
||||
public:
|
||||
@ -97,6 +96,7 @@ private:
|
||||
void setPreBufferAmount(int x);
|
||||
void setFFTSize(double size);
|
||||
void startplay(Range<double> playrange, int numoutchans, String& err);
|
||||
SharedResourcePointer<MyThumbCache> m_thumbcache;
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user