summaryrefslogtreecommitdiff
path: root/drumgizmo
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-04-08 00:15:32 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-04-08 00:15:32 +0200
commit057ef1d83ba263fb2adf1aa86f8e281ab0065c43 (patch)
tree31c1f237e3a9df9fc241d87527f7dd4245665d43 /drumgizmo
parentb530ac02af61e320e137a392decef1b3cc5af2c4 (diff)
Refactoring to finally get rid of MessageHandler/Receiver in favor of the new Settings mechanism.
Diffstat (limited to 'drumgizmo')
-rw-r--r--drumgizmo/drumgizmoc.cc76
-rw-r--r--drumgizmo/drumgizmoc.h17
2 files changed, 28 insertions, 65 deletions
diff --git a/drumgizmo/drumgizmoc.cc b/drumgizmo/drumgizmoc.cc
index 357877d..e993dc3 100644
--- a/drumgizmo/drumgizmoc.cc
+++ b/drumgizmo/drumgizmoc.cc
@@ -92,36 +92,7 @@ static const char usage_str[] =
" dummy:\n"
"\n";
-CliMain::CliMain()
- : MessageReceiver(MSGRCV_UI)
-{
- loading = true; // Block by default
-}
-
-CliMain::~CliMain()
-{
- hug_close();
-}
-
-void CliMain::handleMessage(Message* msg)
-{
- switch(msg->type())
- {
- case Message::LoadStatus:
- {
- auto ls = static_cast<LoadStatusMessage*>(msg);
- if(ls->numer_of_files_loaded == ls->number_of_files)
- {
- loading = false;
- }
- }
- break;
- default:
- break;
- }
-}
-
-int CliMain::run(int argc, char* argv[])
+int main(int argc, char* argv[])
{
int c;
@@ -383,21 +354,37 @@ int CliMain::run(int argc, char* argv[])
return 1;
}
- printf("Loading drumkit, this may take a while...");
- fflush(stdout);
- loading = true;
- while(async == false && loading)
+ printf("Loading drumkit, this may take a while:\n");
+
+ if(!async)
{
+ while(settings.drumkit_load_status.load() != LoadStatus::Done)
+ {
#ifdef WIN32
- SleepEx(500, FALSE);
+ SleepEx(10, FALSE);
#else
- usleep(500000);
+ usleep(10000);
#endif /*WIN32*/
- handleMessages();
- printf(".");
- fflush(stdout);
+
+ int total = settings.number_of_files.load();
+ int loaded = settings.number_of_files_loaded.load();
+
+ printf("\r%d of %d ", loaded, total);
+ fflush(stdout);
+
+ if(settings.drumkit_load_status.load() == LoadStatus::Error)
+ {
+ printf("\nLoad error\n");
+ return 1;
+ }
+
+ if(loaded == total)
+ {
+ //break;
+ }
+ }
+ printf("\ndone\n");
}
- printf("done.\n");
gizmo.setSamplerate(oe->getSamplerate());
@@ -412,14 +399,7 @@ int CliMain::run(int argc, char* argv[])
printf("Quit.\n");
fflush(stdout);
- return 0;
-}
-
-int main(int argc, char* argv[])
-{
- CliMain cli;
-
- cli.run(argc, argv);
+ hug_close();
return 0;
}
diff --git a/drumgizmo/drumgizmoc.h b/drumgizmo/drumgizmoc.h
index 231aec6..cc2f96c 100644
--- a/drumgizmo/drumgizmoc.h
+++ b/drumgizmo/drumgizmoc.h
@@ -24,21 +24,4 @@
* along with DrumGizmo; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-
#pragma once
-
-#include "messagereceiver.h"
-
-class CliMain : public MessageReceiver
-{
-public:
- CliMain();
- virtual ~CliMain();
-
- int run(int argc, char* argv[]);
- void handleMessage(Message* msg);
-
-private:
- bool loading;
-};
-