Use shared thumbnailcache for all plugin instances. Kind of a tricky thing with std::shared_ptr going on here using the deprecated unique method...But, oh well...
This commit is contained in:
parent
9207325698
commit
a109d71f09
@ -154,14 +154,21 @@ void PaulstretchpluginAudioProcessorEditor::chooseFile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WaveformComponent::WaveformComponent(AudioFormatManager* afm) : m_thumbcache(100)
|
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) {};
|
TimeSelectionChangedCallback = [](Range<double>, int) {};
|
||||||
if (m_use_opengl == true)
|
if (m_use_opengl == true)
|
||||||
m_ogl.attachTo(*this);
|
m_ogl.attachTo(*this);
|
||||||
// The default priority of 2 is a bit too low in some cases, it seems...
|
// The default priority of 2 is a bit too low in some cases, it seems...
|
||||||
m_thumbcache.getTimeSliceThread().setPriority(3);
|
m_thumbcache->getTimeSliceThread().setPriority(3);
|
||||||
m_thumb = std::make_unique<AudioThumbnail>(512, *afm, m_thumbcache);
|
m_thumb = std::make_unique<AudioThumbnail>(512, *afm, *m_thumbcache);
|
||||||
m_thumb->addChangeListener(this);
|
m_thumb->addChangeListener(this);
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
}
|
}
|
||||||
@ -271,7 +278,7 @@ void WaveformComponent::setAudioFile(File f)
|
|||||||
{
|
{
|
||||||
m_waveimage = Image();
|
m_waveimage = Image();
|
||||||
if (m_thumb != nullptr && f == m_curfile) // reloading same file, might happen that the overview needs to be redone...
|
if (m_thumb != nullptr && f == m_curfile) // reloading same file, might happen that the overview needs to be redone...
|
||||||
m_thumbcache.removeThumb(m_thumb->getHashCode());
|
m_thumbcache->removeThumb(m_thumb->getHashCode());
|
||||||
if (m_thumb != nullptr)
|
if (m_thumb != nullptr)
|
||||||
m_thumb->reset(0, 0.0);
|
m_thumb->reset(0, 0.0);
|
||||||
m_thumb->setSource(new FileInputSource(f));
|
m_thumb->setSource(new FileInputSource(f));
|
||||||
@ -430,3 +437,11 @@ int WaveformComponent::getTimeSelectionEdge(int x, int y)
|
|||||||
return 2;
|
return 2;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cleanUpGUI()
|
||||||
|
{
|
||||||
|
if (g_thumbcache.unique())
|
||||||
|
{
|
||||||
|
g_thumbcache = nullptr;
|
||||||
|
}
|
||||||
|
}
|
@ -175,7 +175,7 @@ public:
|
|||||||
Value ShowFileCacheRange;
|
Value ShowFileCacheRange;
|
||||||
void setRecordingPosition(double pos) { m_rec_pos = pos; }
|
void setRecordingPosition(double pos) { m_rec_pos = pos; }
|
||||||
private:
|
private:
|
||||||
AudioThumbnailCache m_thumbcache;
|
std::shared_ptr<AudioThumbnailCache> m_thumbcache;
|
||||||
|
|
||||||
std::unique_ptr<AudioThumbnail> m_thumb;
|
std::unique_ptr<AudioThumbnail> m_thumb;
|
||||||
Range<double> m_view_range{ 0.0,1.0 };
|
Range<double> m_view_range{ 0.0,1.0 };
|
||||||
@ -221,3 +221,5 @@ private:
|
|||||||
void chooseFile();
|
void chooseFile();
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessorEditor)
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessorEditor)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void cleanUpGUI();
|
@ -96,6 +96,7 @@ PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor()
|
|||||||
{
|
{
|
||||||
g_activeprocessors.erase(this);
|
g_activeprocessors.erase(this);
|
||||||
m_bufferingthread.stopThread(1000);
|
m_bufferingthread.stopThread(1000);
|
||||||
|
cleanUpGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaulstretchpluginAudioProcessor::setPreBufferAmount(int x)
|
void PaulstretchpluginAudioProcessor::setPreBufferAmount(int x)
|
||||||
|
Loading…
Reference in New Issue
Block a user