diff --git a/Core/HLE/sceAudiocodec.cpp b/Core/HLE/sceAudiocodec.cpp index 7c30f979eb..041bbfb89d 100644 --- a/Core/HLE/sceAudiocodec.cpp +++ b/Core/HLE/sceAudiocodec.cpp @@ -41,9 +41,9 @@ static std::list audioList; static bool oldStateLoaded = false; // find the audio decoder for corresponding ctxPtr in audioList -SimpleAudio * findDecoder(u32 ctxPtr){ - for (std::list::iterator it = audioList.begin(); it != audioList.end(); it++){ - if ((*it)->ctxPtr == ctxPtr){ +static SimpleAudio *findDecoder(u32 ctxPtr) { + for (auto it = audioList.begin(); it != audioList.end(); it++) { + if ((*it)->ctxPtr == ctxPtr) { return (*it); } } @@ -51,9 +51,9 @@ SimpleAudio * findDecoder(u32 ctxPtr){ } // remove decoder from audioList -bool removeDecoder(u32 ctxPtr){ - for (std::list::iterator it = audioList.begin(); it != audioList.end(); it++){ - if ((*it)->ctxPtr == ctxPtr){ +static bool removeDecoder(u32 ctxPtr) { + for (auto it = audioList.begin(); it != audioList.end(); it++) { + if ((*it)->ctxPtr == ctxPtr) { delete *it; audioList.erase(it); return true; @@ -62,16 +62,20 @@ bool removeDecoder(u32 ctxPtr){ return false; } +static void clearDecoders() { + for (auto it = audioList.begin(); it != audioList.end(); it++) { + delete *it; + } + audioList.clear(); +} + void __AudioCodecInit() { oldStateLoaded = false; } void __AudioCodecShutdown() { // We need to kill off any still opened codecs to not leak memory. - for (std::list::iterator it = audioList.begin(); it != audioList.end(); it++){ - delete *it; - } - audioList.clear(); + clearDecoders(); } int sceAudiocodecInit(u32 ctxPtr, int codec) { @@ -170,6 +174,8 @@ void __sceAudiocodecDoState(PointerWrap &p){ if (count > 0) { if (p.mode == PointerWrap::MODE_READ) { + clearDecoders(); + // loadstate if audioList is nonempty auto codec_ = new int[count]; auto ctxPtr_ = new u32[count]; @@ -202,8 +208,3 @@ void __sceAudiocodecDoState(PointerWrap &p){ } } } - -void resetAudioList(){ - audioList.clear(); - INFO_LOG(ME, "Audio playing list is reset"); -} diff --git a/Core/HLE/sceAudiocodec.h b/Core/HLE/sceAudiocodec.h index 8d2012db10..321d80ce0f 100644 --- a/Core/HLE/sceAudiocodec.h +++ b/Core/HLE/sceAudiocodec.h @@ -59,5 +59,4 @@ typedef struct void __AudioCodecInit(); void __AudioCodecShutdown(); void Register_sceAudiocodec(); -void resetAudioList(); void __sceAudiocodecDoState(PointerWrap &p); \ No newline at end of file diff --git a/Core/System.cpp b/Core/System.cpp index 5b421e1415..2a4c27e7a0 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -418,7 +418,6 @@ void PSP_Shutdown() { CPU_Shutdown(); } GPU_Shutdown(); - resetAudioList(); host->SetWindowTitle(0); currentMIPS = 0; pspIsInited = false;