Skip to content

Commit

Permalink
Add feature flag for build script
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Dec 10, 2024
1 parent 46a9fc8 commit 8ac9b6b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 42 deletions.
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn main() {
}

// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1516
#[cfg(target_os = "macos")]
#[cfg(all(feature = "video", target_os = "macos"))]
match system_deps::Config::new().probe() {
Ok(deps) => {
let usr = std::path::Path::new("/usr/lib");
Expand Down
2 changes: 1 addition & 1 deletion src/gui/modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ impl Modal {
.orientation_limit
.current()
.parse::<NonZeroUsize>()
.unwrap_or(playlist::OrientationLimit::DEFAULT_FIXED);
.unwrap_or(playlist::OrientationLimit::default_fixed());
settings.orientation_limit = playlist::OrientationLimit::Fixed(limit);
} else {
settings.orientation_limit = playlist::OrientationLimit::Automatic;
Expand Down
69 changes: 31 additions & 38 deletions src/gui/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,44 +728,37 @@ impl Player {

#[cfg(feature = "audio")]
pub fn reload_audio(&mut self, playback: &Playback) {
match self {
Self::Idle => {}
Self::Error { .. } => {}
Self::Image { .. } => {}
Self::Svg { .. } => {}
Self::Gif { .. } => {}
Self::Audio {
media,
stream: _,
sink,
duration: _,
looping,
dragging,
hovered,
need_play_on_focus,
} => {
let playback = playback.with_paused(sink.is_paused()).with_muted(sink.volume() == 0.0);
let position = sink.get_pos();

*self = match Self::load_audio(media.path(), &playback, position) {
Ok((stream, sink, duration)) => Self::Audio {
media: media.clone(),
stream,
sink,
duration,
looping: *looping,
dragging: *dragging,
hovered: *hovered,
need_play_on_focus: *need_play_on_focus,
},
Err(e) => Self::Error {
media: media.clone(),
message: e.message(),
hovered: false,
},
};
}
Self::Video { .. } => {}
if let Self::Audio {
media,
stream: _,
sink,
duration: _,
looping,
dragging,
hovered,
need_play_on_focus,
} = self
{
let playback = playback.with_paused(sink.is_paused()).with_muted(sink.volume() == 0.0);
let position = sink.get_pos();

*self = match Self::load_audio(media.path(), &playback, position) {
Ok((stream, sink, duration)) => Self::Audio {
media: media.clone(),
stream,
sink,
duration,
looping: *looping,
dragging: *dragging,
hovered: *hovered,
need_play_on_focus: *need_play_on_focus,
},
Err(e) => Self::Error {
media: media.clone(),
message: e.message(),
hovered: false,
},
};
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/resource/playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub enum Orientation {
}

impl Orientation {
pub const ALL: &[Self] = &[Self::Horizontal, Self::Vertical];
pub const ALL: &'static [Self] = &[Self::Horizontal, Self::Vertical];
}

impl ToString for Orientation {
Expand All @@ -166,7 +166,11 @@ pub enum OrientationLimit {
}

impl OrientationLimit {
pub const DEFAULT_FIXED: NonZeroUsize = NonZeroUsize::new(4).unwrap();
pub const DEFAULT_FIXED: usize = 4;

pub fn default_fixed() -> NonZeroUsize {
NonZeroUsize::new(Self::DEFAULT_FIXED).unwrap()
}

pub fn is_fixed(&self) -> bool {
match self {
Expand Down

0 comments on commit 8ac9b6b

Please sign in to comment.