diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2015-04-23 15:20:48 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-01-20 13:24:28 +0100 |
commit | b67e30cb862ab640e4a7ced48b1905b2421885b9 (patch) | |
tree | 73bc34c7c88a6ba33ca6a9c22ed43cff86376e11 /src/drumgizmo.cc | |
parent | eaa2062ea50fea853fa1852b152354ba50d44985 (diff) |
Added run sempahore (wait until thread actually started). Fixed localpos bug. Added 'threaded' argument to init that handles events either directly or in a thread when dispatched. Added cachemanager unit test (currently failing).
Diffstat (limited to 'src/drumgizmo.cc')
-rw-r--r-- | src/drumgizmo.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 2f04488..6c40748 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -50,7 +50,7 @@ DrumGizmo::DrumGizmo(AudioOutputEngine *o, AudioInputEngine *i) loader(), oe(o), ie(i) { is_stopping = false; - cacheManager.init(1000); // start thread + cacheManager.init(1000, true); // start thread } DrumGizmo::~DrumGizmo() @@ -415,10 +415,18 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz) { MutexAutolock l(af->mutex); - size_t n = 0; + size_t n = 0; // default start point is 0. + + // If we are not at offset 0 in current buffer: if(evt->offset > (size_t)pos) n = evt->offset - pos; - size_t end = sz; + + size_t end = sz; // default end point is the end of the buffer. + + // Find the end point intra-buffer if((evt->t + end - n) > af->size) end = af->size - evt->t + n; + + // This should not be necessary but make absolutely shure that we do + // not write over the end of the buffer. if(end > sz) end = sz; if(evt->rampdown == NO_RAMPDOWN) { |