[LIBNX] Synchronize nxlink logging

- Logs were interleaved and caused instability on certain setups
This commit is contained in:
lifajucejo 2018-09-30 19:07:06 -04:00
parent 77fba6d58d
commit c39bc4ecab
2 changed files with 24 additions and 1 deletions

View File

@ -62,6 +62,10 @@ static uint32_t *splashData = NULL;
static bool psmInitialized = false; static bool psmInitialized = false;
#ifdef NXLINK
extern bool nxlink_connected;
#endif
#endif // HAVE_LIBNX #endif // HAVE_LIBNX
static void get_first_valid_core(char *path_return) static void get_first_valid_core(char *path_return)
@ -614,7 +618,7 @@ static void frontend_switch_init(void *data)
#endif // HAVE_OPENGL #endif // HAVE_OPENGL
#ifdef NXLINK #ifdef NXLINK
socketInitializeDefault(); socketInitializeDefault();
nxlinkStdio(); nxlink_connected = nxlinkStdio() != -1;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
verbosity_enable(); verbosity_enable();
#endif // IS_SALAMANDER #endif // IS_SALAMANDER

View File

@ -63,6 +63,11 @@ static void* log_file_buf = NULL;
static bool main_verbosity = false; static bool main_verbosity = false;
static bool log_file_initialized = false; static bool log_file_initialized = false;
#ifdef NXLINK
static Mutex nxlink_mtx;
bool nxlink_connected = false;
#endif
void verbosity_enable(void) void verbosity_enable(void)
{ {
main_verbosity = true; main_verbosity = true;
@ -101,6 +106,11 @@ void retro_main_log_file_init(const char *path)
if (log_file_initialized) if (log_file_initialized)
return; return;
#ifdef NXLINK
if (path == NULL && nxlink_connected)
mutexInit(&nxlink_mtx);
#endif
log_file_fp = stderr; log_file_fp = stderr;
if (path == NULL) if (path == NULL)
return; return;
@ -199,6 +209,10 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
ui_companion_driver_log_msg(buffer); ui_companion_driver_log_msg(buffer);
#else #else
#if defined(NXLINK) && !defined(HAVE_FILE_LOGGER)
if (nxlink_connected)
mutexLock(&nxlink_mtx);
#endif
if (fp) if (fp)
{ {
fprintf(fp, "%s ", fprintf(fp, "%s ",
@ -206,6 +220,11 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
vfprintf(fp, fmt, ap); vfprintf(fp, fmt, ap);
fflush(fp); fflush(fp);
} }
#if defined(NXLINK) && !defined(HAVE_FILE_LOGGER)
if (nxlink_connected)
mutexUnlock(&nxlink_mtx);
#endif
#endif #endif
} }
#endif #endif