Skip to content

Commit

Permalink
refactor(player): inline mpris getter
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaDve committed Sep 16, 2023
1 parent 40b7c83 commit decf133
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ mod imp {
utils::spawn(
glib::Priority::default(),
clone!(@weak obj => async move {
if let Err(err) = obj.mpris_server().unwrap().init_and_run().await {
if let Err(err) =
obj.imp().mpris_server.get().unwrap().init_and_run().await
{
tracing::error!("Failed to run MPRIS server: {:?}", err);
}
}),
Expand Down Expand Up @@ -224,16 +226,12 @@ impl Player {
self.notify_duration();
}

fn mpris_server(&self) -> Option<&LocalServer<Self>> {
self.imp().mpris_server.get()
}

fn mpris_properties_changed(&self, property: impl Into<BitFlags<Property>>) {
let property = property.into();
utils::spawn(
glib::Priority::default(),
clone!(@weak self as obj => async move {
if let Some(server) = obj.mpris_server() {
if let Some(server) = obj.imp().mpris_server.get() {
if let Err(err) = server.properties_changed(property).await {
tracing::error!("Failed to emit MPRIS properties changed: {:?}", err);
}
Expand All @@ -246,7 +244,7 @@ impl Player {
utils::spawn(
glib::Priority::default(),
clone!(@weak self as obj => async move {
if let Some(server) = obj.mpris_server() {
if let Some(server) = obj.imp().mpris_server.get() {
if let Err(err) = server.emit(Signal::Seeked { position }).await {
tracing::error!("Failed to emit MPRIS seeked: {:?}", err);
}
Expand Down

0 comments on commit decf133

Please sign in to comment.