Initialisation: some fixes.
Ensure log file is created before it is used the first time. Only close the log file once at the end. https://github.com/audetto/AppleWin/issues/30 Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
09da101cbb
commit
7b09bacb01
8 changed files with 49 additions and 31 deletions
|
@ -123,9 +123,9 @@ namespace common2
|
|||
HD_Destroy();
|
||||
PrintDestroy();
|
||||
CpuDestroy();
|
||||
DebugDestroy();
|
||||
|
||||
GetCardMgr().GetDisk2CardMgr().Destroy();
|
||||
LogDone();
|
||||
RiffFinishWriteFile();
|
||||
}
|
||||
|
||||
|
|
|
@ -54,10 +54,12 @@ namespace ra2
|
|||
|
||||
unsigned Game::ourInputDevices[MAX_PADS] = {RETRO_DEVICE_NONE};
|
||||
|
||||
Game::Game(const std::shared_ptr<RetroFrame> & frame)
|
||||
: myFrame(frame), mySpeed(true), myButtonStates(RETRO_DEVICE_ID_JOYPAD_R3 + 1)
|
||||
Game::Game()
|
||||
: myLogger(true)
|
||||
, myFrame(new ra2::RetroFrame())
|
||||
, mySpeed(true)
|
||||
, myButtonStates(RETRO_DEVICE_ID_JOYPAD_R3 + 1)
|
||||
{
|
||||
LogInit();
|
||||
InitialiseRetroRegistry();
|
||||
SetFrame(myFrame);
|
||||
myFrame->Initialize();
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "frontends/common2/speed.h"
|
||||
#include "frontends/libretro/environment.h"
|
||||
|
||||
#include "linux/context.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -14,7 +16,7 @@ namespace ra2
|
|||
class Game
|
||||
{
|
||||
public:
|
||||
Game(const std::shared_ptr<RetroFrame> & frame);
|
||||
Game();
|
||||
~Game();
|
||||
|
||||
bool loadGame(const std::string & path);
|
||||
|
@ -33,6 +35,7 @@ namespace ra2
|
|||
static retro_usec_t ourFrameTime;
|
||||
|
||||
private:
|
||||
const Logger myLogger;
|
||||
const std::shared_ptr<RetroFrame> myFrame;
|
||||
|
||||
common2::Speed mySpeed; // fixed speed
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "frontends/libretro/environment.h"
|
||||
#include "frontends/libretro/rdirectsound.h"
|
||||
#include "frontends/libretro/retroregistry.h"
|
||||
#include "frontends/libretro/retroframe.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -180,8 +179,7 @@ bool retro_load_game(const retro_game_info *info)
|
|||
|
||||
try
|
||||
{
|
||||
std::shared_ptr<ra2::RetroFrame> frame(new ra2::RetroFrame());
|
||||
std::unique_ptr<ra2::Game> game(new ra2::Game(frame));
|
||||
std::unique_ptr<ra2::Game> game(new ra2::Game());
|
||||
|
||||
const std::string snapshotEnding = ".aws.yaml";
|
||||
const std::string gamePath = info->path;
|
||||
|
|
|
@ -132,7 +132,6 @@ namespace
|
|||
|
||||
void EnterMessageLoop(const common2::EmulatorOptions & options, const std::shared_ptr<na2::NFrame> & frame)
|
||||
{
|
||||
LogFileTimeUntilFirstKeyReadReset();
|
||||
while (ContinueExecution(options, frame))
|
||||
{
|
||||
}
|
||||
|
@ -146,16 +145,12 @@ namespace
|
|||
if (!run)
|
||||
return 1;
|
||||
|
||||
if (options.log)
|
||||
{
|
||||
LogInit();
|
||||
}
|
||||
|
||||
const Logger logger(options.log);
|
||||
InitializeFileRegistry(options);
|
||||
g_nMemoryClearType = options.memclear;
|
||||
|
||||
std::shared_ptr<na2::NFrame> frame(new na2::NFrame(options.paddleDeviceName));
|
||||
Initialisation init(frame);
|
||||
const std::shared_ptr<na2::NFrame> frame(new na2::NFrame(options.paddleDeviceName));
|
||||
const Initialisation init(frame);
|
||||
|
||||
na2::SetCtrlCHandler(options.headless);
|
||||
applyOptions(options);
|
||||
|
|
|
@ -90,18 +90,11 @@ void run_sdl(int argc, const char * argv [])
|
|||
if (!run)
|
||||
return;
|
||||
|
||||
const Logger logger(options.log);
|
||||
g_nMemoryClearType = options.memclear;
|
||||
InitializeFileRegistry(options);
|
||||
|
||||
if (options.log)
|
||||
{
|
||||
LogInit();
|
||||
}
|
||||
|
||||
g_nMemoryClearType = options.memclear;
|
||||
Paddle::instance.reset(new sa2::Gamepad(0));
|
||||
|
||||
std::shared_ptr<sa2::SDLFrame> frame;
|
||||
|
||||
if (options.imgui)
|
||||
{
|
||||
frame.reset(new sa2::SDLImGuiFrame(options));
|
||||
|
@ -111,13 +104,14 @@ void run_sdl(int argc, const char * argv [])
|
|||
frame.reset(new sa2::SDLRendererFrame(options));
|
||||
}
|
||||
|
||||
Paddle::instance.reset(new sa2::Gamepad(0));
|
||||
const Initialisation init(frame);
|
||||
|
||||
if (SDL_GL_SetSwapInterval(options.glSwapInterval))
|
||||
{
|
||||
throw std::runtime_error(SDL_GetError());
|
||||
}
|
||||
|
||||
Initialisation init(frame);
|
||||
|
||||
applyOptions(options);
|
||||
|
||||
const int fps = getRefreshRate();
|
||||
|
@ -230,8 +224,6 @@ int main(int argc, const char * argv [])
|
|||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
|
||||
// this must happen BEFORE the SDL_Quit() as otherwise we have a double free (of the game controller).
|
||||
Paddle::instance.reset();
|
||||
SDL_Quit();
|
||||
|
||||
return exit;
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#include "StdAfx.h"
|
||||
|
||||
#include "linux/context.h"
|
||||
#include "linux/linuxframe.h"
|
||||
#include "linux/registry.h"
|
||||
#include "linux/paddle.h"
|
||||
#include "linux/duplicates/PropertySheet.h"
|
||||
|
||||
#include "Interface.h"
|
||||
#include "linux/duplicates/PropertySheet.h"
|
||||
#include "linux/linuxframe.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -43,4 +46,20 @@ Initialisation::~Initialisation()
|
|||
{
|
||||
GetFrame().Destroy();
|
||||
SetFrame(std::shared_ptr<FrameBase>());
|
||||
|
||||
Paddle::instance.reset();
|
||||
Registry::instance.reset();
|
||||
}
|
||||
|
||||
Logger::Logger(const bool log)
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
LogInit();
|
||||
}
|
||||
}
|
||||
|
||||
Logger::~Logger()
|
||||
{
|
||||
LogDone();
|
||||
}
|
||||
|
|
|
@ -6,9 +6,18 @@ class FrameBase;
|
|||
|
||||
void SetFrame(const std::shared_ptr<FrameBase> & frame);
|
||||
|
||||
// RAII around Frame Registry and Paddle
|
||||
class Initialisation
|
||||
{
|
||||
public:
|
||||
Initialisation(const std::shared_ptr<FrameBase> & frame);
|
||||
~Initialisation();
|
||||
};
|
||||
|
||||
// RAII around LogInit / LogDone.
|
||||
class Logger
|
||||
{
|
||||
public:
|
||||
Logger(const bool log);
|
||||
~Logger();
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue