Skip to content

Commit

Permalink
better fallback chain
Browse files Browse the repository at this point in the history
  • Loading branch information
torokati44 committed Feb 6, 2024
1 parent ff4890b commit 9c9c068
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions tests/framework/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,29 +178,35 @@ impl PlayerOptions {
// TODO: Do the same dance everywhere we set up a video backend, or
// make ExternalVideoBackend tolerate failure and fall back completely
// to SoftwareVideoBackend internally?
let video: Option<Box<dyn ruffle_video::backend::VideoBackend>> =
if cfg!(feature = "ruffle_video_external") {
match ruffle_video_external::backend::ExternalVideoBackend::new() {
Ok(video) => Some(Box::new(video)),
Err(_e) => {
if cfg!(feature = "ruffle_software_video") {
Some(Box::new(
ruffle_video_software::backend::SoftwareVideoBackend::new(),
))
} else {
None
}
}
}
} else if cfg!(feature = "ruffle_video_software") {
Some(Box::new(
ruffle_video_software::backend::SoftwareVideoBackend::new(),
))
} else {
None
};

if let Some(video) = video {
type VB = Option<Box<dyn ruffle_video::backend::VideoBackend>>;

#[cfg(feature = "ruffle_video_external")]
fn make_video() -> VB {
match ruffle_video_external::backend::ExternalVideoBackend::new() {
Ok(video) => Some(Box::new(video)),
Err(_e) => None,
}
}

#[cfg(all(
not(feature = "ruffle_video_external"),
feature = "ruffle_video_software"
))]
fn make_video() -> VB {
Some(Box::new(
ruffle_video_software::backend::SoftwareVideoBackend::new(),
))
}

#[cfg(all(
not(feature = "ruffle_video_external"),
not(feature = "ruffle_video_software")
))]
fn make_video() -> VB {
None
}

if let Some(video) = make_video() {
player_builder = player_builder.with_boxed_video(video);
}
}
Expand Down

0 comments on commit 9c9c068

Please sign in to comment.