Allow cancelling offline render

This commit is contained in:
xenakios 2018-02-26 20:09:47 +02:00
parent ba067f7d4a
commit d76ac6118a
3 changed files with 12 additions and 3 deletions

View File

@ -360,8 +360,9 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu()
menu.addItem(6, "Dump preset to clipboard", true, false);
#endif
menu.addItem(7, "Show technical info", true, processor.m_show_technical_info);
menu.addItem(8, "Offline render...",
processor.m_offline_render_state == 200 || processor.m_offline_render_state == -1, false);
if (processor.m_offline_render_state==-1 || processor.m_offline_render_state == 200)
menu.addItem(8, "Offline render...", true, false);
else menu.addItem(9, "Cancel render", true, false);
int r = menu.show();
if (r >= 200 && r < 210)
{
@ -423,6 +424,10 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu()
{
processor.offlineRender(File("C:\\MusicAudio\\sourcesamples\\paultesmaus\\plugin_offline_test\\out.wav"));
}
if (r == 9)
{
processor.m_offline_render_cancel_requested = true;
}
}
WaveformComponent::WaveformComponent(AudioFormatManager* afm, AudioThumbnail* thumb)

View File

@ -453,12 +453,15 @@ String PaulstretchpluginAudioProcessor::offlineRender(File outputfile)
auto rendertask = [ss,writer,blocksize,numoutchans, outsr, this]()
{
AudioBuffer<float> renderbuffer(numoutchans, blocksize);
int64_t outlen = 50 * outsr;
int64_t outlen = 250 * outsr;
int64_t outcounter = 0;
AudioSourceChannelInfo asci(renderbuffer);
m_offline_render_state = 0;
m_offline_render_cancel_requested = false;
while (outcounter < outlen)
{
if (m_offline_render_cancel_requested == true)
break;
ss->getNextAudioBlock(asci);
writer->writeFromAudioSampleBuffer(renderbuffer, 0, blocksize);
outcounter += blocksize;

View File

@ -163,6 +163,7 @@ public:
void setStateFromTree(ValueTree tree);
String offlineRender(File outputfile);
std::atomic<int> m_offline_render_state{ -1 };
std::atomic<bool> m_offline_render_cancel_requested{ false };
bool m_state_dirty = false;
std::unique_ptr<AudioThumbnail> m_thumb;
bool m_show_technical_info = false;