Capture: Swap int return types with bool

Additionally fix SPU2 error message
This commit is contained in:
sonicfind 2021-02-22 22:29:34 -06:00 committed by refractionpcsx2
parent df446510da
commit 7b9c8634f4
12 changed files with 33 additions and 35 deletions

View File

@ -134,8 +134,8 @@ void CALLBACK GSsetGameCRC(int crc, int gameoptions);
void CALLBACK GSsetFrameSkip(int frameskip);
// Starts recording GS frame data
// returns a non zero value if successful
int CALLBACK GSsetupRecording(std::string& filename);
// returns true if successful
bool CALLBACK GSsetupRecording(std::string& filename);
// Stops recording GS frame data
void CALLBACK GSendRecording();
@ -185,7 +185,7 @@ typedef void(CALLBACK *_GSsetGameCRC)(int, int);
typedef void(CALLBACK *_GSsetFrameSkip)(int frameskip);
typedef void(CALLBACK *_GSsetVsync)(int enabled);
typedef void(CALLBACK *_GSsetExclusive)(int isExclusive);
typedef int(CALLBACK* _GSsetupRecording)(std::string&);
typedef bool(CALLBACK* _GSsetupRecording)(std::string&);
typedef void(CALLBACK* _GSendRecording)();
typedef void(CALLBACK *_GSreset)();
typedef void(CALLBACK *_GSwriteCSR)(u32 value);

View File

@ -682,7 +682,7 @@ extern SndOutModule* mods[];
extern bool WavRecordEnabled;
extern int RecordStart(const std::string* filename);
extern bool RecordStart(const std::string* filename);
extern void RecordStop();
extern void RecordWrite(const StereoOut16& sample);

View File

@ -110,7 +110,7 @@ bool WavRecordEnabled = false;
static WavOutFile* m_wavrecord = nullptr;
static Mutex WavRecordMutex;
int RecordStart(const std::string* filename)
bool RecordStart(const std::string* filename)
{
try
{
@ -121,16 +121,16 @@ int RecordStart(const std::string* filename)
else
m_wavrecord = new WavOutFile("audio_recording.wav", 48000, 16, 2);
WavRecordEnabled = true;
return 1;
return true;
}
catch (std::runtime_error&)
{
m_wavrecord = nullptr; // not needed, but what the heck. :)
if (filename)
SysMessage("SPU2-X couldn't open file for recording: %s.\nWavfile capture disabled.", filename->c_str());
SysMessage("SPU2 couldn't open file for recording: %s.\nWavfile capture disabled.", filename->c_str());
else
SysMessage("SPU2-X couldn't open file for recording: audio_recording.wav.\nWavfile capture disabled.");
return 0;
SysMessage("SPU2 couldn't open file for recording: audio_recording.wav.\nWavfile capture disabled.");
return false;
}
}

View File

@ -579,7 +579,7 @@ void SPU2write(u32 rmem, u16 value)
}
// returns a non zero value if successful
int SPU2setupRecording(const std::string* filename)
bool SPU2setupRecording(const std::string* filename)
{
return RecordStart(filename);
}

View File

@ -31,8 +31,8 @@ void SPU2write(u32 mem, u16 value);
u16 SPU2read(u32 mem);
// extended funcs
// returns a non zero value if successful
int SPU2setupRecording(const std::string* filename);
// returns true if successful
bool SPU2setupRecording(const std::string* filename);
void SPU2endRecording();
void SPU2setClockPtr(u32* ptr);

View File

@ -680,9 +680,9 @@ void AppConfig::LoadSave( IniInterface& ini )
GSWindow .LoadSave( ini );
Framerate .LoadSave( ini );
#ifndef DISABLE_RECORDING
inputRecording .loadSave( ini );
inputRecording.loadSave(ini);
#endif
AudioCapture .LoadSave( ini );
AudioCapture.LoadSave( ini );
Templates .LoadSave( ini );
ini.Flush();

View File

