Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

sdl: fix: concurrent drawing on Windows

On Windows, we need to prevent the event thread
from drawing at the same time as the main thread,
when window is being adjusted.

Change-Id: I2b4e4a50fec427e53e310593850e2a556a594b31

+18
+6
firmware/target/hosted/sdl/button-sdl.c
··· 243 243 sdl_app_has_input_focus = 0; 244 244 else if(event->window.event == SDL_WINDOWEVENT_RESIZED) 245 245 { 246 + SDL_LockMutex(window_mutex); 246 247 sdl_window_adjustment_needed(false); 248 + SDL_UnlockMutex(window_mutex); 247 249 #if !defined (__APPLE__) && !defined(__WIN32) 248 250 static unsigned long last_tick; 249 251 if (TIME_AFTER(current_tick, last_tick + HZ/20) && !button_queue_full()) ··· 354 356 case SDLK_TAB: 355 357 if (!pressed) 356 358 { 359 + SDL_LockMutex(window_mutex); 357 360 background = !background; 358 361 sdl_window_adjustment_needed(true); 362 + SDL_UnlockMutex(window_mutex); 359 363 #if !defined(__WIN32) && !defined (__APPLE__) 360 364 button_queue_post(SDLK_UNKNOWN, 0); /* update window on main thread */ 361 365 #endif ··· 375 379 display_zoom = 0; 376 380 return; 377 381 } 382 + SDL_LockMutex(window_mutex); 378 383 if (!display_zoom) 379 384 SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, 380 385 strcmp(SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY) ?: 381 386 "best", "best") ? "best": "nearest"); 382 387 383 388 sdl_window_adjustment_needed(!display_zoom); 389 + SDL_UnlockMutex(window_mutex); 384 390 #if !defined(__WIN32) && !defined (__APPLE__) 385 391 button_queue_post(SDLK_UNKNOWN, 0); /* update window on main thread */ 386 392 #endif
+4
firmware/target/hosted/sdl/lcd-sdl.c
··· 102 102 SDL_Rect dest= {ui_x + x_start, ui_y + y_start, width, height}; 103 103 104 104 uint8_t alpha; 105 + 106 + SDL_LockMutex(window_mutex); 107 + 105 108 if (SDL_GetSurfaceAlphaMod(surface,&alpha) == 0 && alpha < 255) 106 109 SDL_FillRect(sim_lcd_surface, NULL, 0); /* alpha needs a black background */ 107 110 ··· 111 114 112 115 if (!sdl_window_adjust()) /* already calls sdl_window_render itself */ 113 116 sdl_window_render(); 117 + SDL_UnlockMutex(window_mutex); 114 118 } 115 119 116 120 /* set a range of bitmap indices to a gradient from startcolour to endcolour */
+2
firmware/target/hosted/sdl/system-sdl.c
··· 175 175 void sim_do_exit() 176 176 { 177 177 sim_kernel_shutdown(); 178 + SDL_UnlockMutex(window_mutex); 179 + SDL_DestroyMutex(window_mutex); 178 180 179 181 SDL_Quit(); 180 182 exit(EXIT_SUCCESS);
+3
firmware/target/hosted/sdl/window-sdl.c
··· 33 33 SDL_Texture *gui_texture; 34 34 SDL_Surface *sim_lcd_surface; 35 35 36 + SDL_mutex *window_mutex; 37 + 36 38 static SDL_Window *window; 37 39 static SDL_Renderer *sdlRenderer; 38 40 static SDL_Surface *picture_surface; ··· 220 222 221 223 SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, display_zoom == 1 ? "best" : "nearest"); 222 224 display_zoom = 0; /* reset to 0 unless/until user requests a scale level change */ 225 + window_mutex = SDL_CreateMutex(); 223 226 }
+3
firmware/target/hosted/sdl/window-sdl.h
··· 26 26 extern SDL_Texture *gui_texture; /* Window content, including background */ 27 27 extern SDL_Surface *sim_lcd_surface; /* LCD content */ 28 28 29 + extern SDL_mutex *window_mutex; /* prevent concurrent drawing from event thread & 30 + main thread on MS Windows */ 31 + 29 32 /* Renders GUI texture. Sets up new texture, if necessary */ 30 33 void sdl_window_render(void); 31 34