stop frame properties from changing after starting, ffmpeg doesn't like that
This commit is contained in:
parent
764485b2b5
commit
bdba596d07
|
@ -28,6 +28,7 @@ struct MyEmulator {
|
||||||
video_filter: filter::Graph,
|
video_filter: filter::Graph,
|
||||||
audio_filter: filter::Graph,
|
audio_filter: filter::Graph,
|
||||||
sys_path: Option<PathBuf>,
|
sys_path: Option<PathBuf>,
|
||||||
|
frame_properties_locked: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn video_filter(
|
fn video_filter(
|
||||||
|
@ -147,6 +148,7 @@ impl MyEmulator {
|
||||||
video_filter,
|
video_filter,
|
||||||
audio_filter,
|
audio_filter,
|
||||||
sys_path: sys_path.as_ref().map(|x| x.as_ref().to_path_buf()),
|
sys_path: sys_path.as_ref().map(|x| x.as_ref().to_path_buf()),
|
||||||
|
frame_properties_locked: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut pin_emu = Box::pin(emu);
|
let mut pin_emu = Box::pin(emu);
|
||||||
|
@ -243,6 +245,10 @@ impl retro::wrapper::Handler for MyEmulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_pixel_format(&mut self, format: PixelFormat) -> bool {
|
fn set_pixel_format(&mut self, format: PixelFormat) -> bool {
|
||||||
|
if self.frame_properties_locked {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
self.video_pixel_format = match format {
|
self.video_pixel_format = match format {
|
||||||
PixelFormat::ARGB1555 => format::Pixel::RGB555,
|
PixelFormat::ARGB1555 => format::Pixel::RGB555,
|
||||||
PixelFormat::ARGB8888 => format::Pixel::RGB32,
|
PixelFormat::ARGB8888 => format::Pixel::RGB32,
|
||||||
|
@ -253,16 +259,26 @@ impl retro::wrapper::Handler for MyEmulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_system_av_info(&mut self, system_av_info: SystemAvInfo) -> bool {
|
fn set_system_av_info(&mut self, system_av_info: SystemAvInfo) -> bool {
|
||||||
|
if self.frame_properties_locked {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
self.video_encoder.set_frame_rate(system_av_info.timing.fps.into());
|
self.video_encoder.set_frame_rate(system_av_info.timing.fps.into());
|
||||||
|
/*
|
||||||
if system_av_info.timing.sample_rate.round() as i32 > 0 {
|
if system_av_info.timing.sample_rate.round() as i32 > 0 {
|
||||||
self.audio_encoder.set_rate(system_av_info.timing.sample_rate.round() as i32);
|
self.audio_encoder.set_rate(system_av_info.timing.sample_rate.round() as i32);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
self.av_info.timing = system_av_info.timing;
|
self.av_info.timing = system_av_info.timing;
|
||||||
self.set_geometry(system_av_info.geometry);
|
self.set_geometry(system_av_info.geometry);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_geometry(&mut self, geometry: GameGeometry) -> bool {
|
fn set_geometry(&mut self, geometry: GameGeometry) -> bool {
|
||||||
|
if self.frame_properties_locked {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
self.video_encoder.set_width(geometry.base_width);
|
self.video_encoder.set_width(geometry.base_width);
|
||||||
self.video_encoder.set_height(geometry.base_height);
|
self.video_encoder.set_height(geometry.base_height);
|
||||||
self.video_encoder.set_aspect_ratio(geometry.aspect_ratio as f64);
|
self.video_encoder.set_aspect_ratio(geometry.aspect_ratio as f64);
|
||||||
|
@ -322,6 +338,7 @@ fn main() -> Fallible<()> {
|
||||||
let mut emu = MyEmulator::new(opt.core, &opt.system, video_encoder, audio_encoder);
|
let mut emu = MyEmulator::new(opt.core, &opt.system, video_encoder, audio_encoder);
|
||||||
emu.load_game(opt.rom);
|
emu.load_game(opt.rom);
|
||||||
|
|
||||||
|
emu.frame_properties_locked = true;
|
||||||
octx.write_header().unwrap();
|
octx.write_header().unwrap();
|
||||||
|
|
||||||
for _ in 0..60*60 {
|
for _ in 0..60*60 {
|
||||||
|
|
Loading…
Reference in New Issue