From d0e5951bfc998872fbef606069daba079b9995f8 Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Fri, 15 Nov 2013 20:49:48 +0000 Subject: [PATCH] -Fixed loading issue in DiskReader --- src/diskreader.cxx | 51 ++++++++++++++++++++++++++++++---------------- src/diskreader.hxx | 3 +++ 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/diskreader.cxx b/src/diskreader.cxx index 4b30a41..38f3fa8 100644 --- a/src/diskreader.cxx +++ b/src/diskreader.cxx @@ -73,7 +73,7 @@ int DiskReader::loadPreferences() } cJSON_Delete( preferencesJson ); - free ( sampleString ); + delete[] sampleString; } else { @@ -84,6 +84,27 @@ int DiskReader::loadPreferences() return LUPPP_RETURN_OK; } +int DiskReader::showAudioEditor(AudioBuffer* ab) +{ + while ( ab->getBeats() == 0 ) + { + // FIXME: Cancel = no load sample? + gui->getAudioEditor()->show( ab, true ); + + while ( gui->getAudioEditor()->shown() ) Fl::wait(); + + // handle "cancel" return + if ( ab->getBeats() == -1 ) + { + LUPPP_WARN("cancel clicked, deleting audiobuffer" ); + return LUPPP_RETURN_ERROR; + } + } + + return LUPPP_RETURN_OK; +} + + int DiskReader::loadSample( int track, int scene, string path ) { /// load the sample @@ -176,6 +197,11 @@ int DiskReader::loadSample( int track, int scene, string path ) else { cout << "Warning: audio.cfg has no entry for beats." << endl; + int error = showAudioEditor( ab ); + if ( error == LUPPP_RETURN_ERROR ) + { + delete ab; + } } cJSON_Delete( audioJson ); @@ -184,24 +210,13 @@ int DiskReader::loadSample( int track, int scene, string path ) } else { - - while ( ab->getBeats() == 0 ) + // this means there's no audio.cfg file found for the sample: show the user + // the file, and ask what the intended beat number is, and load the AudioBuffer + LUPPP_WARN("%s %s","Empty or no audio.cfg found at ",base.str().c_str() ); + int error = showAudioEditor( ab ); + if ( error == LUPPP_RETURN_ERROR ) { - // this means there's no audio.cfg file found for the sample: show the user - // the file, and ask what the intended beat number is, and load the AudioBuffer - LUPPP_WARN("%s %s","Empty or no audio.cfg found at ",base.str().c_str() ); - - // FIXME: Cancel = no load sample? - gui->getAudioEditor()->show( ab, true ); - while ( gui->getAudioEditor()->shown() ) Fl::wait(); - - // handle "cancel" return - if ( ab->getBeats() == -1 ) - { - LUPPP_WARN("cancel clicked, deleting audiobuffer" ); - delete ab; - return LUPPP_RETURN_OK; - } + delete ab; } } diff --git a/src/diskreader.hxx b/src/diskreader.hxx index 5e1614e..41ecd9e 100644 --- a/src/diskreader.hxx +++ b/src/diskreader.hxx @@ -48,6 +48,9 @@ class DiskReader int readTracks(); int readMaster(); int readScenes(int t, cJSON* track); + + // ui show editor + int showAudioEditor(AudioBuffer* ); }; #endif // LUPPP_DISK_READER_H