mirror of
https://github.com/Dangoware/dango-music-player.git
synced 2025-04-19 10:02:53 -05:00
Applied clippy suggestions
This commit is contained in:
parent
5000d24a77
commit
045cea90bf
7 changed files with 20 additions and 24 deletions
|
@ -179,7 +179,7 @@ impl Player {
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
gst::MessageView::Eos(_) => {}
|
gst::MessageView::Eos(_) => {}
|
||||||
gst::MessageView::StreamStart(_) => println!("Stream start"),
|
gst::MessageView::StreamStart(_) => println!("Stream start"),
|
||||||
gst::MessageView::Error(e) => {
|
gst::MessageView::Error(_) => {
|
||||||
playbin_bus_ctrl
|
playbin_bus_ctrl
|
||||||
.write()
|
.write()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -201,7 +201,7 @@ impl Player {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.set_state(gst::State::Paused)
|
.set_state(gst::State::Paused)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
} else if *paused_bus_ctrl.read().unwrap() == false {
|
} else if !(*paused_bus_ctrl.read().unwrap()) {
|
||||||
*buffer_bus_ctrl.write().unwrap() = None;
|
*buffer_bus_ctrl.write().unwrap() = None;
|
||||||
playbin_bus_ctrl
|
playbin_bus_ctrl
|
||||||
.write()
|
.write()
|
||||||
|
@ -377,19 +377,17 @@ impl Player {
|
||||||
|
|
||||||
/// Seek absolutely
|
/// Seek absolutely
|
||||||
pub fn seek_to(&mut self, target_pos: Duration) -> Result<(), Box<dyn Error>> {
|
pub fn seek_to(&mut self, target_pos: Duration) -> Result<(), Box<dyn Error>> {
|
||||||
let start;
|
let start = if self.start.read().unwrap().is_none() {
|
||||||
if self.start.read().unwrap().is_none() {
|
|
||||||
return Err("Failed to seek: No START time".into());
|
return Err("Failed to seek: No START time".into());
|
||||||
} else {
|
} else {
|
||||||
start = self.start.read().unwrap().unwrap();
|
self.start.read().unwrap().unwrap()
|
||||||
}
|
};
|
||||||
|
|
||||||
let end;
|
let end = if self.end.read().unwrap().is_none() {
|
||||||
if self.end.read().unwrap().is_none() {
|
|
||||||
return Err("Failed to seek: No END time".into());
|
return Err("Failed to seek: No END time".into());
|
||||||
} else {
|
} else {
|
||||||
end = self.end.read().unwrap().unwrap();
|
self.end.read().unwrap().unwrap()
|
||||||
}
|
};
|
||||||
|
|
||||||
let adjusted_target = target_pos + start;
|
let adjusted_target = target_pos + start;
|
||||||
let clamped_target = adjusted_target.clamp(start, end);
|
let clamped_target = adjusted_target.clamp(start, end);
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
use chrono::{DateTime, TimeZone, Utc};
|
use chrono::{DateTime, TimeZone, Utc};
|
||||||
|
|
||||||
pub fn get_bytes<const S: usize>(iterator: &mut std::vec::IntoIter<u8>) -> [u8; S] {
|
pub fn get_bytes<const S: usize>(iterator: &mut std::vec::IntoIter<u8>) -> [u8; S] {
|
||||||
let mut bytes = [0; S];
|
let mut bytes = [0; S];
|
||||||
|
|
||||||
for i in 0..S {
|
for byte in bytes.iter_mut().take(S) {
|
||||||
bytes[i] = iterator.next().unwrap();
|
*byte = iterator.next().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytes;
|
bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_bytes_vec(iterator: &mut std::vec::IntoIter<u8>, number: usize) -> Vec<u8> {
|
pub fn get_bytes_vec(iterator: &mut std::vec::IntoIter<u8>, number: usize) -> Vec<u8> {
|
||||||
|
@ -19,7 +17,7 @@ pub fn get_bytes_vec(iterator: &mut std::vec::IntoIter<u8>, number: usize) -> Ve
|
||||||
bytes.push(iterator.next().unwrap());
|
bytes.push(iterator.next().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytes;
|
bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts the windows DateTime into Chrono DateTime
|
/// Converts the windows DateTime into Chrono DateTime
|
||||||
|
@ -28,7 +26,7 @@ pub fn get_datetime(iterator: &mut std::vec::IntoIter<u8>, topbyte: bool) -> Dat
|
||||||
|
|
||||||
if topbyte {
|
if topbyte {
|
||||||
// Zero the topmost byte
|
// Zero the topmost byte
|
||||||
datetime_i64 = datetime_i64 & 0x00FFFFFFFFFFFFFFF;
|
datetime_i64 &= 0x00FFFFFFFFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if datetime_i64 <= 0 {
|
if datetime_i64 <= 0 {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use std::path::PathBuf;
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::music_storage::library::Song;
|
use crate::music_storage::library::Song;
|
||||||
|
|
||||||
pub trait ExternalLibrary {
|
pub trait ExternalLibrary {
|
||||||
fn from_file(file: &PathBuf) -> Self;
|
fn from_file(file: &Path) -> Self;
|
||||||
fn write(&self) {
|
fn write(&self) {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::{fs::File, io::Read, path::PathBuf, time::Duration};
|
use std::{fs::File, io::Read, path::Path, time::Duration};
|
||||||
|
|
||||||
use crate::music_storage::db_reader::common::{get_bytes, get_bytes_vec};
|
use crate::music_storage::db_reader::common::{get_bytes, get_bytes_vec};
|
||||||
use crate::music_storage::db_reader::extern_library::ExternalLibrary;
|
use crate::music_storage::db_reader::extern_library::ExternalLibrary;
|
||||||
|
@ -19,7 +19,7 @@ pub struct FoobarPlaylist {
|
||||||
impl ExternalLibrary for FoobarPlaylist {
|
impl ExternalLibrary for FoobarPlaylist {
|
||||||
/// Reads the entire MusicBee library and returns relevant values
|
/// Reads the entire MusicBee library and returns relevant values
|
||||||
/// as a `Vec` of `Song`s
|
/// as a `Vec` of `Song`s
|
||||||
fn from_file(file: &PathBuf) -> Self {
|
fn from_file(file: &Path) -> Self {
|
||||||
let mut f = File::open(file).unwrap();
|
let mut f = File::open(file).unwrap();
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
let mut retrieved_songs: Vec<FoobarPlaylistTrack> = Vec::new();
|
let mut retrieved_songs: Vec<FoobarPlaylistTrack> = Vec::new();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pub fn meta_offset(metadata: &Vec<u8>, offset: usize) -> String {
|
pub fn meta_offset(metadata: &[u8], offset: usize) -> String {
|
||||||
let mut result_vec = Vec::new();
|
let mut result_vec = Vec::new();
|
||||||
|
|
||||||
let mut i = offset;
|
let mut i = offset;
|
||||||
|
|
|
@ -29,7 +29,7 @@ impl MusicBeeDatabase {
|
||||||
// Get the song count from the first 4 bytes
|
// Get the song count from the first 4 bytes
|
||||||
// and then right shift it by 8 for some reason
|
// and then right shift it by 8 for some reason
|
||||||
let mut database_song_count = i32::from_le_bytes(get_bytes(&mut buf_iter));
|
let mut database_song_count = i32::from_le_bytes(get_bytes(&mut buf_iter));
|
||||||
database_song_count = database_song_count >> 8;
|
database_song_count >>= 8;
|
||||||
|
|
||||||
let mut song_count = 0;
|
let mut song_count = 0;
|
||||||
loop {
|
loop {
|
||||||
|
|
|
@ -28,7 +28,7 @@ impl XmlLibrary {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl ExternalLibrary for XmlLibrary {
|
impl ExternalLibrary for XmlLibrary {
|
||||||
fn from_file(file: &PathBuf) -> Self {
|
fn from_file(file: &Path) -> Self {
|
||||||
let mut reader = Reader::from_file(file).unwrap();
|
let mut reader = Reader::from_file(file).unwrap();
|
||||||
reader.trim_text(true);
|
reader.trim_text(true);
|
||||||
//count every event, for fun ig?
|
//count every event, for fun ig?
|
||||||
|
|
Loading…
Reference in a new issue