summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-06-29 21:48:09 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2013-06-29 21:48:09 +0200
commit1d552637fd68a82b454b7d5c50d3599707914d5b (patch)
tree9268a6410f0e677302e502bb1e0a017b939c7651 /src
parent1deb487ccc9fbb40f4abbe7695048609a6c5a99d (diff)
Add some more AudioFile protection (mutex/magic word)
Diffstat (limited to 'src')
-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;
}