Use Juce CriticalSection for main audio processor too. Use tryEnter for changing main volume parameter. Looks like it's best to do the tryEnter stuff for everything possible...
This commit is contained in:
parent
7805f1a0aa
commit
5a17f43763
@ -134,9 +134,12 @@ void StretchAudioSource::setMainVolume(double decibels)
|
|||||||
{
|
{
|
||||||
if (decibels == m_main_volume)
|
if (decibels == m_main_volume)
|
||||||
return;
|
return;
|
||||||
ScopedLock locker(m_cs);
|
if (m_cs.tryEnter())
|
||||||
m_main_volume = jlimit(-144.0, 12.0, decibels);
|
{
|
||||||
++m_param_change_count;
|
m_main_volume = jlimit(-144.0, 12.0, decibels);
|
||||||
|
++m_param_change_count;
|
||||||
|
m_cs.exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StretchAudioSource::setLoopXFadeLength(double lenseconds)
|
void StretchAudioSource::setLoopXFadeLength(double lenseconds)
|
||||||
|
@ -226,7 +226,7 @@ void PaulstretchpluginAudioProcessor::startplay(Range<double> playrange, int num
|
|||||||
|
|
||||||
void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
|
void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> locker(m_mutex);
|
ScopedLock locker(m_cs);
|
||||||
if (getNumOutputChannels() != m_cur_num_out_chans)
|
if (getNumOutputChannels() != m_cur_num_out_chans)
|
||||||
m_ready_to_play = false;
|
m_ready_to_play = false;
|
||||||
if (m_using_memory_buffer == true)
|
if (m_using_memory_buffer == true)
|
||||||
@ -301,7 +301,7 @@ void copyAudioBufferWrappingPosition(const AudioBuffer<float>& src, AudioBuffer<
|
|||||||
|
|
||||||
void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
|
void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> locker(m_mutex);
|
ScopedLock locker(m_cs);
|
||||||
ScopedNoDenormals noDenormals;
|
ScopedNoDenormals noDenormals;
|
||||||
const int totalNumInputChannels = getTotalNumInputChannels();
|
const int totalNumInputChannels = getTotalNumInputChannels();
|
||||||
const int totalNumOutputChannels = getTotalNumOutputChannels();
|
const int totalNumOutputChannels = getTotalNumOutputChannels();
|
||||||
@ -394,7 +394,7 @@ void PaulstretchpluginAudioProcessor::setStateInformation (const void* data, int
|
|||||||
if (tree.isValid())
|
if (tree.isValid())
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> locker(m_mutex);
|
ScopedLock locker(m_cs);
|
||||||
for (int i = 0; i < getNumParameters(); ++i)
|
for (int i = 0; i < getNumParameters(); ++i)
|
||||||
{
|
{
|
||||||
auto par = getFloatParameter(i);
|
auto par = getFloatParameter(i);
|
||||||
@ -416,7 +416,7 @@ void PaulstretchpluginAudioProcessor::setStateInformation (const void* data, int
|
|||||||
|
|
||||||
void PaulstretchpluginAudioProcessor::setRecordingEnabled(bool b)
|
void PaulstretchpluginAudioProcessor::setRecordingEnabled(bool b)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> locker(m_mutex);
|
ScopedLock locker(m_cs);
|
||||||
int lenbufframes = getSampleRate()*m_max_reclen;
|
int lenbufframes = getSampleRate()*m_max_reclen;
|
||||||
if (b == true)
|
if (b == true)
|
||||||
{
|
{
|
||||||
@ -462,7 +462,7 @@ String PaulstretchpluginAudioProcessor::setAudioFile(File f)
|
|||||||
//MessageManager::callAsync([cb, file]() { cb("Too high bit depth in file " + file.getFullPathName()); });
|
//MessageManager::callAsync([cb, file]() { cb("Too high bit depth in file " + file.getFullPathName()); });
|
||||||
return "Too high bit depth in file " + f.getFullPathName();
|
return "Too high bit depth in file " + f.getFullPathName();
|
||||||
}
|
}
|
||||||
std::lock_guard<std::mutex> locker(m_mutex);
|
ScopedLock locker(m_cs);
|
||||||
m_stretch_source->setAudioFile(f);
|
m_stretch_source->setAudioFile(f);
|
||||||
m_current_file = f;
|
m_current_file = f;
|
||||||
m_using_memory_buffer = false;
|
m_using_memory_buffer = false;
|
||||||
|
@ -104,7 +104,7 @@ private:
|
|||||||
void finishRecording(int lenrecorded);
|
void finishRecording(int lenrecorded);
|
||||||
bool m_using_memory_buffer = true;
|
bool m_using_memory_buffer = true;
|
||||||
int m_cur_num_out_chans = 2;
|
int m_cur_num_out_chans = 2;
|
||||||
std::mutex m_mutex;
|
CriticalSection m_cs;
|
||||||
File m_current_file;
|
File m_current_file;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user