all repos — mgba @ cb2a2126f293663d1607d0040250094da82b9a84

mGBA Game Boy Advance Emulator

Libretro: Only set camera peripheral when it is available (#1931)

Otherwise, if the frontend does not support GET_CAMERA_INTERFACE,
the start and stop functions are NULL, causing a crash when a gameboy
ROM is unloaded.
Michael Forney mforney@mforney.org
Sat, 07 Nov 2020 14:23:34 -0800
commit

cb2a2126f293663d1607d0040250094da82b9a84

parent

d2af8b83e06019ed28b68ec311fcffc3c863433d

1 files changed, 3 insertions(+), 2 deletions(-)

jump to
M src/platform/libretro/libretro.csrc/platform/libretro/libretro.c

@@ -614,9 +614,10 @@ cam.height = GBCAM_HEIGHT;

cam.width = GBCAM_WIDTH; cam.caps = 1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER; cam.frame_raw_framebuffer = _updateCamera; - core->setPeripheral(core, mPERIPH_IMAGE_SOURCE, &imageSource); + if (environCallback(RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE, &cam)) { + core->setPeripheral(core, mPERIPH_IMAGE_SOURCE, &imageSource); + } - environCallback(RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE, &cam); const char* modelName = mCoreConfigGetValue(&core->config, "gb.model"); struct GB* gb = core->board;