A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

sdl: use mutex in printf()

This prevents lines of output being overwritten by different threads.

Change-Id: I24cee52238b53c8a4b2536e082bb4bcd103d8d60

+17 -1
+17 -1
apps/plugins/sdl/wrappers.c
··· 333 333 return 1; 334 334 } 335 335 336 + 336 337 /* stolen from doom */ 337 338 // Here is a hacked up printf command to get the output from the game. 338 339 int printf_wrapper(const char *fmt, ...) 339 340 { 340 - static int p_xtpt; 341 + static volatile struct mutex printf_mutex; 342 + static volatile int mutex_init = 0; 343 + 344 + if(!mutex_init) 345 + { 346 + rb->mutex_init(&printf_mutex); 347 + mutex_init = 1; 348 + } 349 + 350 + static volatile int p_xtpt; 351 + 352 + rb->mutex_lock(&printf_mutex); 353 + 341 354 char p_buf[256]; 342 355 rb->yield(); 343 356 va_list ap; ··· 362 375 rb->lcd_clear_display(); 363 376 } 364 377 } 378 + 379 + rb->mutex_unlock(&printf_mutex); 380 + 365 381 return 1; 366 382 } 367 383