From b5a106f0b09976c386c40e5c814d1c1e30fa8dd7 Mon Sep 17 00:00:00 2001 From: xenakios Date: Thu, 8 Nov 2018 22:48:06 +0200 Subject: [PATCH] Use plugin settings file directory for captures. Use Juce ThreadPool instead of detached std::thread for the capture saving task. --- Source/PluginProcessor.cpp | 7 +++---- Source/PluginProcessor.h | 8 +++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 1a9ea54..4ddfb7e 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -487,8 +487,8 @@ void PaulstretchpluginAudioProcessor::saveCaptureBuffer() return; Uuid uid; WavAudioFormat wavformat; - String outfn = File::getSpecialLocation(File::SpecialLocationType::userDocumentsDirectory).getFullPathName() + "/paulxstretchaudiocaptures/" + - uid.toString() + ".wav"; + String propsdir = m_propsfile->m_props_file->getFile().getParentDirectory().getFullPathName(); + String outfn = propsdir + "/paulxstretchaudiocaptures/" + uid.toString() + ".wav"; Logger::writeToLog("Attempting to save capture to file " + outfn); File outfile(outfn); outfile.create(); @@ -515,8 +515,7 @@ void PaulstretchpluginAudioProcessor::saveCaptureBuffer() else Logger::writeToLog("Could not create output file"); }; - std::thread th(task); - th.detach(); + m_threadpool->addJob(task); } String PaulstretchpluginAudioProcessor::offlineRender(File outputfile) diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index e52b794..ab3d4cd 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -89,6 +89,12 @@ const int cpi_looping_enabled = 60; const int cpi_rewind = 61; const int cpi_dryplayrate = 62; +class MyThreadPool : public ThreadPool +{ +public: + MyThreadPool() : ThreadPool(2) {} +}; + class MyPropertiesFile { public: @@ -263,7 +269,7 @@ private: bool m_lastrewind = false; AudioFilePreviewComponent* m_previewcomponent = nullptr; void saveCaptureBuffer(); - + SharedResourcePointer m_threadpool; //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor) };