summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/audiofile.h3
-rw-r--r--src/drumgizmo.cc7
2 files changed, 8 insertions, 2 deletions
diff --git a/src/audiofile.h b/src/audiofile.h
index c364b85..46c9285 100644
--- a/src/audiofile.h
+++ b/src/audiofile.h
@@ -95,9 +95,10 @@ public:
bool isValid();
int ref_count;
+ Mutex mutex;
+
private:
void *magic;
- Mutex mutex;
bool is_loaded;
};
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc
index 135975d..5e14179 100644
--- a/src/drumgizmo.cc
+++ b/src/drumgizmo.cc
@@ -351,11 +351,14 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz)
EventSample *evt = (EventSample *)event;
AudioFile *af = evt->file;
- if(!af->isLoaded() || s == NULL) {
+ if(!af->isLoaded() || !af->isValid() || s == NULL) {
removeevent = true;
break;
}
+ {
+ MutexAutolock l(af->mutex);
+
size_t n = 0;
if(evt->offset > (size_t)pos) n = evt->offset - pos;
size_t end = sz;
@@ -389,6 +392,8 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz)
// LAZYLOAD:
// loader.reset(af);
}
+
+ }
}
break;
}