Skip to content

Commit

Permalink
sound: remove unneeded code, restore deferred calls to audio init
Browse files Browse the repository at this point in the history
  • Loading branch information
KrahJohlito committed Jul 5, 2020
1 parent c487160 commit 6a1cdd1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 0 additions & 2 deletions include/opl.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ int gCheatSource;
int gGSMSource;
int gPadEmuSource;

int toggleSfx;

int showCfgPopup;

#ifdef IGS
Expand Down
30 changes: 17 additions & 13 deletions src/opl.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ static void clearIOModuleT(opl_io_module_t *mod)
static void clearMenuGameList(opl_io_module_t *mdl);
static void moduleCleanup(opl_io_module_t *mod, int exception, int modeSelected);
static void reset(void);
static void deferredAudioInit(void);

// frame counter
static unsigned int frameCounter;
Expand Down Expand Up @@ -1251,12 +1252,6 @@ static int loadHdldSvr(void)
{
int ret, padStatus;

// disable sfx before audio lib
if (gEnableSFX) {
gEnableSFX = 0;
toggleSfx = 1;
}

// deint audio lib while hdl server is running
sfxEnd();

Expand Down Expand Up @@ -1317,12 +1312,8 @@ static void unloadHdldSvr(void)
// init all supports again
initAllSupport(1);

// reinit audio lib
sfxInit(1);
if (!gEnableSFX && toggleSfx) {
gEnableSFX = 1;
toggleSfx = 0;
}
// deferred reinit of audio lib to avoid crashing if devices aren't ready
ioPutRequest(IO_CUSTOM_SIMPLEACTION, &deferredAudioInit);
}

void handleHdlSrv()
Expand Down Expand Up @@ -1510,7 +1501,6 @@ static void init(void)
lngInit();
thmInit();
guiInit();
sfxInit(1);
ioInit();
menuInit();

Expand All @@ -1527,6 +1517,9 @@ static void init(void)

// try to restore config
_loadConfig();

// queue deffered init of sound effects, which will take place after the preceding initialization steps within the queue are complete.
ioPutRequest(IO_CUSTOM_SIMPLEACTION, &deferredAudioInit);
}

static void deferredInit(void)
Expand All @@ -1543,6 +1536,17 @@ static void deferredInit(void)
}
}

static void deferredAudioInit(void)
{
int ret;

ret = sfxInit(1);
if (ret < 0)
LOG("sfxInit: failed to initialize - %d.\n", ret);
else
LOG("sfxInit: %d samples loaded.\n", ret);
}

// --------------------- Main --------------------
int main(int argc, char *argv[])
{
Expand Down

0 comments on commit 6a1cdd1

Please sign in to comment.