comparison render_sdl.c @ 2664:36ae207af490

Awful hack to work around what seems like a bug in the Emscripten version of SDL2
author Michael Pavone <pavone@retrodev.com>
date Thu, 06 Mar 2025 01:47:49 -0800
parents 568c1c22f3e3
children 1f6503bcb1d5
comparison
equal deleted inserted replaced
2663:568c1c22f3e3 2664:36ae207af490
1401 debug_message("Added %d game controller mappings from gamecontrollerdb.txt\n", added); 1401 debug_message("Added %d game controller mappings from gamecontrollerdb.txt\n", added);
1402 } 1402 }
1403 } 1403 }
1404 static int in_toggle; 1404 static int in_toggle;
1405 1405
1406 #ifdef __EMSCRIPTEN__
1407 void resume_config_update(void *arg)
1408 {
1409 uint8_t was_paused = arg != NULL;
1410 quitting = 0;
1411 init_audio();
1412 render_set_video_standard(video_standard);
1413
1414 drain_events();
1415 in_toggle = 0;
1416 if (!was_paused) {
1417 SDL_PauseAudio(0);
1418 }
1419 emscripten_resume_main_loop();
1420 }
1421 #endif __EMSCRIPTEN__
1422
1406 void render_config_updated(void) 1423 void render_config_updated(void)
1407 { 1424 {
1408 for (int i = 0; i <= FRAMEBUFFER_UI; i++) 1425 for (int i = 0; i <= FRAMEBUFFER_UI; i++)
1409 { 1426 {
1410 if (sdl_textures[i]) { 1427 if (sdl_textures[i]) {
1477 ac.samples != current_audio_config.samples || ac.format != current_audio_config.format; 1494 ac.samples != current_audio_config.samples || ac.format != current_audio_config.format;
1478 } 1495 }
1479 if (do_audio_reinit) { 1496 if (do_audio_reinit) {
1480 was_paused = SDL_GetAudioStatus() == SDL_AUDIO_PAUSED; 1497 was_paused = SDL_GetAudioStatus() == SDL_AUDIO_PAUSED;
1481 render_close_audio(); 1498 render_close_audio();
1499 #ifdef __EMSCRIPTEN__
1500 emscripten_pause_main_loop();
1501 emscripten_async_call(resume_config_update, was_paused ? config : NULL, 1000);
1502 #else
1482 quitting = 0; 1503 quitting = 0;
1483 init_audio(); 1504 init_audio();
1505 #endif
1484 } 1506 }
1485 render_set_video_standard(video_standard); 1507 render_set_video_standard(video_standard);
1486 1508
1487 drain_events(); 1509 drain_events();
1488 in_toggle = 0; 1510 in_toggle = 0;