mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Minor fixes after review.
This commit is contained in:
parent
9ff6fe900c
commit
1518459048
1 changed files with 7 additions and 19 deletions
|
@ -1,6 +1,6 @@
|
||||||
use futures::sync::oneshot;
|
use futures::sync::oneshot;
|
||||||
use futures::{future, Future};
|
use futures::{future, Future};
|
||||||
use futures::sync::mpsc::{UnboundedReceiver, UnboundedSender, unbounded};
|
use futures;
|
||||||
use std;
|
use std;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::io::{Read, Seek, SeekFrom, Result};
|
use std::io::{Read, Seek, SeekFrom, Result};
|
||||||
|
@ -33,7 +33,7 @@ struct PlayerInternal {
|
||||||
sink: Box<Sink>,
|
sink: Box<Sink>,
|
||||||
sink_running: bool,
|
sink_running: bool,
|
||||||
audio_filter: Option<Box<AudioFilter + Send>>,
|
audio_filter: Option<Box<AudioFilter + Send>>,
|
||||||
event_sender: UnboundedSender<PlayerEvent>,
|
event_sender: futures::sync::mpsc::UnboundedSender<PlayerEvent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PlayerCommand {
|
enum PlayerCommand {
|
||||||
|
@ -60,7 +60,7 @@ pub enum PlayerEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlayerEventChannel = UnboundedReceiver<PlayerEvent>;
|
type PlayerEventChannel = futures::sync::mpsc::UnboundedReceiver<PlayerEvent>;
|
||||||
impl Player {
|
impl Player {
|
||||||
pub fn new<F>(config: PlayerConfig, session: Session,
|
pub fn new<F>(config: PlayerConfig, session: Session,
|
||||||
audio_filter: Option<Box<AudioFilter + Send>>,
|
audio_filter: Option<Box<AudioFilter + Send>>,
|
||||||
|
@ -68,7 +68,7 @@ impl Player {
|
||||||
where F: FnOnce() -> Box<Sink> + Send + 'static
|
where F: FnOnce() -> Box<Sink> + Send + 'static
|
||||||
{
|
{
|
||||||
let (cmd_tx, cmd_rx) = std::sync::mpsc::channel();
|
let (cmd_tx, cmd_rx) = std::sync::mpsc::channel();
|
||||||
let (event_sender, event_receiver) = unbounded();
|
let (event_sender, event_receiver) = futures::sync::mpsc::unbounded();
|
||||||
|
|
||||||
let handle = thread::spawn(move || {
|
let handle = thread::spawn(move || {
|
||||||
debug!("new Player[{}]", session.session_id());
|
debug!("new Player[{}]", session.session_id());
|
||||||
|
@ -172,24 +172,12 @@ impl PlayerState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_end_of_track(self) {
|
|
||||||
use self::PlayerState::*;
|
|
||||||
match self {
|
|
||||||
Paused { end_of_track, .. } |
|
|
||||||
Playing { end_of_track, .. } => {
|
|
||||||
let _ = end_of_track.send(());
|
|
||||||
},
|
|
||||||
_ => ()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn playing_to_end_of_track(&mut self) {
|
fn playing_to_end_of_track(&mut self) {
|
||||||
use self::PlayerState::*;
|
use self::PlayerState::*;
|
||||||
match *self {
|
match mem::replace(self, Invalid) {
|
||||||
Paused { track_id, .. } |
|
Playing { track_id, end_of_track, ..} => {
|
||||||
Playing { track_id, .. } => {
|
end_of_track.send(());
|
||||||
let old_state = mem::replace(self, EndOfTrack { track_id });
|
let old_state = mem::replace(self, EndOfTrack { track_id });
|
||||||
old_state.send_end_of_track();
|
|
||||||
},
|
},
|
||||||
_ => panic!("Called playing_to_end_of_track in non-playing state.")
|
_ => panic!("Called playing_to_end_of_track in non-playing state.")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue