Avoid resetting Mockingboard state machine when all we need to do is reset the backend

- Also slightly disentangles audio initialization from reinitialization
This commit is contained in:
Aaron Culliney 2016-01-24 12:54:58 -08:00
parent b5fbf29f21
commit ba07bcc274
2 changed files with 23 additions and 3 deletions

View File

@ -1743,6 +1743,18 @@ void MB_Initialize()
}
}
#ifdef APPLE2IX
// HACK functions for "soft" destroying backend audio resource (but keeping current state)
void MB_SoftDestroy(void) {
assert(pthread_self() == cpu_thread_id);
MB_DSUninit();
}
void MB_SoftInitialize(void) {
assert(pthread_self() == cpu_thread_id);
MB_DSInit();
}
#endif
//-----------------------------------------------------------------------------
// NB. Called when /cycles_persec_target/ changes

View File

@ -72,7 +72,7 @@ bool alt_speed_enabled = false;
// misc
volatile uint8_t emul_reinitialize = 1;
#ifdef AUDIO_ENABLED
static bool emul_reinitialize_audio = true;
static bool emul_reinitialize_audio = false;
static bool emul_pause_audio = false;
static bool emul_resume_audio = false;
#endif
@ -286,6 +286,12 @@ static void *cpu_thread(void *dummyptr) {
unsigned long dbg_cycles_executed = 0;
#endif
#ifdef AUDIO_ENABLED
audio_init();
speaker_init();
MB_Initialize();
#endif
do
{
#ifdef AUDIO_ENABLED
@ -295,12 +301,14 @@ static void *cpu_thread(void *dummyptr) {
emul_reinitialize_audio = false;
speaker_destroy();
MB_Destroy();
extern void MB_SoftDestroy(void);
MB_SoftDestroy();
audio_shutdown();
audio_init();
speaker_init();
MB_Initialize();
extern void MB_SoftInitialize(void);
MB_SoftInitialize();
}
pthread_mutex_unlock(&interface_mutex);
LOG("UNLOCKING FOR MAYBE INITIALIZING AUDIO ...");