Use plugin settings file directory for captures. Use Juce ThreadPool instead of detached std::thread for the capture saving task.
This commit is contained in:
		@@ -487,8 +487,8 @@ void PaulstretchpluginAudioProcessor::saveCaptureBuffer()
 | 
				
			|||||||
			return;
 | 
								return;
 | 
				
			||||||
		Uuid uid;
 | 
							Uuid uid;
 | 
				
			||||||
		WavAudioFormat wavformat;
 | 
							WavAudioFormat wavformat;
 | 
				
			||||||
		String outfn = File::getSpecialLocation(File::SpecialLocationType::userDocumentsDirectory).getFullPathName() + "/paulxstretchaudiocaptures/" +
 | 
							String propsdir = m_propsfile->m_props_file->getFile().getParentDirectory().getFullPathName();
 | 
				
			||||||
			uid.toString() + ".wav";
 | 
							String outfn = propsdir + "/paulxstretchaudiocaptures/" + uid.toString() + ".wav";
 | 
				
			||||||
		Logger::writeToLog("Attempting to save capture to file " + outfn);
 | 
							Logger::writeToLog("Attempting to save capture to file " + outfn);
 | 
				
			||||||
		File outfile(outfn);
 | 
							File outfile(outfn);
 | 
				
			||||||
		outfile.create();
 | 
							outfile.create();
 | 
				
			||||||
@@ -515,8 +515,7 @@ void PaulstretchpluginAudioProcessor::saveCaptureBuffer()
 | 
				
			|||||||
		else
 | 
							else
 | 
				
			||||||
			Logger::writeToLog("Could not create output file");
 | 
								Logger::writeToLog("Could not create output file");
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	std::thread th(task);
 | 
						m_threadpool->addJob(task);
 | 
				
			||||||
	th.detach();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
String PaulstretchpluginAudioProcessor::offlineRender(File outputfile)
 | 
					String PaulstretchpluginAudioProcessor::offlineRender(File outputfile)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -89,6 +89,12 @@ const int cpi_looping_enabled = 60;
 | 
				
			|||||||
const int cpi_rewind = 61;
 | 
					const int cpi_rewind = 61;
 | 
				
			||||||
const int cpi_dryplayrate = 62;
 | 
					const int cpi_dryplayrate = 62;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class MyThreadPool : public ThreadPool
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						MyThreadPool() : ThreadPool(2) {}
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MyPropertiesFile
 | 
					class MyPropertiesFile
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
@@ -263,7 +269,7 @@ private:
 | 
				
			|||||||
	bool m_lastrewind = false;
 | 
						bool m_lastrewind = false;
 | 
				
			||||||
	AudioFilePreviewComponent* m_previewcomponent = nullptr;
 | 
						AudioFilePreviewComponent* m_previewcomponent = nullptr;
 | 
				
			||||||
	void saveCaptureBuffer();
 | 
						void saveCaptureBuffer();
 | 
				
			||||||
	
 | 
						SharedResourcePointer<MyThreadPool> m_threadpool;
 | 
				
			||||||
	//==============================================================================
 | 
						//==============================================================================
 | 
				
			||||||
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
 | 
					    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user