Fixed register/unregister wave callback (found while testing OPL code).

This commit is contained in:
Volker Ruppert 2015-01-10 19:36:50 +00:00
parent fe953485b1
commit 15ccdef0d1
2 changed files with 6 additions and 3 deletions

View File

@ -213,7 +213,9 @@ bx_sb16_c::~bx_sb16_c(void)
{
closemidioutput();
soundmod->unregister_wave_callback(fmopl_callback_id);
if (soundmod != NULL) {
soundmod->unregister_wave_callback(fmopl_callback_id);
}
if (DSP.inputinit != 0) {
BX_SB16_OUTPUT->closewaveinput();
}

View File

@ -208,15 +208,16 @@ int bx_sound_sdl_c::register_wave_callback(void *arg, get_wave_cb_t wd_cb)
if (cb_count < BX_MAX_WAVE_CALLBACKS) {
get_wave[cb_count].device = arg;
get_wave[cb_count].cb = wd_cb;
cb_count++;
return cb_count++;
}
return cb_count;
return -1;
}
void bx_sound_sdl_c::unregister_wave_callback(int callback_id)
{
SDL_LockAudio();
if ((callback_id >= 0) && (callback_id < BX_MAX_WAVE_CALLBACKS)) {
get_wave[callback_id].device = NULL;
get_wave[callback_id].cb = NULL;
}
SDL_UnlockAudio();