mirror of
https://github.com/Dangoware/dmp-core.git
synced 2025-04-19 17:42:56 -05:00
Fixed an issue with CUE playback, fixed an issue with CUE file reading
The CUE artist was being inserted as the Album title
This commit is contained in:
parent
38b27c66c2
commit
d87927a7db
2 changed files with 21 additions and 11 deletions
|
@ -73,8 +73,8 @@ impl Player {
|
||||||
let end: Arc<RwLock<Option<Duration>>> = Arc::new(RwLock::new(None));
|
let end: Arc<RwLock<Option<Duration>>> = Arc::new(RwLock::new(None));
|
||||||
|
|
||||||
let position_update = position.clone();
|
let position_update = position.clone();
|
||||||
let start_update = start.clone();
|
let start_update = Arc::clone(&start);
|
||||||
let end_update = end.clone();
|
let end_update = Arc::clone(&end);
|
||||||
let (message_tx, message_rx) = bounded(1);
|
let (message_tx, message_rx) = bounded(1);
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
loop {
|
loop {
|
||||||
|
@ -88,8 +88,6 @@ impl Player {
|
||||||
&& start_update.read().unwrap().is_some()
|
&& start_update.read().unwrap().is_some()
|
||||||
&& end_update.read().unwrap().is_some()
|
&& end_update.read().unwrap().is_some()
|
||||||
{
|
{
|
||||||
if let Some(time) = *start_update.read().unwrap() { pos_temp = Some(pos_temp.unwrap() - time) }
|
|
||||||
|
|
||||||
let atf = end_update.read().unwrap().unwrap() - Duration::milliseconds(100);
|
let atf = end_update.read().unwrap().unwrap() - Duration::milliseconds(100);
|
||||||
if pos_temp.unwrap() >= end_update.read().unwrap().unwrap() {
|
if pos_temp.unwrap() >= end_update.read().unwrap().unwrap() {
|
||||||
message_tx.try_send(PlayerCmd::Eos).unwrap();
|
message_tx.try_send(PlayerCmd::Eos).unwrap();
|
||||||
|
@ -102,10 +100,16 @@ impl Player {
|
||||||
*end_update.write().unwrap() = None;
|
*end_update.write().unwrap() = None;
|
||||||
} else if pos_temp.unwrap() >= atf {
|
} else if pos_temp.unwrap() >= atf {
|
||||||
match message_tx.try_send(PlayerCmd::AboutToFinish) {
|
match message_tx.try_send(PlayerCmd::AboutToFinish) {
|
||||||
Ok(_) => println!("Sent ATF"),
|
Ok(_) => (),
|
||||||
Err(err) => println!("{}", err),
|
Err(_) => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This has to be done AFTER the current time in the file
|
||||||
|
// is calculated, or everything else is wrong
|
||||||
|
if let Some(time) = *start_update.read().unwrap() {
|
||||||
|
pos_temp = Some(pos_temp.unwrap() - time)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*position_update.write().unwrap() = pos_temp;
|
*position_update.write().unwrap() = pos_temp;
|
||||||
|
@ -159,11 +163,14 @@ impl Player {
|
||||||
self.pause().unwrap();
|
self.pause().unwrap();
|
||||||
|
|
||||||
// Wait for it to be ready, and then move to the proper position
|
// Wait for it to be ready, and then move to the proper position
|
||||||
while self.playbin.read().unwrap().query_duration::<ClockTime>().is_none() {
|
let now = std::time::Instant::now();
|
||||||
|
while now.elapsed() < std::time::Duration::from_millis(20) {
|
||||||
|
if self.seek_to(Duration::from_std(*start).unwrap()).is_ok() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::thread::sleep(std::time::Duration::from_millis(1));
|
std::thread::sleep(std::time::Duration::from_millis(1));
|
||||||
};
|
}
|
||||||
|
panic!("Couldn't seek to beginning of cue track in reasonable time (>20ms)");
|
||||||
self.seek_to(Duration::from_std(*start).unwrap()).unwrap();
|
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
self.playbin.write().unwrap().set_property("uri", source.as_uri());
|
self.playbin.write().unwrap().set_property("uri", source.as_uri());
|
||||||
|
|
|
@ -149,6 +149,7 @@ impl Song {
|
||||||
self.tags.get(target_key)
|
self.tags.get(target_key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Gets an internal field from a song
|
||||||
pub fn get_field(&self, target_field: &str) -> Option<Field> {
|
pub fn get_field(&self, target_field: &str) -> Option<Field> {
|
||||||
let lower_target = target_field.to_lowercase();
|
let lower_target = target_field.to_lowercase();
|
||||||
match lower_target.as_str() {
|
match lower_target.as_str() {
|
||||||
|
@ -164,10 +165,12 @@ impl Song {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the value of a tag in the song
|
||||||
pub fn set_tag(&mut self, target_key: Tag, new_value: String) {
|
pub fn set_tag(&mut self, target_key: Tag, new_value: String) {
|
||||||
self.tags.insert(target_key, new_value);
|
self.tags.insert(target_key, new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deletes a tag from the song
|
||||||
pub fn remove_tag(&mut self, target_key: &Tag) {
|
pub fn remove_tag(&mut self, target_key: &Tag) {
|
||||||
self.tags.remove(target_key);
|
self.tags.remove(target_key);
|
||||||
}
|
}
|
||||||
|
@ -648,7 +651,7 @@ impl MusicLibrary {
|
||||||
}
|
}
|
||||||
match album_artist {
|
match album_artist {
|
||||||
Some(artist) => {
|
Some(artist) => {
|
||||||
tags.insert(Tag::Album, artist.clone());
|
tags.insert(Tag::Artist, artist.clone());
|
||||||
}
|
}
|
||||||
None => (),
|
None => (),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue