diff --git a/Core/Config.cpp b/Core/Config.cpp index 9ddda1a9e9..9e0537ed24 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -360,6 +360,7 @@ static ConfigSetting generalSettings[] = { ConfigSetting("UseFFV1", &g_Config.bUseFFV1, false), ConfigSetting("DumpFrames", &g_Config.bDumpFrames, false), ConfigSetting("DumpAudio", &g_Config.bDumpAudio, false), + ConfigSetting("SaveLoadResetsAVdumping", &g_Config.bSaveLoadResetsAVdumping, false), ConfigSetting("StateSlot", &g_Config.iCurrentStateSlot, 0, true, true), ConfigSetting("RewindFlipFrequency", &g_Config.iRewindFlipFrequency, 0, true, true), diff --git a/Core/Config.h b/Core/Config.h index 6a1d4c2134..ee63af6f30 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -105,6 +105,7 @@ public: bool bUseFFV1; bool bDumpFrames; bool bDumpAudio; + bool bSaveLoadResetsAVdumping; bool bEnableLogging; bool bDumpDecryptedEboot; bool bFullscreenOnDoubleclick; diff --git a/Core/HLE/__sceAudio.cpp b/Core/HLE/__sceAudio.cpp index 1b4fc50ef6..c933b9fa9f 100644 --- a/Core/HLE/__sceAudio.cpp +++ b/Core/HLE/__sceAudio.cpp @@ -331,7 +331,7 @@ void __AudioSetOutputFrequency(int freq) { // Mix samples from the various audio channels into a single sample queue. // This single sample queue is where __AudioMix should read from. If the sample queue is full, we should // just sleep the main emulator thread a little. -void __AudioUpdate() { +void __AudioUpdate(bool resetRecording) { // Audio throttle doesn't really work on the PSP since the mixing intervals are so closely tied // to the CPU. Much better to throttle the frame rate on frame display and just throw away audio // if the buffer somehow gets full. @@ -384,6 +384,16 @@ void __AudioUpdate() { if (g_Config.bEnableSound) { resampler.PushSamples(mixBuffer, hwBlockSize); #ifndef MOBILE_DEVICE + if (g_Config.bSaveLoadResetsAVdumping && resetRecording) { + __StopLogAudio(); + std::string discID = g_paramSFO.GetDiscID(); + std::string audio_file_name = StringFromFormat("%s%s_%d.wav", GetSysDirectory(DIRECTORY_AUDIO).c_str(), discID, returnEmulatedTime()).c_str(); + INFO_LOG(COMMON, "Restarted audio recording to: %s", audio_file_name.c_str()); + if (!File::Exists(GetSysDirectory(DIRECTORY_AUDIO))) + File::CreateDir(GetSysDirectory(DIRECTORY_AUDIO)); + File::CreateEmptyFile(audio_file_name); + __StartLogAudio(audio_file_name); + } if (!m_logAudio) { if (g_Config.bDumpAudio) { // Use gameID_EmulatedTimestamp for filename @@ -450,3 +460,7 @@ void __StopLogAudio() { } } #endif + +void WAVDump::Reset() { + __AudioUpdate(true); +} diff --git a/Core/HLE/__sceAudio.h b/Core/HLE/__sceAudio.h index 87365fb361..39f83d8401 100644 --- a/Core/HLE/__sceAudio.h +++ b/Core/HLE/__sceAudio.h @@ -33,7 +33,7 @@ struct AudioDebugStats { void __AudioInit(); void __AudioDoState(PointerWrap &p); -void __AudioUpdate(); +void __AudioUpdate(bool resetRecording = false); void __AudioShutdown(); void __AudioSetOutputFrequency(int freq); @@ -49,3 +49,9 @@ void __PushExternalAudio(const s32 *audio, int numSamples); // Should not be us // Audio Dumping stuff void __StartLogAudio(const std::string& filename); void __StopLogAudio(); + +class WAVDump +{ +public: + static void Reset(); +}; diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index 4b5a4a5426..ebed78f879 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -46,6 +46,14 @@ #include "HW/MemoryStick.h" #include "GPU/GPUState.h" +#ifndef MOBILE_DEVICE +#include "Core/AVIDump.h" +#include "Core/HLE/__sceAudio.h" + +AVIDump video; +WAVDump audio; +#endif + namespace SaveState { struct SaveStart @@ -591,6 +599,17 @@ namespace SaveState callbackMessage = sc->T("Loaded State"); callbackResult = true; hasLoadedState = true; +#ifndef MOBILE_DEVICE + if (g_Config.bSaveLoadResetsAVdumping) { + if (g_Config.bDumpFrames) { + video.Stop(); + video.Start(PSP_CoreParameter().renderWidth, PSP_CoreParameter().renderHeight); + } + if (g_Config.bDumpAudio) { + audio.Reset(); + } + } +#endif } else if (result == CChunkFileReader::ERROR_BROKEN_STATE) { HandleFailure(); callbackMessage = i18nLoadFailure; @@ -615,6 +634,17 @@ namespace SaveState if (result == CChunkFileReader::ERROR_NONE) { callbackMessage = sc->T("Saved State"); callbackResult = true; +#ifndef MOBILE_DEVICE + if (g_Config.bSaveLoadResetsAVdumping) { + if (g_Config.bDumpFrames) { + video.Stop(); + video.Start(PSP_CoreParameter().renderWidth, PSP_CoreParameter().renderHeight); + } + if (g_Config.bDumpAudio) { + audio.Reset(); + } + } +#endif } else if (result == CChunkFileReader::ERROR_BROKEN_STATE) { HandleFailure(); callbackMessage = i18nSaveFailure; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 68cb2d71bf..5e7d7fa2f7 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -781,6 +781,7 @@ void GameSettingsScreen::CreateViews() { systemSettings->Add(new CheckBox(&g_Config.bDumpFrames, sy->T("Record Display"))); systemSettings->Add(new CheckBox(&g_Config.bUseFFV1, sy->T("Use Lossless Video Codec (FFV1)"))); systemSettings->Add(new CheckBox(&g_Config.bDumpAudio, sy->T("Record Audio"))); + systemSettings->Add(new CheckBox(&g_Config.bSaveLoadResetsAVdumping, sy->T("Reset Recording on Save/Load State"))); #endif systemSettings->Add(new CheckBox(&g_Config.bDayLightSavings, sy->T("Day Light Saving"))); static const char *dateFormat[] = { "YYYYMMDD", "MMDDYYYY", "DDMMYYYY"};