Make getting AV info lazy

Some cores (Dolphin) don't initalize AV info, or use resources that are not allocated yet, until after a game is loaded.
This commit is contained in:
Lily Tsuru 2024-08-06 21:44:41 -04:00
parent 4e8ad7616f
commit 16e6875228

View file

@ -327,13 +327,6 @@ impl Frontend {
);
info!("Core {} loaded", path.as_ref().display());
// Get AV info
// Like core API, we have to MaybeUninit again.
let mut av_info: MaybeUninit<SystemAvInfo> = MaybeUninit::uninit();
(core_api_ref.retro_get_system_av_info)(av_info.as_mut_ptr());
self.av_info = Some(av_info.assume_init());
}
Ok(())
@ -436,7 +429,17 @@ impl Frontend {
if let Some(av) = self.av_info.as_ref() {
Ok(av.clone())
} else {
Err(Error::NoAvInfo)
// Get AV info
// Like core API, we have to MaybeUninit again.
let mut av_info: MaybeUninit<SystemAvInfo> = MaybeUninit::uninit();
unsafe {
let core_api = self.core_api.as_ref().unwrap();
(core_api.retro_get_system_av_info)(av_info.as_mut_ptr());
self.av_info = Some(av_info.assume_init());
}
Ok(self.av_info.as_ref().unwrap().clone())
}
}