void Pcsx2App::EnableAllLogging() { AffinityAssert_AllowFrom_MainUI(); const bool logBoxOpen = (m_ptr_ProgramLog != NULL); const IConsoleWriter* newHandler = NULL; if( emuLog ) { if( !m_StdoutRedirHandle ) m_StdoutRedirHandle = NewPipeRedir(stdout); if( !m_StderrRedirHandle ) m_StderrRedirHandle = NewPipeRedir(stderr); newHandler = logBoxOpen ? (IConsoleWriter*)&ConsoleWriter_WindowAndFile : (IConsoleWriter*)&ConsoleWriter_File; } else { if( logBoxOpen ) { if( !m_StdoutRedirHandle ) m_StdoutRedirHandle = NewPipeRedir(stdout); if( !m_StderrRedirHandle ) m_StderrRedirHandle = NewPipeRedir(stderr); newHandler = &ConsoleWriter_Window; } else newHandler = &ConsoleWriter_Stdout; } Console_SetActiveHandler( *newHandler ); }
void Close() { _is_init = false; _replay = Replay(); Utilities::RestoreSettings(); if(_mcd_backup.size()) { Utilities::WriteMCD(0,0,_mcd_backup); _mcd_backup.clear(); } Utilities::ExecuteOnMainThread([&]() { UI_EnableEverything(); Console_SetActiveHandler(_console); }); }
// Used to disable the emuLog disk logger, typically used when disabling or re-initializing the // emuLog file handle. Call SetConsoleLogging to re-enable the disk logger when finished. void Pcsx2App::DisableDiskLogging() const { AffinityAssert_AllowFrom_MainUI(); const bool logBoxOpen = (GetProgramLog() != NULL); Console_SetActiveHandler( logBoxOpen ? (IConsoleWriter&)ConsoleWriter_Window : (IConsoleWriter&)ConsoleWriter_Stdout ); // Semi-hack: It's possible, however very unlikely, that a secondary thread could attempt // to write to the logfile just before we disable logging, and would thus have a pending write // operation to emuLog file handle at the same time we're trying to re-initialize it. The CRT // has some guards of its own, and PCSX2 itself typically suspends the "log happy" threads // when changing settings, so the chance for problems is low. We minimize it further here // by sleeping off 5ms, which should allow any pending log-to-disk events to finish up. // // (the most correct solution would be a mutex lock in the Disk logger itself, but for now I // am going to try and keep the logger lock-free and use this semi-hack instead). Threading::Sleep( 5 ); }
void Pcsx2App::DisableWindowLogging() const { AffinityAssert_AllowFrom_MainUI(); Console_SetActiveHandler( (emuLog!=NULL) ? (IConsoleWriter&)ConsoleWriter_File : (IConsoleWriter&)ConsoleWriter_Stdout ); }
void Open() { try { _console = Console; Utilities::ExecuteOnMainThread([&] { Console_SetActiveHandler(ConsoleWriter_Null); }); if(_replay.LoadFromFile(g_Conf->Replay.FilePath)) { _replay.Mode(Playback); auto state = Utilities::GetSyncState(); if(state) { if(memcmp(_replay.SyncState().biosVersion, state->biosVersion, sizeof(state->biosVersion))) { std::stringstream ss; ss << "REPLAY: Incompatible BIOS detected. Please use "; ss.write(_replay.SyncState().biosVersion, sizeof(state->biosVersion)); Stop(); _console.Error(ss.str().c_str()); return; } if(memcmp(_replay.SyncState().discId, state->discId, sizeof(state->discId))) { size_t myDiscIdLen = sizeof(state->discId); size_t replayDiscIdLen = sizeof(_replay.SyncState().discId); for(size_t i = 0; i < myDiscIdLen; i++) { if(state->discId[i] == 0) { myDiscIdLen = i; break; } } for(size_t i = 0; i < replayDiscIdLen; i++) { if(_replay.SyncState().discId[i] == 0) { replayDiscIdLen = i; break; } } wxString myDiscId(state->discId, wxConvUTF8, myDiscIdLen); wxString replayDiscId(_replay.SyncState().discId, wxConvUTF8, replayDiscIdLen); wxString msg = wxString(wxT("REPLAY: Incompatible disc detected: ")) + Utilities::GetDiscNameById(myDiscId) + wxString(wxT(" instead of ")) + Utilities::GetDiscNameById(replayDiscId); Stop(); _console.Error(msg); return; } } else { Stop(); return; } _mcd_backup = Utilities::ReadMCD(0,0); Utilities::WriteMCD(0,0,_replay.Data()); } else { Stop(); _console.Error("REPLAY: file is corrupted or of the older version."); } } catch(std::exception& e) { Stop(); _console.Error("REPLAY: %s", e.what()); } }