diff options
author | Nils Wallménius <nils@rockbox.org> | 2007-10-21 22:50:10 +0000 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2007-10-21 22:50:10 +0000 |
commit | 2d91cf3ea39e409bc72fd687aa7638cc34191bd9 (patch) | |
tree | 5986cd4528f94105da180daa06b07b4eb5a8d76b /apps/plugins/midi | |
parent | 47d8323deb8c7351c66a89599f15b60e06a5b814 (diff) |
Increase temp buffer size to fit more samples, put in simple safeguard to avoid memory corruption when writing to the temp buffer
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15253 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/midi')
-rw-r--r-- | apps/plugins/midi/synth.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c index 3c60d9bd82..4e04975e0b 100644 --- a/apps/plugins/midi/synth.c +++ b/apps/plugins/midi/synth.c @@ -424,29 +424,33 @@ static inline void synthVoice(struct SynthObject * so, int32_t * out, unsigned i /* buffer to hold all the samples for the current tick, this is a hack neccesary for coldfire targets as pcm_play_data uses the dma which cannot access iram */ -int32_t samp_buf[256] IBSS_ATTR; +int32_t samp_buf[512] IBSS_ATTR; /* synth num_samples samples and write them to the */ /* buffer pointed to by buf_ptr */ void synthSamples(int32_t *buf_ptr, unsigned int num_samples) ICODE_ATTR; void synthSamples(int32_t *buf_ptr, unsigned int num_samples) { - int i; - struct SynthObject *voicept; + if (num_samples > 512) + DEBUGF("num_samples is too big!\n"); + else + { + int i; + struct SynthObject *voicept; - rb->memset(samp_buf, 0, num_samples*4); + rb->memset(samp_buf, 0, num_samples*4); - for(i=0; i < MAX_VOICES; i++) - { - voicept=&voices[i]; - if(voicept->isUsed==1) + for(i=0; i < MAX_VOICES; i++) { - synthVoice(voicept, samp_buf, num_samples); + voicept=&voices[i]; + if(voicept->isUsed==1) + { + synthVoice(voicept, samp_buf, num_samples); + } } - } - - rb->memcpy(buf_ptr, samp_buf, num_samples*4); + rb->memcpy(buf_ptr, samp_buf, num_samples*4); + } /* TODO: Automatic Gain Control, anyone? */ /* Or, should this be implemented on the DSP's output volume instead? */ |