All logging should go through retro_log

This commit is contained in:
twinaphex 2014-06-17 00:31:15 +02:00
parent 0684e0b406
commit 6e114f5acc
7 changed files with 48 additions and 68 deletions

View File

@ -9,6 +9,18 @@
#include "libretro.h"
#include "thread.h"
struct retro_perf_callback perf_cb;
retro_get_cpu_features_t perf_get_cpu_features_cb = NULL;
retro_log_printf_t log_cb;
static retro_video_refresh_t video_cb;
static retro_audio_sample_t audio_cb;
static retro_audio_sample_batch_t audio_batch_cb;
static retro_environment_t environ_cb;
static retro_input_poll_t input_poll_cb;
static retro_input_state_t input_state_cb;
static retro_rumble_interface rumble;
/* start of Mednafen psx.cpp */
/* Mednafen - Multi-system Emulator
@ -1701,7 +1713,8 @@ static void CloseGame(void)
}
catch(std::exception &e)
{
MDFN_PrintError("%s", e.what());
if (log_cb)
log_cb(RETRO_LOG_ERROR, "%s\n", e.what());
}
}
@ -1975,17 +1988,6 @@ MDFNGI EmulatedPSX =
extern void Emulate(EmulateSpecStruct *espec);
extern void SetInput(int port, const char *type, void *ptr);
struct retro_perf_callback perf_cb;
retro_get_cpu_features_t perf_get_cpu_features_cb = NULL;
retro_log_printf_t log_cb;
static retro_video_refresh_t video_cb;
static retro_audio_sample_t audio_cb;
static retro_audio_sample_batch_t audio_batch_cb;
static retro_environment_t environ_cb;
static retro_input_poll_t input_poll_cb;
static retro_input_state_t input_state_cb;
static retro_rumble_interface rumble;
static bool overscan;
static double last_sound_rate;
@ -3187,12 +3189,6 @@ void MDFND_Message(const char *str)
log_cb(RETRO_LOG_INFO, "%s\n", str);
}
void MDFND_PrintError(const char* err)
{
if (log_cb)
log_cb(RETRO_LOG_ERROR, "%s\n", err);
}
void MDFND_Sleep(unsigned int time)
{
retro_sleep(time);

View File

@ -48,6 +48,10 @@
#include "audioreader.h"
#include "../../libretro.h"
extern retro_log_printf_t log_cb;
#include <map>
using namespace CDUtility;
@ -363,8 +367,9 @@ void CDAccess_Image::ImageOpen(const char *path, bool image_memcache)
if(fp.read(bom_tmp, 3, false) == 3 && bom_tmp[0] == 0xEF && bom_tmp[1] == 0xBB && bom_tmp[2] == 0xBF)
{
// Print an annoying error message, but don't actually error out.
MDFN_PrintError(_("UTF-8 BOM detected at start of CUE sheet."));
// Print an annoying error message, but don't actually error out.
if (log_cb)
log_cb(RETRO_LOG_ERROR, "UTF-8 BOM detected at start of CUE sheet.\n");
}
else
fp.seek(0, SEEK_SET);

View File

@ -24,6 +24,9 @@
#include "../general.h"
#include <algorithm>
#include "../../libretro.h"
extern retro_log_printf_t log_cb;
using namespace CDUtility;
@ -381,7 +384,8 @@ int CDIF_MT::ReadThreadStart()
}
catch(std::exception &e)
{
MDFN_PrintError(_("Sector %u read error: %s"), ra_lba, e.what());
if (log_cb)
log_cb(RETRO_LOG_ERROR, "Sector %u read error: %s\n", ra_lba, e.what());
memset(tmpbuf, 0, sizeof(tmpbuf));
error_condition = true;
}
@ -454,8 +458,9 @@ CDIF_MT::~CDIF_MT()
}
catch(std::exception &e)
{
MDFND_PrintError(e.what());
thread_deaded_failed = true;
if (log_cb)
log_cb(RETRO_LOG_ERROR, "%s.\n", e.what());
thread_deaded_failed = true;
}
if(!thread_deaded_failed)
@ -558,9 +563,12 @@ int CDIF::ReadSector(uint8* pBuf, uint32 lba, uint32 nSectors)
if(!ValidateRawSector(tmpbuf))
{
MDFN_DispMessage(_("Uncorrectable data at sector %d"), lba);
MDFN_PrintError(_("Uncorrectable data at sector %d"), lba);
return(false);
if (log_cb)
{
log_cb(RETRO_LOG_ERROR, "Uncorrectable data at sector %d\n", lba);
log_cb(RETRO_LOG_ERROR, "Uncorrectable data at sector %d\n", lba);
}
return(false);
}
const int mode = tmpbuf[12 + 3];
@ -603,8 +611,8 @@ bool CDIF_MT::Eject(bool eject_status)
}
catch(std::exception &e)
{
MDFN_PrintError(_("Error on eject/insert attempt: %s"), e.what());
return(false);
log_cb(RETRO_LOG_ERROR, "Error on eject/insert attempt: %s\n", e.what());
return(false);
}
return(true);
@ -660,7 +668,8 @@ bool CDIF_ST::ReadRawSector(uint8 *buf, uint32 lba)
}
catch(std::exception &e)
{
MDFN_PrintError(_("Sector %u read error: %s"), lba, e.what());
if (log_cb)
log_cb(RETRO_LOG_ERROR, "Sector %u read error: %s\n", lba, e.what());
memset(buf, 0, 2352 + 96);
return(false);
}
@ -696,8 +705,9 @@ bool CDIF_ST::Eject(bool eject_status)
}
catch(std::exception &e)
{
MDFN_PrintError("%s", e.what());
return(false);
if (log_cb)
log_cb(RETRO_LOG_ERROR, "%s\n", e.what());
return(false);
}
return(true);

View File

@ -13,10 +13,7 @@ extern std::vector<MDFNGI *>MDFNSystems;
void MDFN_indent(int indent);
void MDFN_printf(const char *format, ...);
#define MDFNI_printf MDFN_printf
/* Displays an error. Can block or not. */
void MDFND_PrintError(const char *s);
void MDFND_Message(const char *s);
uint32 MDFND_GetTime(void);

