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:
parent
4e8ad7616f
commit
16e6875228
1 changed files with 11 additions and 8 deletions
|
@ -327,13 +327,6 @@ impl Frontend {
|
||||||
);
|
);
|
||||||
|
|
||||||
info!("Core {} loaded", path.as_ref().display());
|
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(())
|
Ok(())
|
||||||
|
@ -436,7 +429,17 @@ impl Frontend {
|
||||||
if let Some(av) = self.av_info.as_ref() {
|
if let Some(av) = self.av_info.as_ref() {
|
||||||
Ok(av.clone())
|
Ok(av.clone())
|
||||||
} else {
|
} 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())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue