summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorSebastian Leonhardt <sebastian.leonhardt@web.de>2016-10-01 22:58:50 +0200
committerGerrit Rockbox <gerrit@rockbox.org>2017-01-06 20:44:25 +0100
commit5279d60e0afb13b39efdcd21585baa251d0133a6 (patch)
treef62ad61023b62e1714b4a2f5103312ab49d238f3 /apps/plugins
parent69e9738a1c7bba243eda271f1e22ef8b0b5a1cec (diff)
Midi Player: fix premature stopping of audio buffer playback
Change-Id: I3794e8d8837722442b25e2b48db1b5b3c3c2dc51
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/midi/midiplay.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c
index 6df1578bb3..344efd317e 100644
--- a/apps/plugins/midi/midiplay.c
+++ b/apps/plugins/midi/midiplay.c
@@ -323,6 +323,7 @@ long bpm IBSS_ATTR;
int32_t gmbuf[BUF_SIZE*NBUF];
static unsigned int samples_in_buf;
+bool midi_end = false;
bool quit = false;
bool swap = false;
bool lastswap = true;
@@ -341,6 +342,10 @@ static inline void synthbuf(void)
#else
outptr = gmbuf;
#endif
+ if (midi_end) {
+ samples_in_buf = 0;
+ return;
+ }
/* synth samples for as many whole ticks as we can fit in the buffer */
for (; i >= number_of_samples; i -= number_of_samples)
@@ -353,7 +358,7 @@ static inline void synthbuf(void)
rb->yield();
#endif
if (tick() == 0)
- quit = true;
+ midi_end = true; /* no more midi data to play */
}
/* how many samples did we write to the buffer? */
@@ -379,6 +384,10 @@ static void get_more(const void** start, size_t* size)
#else
*start = gmbuf;
#endif
+ if (samples_in_buf==0) {
+ *start = NULL;
+ quit = true; /* this was the last buffer to play */
+ }
}
static int midimain(const void * filename)