From aa8599e808008a14ac0f7d40f91dc2e05bd3bd0a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 12 Apr 2014 19:59:17 +0200 Subject: Make engine ask output module for buffer size. Use this new feature to adapt internal buffers to buffer size reported by jack. --- src/audiooutputengine.h | 5 +++++ src/drumgizmo.cc | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/audiooutputengine.h b/src/audiooutputengine.h index 8b2b768..7f15e49 100644 --- a/src/audiooutputengine.h +++ b/src/audiooutputengine.h @@ -50,6 +50,11 @@ public: // Reimplement this if you wish to use internal buffer directly. virtual sample_t *getBuffer(int ch) { return NULL; } + + /* + * Overload this method to force engine to use different buffer size. + */ + virtual size_t getBufferSize() { return 1024; } }; #endif/*__DRUMGIZMO_AUDIOOUTPUTENGINE_H__*/ diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 4bd6a77..5d67c86 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -284,13 +284,13 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) void DrumGizmo::run(int endpos) { + size_t pos = 0; + size_t nsamples = oe->getBufferSize(); + sample_t *samples = (sample_t *)malloc(nsamples * sizeof(sample_t)); + ie->start(); oe->start(); - size_t pos = 0; - size_t nsamples = 128;//1024; - sample_t samples[nsamples]; - while(run(pos, samples, nsamples) == true) { pos += nsamples; if(endpos != -1 && pos >= (size_t)endpos) break; @@ -298,6 +298,8 @@ void DrumGizmo::run(int endpos) ie->stop(); oe->stop(); + + free(samples); } #ifdef SSE -- cgit v1.2.3