summaryrefslogtreecommitdiff
path: root/drumgizmo/drumgizmoc.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2015-02-08 10:30:21 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2015-02-08 10:30:21 +0100
commit711c3124bb939a8edfa8e483001307826d0c5d86 (patch)
treee057e6414c7e0410734d36b4230a58cc84348c72 /drumgizmo/drumgizmoc.cc
parent25fbccf770d4e68950311a434c810af3a98f127f (diff)
[PATCH] Wait for the drumkit to get loaded before starting playback (by Sergey 'Jin' Bostandzhyan)
Diffstat (limited to 'drumgizmo/drumgizmoc.cc')
-rw-r--r--drumgizmo/drumgizmoc.cc58
1 files changed, 57 insertions, 1 deletions
diff --git a/drumgizmo/drumgizmoc.cc b/drumgizmo/drumgizmoc.cc
index 61f8eaa..d8479fa 100644
--- a/drumgizmo/drumgizmoc.cc
+++ b/drumgizmo/drumgizmoc.cc
@@ -30,8 +30,10 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#include "drumgizmo.h"
+#include "drumgizmoc.h"
#include "audiooutputenginedl.h"
#include "audioinputenginedl.h"
@@ -64,7 +66,29 @@ static const char usage_str[] =
" -h, --help Print this message and exit.\n"
;
-int main(int argc, char *argv[])
+CliMain::CliMain() : MessageReceiver(MSGRCV_UI), loading(false)
+{}
+
+CliMain::~CliMain()
+{}
+
+void CliMain::handleMessage(Message *msg)
+{
+ switch(msg->type()) {
+ case Message::LoadStatus:
+ {
+ LoadStatusMessage *ls = (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 c;
@@ -243,11 +267,27 @@ int main(int argc, char *argv[])
printf("Using kitfile: %s\n", kitfile.c_str());
DrumGizmo gizmo(oe, ie);
+
if(kitfile == "" || !gizmo.loadkit(kitfile)) {
printf("Failed to load \"%s\".\n", kitfile.c_str());
return 1;
}
+ printf("Loading drumkit, this may take a while...");
+ fflush(stdout);
+ loading = true;
+ while (loading) {
+#ifdef WIN32
+ SleepEx(500, FALSE);
+#else
+ usleep(500000);
+#endif/*WIN32*/
+ handleMessages();
+ printf(".");
+ fflush(stdout);
+ }
+ printf("done.\n");
+
gizmo.setSamplerate(oe->samplerate());
if(!gizmo.init(preload)) {
@@ -264,3 +304,19 @@ int main(int argc, char *argv[])
return 0;
}
+
+int main(int argc, char *argv[])
+{
+
+ CliMain* cli = new CliMain();
+ if (cli == NULL) {
+ printf("Could not initialize command line client\n");
+ return 1;
+ }
+
+ cli->run(argc, argv);
+ delete cli;
+
+ return 0;
+
+}