From 1d552637fd68a82b454b7d5c50d3599707914d5b Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 29 Jun 2013 21:48:09 +0200 Subject: Add some more AudioFile protection (mutex/magic word) --- src/audiofile.h | 3 ++- src/drumgizmo.cc | 7 ++++++- 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; } -- cgit v1.2.3