xworld: fix several horrendous bugs

- unregisters timer on exit, preventing possible crash
- disables synchronization mechanisms when used from an IRQ
- prevents memory allocations from overflowing the audio buffer (unlikely)

Change-Id: I3c2c4ebe93c10ca9176ed0455e7aacc2d10c059e
This commit is contained in:
Franklin Wei 2017-02-12 20:28:53 -05:00
parent e4a04fa105
commit 0a9f71790b

View file

@ -117,6 +117,7 @@ void exit_handler(void)
{ {
sys_save_settings(save_sys); sys_save_settings(save_sys);
sys_stopAudio(save_sys); sys_stopAudio(save_sys);
rb->timer_unregister();
#ifdef HAVE_ADJUSTABLE_CPU_FREQ #ifdef HAVE_ADJUSTABLE_CPU_FREQ
rb->cpu_boost(false); rb->cpu_boost(false);
#endif #endif
@ -1114,7 +1115,8 @@ void *sys_get_buffer(struct System* sys, size_t sz)
{ {
void* ret = sys->membuf; void* ret = sys->membuf;
rb->memset(ret, 0, sz); rb->memset(ret, 0, sz);
sys->membuf += sz; sys->membuf = (char*)(sys->membuf) + sz;
sys->bytes_left -= sz;
return ret; return ret;
} }
else else
@ -1128,11 +1130,12 @@ void MutexStack(struct MutexStack_t* s, struct System *stub, void *mutex)
{ {
s->sys = stub; s->sys = stub;
s->_mutex = mutex; s->_mutex = mutex;
sys_lockMutex(s->sys, s->_mutex); /* FW 2017-2-12: disabled; no blocking ops in IRQ context! */
/*sys_lockMutex(s->sys, s->_mutex);*/
} }
void MutexStack_destroy(struct MutexStack_t* s) void MutexStack_destroy(struct MutexStack_t* s)
{ {
sys_unlockMutex(s->sys, s->_mutex); (void) s;
/*sys_unlockMutex(s->sys, s->_mutex);*/
} }