diff options
| author | Jokler <jokler@protonmail.com> | 2020-08-19 03:38:48 +0200 |
|---|---|---|
| committer | Jokler <jokler@protonmail.com> | 2020-08-19 03:38:48 +0200 |
| commit | 237e0c4fb48d9694c263f703a42f7790a99368ef (patch) | |
| tree | cd7f8351d92a2cd58c3eff08164a2eb7070d65f3 /src/audio_player.rs | |
| parent | 681950517d511d1c4b8e465f9b9758c027ecd6bf (diff) | |
| download | pokebot-237e0c4fb48d9694c263f703a42f7790a99368ef.tar.gz pokebot-237e0c4fb48d9694c263f703a42f7790a99368ef.zip | |
Run clippy and fmt
Diffstat (limited to 'src/audio_player.rs')
| -rw-r--r-- | src/audio_player.rs | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/audio_player.rs b/src/audio_player.rs index 5f9c625..79c54ef 100644 --- a/src/audio_player.rs +++ b/src/audio_player.rs @@ -13,8 +13,8 @@ use log::{debug, error, info, warn}; use std::sync::{Arc, RwLock}; use tokio02::sync::mpsc::UnboundedSender; -use crate::youtube_dl::AudioMetadata; use crate::command::{Seek, VolumeChange}; +use crate::youtube_dl::AudioMetadata; static GST_INIT: Once = Once::new(); @@ -63,18 +63,15 @@ fn add_decode_bin_new_pad_callback( None }; - match name.as_deref() { - Some("audio/x-raw") => { - if let Some(peer) = ghost_pad.get_peer() { - peer.unlink(&ghost_pad).unwrap(); - } + if let Some("audio/x-raw") = name.as_deref() { + if let Some(peer) = ghost_pad.get_peer() { + peer.unlink(&ghost_pad).unwrap(); + } - info!("Found raw audio, linking audio bin"); - new_pad.link(&ghost_pad).unwrap(); + info!("Found raw audio, linking audio bin"); + new_pad.link(&ghost_pad).unwrap(); - audio_bin.sync_state_with_parent().unwrap(); - } - _ => {} + audio_bin.sync_state_with_parent().unwrap(); } }); } @@ -233,7 +230,7 @@ impl AudioPlayer { pub fn position(&self) -> Option<Duration> { self.pipeline .query_position::<gst::ClockTime>() - .and_then(|t| t.0.map(|v| Duration::from_nanos(v))) + .and_then(|t| t.0.map(Duration::from_nanos)) } pub fn currently_playing(&self) -> Option<AudioMetadata> { @@ -313,9 +310,10 @@ impl AudioPlayer { pub fn quit(&self, reason: String) { info!("Quitting audio player"); - if let Err(_) = self + if self .bus .post(&gst::Message::new_application(gst::Structure::new_empty("quit")).build()) + .is_err() { warn!("Tried to send \"quit\" app event on flushing bus."); } |
