diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index ab2211ad9..5314e49d4 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -2120,9 +2120,7 @@ void NDS_Reset() TotalLagFrames = 0; } - //spu must reset early on, since it will crash due to keeping a pointer into MMU memory for the sample pointers. yuck! - SPU_Reset(); - + SPU_DeInit(); MMU_Reset(); @@ -2476,6 +2474,8 @@ void NDS_Reset() memcpy(FW_Mac, (MMU.fw.data + 0x36), 6); initSchedule(); + + SPU_ReInit(); } static std::string MakeInputDisplayString(u16 pad, const std::string* Buttons, int count) { diff --git a/desmume/src/SPU.cpp b/desmume/src/SPU.cpp index 143e0ca3a..b8c9b3da6 100644 --- a/desmume/src/SPU.cpp +++ b/desmume/src/SPU.cpp @@ -64,6 +64,7 @@ static int buffersize = 0; static ESynchMode synchmode = ESynchMode_DualSynchAsynch; static ESynchMethod synchmethod = ESynchMethod_N; +static int SNDCoreId=-1; static SoundInterface_struct *SNDCore=NULL; extern SoundInterface_struct *SNDCoreList[]; @@ -151,6 +152,8 @@ int SPU_ChangeSoundCore(int coreid, int buffersize) } } + SNDCoreId = coreid; + //If the user picked the dummy core, disable the user spu if(SNDCore == &SNDDummy) return 0; @@ -178,6 +181,11 @@ SoundInterface_struct *SPU_SoundCore() return SNDCore; } +void SPU_ReInit() +{ + SPU_Init(SNDCoreId, buffersize); +} + //static double cos_lut[256]; int SPU_Init(int coreid, int buffersize) { diff --git a/desmume/src/SPU.h b/desmume/src/SPU.h index f5520153b..e4f7f1c61 100644 --- a/desmume/src/SPU.h +++ b/desmume/src/SPU.h @@ -198,6 +198,7 @@ public: int SPU_ChangeSoundCore(int coreid, int buffersize); SoundInterface_struct *SPU_SoundCore(); +void SPU_ReInit(); int SPU_Init(int coreid, int buffersize); void SPU_Pause(int pause); void SPU_SetVolume(int volume); diff --git a/desmume/src/windows/hotkey.cpp b/desmume/src/windows/hotkey.cpp index 06baa7458..4d734a4a0 100644 --- a/desmume/src/windows/hotkey.cpp +++ b/desmume/src/windows/hotkey.cpp @@ -197,9 +197,6 @@ void HK_StateLoadSlot(int num, bool justPressed) { if (romloaded && justPressed) { - //keep the spu from running while we do the loadstate (or else it may trample on spu structures in the midst of getting twiddled) - Lock lock; - BOOL wasPaused = paused; Pause(); loadstate_slot(num); //Loadstate