Midi Player: fix premature stopping of audio buffer playback
Change-Id: I3794e8d8837722442b25e2b48db1b5b3c3c2dc51
This commit is contained in:
parent
69e9738a1c
commit
5279d60e0a
1 changed files with 10 additions and 1 deletions
|
@ -323,6 +323,7 @@ long bpm IBSS_ATTR;
|
||||||
int32_t gmbuf[BUF_SIZE*NBUF];
|
int32_t gmbuf[BUF_SIZE*NBUF];
|
||||||
static unsigned int samples_in_buf;
|
static unsigned int samples_in_buf;
|
||||||
|
|
||||||
|
bool midi_end = false;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
bool swap = false;
|
bool swap = false;
|
||||||
bool lastswap = true;
|
bool lastswap = true;
|
||||||
|
@ -341,6 +342,10 @@ static inline void synthbuf(void)
|
||||||
#else
|
#else
|
||||||
outptr = gmbuf;
|
outptr = gmbuf;
|
||||||
#endif
|
#endif
|
||||||
|
if (midi_end) {
|
||||||
|
samples_in_buf = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* synth samples for as many whole ticks as we can fit in the buffer */
|
/* synth samples for as many whole ticks as we can fit in the buffer */
|
||||||
for (; i >= number_of_samples; i -= number_of_samples)
|
for (; i >= number_of_samples; i -= number_of_samples)
|
||||||
|
@ -353,7 +358,7 @@ static inline void synthbuf(void)
|
||||||
rb->yield();
|
rb->yield();
|
||||||
#endif
|
#endif
|
||||||
if (tick() == 0)
|
if (tick() == 0)
|
||||||
quit = true;
|
midi_end = true; /* no more midi data to play */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* how many samples did we write to the buffer? */
|
/* how many samples did we write to the buffer? */
|
||||||
|
@ -379,6 +384,10 @@ static void get_more(const void** start, size_t* size)
|
||||||
#else
|
#else
|
||||||
*start = gmbuf;
|
*start = gmbuf;
|
||||||
#endif
|
#endif
|
||||||
|
if (samples_in_buf==0) {
|
||||||
|
*start = NULL;
|
||||||
|
quit = true; /* this was the last buffer to play */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int midimain(const void * filename)
|
static int midimain(const void * filename)
|
||||||
|
|
Loading…
Reference in a new issue