diff --git a/general.h b/general.h index 07c97cae23..6bde38a5a7 100644 --- a/general.h +++ b/general.h @@ -183,6 +183,7 @@ struct settings #ifdef SSNES_CONSOLE struct console_settings { + msg_queue_t *stderr_queue; #ifdef __CELLOS_LV2__ bool custom_bgm_enable; #endif @@ -358,7 +359,6 @@ struct global } filter; msg_queue_t *msg_queue; - msg_queue_t *stderr_queue; // Rewind support. state_manager_t *state_manager; @@ -480,33 +480,35 @@ extern struct console_settings g_console; #include "logger_override.h" #else -#define SSNES_LOG_MSG_QUEUE(...) do { \ - char msg__[512]; \ - snprintf(msg__, sizeof(msg__), __VA_ARGS__); \ - if (g_extern.stderr_queue) \ - msg_queue_push_simple(g_extern.stderr_queue, msg__); \ +#ifdef SSNES_CONSOLE +#define SSNES_LOG_MSG_QUEUE(base, ...) do { \ + char msg[512]; + snprintf(msg, sizeof(msg), base ## __VA_ARGS__); \ + if (g_console.stderr_queue) \ + msg_queue_push_simple(g_console.stderr_queue, msg); \ } while(0) +#else +#define SSNES_LOG_MSG_QUEUE(base, ...) ((void)0) +#endif #define SSNES_LOG(...) do { \ if (g_extern.verbose) \ - { \ fprintf(stderr, "SSNES: " __VA_ARGS__); \ fflush(stderr); \ - SSNES_LOG_MSG_QUEUE("SSNES: " __VA_ARGS__); \ - } \ -} while (0) + SSNES_LOG_MSG_QUEUE("SSNES: ", __VA_ARGS__); \ + } while (0) #define SSNES_ERR(...) do { \ - fprintf(stderr, "SSNES [ERROR] :: " __VA_ARGS__); \ - fflush(stderr); \ - SSNES_LOG_MSG_QUEUE("SSNES [ERROR]: " __VA_ARGS__); \ -} while (0) + fprintf(stderr, "SSNES [ERROR] :: " __VA_ARGS__); \ + fflush(stderr); \ + SSNES_LOG_MSG_QUEUE("SSNES [ERROR]: ", __VA_ARGS__); \ + } while (0) #define SSNES_WARN(...) do { \ - fprintf(stderr, "SSNES [WARN] :: " __VA_ARGS__); \ - fflush(stderr); \ - SSNES_LOG_MSG_QUEUE("SSNES [WARN]: " __VA_ARGS__); \ -} while (0) + fprintf(stderr, "SSNES [WARN] :: " __VA_ARGS__); \ + fflush(stderr); \ + SSNES_LOG_MSG_QUEUE("SSNES [WARN]: ", __VA_ARGS__); \ + } while (0) #endif #ifndef max diff --git a/ssnes.c b/ssnes.c index d788836371..650828a0ec 100644 --- a/ssnes.c +++ b/ssnes.c @@ -1197,8 +1197,10 @@ void ssnes_init_msg_queue(void) if (!g_extern.msg_queue) ssnes_assert(g_extern.msg_queue = msg_queue_new(8)); - if (!g_extern.stderr_queue) - ssnes_assert(g_extern.stderr_queue = msg_queue_new(256)); +#ifdef SSNES_CONSOLE + if (!g_console.stderr_queue) + ssnes_assert(g_console.stderr_queue = msg_queue_new(256)); +#endif } static void deinit_msg_queue(void) @@ -1206,8 +1208,10 @@ static void deinit_msg_queue(void) if (g_extern.msg_queue) msg_queue_free(g_extern.msg_queue); - if (g_extern.stderr_queue) - msg_queue_free(g_extern.stderr_queue); +#ifdef SSNES_CONSOLE + if (g_console.stderr_queue) + msg_queue_free(g_console.stderr_queue); +#endif } #ifdef HAVE_XML