Permalink
Browse files

Merge pull request #10122 from LunaMoo/videoR

Improve Video/Audio dumps naming and add option to reset recording on save/load state
  • Loading branch information...
unknownbrackets committed Nov 14, 2017
2 parents 1014598 + 2ff4104 commit 95f952e5cb3ca5ab5c1993a382dc96847bfffcbe
View
@@ -34,6 +34,10 @@ extern "C" {
#include "GPU/Common/GPUDebugInterface.h"
#include "Core/ELF/ParamSFO.h"
#include "Core/HLE/sceKernelTime.h"
#include "StringUtils.h"
#ifdef USE_FFMPEG
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55, 28, 1)
@@ -86,10 +90,16 @@ bool AVIDump::CreateAVI() {
#ifdef USE_FFMPEG
AVCodec* codec = nullptr;
// Use gameID_EmulatedTimestamp for filename
std::string discID = g_paramSFO.GetDiscID();
std::string video_file_name = StringFromFormat("%s%s_%d.avi", GetSysDirectory(DIRECTORY_VIDEO).c_str(), discID.c_str(), KernelTimeNow()).c_str();
s_format_context = avformat_alloc_context();
std::stringstream s_file_index_str;
s_file_index_str << s_file_index;
snprintf(s_format_context->filename, sizeof(s_format_context->filename), "%s", (GetSysDirectory(DIRECTORY_VIDEO) + "framedump" + s_file_index_str.str() + ".avi").c_str());
s_file_index_str << video_file_name;
snprintf(s_format_context->filename, sizeof(s_format_context->filename), "%s", s_file_index_str.str().c_str());
INFO_LOG(COMMON, "Recording Video to: %s", s_format_context->filename);
// Make sure that the path exists
if (!File::Exists(GetSysDirectory(DIRECTORY_VIDEO)))
File::CreateDir(GetSysDirectory(DIRECTORY_VIDEO));
View
@@ -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),
View
@@ -105,6 +105,7 @@ struct Config {
bool bUseFFV1;
bool bDumpFrames;
bool bDumpAudio;
bool bSaveLoadResetsAVdumping;
bool bEnableLogging;
bool bDumpDecryptedEboot;
bool bFullscreenOnDoubleclick;
View
@@ -35,6 +35,9 @@
#include "Core/System.h"
#ifndef MOBILE_DEVICE
#include "Core/WaveFile.h"
#include "Core/ELF/ParamSFO.h"
#include "Core/HLE/sceKernelTime.h"
#include "StringUtils.h"
#endif
#include "Core/HLE/__sceAudio.h"
#include "Core/HLE/sceAudio.h"
@@ -328,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.
@@ -381,11 +384,25 @@ 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.c_str(), KernelTimeNow()).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) {
std::string audio_file_name = GetSysDirectory(DIRECTORY_AUDIO) + "audiodump.wav";
// Use gameID_EmulatedTimestamp for filename
std::string discID = g_paramSFO.GetDiscID();
std::string audio_file_name = StringFromFormat("%s%s_%d.wav", GetSysDirectory(DIRECTORY_AUDIO).c_str(), discID.c_str(), KernelTimeNow()).c_str();
INFO_LOG(COMMON,"Recording audio to: %s", audio_file_name.c_str());
// Create the path just in case it doesn't exist
File::CreateDir(GetSysDirectory(DIRECTORY_AUDIO));
if (!File::Exists(GetSysDirectory(DIRECTORY_AUDIO)))
File::CreateDir(GetSysDirectory(DIRECTORY_AUDIO));
File::CreateEmptyFile(audio_file_name);
__StartLogAudio(audio_file_name);
}
@@ -443,3 +460,7 @@ void __StopLogAudio() {
}
}
#endif
void WAVDump::Reset() {
__AudioUpdate(true);
}
View
@@ -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();
};
@@ -171,3 +171,7 @@ u32 sceKernelLibcGettimeofday(u32 timeAddr, u32 tzAddr)
hleReSchedule("libc timeofday");
return 0;
}
u32 KernelTimeNow() {
return (u32)start_time + (u32)(CoreTiming::GetGlobalTimeUs() / 1000000ULL);
}
View
@@ -27,6 +27,7 @@ int sceKernelSysClock2USec(u32 sysclockPtr, u32 highPtr, u32 lowPtr);
int sceKernelSysClock2USecWide(u32 lowClock, u32 highClock, u32 lowPtr, u32 highPtr);
u64 sceKernelUSec2SysClockWide(u32 usec);
u32 sceKernelLibcClock();
u32 KernelTimeNow();
void __KernelTimeInit();
void __KernelTimeDoState(PointerWrap &p);
View
@@ -46,6 +46,11 @@
#include "HW/MemoryStick.h"
#include "GPU/GPUState.h"
#ifndef MOBILE_DEVICE
#include "Core/AVIDump.h"
#include "Core/HLE/__sceAudio.h"
#endif
namespace SaveState
{
struct SaveStart
@@ -591,6 +596,17 @@ namespace SaveState
callbackMessage = sc->T("Loaded State");
callbackResult = true;
hasLoadedState = true;
#ifndef MOBILE_DEVICE
if (g_Config.bSaveLoadResetsAVdumping) {
if (g_Config.bDumpFrames) {
AVIDump::Stop();
AVIDump::Start(PSP_CoreParameter().renderWidth, PSP_CoreParameter().renderHeight);
}
if (g_Config.bDumpAudio) {
WAVDump::Reset();
}
}
#endif
} else if (result == CChunkFileReader::ERROR_BROKEN_STATE) {
HandleFailure();
callbackMessage = i18nLoadFailure;
@@ -615,6 +631,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) {
AVIDump::Stop();
AVIDump::Start(PSP_CoreParameter().renderWidth, PSP_CoreParameter().renderHeight);
}
if (g_Config.bDumpAudio) {
WAVDump::Reset();
}
}
#endif
} else if (result == CChunkFileReader::ERROR_BROKEN_STATE) {
HandleFailure();
callbackMessage = i18nSaveFailure;
View
@@ -79,7 +79,7 @@
#endif
#ifndef MOBILE_DEVICE
AVIDump avi;
static AVIDump avi;
#endif
static bool frameStep_;
@@ -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"};

0 comments on commit 95f952e

Please sign in to comment.