ref: f70b0dfb8b5d4d2d4e1b2f65f13d64b4323d0ded
parent: e641956fc4e42119fc587cb7129474e412d9c951
author: Jonne Kokkonen <jonne.kokkonen@gmail.com>
date: Mon Apr 14 17:33:02 EDT 2025
try to have less glitches when starting the app with mixer screen on macos
--- a/src/backends/m8_libserialport.c
+++ b/src/backends/m8_libserialport.c
@@ -114,7 +114,7 @@
while (cur < end) {const int slip_result = slip_read_byte(slip, *cur++);
if (slip_result != SLIP_NO_ERROR) {- SDL_LogError(SDL_LOG_CATEGORY_ERROR, "SLIP error %d\n", slip_result);
+ SDL_LogError(SDL_LOG_CATEGORY_ERROR, "SLIP error %d", slip_result);
}
}
}
@@ -187,7 +187,6 @@
static int initialize_serial_thread() {init_queue(&queue);
- thread_params.should_stop = 0;
serial_thread = SDL_CreateThread(thread_process_serial_data, "SerialThread", &thread_params);
if (!serial_thread) {@@ -196,6 +195,8 @@
return 0;
}
+ thread_params.should_stop = 0;
+
return 1;
}
@@ -244,7 +245,7 @@
slip_init(&slip, &slip_descriptor);
if (verbose) {- SDL_Log("Looking for USB serial devices.\n");+ SDL_Log("Looking for USB serial devices");}
// Detect and select M8 device
@@ -330,7 +331,7 @@
}
int m8_reset_display() {- SDL_Log("Reset display\n");+ SDL_Log("Reset display"); const unsigned char buf[1] = {'R'};const int result = sp_blocking_write(m8_port, buf, 1, 5);
@@ -342,7 +343,7 @@
}
int m8_enable_and_reset_display() {- SDL_Log("Enabling and resetting M8 display\n");+ SDL_Log("Enabling and resetting M8 display"); const char buf[1] = {'E'};int result = sp_blocking_write(m8_port, buf, 1, 5);
--- a/src/main.c
+++ b/src/main.c
@@ -6,6 +6,7 @@
// #define DEBUG_MSG
#include <SDL3/SDL.h>
+#include <SDL3/SDL_main.h>
#include <signal.h>
#include <stdlib.h>
@@ -18,13 +19,9 @@
#include "input.h"
#include "render.h"
-#if TARGET_OS_IOS
-#include <SDL3/SDL_main.h>
-unsigned char app_suspended = 0;
-#endif // TARGET_OS_IOS
-
enum app_state app_state = WAIT_FOR_DEVICE;
unsigned char device_connected = 0;
+unsigned char app_suspended = 0;
// Handle CTRL+C / SIGINT, SIGKILL etc.
static void signal_handler(int unused) {@@ -214,7 +211,7 @@
do { if (!device_connected) {- device_connected = m8_initialize(1, preferred_device);
+ device_connected = handle_device_initialization(conf->wait_for_device, preferred_device);
}
if (device_connected && m8_enable_and_reset_display()) { if (conf->audio_enabled) {--- a/src/render.c
+++ b/src/render.c
@@ -98,7 +98,10 @@
SDL_SetRenderDrawColor(rend, global_background_color.r, global_background_color.g,
global_background_color.b, global_background_color.a);
- SDL_RenderClear(rend);
+ if (!SDL_RenderClear(rend)) {+ SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Couldn't clear renderer: %s", SDL_GetError());
+ return 0;
+ }
renderer_set_font_mode(0);
@@ -107,6 +110,9 @@
#endif
dirty = 1;
+
+ SDL_PumpEvents();
+ render_screen();
return 1;
}
--
⑨