mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Move structs which are send across threads to own module
This commit is contained in:
parent
da537b57f4
commit
48a43f4948
7 changed files with 30 additions and 30 deletions
|
@ -63,6 +63,7 @@ pub mod player;
|
||||||
pub mod stream;
|
pub mod stream;
|
||||||
pub mod version;
|
pub mod version;
|
||||||
pub mod mixer;
|
pub mod mixer;
|
||||||
|
pub mod messaging;
|
||||||
|
|
||||||
#[cfg(feature = "with-syntex")] include!(concat!(env!("OUT_DIR"), "/lib.rs"));
|
#[cfg(feature = "with-syntex")] include!(concat!(env!("OUT_DIR"), "/lib.rs"));
|
||||||
#[cfg(not(feature = "with-syntex"))] include!("lib.in.rs");
|
#[cfg(not(feature = "with-syntex"))] include!("lib.in.rs");
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::mem::replace;
|
||||||
|
|
||||||
use protocol;
|
use protocol;
|
||||||
use session::{Session, PacketHandler};
|
use session::{Session, PacketHandler};
|
||||||
use spirc::MercuryResponseSender;
|
use messaging::{MercuryResponse, MercuryResponseSender};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum MercuryMethod {
|
pub enum MercuryMethod {
|
||||||
|
@ -24,12 +24,6 @@ pub struct MercuryRequest {
|
||||||
pub payload: Vec<Vec<u8>>,
|
pub payload: Vec<Vec<u8>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct MercuryResponse {
|
|
||||||
pub uri: String,
|
|
||||||
pub payload: Vec<Vec<u8>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum MercuryCallback {
|
enum MercuryCallback {
|
||||||
Future(eventual::Complete<MercuryResponse, ()>),
|
Future(eventual::Complete<MercuryResponse, ()>),
|
||||||
Subscription(MercuryResponseSender),
|
Subscription(MercuryResponseSender),
|
||||||
|
|
22
src/messaging/mod.rs
Normal file
22
src/messaging/mod.rs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
pub struct UpdateMessage;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct MercuryResponse {
|
||||||
|
pub uri: String,
|
||||||
|
pub payload: Vec<Vec<u8>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum SpircMessage {
|
||||||
|
MercuryMsg(MercuryResponse),
|
||||||
|
UpdateMsg(UpdateMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
implement_sender!(name => MercuryResponseSender,
|
||||||
|
wrap => MercuryResponse,
|
||||||
|
with => SpircMessage,
|
||||||
|
variant => MercuryMsg);
|
||||||
|
|
||||||
|
implement_sender!(name => UpdateMessageSender,
|
||||||
|
wrap => UpdateMessage,
|
||||||
|
with => SpircMessage,
|
||||||
|
variant => UpdateMsg);
|
|
@ -1,4 +1,4 @@
|
||||||
use spirc::UpdateMessageSender;
|
use messaging::UpdateMessageSender;
|
||||||
|
|
||||||
use self::softmixer::SoftMixer;
|
use self::softmixer::SoftMixer;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
use spirc::UpdateMessageSender;
|
use messaging::{UpdateMessage, UpdateMessageSender};
|
||||||
use spirc::UpdateMessage;
|
|
||||||
|
|
||||||
use super::Mixer;
|
use super::Mixer;
|
||||||
use super::AudioFilter;
|
use super::AudioFilter;
|
||||||
|
|
|
@ -20,11 +20,11 @@ use authentication::Credentials;
|
||||||
use cache::Cache;
|
use cache::Cache;
|
||||||
use connection::{self, PlainConnection, CipherConnection};
|
use connection::{self, PlainConnection, CipherConnection};
|
||||||
use diffie_hellman::DHLocalKeys;
|
use diffie_hellman::DHLocalKeys;
|
||||||
use mercury::{MercuryManager, MercuryRequest, MercuryResponse};
|
use mercury::{MercuryManager, MercuryRequest};
|
||||||
use metadata::{MetadataManager, MetadataRef, MetadataTrait};
|
use metadata::{MetadataManager, MetadataRef, MetadataTrait};
|
||||||
use protocol;
|
use protocol;
|
||||||
use stream::StreamManager;
|
use stream::StreamManager;
|
||||||
use spirc::MercuryResponseSender;
|
use messaging::{MercuryResponse, MercuryResponseSender};
|
||||||
use util::{self, SpotifyId, FileId, ReadSeek};
|
use util::{self, SpotifyId, FileId, ReadSeek};
|
||||||
use version;
|
use version;
|
||||||
|
|
||||||
|
|
20
src/spirc.rs
20
src/spirc.rs
|
@ -4,7 +4,8 @@ use std::borrow::Cow;
|
||||||
use std::sync::{mpsc, Mutex, Arc};
|
use std::sync::{mpsc, Mutex, Arc};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use mercury::{MercuryRequest, MercuryMethod, MercuryResponse};
|
use mercury::{MercuryRequest, MercuryMethod};
|
||||||
|
use messaging::{SpircMessage, MercuryResponseSender, UpdateMessageSender};
|
||||||
use player::{Player, PlayerState};
|
use player::{Player, PlayerState};
|
||||||
use mixer::Mixer;
|
use mixer::Mixer;
|
||||||
use session::Session;
|
use session::Session;
|
||||||
|
@ -56,23 +57,6 @@ pub struct State {
|
||||||
pub end_of_track: bool,
|
pub end_of_track: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UpdateMessage;
|
|
||||||
|
|
||||||
pub enum SpircMessage {
|
|
||||||
MercuryMsg(MercuryResponse),
|
|
||||||
UpdateMsg(UpdateMessage)
|
|
||||||
}
|
|
||||||
|
|
||||||
implement_sender!(name => MercuryResponseSender,
|
|
||||||
wrap => MercuryResponse,
|
|
||||||
with => SpircMessage,
|
|
||||||
variant => MercuryMsg);
|
|
||||||
|
|
||||||
implement_sender!(name => UpdateMessageSender,
|
|
||||||
wrap => UpdateMessage,
|
|
||||||
with => SpircMessage,
|
|
||||||
variant => UpdateMsg);
|
|
||||||
|
|
||||||
impl SpircManager {
|
impl SpircManager {
|
||||||
pub fn new(session: Session, player: Player, mixer: Box<Mixer + Send>) -> SpircManager {
|
pub fn new(session: Session, player: Player, mixer: Box<Mixer + Send>) -> SpircManager {
|
||||||
let ident = session.device_id().to_owned();
|
let ident = session.device_id().to_owned();
|
||||||
|
|
Loading…
Reference in a new issue