summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2007-10-23 15:00:45 +0000
committerNils Wallménius <nils@rockbox.org>2007-10-23 15:00:45 +0000
commita3117328e943c23cf542059386e2ce53a0e796fe (patch)
treee658a13829686a1b746967dd8e05ed0eeff08c13 /apps
parenteed41ff985ba92181a00e6a060dc460828feb7dc (diff)
downloadrockbox-a3117328e943c23cf542059386e2ce53a0e796fe.tar.gz
rockbox-a3117328e943c23cf542059386e2ce53a0e796fe.zip
Fix vroken logic that _could_ lead to memory corruption though it was very unlikely
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15281 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/midi/midiplay.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c
index 325d90c375..974dc99069 100644
--- a/apps/plugins/midi/midiplay.c
+++ b/apps/plugins/midi/midiplay.c
@@ -89,7 +89,7 @@ PLUGIN_IRAM_DECLARE
89 89
90struct MIDIfile * mf IBSS_ATTR; 90struct MIDIfile * mf IBSS_ATTR;
91 91
92int numberOfSamples IBSS_ATTR; 92int numberOfSamples IBSS_ATTR; /* the number of samples in the current tick */
93long bpm IBSS_ATTR; 93long bpm IBSS_ATTR;
94 94
95int32_t gmbuf[BUF_SIZE*NBUF]; 95int32_t gmbuf[BUF_SIZE*NBUF];
@@ -150,7 +150,7 @@ bool lastswap=1;
150static inline void synthbuf(void) 150static inline void synthbuf(void)
151{ 151{
152 int32_t *outptr; 152 int32_t *outptr;
153 int i; 153 int i=BUF_SIZE;
154 154
155#ifndef SYNC 155#ifndef SYNC
156 if(lastswap==swap) return; 156 if(lastswap==swap) return;
@@ -162,7 +162,7 @@ static inline void synthbuf(void)
162#endif 162#endif
163 163
164 /* synth samples for as many whole ticks as we can fit in the buffer */ 164 /* synth samples for as many whole ticks as we can fit in the buffer */
165 for(i=0; i < BUF_SIZE/numberOfSamples; i++) 165 for(; i >= numberOfSamples; i -= numberOfSamples)
166 { 166 {
167 synthSamples((int32_t*)outptr, numberOfSamples); 167 synthSamples((int32_t*)outptr, numberOfSamples);
168 outptr += numberOfSamples; 168 outptr += numberOfSamples;
@@ -171,7 +171,7 @@ static inline void synthbuf(void)
171 } 171 }
172 172
173 /* how many samples did we write to the buffer? */ 173 /* how many samples did we write to the buffer? */
174 samples_in_buf = BUF_SIZE-(BUF_SIZE%numberOfSamples); 174 samples_in_buf = BUF_SIZE-i;
175 175
176} 176}
177 177