View File

@ -122,33 +122,3 @@ void MDFN_printf(const char *format, ...)
va_end(ap);
}
void MDFN_PrintError(const char *format, ...)
{
char *temp;
va_list ap;
va_start(ap, format);
temp = trio_vaprintf(format, ap);
MDFND_PrintError(temp);
free(temp);
va_end(ap);
}
void MDFN_DebugPrintReal(const char *file, const int line, const char *format, ...)
{
char *temp;
va_list ap;
va_start(ap, format);
temp = trio_vaprintf(format, ap);
fprintf(stderr, "%s:%d %s\n", file, line, temp);
free(temp);
va_end(ap);
}

View File

@ -47,12 +47,9 @@ extern MDFNGI *MDFNGameInfo;
#include "settings.h"
void MDFN_PrintError(const char *format, ...);
void MDFN_printf(const char *format, ...);
void MDFN_DispMessage(const char *format, ...);
void MDFN_DebugPrintReal(const char *file, const int line, const char *format, ...);
void MDFN_LoadGameCheats(void *override);
void MDFN_FlushGameCheats(int nosave);

View File

@ -31,6 +31,10 @@
#include "msvc_compat.h"
#endif
#include "../libretro.h"
extern retro_log_printf_t log_cb;
static uint8 **RAMPtrs = NULL;
static uint32 PageSize;
static uint32 NumPages;
@ -167,7 +171,8 @@ void MDFNMP_RemoveReadPatches(void)
static void CheatMemErr(void)
{
MDFN_PrintError(_("Error allocating memory for cheat data."));
if (log_cb)
log_cb(RETRO_LOG_ERROR, "Error allocating memory for cheat data.\n");
}
/* This function doesn't allocate any memory for "name" */