fixes for genplusgx

This commit is contained in:
lif 2019-11-18 01:01:12 -08:00
parent 71683dba82
commit 7f36723025
2 changed files with 15 additions and 8 deletions

View File

@ -70,10 +70,6 @@ impl MyEmulator {
if av_info.timing.sample_rate == 0.0 {
av_info.timing.sample_rate = 32040.0;
}
// similar hack, this one making sure we don't divide by zero in our frame limiter.
if av_info.timing.fps == 0.0 {
av_info.timing.fps = 60.0;
}
let sdl_context = sdl2::init().unwrap();
@ -159,7 +155,12 @@ impl MyEmulator {
self.retro.run();
self.canvas.present();
Duration::from_secs_f64(1.0 / self.av_info.timing.fps)
// similar hack to the sample rate, make sure we don't divide by zero.
let mut spf = 1.0 / self.av_info.timing.fps;
if spf.is_nan() {
spf = 1.0 / 60.0;
}
Duration::from_secs_f64(spf)
.checked_sub(frame_begin.elapsed())
.map(std::thread::sleep);
}

View File

@ -1,3 +1,4 @@
use std::ffi::CString;
use std::os::raw::{c_char, c_void};
use std::path::Path;
@ -166,15 +167,20 @@ impl LibretroApi {
size: 0,
meta: std::ptr::null(),
};
if let Some(p) = path.and_then(Path::to_str) {
game.path = p.as_bytes().as_ptr() as *const c_char;
// scope for lifetimes to outlive the call to retro_load_game (pointer safety)
let c_path;
let c_meta;
if let Some(p) = path {
c_path = CString::new(p.to_string_lossy().as_bytes().to_vec())?;
game.path = c_path.as_ptr();
}
if let Some(d) = data {
game.data = d.as_ptr() as *const c_void;
game.size = d.len();
}
if let Some(m) = meta {
game.meta = m.as_bytes().as_ptr() as *const c_char;
c_meta = CString::new(m.as_bytes().to_vec())?;
game.meta = c_meta.as_ptr();
}
if unsafe { (&self.core_api.retro_load_game)(&game) } {