summaryrefslogtreecommitdiff
path: root/src/drumkitloader.cc
diff options
context:
space:
mode:
authorjsc@umbraculum.org <jsc@umbraculum.org>2013-04-26 09:33:03 +0200
committerjsc@umbraculum.org <jsc@umbraculum.org>2013-04-26 09:33:03 +0200
commitb01735c66d7a3aaa9102b9994a50b80db746c8f0 (patch)
tree5e82f11a9c973433226e418c0409c8ce4309ba2e /src/drumkitloader.cc
parent510d7da958153afd3749906e2dd816bc9c41efc6 (diff)
parent3dcc42c508dd798b9034f77e6f83ec75e648936c (diff)
Merge branch 'master' of http://git.drumgizmo.org/drumgizmo
Diffstat (limited to 'src/drumkitloader.cc')
-rw-r--r--src/drumkitloader.cc25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/drumkitloader.cc b/src/drumkitloader.cc
index be74624..79d000a 100644
--- a/src/drumkitloader.cc
+++ b/src/drumkitloader.cc
@@ -36,15 +36,30 @@ DrumKitLoader::DrumKitLoader(DrumGizmo *dg)
drumgizmo = dg;
is_done = false;
quitit = false;
+ skipit = false;
}
DrumKitLoader::~DrumKitLoader()
{
+ if(!quitit) {
+ stop();
+ }
+}
+
+void DrumKitLoader::stop()
+{
quitit = true;
semaphore.post();
wait_stop();
}
+void DrumKitLoader::skip()
+{
+ skipit = true;
+ semaphore.post();
+ skip_semaphore.wait();
+}
+
bool DrumKitLoader::isDone()
{
bool done;
@@ -67,8 +82,6 @@ void DrumKitLoader::loadKit(DrumKit *kit)
semaphore.post();
}
-
-
void DrumKitLoader::thread_main()
{
while(1) {
@@ -79,6 +92,12 @@ void DrumKitLoader::thread_main()
if(quitit) return;
+ if(skipit) {
+ skip_semaphore.post();
+ skipit = false;
+ continue;
+ }
+
unsigned int count = 0;
if(kit && !kit->isValid()) goto finish;
@@ -125,6 +144,8 @@ void DrumKitLoader::thread_main()
drumgizmo->sendGUIMessage(ls);
a++;
+
+ if(skipit) goto finish;
}
i++;