Mercurial > repos > blastem
diff render_sdl.c @ 2041:638eb2d25696 mame_interp
Merge from default
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 05 Aug 2021 09:29:33 -0700 |
parents | 0757da8ee702 |
children | 46ee354f29bd |
line wrap: on
line diff
--- a/render_sdl.c Sun May 10 00:16:00 2020 -0700 +++ b/render_sdl.c Thu Aug 05 09:29:33 2021 -0700 @@ -171,8 +171,14 @@ void render_audio_created(audio_source *source) { - if (render_is_audio_sync()) { - SDL_PauseAudio(0); + if (sync_src == SYNC_AUDIO) { + //SDL_PauseAudio acquires the audio device lock, which is held while the callback runs + //since our callback can itself be stuck waiting on the audio_ready condition variable + //calling SDL_PauseAudio(0) again for audio sources after the first can deadlock + //fortunately SDL_GetAudioStatus does not acquire the lock so is safe to call here + if (SDL_GetAudioStatus() == SDL_AUDIO_PAUSED) { + SDL_PauseAudio(0); + } } if (current_system && sync_src == SYNC_AUDIO_THREAD) { system_request_exit(current_system, 0); @@ -194,8 +200,14 @@ void render_source_resumed(audio_source *src) { - if (render_is_audio_sync()) { - SDL_PauseAudio(0); + if (sync_src == SYNC_AUDIO) { + //SDL_PauseAudio acquires the audio device lock, which is held while the callback runs + //since our callback can itself be stuck waiting on the audio_ready condition variable + //calling SDL_PauseAudio(0) again for audio sources after the first can deadlock + //fortunately SDL_GetAudioStatus does not acquire the lock so is safe to call here + if (SDL_GetAudioStatus() == SDL_AUDIO_PAUSED) { + SDL_PauseAudio(0); + } } if (current_system && sync_src == SYNC_AUDIO_THREAD) { system_request_exit(current_system, 0); @@ -394,7 +406,7 @@ } else { tex_width = tex_height = 512; } - printf("Using %dx%d textures\n", tex_width, tex_height); + debug_message("Using %dx%d textures\n", tex_width, tex_height); for (int i = 0; i < 3; i++) { glBindTexture(GL_TEXTURE_2D, textures[i]); @@ -1191,6 +1203,19 @@ atexit(render_quit); } + +void render_reset_mappings(void) +{ + SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER); + SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER); + uint32_t db_size; + char *db_data = read_bundled_file("gamecontrollerdb.txt", &db_size); + if (db_data) { + int added = SDL_GameControllerAddMappingsFromRW(SDL_RWFromMem(db_data, db_size), 1); + free(db_data); + debug_message("Added %d game controller mappings from gamecontrollerdb.txt\n", added); + } +} static int in_toggle; void render_config_updated(void) @@ -1706,6 +1731,7 @@ if (sync_src != SYNC_AUDIO_THREAD && sync_src != SYNC_EXTERNAL) { return; } + SDL_PauseAudio(0); SDL_LockMutex(frame_mutex); for(;;) {