@ -287,7 +287,7 @@ public:
struct CaptureOptions
{
bool EnableAudio;
bool EnableAudio;
CaptureOptions();

View File

@ -811,28 +811,28 @@ void pt(const char* str){
printf("%02i:%02i:%02i%s", current->tm_hour, current->tm_min, current->tm_sec, str);
}
EXPORT_C_(int) GSsetupRecording(std::string& filename)
EXPORT_C_(bool) GSsetupRecording(std::string& filename)
{
if (s_gs == NULL) {
printf("GSdx: no s_gs for recording\n");
return 0;
return false;
}
#if defined(__unix__) || defined(__APPLE__)
if (!theApp.GetConfigB("capture_enabled")) {
printf("GSdx: Recording is disabled\n");
return 0;
return false;
}
#endif
printf("GSdx: Recording start command\n");
if (s_gs->BeginCapture(filename))
{
pt(" - Capture started\n");
return 1;
return true;
}
else
{
pt(" - Capture cancelled\n");
return 0;
return false;
}
}

View File

@ -404,7 +404,7 @@ GSCapture::~GSCapture()
EndCapture();
}
int GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float aspect, std::string& filename)
bool GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float aspect, std::string& filename)
{
printf("Recommended resolution: %d x %d, DAR for muxing: %.4f\n", recommendedResolution.x, recommendedResolution.y, aspect);
std::lock_guard<std::recursive_mutex> lock(m_lock);
@ -418,7 +418,7 @@ int GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float a
GSCaptureDlg dlg;
if (IDOK != dlg.DoModal())
return 0;
return false;
{
const int start = dlg.m_filename.length() - 4;
@ -438,12 +438,10 @@ int GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float a
else
{
dlg.InvalidFile();
return 0;
return false;
}
}
;
m_size.x = (dlg.m_width + 7) & ~7;
m_size.y = (dlg.m_height + 7) & ~7;
//
@ -458,7 +456,7 @@ int GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float a
|| FAILED(hr = cgb->SetFiltergraph(m_graph))
|| FAILED(hr = cgb->SetOutputFileName(&MEDIASUBTYPE_Avi, std::wstring(dlg.m_filename.begin(), dlg.m_filename.end()).c_str(), &mux, NULL)))
{
return 0;
return false;
}
m_src = new GSSource(m_size.x, m_size.y, fps, NULL, hr, dlg.m_colorspace);
@ -466,22 +464,22 @@ int GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float a
if (dlg.m_enc==0)
{
if (FAILED(hr = m_graph->AddFilter(m_src, L"Source")))
return 0;
return false;
if (FAILED(hr = m_graph->ConnectDirect(GetFirstPin(m_src, PINDIR_OUTPUT), GetFirstPin(mux, PINDIR_INPUT), NULL)))
return 0;
return false;
}
else
{
if(FAILED(hr = m_graph->AddFilter(m_src, L"Source"))
|| FAILED(hr = m_graph->AddFilter(dlg.m_enc, L"Encoder")))
{
return 0;
return false;
}
if(FAILED(hr = m_graph->ConnectDirect(GetFirstPin(m_src, PINDIR_OUTPUT), GetFirstPin(dlg.m_enc, PINDIR_INPUT), NULL))
|| FAILED(hr = m_graph->ConnectDirect(GetFirstPin(dlg.m_enc, PINDIR_OUTPUT), GetFirstPin(mux, PINDIR_INPUT), NULL)))
{
return 0;
return false;
}
}
@ -510,7 +508,7 @@ int GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float a
m_capturing = true;
filename = dlg.m_filename.erase(dlg.m_filename.length() - 3, 3) + "wav";
return 1;
return true;
#elif defined(__unix__)
// Note I think it doesn't support multiple depth creation
GSmkdir(m_out_dir.c_str());
@ -527,7 +525,7 @@ int GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float a
m_capturing = true;
filename = m_out_dir + "/audio_recording.wav";
return 1;
return true;
#endif
}

View File

@ -53,7 +53,7 @@ public:
GSCapture();
virtual ~GSCapture();
int BeginCapture(float fps, GSVector2i recommendedResolution, float aspect, std::string& filename);
bool BeginCapture(float fps, GSVector2i recommendedResolution, float aspect, std::string& filename);
bool DeliverFrame(const void* bits, int pitch, bool rgba);
bool EndCapture();

View File

@ -533,7 +533,7 @@ bool GSRenderer::MakeSnapshot(const std::string& path)
return true;
}
int GSRenderer::BeginCapture(std::string& filename)
bool GSRenderer::BeginCapture(std::string& filename)
{
GSVector4i disp = m_wnd->GetClientRect().fit(m_aspectratio);
float aspect = (float)disp.width() / std::max(1, disp.height());

View File

@ -72,7 +72,7 @@ public:
void SetAspectRatio(int aspect) {m_aspectratio = aspect;}
void SetVSync(int vsync);
virtual int BeginCapture(std::string& filename);
virtual bool BeginCapture(std::string& filename);
virtual void EndCapture();
void PurgePool();